Menu reopens when all windows are closed

This commit is contained in:
Lukasz Baldyga committed 2020-10-06 13:02:56 +01:00
1 parent 5d2513d6af
commit a911defa29
5 files changed
+52 -16

No files matched your search

@@ -12,6 +12,21 @@
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -32,6 +47,10 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>
</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -52,7 +71,7 @@
<Compile Include="Console.Designer.cs">
<DependentUpon>Console.cs</DependentUpon>
</Compile>
<Compile Include="Settings.cs" />
<Compile Include="SettingsAndHelperFunctions.cs" />
<Compile Include="Menu.cs">
<SubType>Form</SubType>
</Compile>
@@ -89,5 +108,17 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -19,8 +19,8 @@ namespace Advanced_Software_Engineering
private void Console_FormClosed(object sender, FormClosedEventArgs e)
{
SettingsAndHelperFunctions.NumberOfWindows--;
SettingsAndHelperFunctions.WindowClosed();
}
}
}
@@ -41,11 +41,6 @@ namespace Advanced_Software_Engineering
this.Close();
}
public static void CheckWindows()
{
if (SettingsAndHelperFunctions.NumberOfWindows == 0) Menu.Show();
}
private void Menu_Load(object sender, EventArgs e)
{
//Do things on load
@@ -8,6 +8,8 @@ namespace Advanced_Software_Engineering
{
static class Program
{
public static Form MainMenu;
/// <summary>
/// The main entry point for the application.
/// </summary>
@@ -16,7 +18,9 @@ namespace Advanced_Software_Engineering
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Menu());
MainMenu = new Menu();
Application.Run(MainMenu);
}
}
}
@@ -1,14 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms;
namespace Advanced_Software_Engineering
{
class SettingsAndHelperFunctions
public class SettingsAndHelperFunctions
{
public static int NumberOfWindows = 0;
public static void WindowClosed()
{
NumberOfWindows--;
if (NumberOfWindows == 0)
{
System.Console.WriteLine("Showing MainMenu");
Program.MainMenu.Show();
}
}
}
}