-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainForm.cs
291 lines (263 loc) · 11.9 KB
/
MainForm.cs
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
using System;
using System.Drawing;
using System.Collections.Generic;
using System.Windows.Forms;
using System.IO;
//using Microsoft.SDK.Samples.VistaBridge.Dialogs;
namespace AssemblerStudioDevelop
{
/// <summary>
/// Copyright © Bridge Team & Tarek Itien software engineering 2011
/// </summary>
public partial class MainForm : Form
{
#region < Fields >
public int childFormNumber = 0;
public ChildForm CF = null;
StartPage SP;
MouseEventArgs Mouse;
#endregion
#region < Constructors >
public MainForm()
{
MottoSplash MySplash = new MottoSplash();
this.Visible = false;
InitializeComponent();
MySplash.ShowDialog();
this.Visible = true;
}
#endregion
#region < Methods >
public void EnableChildBox(bool x)
{
if (x)
{
saveToolStripMenuItem.Enabled = saveAsToolStripMenuItem.Enabled = printToolStripMenuItem.Enabled = printPreviewToolStripMenuItem.Enabled = pageSetupToolStripMenuItem.Enabled = true;
cutToolStripMenuItem.Enabled = copyToolStripMenuItem.Enabled = pasteToolStripMenuItem.Enabled = undoToolStripMenuItem.Enabled = redoToolStripMenuItem.Enabled = selectAllToolStripMenuItem.Enabled = deselectAllToolStripMenuItem.Enabled = true;
findToolStripButton6.Enabled = findToolStripMenuItem.Enabled = true;
cutToolStripButton.Enabled = copyToolStripButton.Enabled = pasteToolStripButton.Enabled = selectAllToolStripButton.Enabled = deselectAllToolStripButton.Enabled = true;
propertiesFileToolStripMenuItem.Enabled = PropertiesFileToolStripButton.Enabled = true;
SaveToolStripButton.Enabled = SaveAsToolStripButton.Enabled = true;
PageSetupToolStripButton.Enabled = PrintToolStripButton.Enabled = PrintPreviewToolStripButton.Enabled = true;
startToolStripMenuItem3.Enabled = buildToolStripMenuItem.Visible = startToolStripButton.Visible = true;
}
else
{
saveToolStripMenuItem.Enabled = saveAsToolStripMenuItem.Enabled = printToolStripMenuItem.Enabled = printPreviewToolStripMenuItem.Enabled = pageSetupToolStripMenuItem.Enabled = false;
cutToolStripMenuItem.Enabled = copyToolStripMenuItem.Enabled = pasteToolStripMenuItem.Enabled = undoToolStripMenuItem.Enabled = redoToolStripMenuItem.Enabled = selectAllToolStripMenuItem.Enabled = deselectAllToolStripMenuItem.Enabled = false;
findToolStripButton6.Enabled = findToolStripMenuItem.Enabled = false;
cutToolStripButton.Enabled = copyToolStripButton.Enabled = pasteToolStripButton.Enabled = selectAllToolStripButton.Enabled = deselectAllToolStripButton.Enabled = false;
propertiesFileToolStripMenuItem.Enabled = PropertiesFileToolStripButton.Enabled = false;
SaveToolStripButton.Enabled = SaveAsToolStripButton.Enabled = false;
PageSetupToolStripButton.Enabled = PrintToolStripButton.Enabled = PrintPreviewToolStripButton.Enabled = false;
startToolStripMenuItem3.Enabled = buildToolStripMenuItem.Visible = startToolStripButton.Visible = false;
}
}
public void ChildFormDesigner(ChildForm childForm)
{
//Tool Strip Menu Item
this.undoToolStripMenuItem.Click += new EventHandler(childForm.undoToolStripMenuItem_Click);
this.redoToolStripMenuItem.Click += new EventHandler(childForm.redoToolStripMenuItem_Click);
this.cutToolStripMenuItem.Click += new EventHandler(childForm.cutToolStripMenuItem_Click);
this.copyToolStripMenuItem.Click += new EventHandler(childForm.copyToolStripMenuItem_Click);
this.pasteToolStripMenuItem.Click += new EventHandler(childForm.pasteToolStripMenuItem_Click);
this.selectAllToolStripMenuItem.Click += new EventHandler(childForm.selectAllToolStripMenuItem_Click);
this.deselectAllToolStripMenuItem.Click += new EventHandler(childForm.deselectAllToolStripMenuItem_Click);
//Tool Strip Button
this.cutToolStripButton.Click += new EventHandler(childForm.cutToolStripMenuItem_Click);
this.copyToolStripButton.Click += new EventHandler(childForm.copyToolStripMenuItem_Click);
this.pasteToolStripButton.Click += new EventHandler(childForm.pasteToolStripMenuItem_Click);
this.selectAllToolStripButton.Click += new EventHandler(childForm.selectAllToolStripMenuItem_Click);
this.deselectAllToolStripButton.Click += new EventHandler(childForm.deselectAllToolStripMenuItem_Click);
CF = childForm;
}
#endregion
#region < Event Methods >
private void ShowNewForm(object sender, EventArgs e)
{
NewProjectForm NPF = new NewProjectForm(this);
NPF.ShowDialog();
//ChildForm childForm = new ChildForm();
//ChildFormDesigner(childForm);
//childForm.Show();
}
private void OpenFile(object sender, EventArgs e)
{
try
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
openFileDialog.Filter = "Text Files (*.txt;*.asm)|*.txt;*.asm|All Files (*.*)|*.*";
if (openFileDialog.ShowDialog(this) == DialogResult.OK)
{
//string FileName = openFileDialog.FileName;
ChildForm childForm = new ChildForm(this);
childForm.MdiParent = this;
StreamReader SR = new StreamReader(openFileDialog.FileName);
childForm.LoadFile(SR, openFileDialog.FileName);
SR.Close();
childForm.Text = "Project: " +
openFileDialog.FileName.Remove(0, openFileDialog.InitialDirectory.Length + 1) +
" (" + childFormNumber++ + ")";
childForm.Show();
}
}
catch (Exception E) { MessageBox.Show(E.Message, "Error File", MessageBoxButtons.OK, MessageBoxIcon.Error); }
}
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
CF.SaveFile();
}
private void SaveAsFile(object sender, EventArgs e)
{
CF.SaveAsFile();
}
public void findToolStripButton_MouseDown(object sender, MouseEventArgs e)
{
Point p = new Point(500, 100);
MenuStrip OpeningMenu = new MenuStrip(this);
PoperContainer m_poperContainerForButton = new PoperContainer(OpeningMenu);
//MenuStrip MSE = new MenuStrip(this);
if (e.Button == MouseButtons.Left)
m_poperContainerForButton.Show(this, p);
Mouse = e;
}
private void cascadeToolStripMenuItem_Click(object sender, EventArgs e)
{
LayoutMdi(MdiLayout.Cascade);
}
private void tileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
{
LayoutMdi(MdiLayout.TileVertical);
}
private void tileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
{
LayoutMdi(MdiLayout.TileHorizontal);
}
private void arrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
{
LayoutMdi(MdiLayout.ArrangeIcons);
}
private void toolbarToolStripMenuItem_Click(object sender, EventArgs e)
{
toolStrip1.Visible = toolbarToolStripMenuItem.Checked;
}
private void statusBarToolStripMenuItem_Click(object sender, EventArgs e)
{
statusStrip1.Visible = statusBarToolStripMenuItem.Checked;
}
private void closeAllToolStripMenuItem_Click(object sender, EventArgs e)
{
foreach (Form childForm in MdiChildren)
{
//if (this.Contains(SP))
//{
// SP.Visible = false;
// continue;
//}
childForm.Close();
}
childFormNumber = 0;
EnableChildBox(false);
}
private void MainForm_Load(object sender, EventArgs e)
{
SP = new StartPage(this);
SP.MdiParent = this;
SP.WindowState = FormWindowState.Maximized;
SP.Show();
//EnableChildBox(false);
//StringReader SR = new StringReader(Properties.Resources.Instructions);
//Instructions = new List<string>();
//string str = "j";
//while(true)
//{
// str = SR.ReadLine();
// if (!String.IsNullOrWhiteSpace(str)) Instructions.Add(str.Substring(0, str.IndexOf(',')));
// else break;
//}
// SR.Close();
}
private void StartingPagetoolStripButton_Click(object sender, EventArgs e)
{
if (this.Contains(SP))
SP.Visible = true;
else
{
SP = new StartPage(this);
SP.MdiParent = this;
//SP.Anchor = ((AnchorStyles)((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
//SP.Dock = DockStyle.Fill;
SP.WindowState = FormWindowState.Maximized;
SP.Show();
}
}
private void MainForm_DragDrop(object sender, DragEventArgs e)
{
try
{
string[] s = (string[])e.Data.GetData("FileName");
StreamReader SR = new StreamReader(s[0]);
ChildForm CF = new ChildForm(this);
CF.MdiParent = this;
CF.LoadFile(SR, s[0]);
CF.Show();
//this.Text = SR.ReadToEnd().ToUpper().Insert(0, "\n");
//ProcessAllLines();
SR.Close();
//Bitmap o = (Bitmap)Image.FromFile(s[0]);
//MainPictureBox.Image = o;
}
catch { MessageBox.Show("It Does Not Allow For This Type", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
}
private void MainForm_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))//.FileDrop))
{
e.Effect = DragDropEffects.Copy;
}// Okay
else
{
e.Effect = DragDropEffects.None;
}
}
private void toolStripButton_Click(object sender, EventArgs e)
{
About about = new About();
about.ShowDialog();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void propertiesFileToolStripMenuItem_Click(object sender, EventArgs e)
{
CF.propertiesFile_Click(sender, e);
}
private void findToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
this.findToolStripButton_MouseDown(sender, Mouse);
}
catch { this.toolStripStatusLabel01Ready.Text = "Cannot Do It Right Now"; }
}
private void pageSetupToolStripMenuItem_Click(object sender, EventArgs e)
{
CF.PageSetup(sender, e);
}
private void printToolStripMenuItem_Click(object sender, EventArgs e)
{
CF.Print(sender, e);
}
private void printPreviewToolStripMenuItem_Click(object sender, EventArgs e)
{
CF.PrintPreview(sender, e);
}
private void startToolStripMenuItem3_Click(object sender, EventArgs e)
{
CF.Start_Click(sender, e);
}
#endregion
}
}