From c021e2a6272dc6655cd94992eeb67695442a18ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=B9i=20Nguy=E1=BB=85n=20T=E1=BA=A5n=20Sang?= Date: Tue, 9 Jul 2024 13:29:18 +0700 Subject: [PATCH] Closing alert --- Create.cs | 14 ++++++++++++++ Main.cs | 16 ++++++++++++++++ .../PublishProfiles/FolderProfile.pubxml.user | 2 +- .../Lithicsoft Trainer Studio.AssemblyInfo.cs | 2 +- ...csoft Trainer Studio.AssemblyInfoInputs.cache | 2 +- 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/Create.cs b/Create.cs index e8c56e8..c2bd626 100644 --- a/Create.cs +++ b/Create.cs @@ -7,6 +7,7 @@ */ using Microsoft.ML.Runtime; +using System.ComponentModel; using System.Diagnostics; using System.IO.Compression; using System.Management; @@ -24,6 +25,7 @@ public Create() private async void button1_Click(object sender, EventArgs e) { button1.Enabled = false; + this.Closing += OnClosing; try { Directory.CreateDirectory($"projects\\{textBox1.Text}"); @@ -242,5 +244,17 @@ private Task UpdateProgressBarAsync(int value) } }); } + + private void OnClosing(object sender, CancelEventArgs cancelEventArgs) + { + string msg = "Do you want to exit Trainer Studio?"; + DialogResult result = MessageBox.Show(msg, "Close Confirmation", + MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (result == DialogResult.Yes) + Application.Exit(); + else if (result == DialogResult.No) + cancelEventArgs.Cancel = false; + + } } } diff --git a/Main.cs b/Main.cs index ceaa754..02973a5 100644 --- a/Main.cs +++ b/Main.cs @@ -6,6 +6,8 @@ * Author: Bui Nguyen Tan Sang */ +using System.ComponentModel; + namespace Lithicsoft_Trainer { public partial class Main : Form @@ -16,6 +18,8 @@ public Main(string projectName, string projectLanguage, string ProjectType) { InitializeComponent(); + this.Closing += OnClosing; + try { if (projectLanguage == "C#") @@ -61,5 +65,17 @@ public Main(string projectName, string projectLanguage, string ProjectType) } } + + private void OnClosing(object sender, CancelEventArgs cancelEventArgs) + { + string msg = "Do you want to exit Trainer Studio?"; + DialogResult result = MessageBox.Show(msg, "Close Confirmation", + MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (result == DialogResult.Yes) + Application.Exit(); + else if (result == DialogResult.No) + cancelEventArgs.Cancel = false; + + } } } diff --git a/Properties/PublishProfiles/FolderProfile.pubxml.user b/Properties/PublishProfiles/FolderProfile.pubxml.user index db2bfa9..5d0bd11 100644 --- a/Properties/PublishProfiles/FolderProfile.pubxml.user +++ b/Properties/PublishProfiles/FolderProfile.pubxml.user @@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - True|2024-07-09T04:16:04.8352682Z||;True|2024-07-09T10:19:37.3610289+07:00||;True|2024-07-03T08:52:06.0791707+07:00||;True|2024-07-03T08:36:48.0337116+07:00||;True|2024-07-03T08:36:29.1380094+07:00||;True|2024-07-03T08:02:18.9511310+07:00||;True|2024-07-03T08:01:22.9038707+07:00||;True|2024-07-02T17:35:09.8225888+07:00||;True|2024-07-02T17:32:48.0607939+07:00||;True|2024-07-02T16:34:30.8649130+07:00||;True|2024-07-02T16:33:17.8244660+07:00||;True|2024-07-02T14:08:52.1255404+07:00||;True|2024-07-02T07:05:34.1669329+07:00||; + True|2024-07-09T06:15:58.5882820Z||;True|2024-07-09T11:16:04.8352682+07:00||;True|2024-07-09T10:19:37.3610289+07:00||;True|2024-07-03T08:52:06.0791707+07:00||;True|2024-07-03T08:36:48.0337116+07:00||;True|2024-07-03T08:36:29.1380094+07:00||;True|2024-07-03T08:02:18.9511310+07:00||;True|2024-07-03T08:01:22.9038707+07:00||;True|2024-07-02T17:35:09.8225888+07:00||;True|2024-07-02T17:32:48.0607939+07:00||;True|2024-07-02T16:34:30.8649130+07:00||;True|2024-07-02T16:33:17.8244660+07:00||;True|2024-07-02T14:08:52.1255404+07:00||;True|2024-07-02T07:05:34.1669329+07:00||; \ No newline at end of file diff --git a/obj/Debug/net8.0-windows/Lithicsoft Trainer Studio.AssemblyInfo.cs b/obj/Debug/net8.0-windows/Lithicsoft Trainer Studio.AssemblyInfo.cs index 5298068..c08a216 100644 --- a/obj/Debug/net8.0-windows/Lithicsoft Trainer Studio.AssemblyInfo.cs +++ b/obj/Debug/net8.0-windows/Lithicsoft Trainer Studio.AssemblyInfo.cs @@ -14,7 +14,7 @@ [assembly: System.Reflection.AssemblyCompanyAttribute("Lithicsoft Trainer Studio")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2c7ff433f7f0f33c64a195683371afe5a7a5d517")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1f8bc14045c36b91557f3d1db41c82faa1a345b2")] [assembly: System.Reflection.AssemblyProductAttribute("Lithicsoft Trainer Studio")] [assembly: System.Reflection.AssemblyTitleAttribute("Lithicsoft Trainer Studio")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/obj/Debug/net8.0-windows/Lithicsoft Trainer Studio.AssemblyInfoInputs.cache b/obj/Debug/net8.0-windows/Lithicsoft Trainer Studio.AssemblyInfoInputs.cache index ce41877..6cff219 100644 --- a/obj/Debug/net8.0-windows/Lithicsoft Trainer Studio.AssemblyInfoInputs.cache +++ b/obj/Debug/net8.0-windows/Lithicsoft Trainer Studio.AssemblyInfoInputs.cache @@ -1 +1 @@ -5ac171f6af6751c0c881d2fe4af366fc82ee1a2a81b282c2bd048554e7257b0d +d5f1a474ef3c0b3f3743c1cd60ea904b0c89bebd301cb8b9d2205e73a36b9334