aboutsummaryrefslogtreecommitdiff
path: root/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicNotepad.cs
blob: 6dd6ee87f1263f908a42a5476ab0274e0e04e279 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TimeHACK.Engine;
using static TimeHACK.Engine.FileDialogBoxManager;
using System.IO;

namespace TimeHACK.OS.Win95.Win95Apps
{
    public partial class WinClassicNotepad : UserControl
    {
        public WinClassicNotepad()
        {
            InitializeComponent();
            foreach (ToolStripMenuItem item in menuStrip1.Items)
            {
                item.Font = new Font(TitleScreen.pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((0)));
                item.BackColor = Color.Silver;
                item.BackgroundImage = Properties.Resources.sliversilver;
                item.BackgroundImageLayout = ImageLayout.Center;
                item.DisplayStyle = ToolStripItemDisplayStyle.Text;
            }
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.ParentForm.Close();
        }

        private void aboutNotepadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            WindowManager wm = new WindowManager();
            wm.startAboutBox95("Notepad", "Microsoft Notepad", Properties.Resources.WinClassicNotepad);
        }

        private void wordWrapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            mainText.WordWrap = wordWrapToolStripMenuItem.Checked;
        }

        private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            mainText.SelectAll();
        }

        private void undoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            mainText.Undo();
        }

        private void cutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (mainText.SelectedText.Length >= 0)
            {
                mainText.Cut();
            }
        }

        private void copyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (mainText.SelectedText.Length >= 0)
            {
                mainText.Copy();
            }
        }

        private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            mainText.Paste();
        }

        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            mainText.Text.Remove(mainText.SelectionStart, mainText.SelectedText.Length);
        }

        private void timeDateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string DateTime = System.DateTime.Now.ToString("HH:mm tt dd/MM/yyyy");
            mainText.AppendText(DateTime);
        }

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                ActivateSaveFileDialog(".txt");
                String selectedPath;
                selectedPath = Program.OpenFileExplorerAsDialogAndReturnGivenPath();

                MessageBox.Show(selectedPath);
                if (selectedPath != "")
                {
                    mainText.Text = ReadTextFile(selectedPath);
                }
            }
            catch
            {
            }
        }

        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                ActivateSaveFileDialog(".txt");
                String selectedPath;
                selectedPath = Program.OpenFileExplorerAsDialogAndReturnGivenPath();

                MessageBox.Show(selectedPath);
                if (selectedPath != "")
                {
                    File.WriteAllText(selectedPath, mainText.Text);
                }
            } catch {
            }               
        }
    }
}