aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Main/ShiftOS/Apps/TextPad.cs
blob: e86b1bec6c602fe9a6645b56dedfd7abde218986 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.IO;
using System.Windows.Forms;

namespace ShiftOS.Main.ShiftOS.Apps
{
	public partial class TextPad : UserControl
	{
		readonly string _editedText;

		public TextPad()
		{
			InitializeComponent();
			_editedText = textBox.Text;
		}

		bool IsEdited() => _editedText != textBox.Text;

		void openToolStripMenuItem_Click(object sender, EventArgs e)
		{
			if (openFileDialog1.ShowDialog() != DialogResult.OK) return;
			
			var sr = new StreamReader(openFileDialog1.FileName);
			textBox.Text = sr.ReadToEnd();
			sr.Close();
		}

		void newToolStripMenuItem_Click(object sender, EventArgs e)
		{
			if (IsEdited())
			{
				MessageBox.Show("yay it works");
			}
		}
	}
}