Private
Public Access
Refactored Menu controls from Settings And HelperFunctions
a
This commit is contained in:
1 parent
38a40994cf
commit
b290848034
7 files changed
+46
-29
No files matched your search
+1
@@ -69,6 +69,7 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="MenuManager.cs" />
|
||||||
<Compile Include="Properties\Resources.Designer.cs">
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Advanced_Software_Engineering {
|
||||||
|
public static partial class MenuManager {
|
||||||
|
/// <summary>
|
||||||
|
/// The variable simply keep track of the windows that are currently shown (excluding <see cref="Menu"/>).
|
||||||
|
/// </summary>
|
||||||
|
public static int NumberOfWindows = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This helper function is executed when a window is closed. It shows the <see cref="Menu"/> when the count is 0
|
||||||
|
/// </summary>
|
||||||
|
public static void WindowClosed() {
|
||||||
|
NumberOfWindows--;
|
||||||
|
if (NumberOfWindows == 0) {
|
||||||
|
Console.WriteLine("Showing MainMenu");
|
||||||
|
Program.MainMenu.Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
-16
@@ -26,22 +26,6 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class SettingsAndHelperFunctions {
|
public class SettingsAndHelperFunctions {
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The variable simply keep track of the windows that are currently shown (excluding <see cref="MainMenu"/>).
|
|
||||||
/// </summary>
|
|
||||||
public static int NumberOfWindows = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This helper function is executed when a window is closed. It shows the <see cref="MainMenu"/> when the count is 0
|
|
||||||
/// </summary>
|
|
||||||
public static void WindowClosed() {
|
|
||||||
NumberOfWindows--;
|
|
||||||
if (NumberOfWindows == 0) {
|
|
||||||
System.Console.WriteLine("Showing MainMenu");
|
|
||||||
Program.MainMenu.Show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This function removes spaces from the start and the end of the text. This should be unit tested.
|
/// This function removes spaces from the start and the end of the text. This should be unit tested.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -28,8 +28,15 @@ namespace Advanced_Software_Engineering {
|
|||||||
string[] commandParameters = result.getParameters();
|
string[] commandParameters = result.getParameters();
|
||||||
if (command == null) throw new Exception("There is no command to process");
|
if (command == null) throw new Exception("There is no command to process");
|
||||||
|
|
||||||
//process declarations first
|
//check for names in directory
|
||||||
|
if (drawer.CheckVariableExists(command)) {
|
||||||
|
|
||||||
|
if (commandParameters.Length == 1) {
|
||||||
|
//return new UpdateVariable(drawer, );
|
||||||
|
} else throw new Exception(command + "needs something to be assigned to it");
|
||||||
|
}
|
||||||
|
|
||||||
|
//process declarations
|
||||||
if (!(commandParameters == null))
|
if (!(commandParameters == null))
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case "int":
|
case "int":
|
||||||
@@ -56,7 +63,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
}
|
}
|
||||||
int parameterLength = parameters.Count;
|
int parameterLength = parameters.Count;
|
||||||
|
|
||||||
//process drawing commands and extras second
|
//process drawing commands and extras
|
||||||
switch (command) {
|
switch (command) {
|
||||||
//Drawing commands
|
//Drawing commands
|
||||||
case "move":
|
case "move":
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
namespace Advanced_Software_Engineering {
|
namespace Advanced_Software_Engineering {
|
||||||
|
|
||||||
public partial class About_Window : Form {
|
partial class About_Window : Form {
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
///Creates an About Window which shows details about the program.
|
///Creates an About Window which shows details about the program.
|
||||||
///</summary>
|
///</summary>
|
||||||
public About_Window() {
|
public About_Window() {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
SettingsAndHelperFunctions.NumberOfWindows++;
|
MenuManager.NumberOfWindows++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -18,7 +18,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void About_Window_FormClosed(object sender, FormClosedEventArgs e) {
|
private void About_Window_FormClosed(object sender, FormClosedEventArgs e) {
|
||||||
SettingsAndHelperFunctions.WindowClosed();
|
MenuManager.WindowClosed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
public Draw_Preview() {
|
public Draw_Preview() {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
SettingsAndHelperFunctions.NumberOfWindows++;
|
MenuManager.NumberOfWindows++;
|
||||||
graphics = panel1.CreateGraphics();
|
graphics = panel1.CreateGraphics();
|
||||||
graphics.ResetClip();
|
graphics.ResetClip();
|
||||||
commander = new Commander(graphics);
|
commander = new Commander(graphics);
|
||||||
@@ -32,7 +32,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
public Draw_Preview(string commands) {
|
public Draw_Preview(string commands) {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
SettingsAndHelperFunctions.NumberOfWindows++;
|
MenuManager.NumberOfWindows++;
|
||||||
graphics = panel1.CreateGraphics();
|
graphics = panel1.CreateGraphics();
|
||||||
graphics.ResetClip();
|
graphics.ResetClip();
|
||||||
commander = new Commander(graphics, commands);
|
commander = new Commander(graphics, commands);
|
||||||
@@ -43,7 +43,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void DrawPreview_FormClosed(object sender, FormClosedEventArgs e) {
|
private void DrawPreview_FormClosed(object sender, FormClosedEventArgs e) {
|
||||||
SettingsAndHelperFunctions.WindowClosed();
|
MenuManager.WindowClosed();
|
||||||
Dispose();
|
Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// The text editor is the main window that the user will be using for writing code.
|
/// The text editor is the main window that the user will be using for writing code.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TextEditor() {
|
public TextEditor() {
|
||||||
SettingsAndHelperFunctions.NumberOfWindows++;
|
MenuManager.NumberOfWindows++;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
UpdateTitle();
|
UpdateTitle();
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="openFile">File dialog which points to the file to open</param>
|
/// <param name="openFile">File dialog which points to the file to open</param>
|
||||||
public TextEditor(OpenFileDialog openFile) {
|
public TextEditor(OpenFileDialog openFile) {
|
||||||
SettingsAndHelperFunctions.NumberOfWindows++;
|
MenuManager.NumberOfWindows++;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
StreamReader fileStream = new StreamReader(openFile.OpenFile());
|
StreamReader fileStream = new StreamReader(openFile.OpenFile());
|
||||||
@@ -159,7 +159,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
tmpDrawPreview.SubmitCommands(TextBox.Text);
|
tmpDrawPreview.SubmitCommands(TextBox.Text);
|
||||||
if (tmpDrawPreview.IsSuccess()) new ErrorWindow("No errors", "No errors found in the program", "There have been no errors found", ErrorWindow.INFO_MESSAGE).Show();
|
if (tmpDrawPreview.IsSuccess()) new ErrorWindow("No errors", "No errors found in the program", "There have been no errors found", ErrorWindow.INFO_MESSAGE).Show();
|
||||||
tmpDrawPreview.Close();
|
tmpDrawPreview.Close();
|
||||||
SettingsAndHelperFunctions.WindowClosed();
|
MenuManager.WindowClosed();
|
||||||
tmpDrawPreview.Dispose();
|
tmpDrawPreview.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
Console.WriteLine(commandDesc);
|
Console.WriteLine(commandDesc);
|
||||||
|
|
||||||
tmpDrawPreview.Close();
|
tmpDrawPreview.Close();
|
||||||
SettingsAndHelperFunctions.WindowClosed();
|
MenuManager.WindowClosed();
|
||||||
tmpDrawPreview.Dispose();
|
tmpDrawPreview.Dispose();
|
||||||
|
|
||||||
new DetailsWindow(commandDesc, "Command explanation").Show();
|
new DetailsWindow(commandDesc, "Command explanation").Show();
|
||||||
@@ -187,7 +187,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
|
|
||||||
private void Console_FormClosed(object sender, FormClosedEventArgs e) {
|
private void Console_FormClosed(object sender, FormClosedEventArgs e) {
|
||||||
if (DisplayForm != null && !DisplayForm.IsDisposed) DisplayForm.ReleaseCommandLock();
|
if (DisplayForm != null && !DisplayForm.IsDisposed) DisplayForm.ReleaseCommandLock();
|
||||||
SettingsAndHelperFunctions.WindowClosed();
|
MenuManager.WindowClosed();
|
||||||
Dispose();
|
Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user