aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Main/Apps/TextPad.cs
blob: ee4a37936a4fe1f0caafe2479fd3622885b344ce (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
37
38
39
40
using ShiftOS.Engine.ShiftFS.FileGUI;
using ShiftOS.Engine.WindowManager;
using System;
using System.IO;
using System.Windows.Forms;

namespace ShiftOS.Main.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");
			}
            var f = new FileOpener();
            ShiftWM.Init(f, "testing", null);
		}
	}
}