Skip to content

Commit bcb5ae3

Browse files
committed
Add asterisk to title bar when a file has unsaved changes, and add exit confirmation dialog when a file has unsaved changes
1 parent 3838a18 commit bcb5ae3

File tree

9 files changed

+64
-31
lines changed

9 files changed

+64
-31
lines changed
Binary file not shown.
0 Bytes
Binary file not shown.
-16 KB
Binary file not shown.
16.2 KB
Binary file not shown.

Text Editor Setup/Text Editor Setup-cache/part1/output-info.ini renamed to Text Editor Setup/Text Editor Setup-cache/part2/output-info.ini

1.42 KB
Binary file not shown.

Text Editor Setup/Text Editor Setup.aip

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
<ROW Property="ARPCOMMENTS" Value="This installer database contains the logic and data required to install [|ProductName]." ValueLocId="*"/>
1212
<ROW Property="ARPPRODUCTICON" Value="icon72.exe" Type="8"/>
1313
<ROW Property="Manufacturer" Value="Zach, Inc."/>
14-
<ROW Property="ProductCode" Value="1033:{A2B61194-F215-4E18-9319-7DDBEB6B07B9} " Type="16"/>
14+
<ROW Property="ProductCode" Value="1033:{D01CB925-8853-458C-898A-1BBDA4315485} " Type="16"/>
1515
<ROW Property="ProductLanguage" Value="1033"/>
1616
<ROW Property="ProductName" Value="Text Editor"/>
17-
<ROW Property="ProductVersion" Value="1.0.7" Type="32"/>
17+
<ROW Property="ProductVersion" Value="1.0.8" Type="32"/>
1818
<ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND"/>
1919
<ROW Property="UpgradeCode" Value="{6F659083-3442-43A7-8DA3-D7192D778487}"/>
2020
<ROW Property="WindowsType9X" MultiBuildValue="DefaultBuild:Windows 9x/ME" ValueLocId="-"/>
@@ -57,7 +57,7 @@
5757
<ROW BootstrOptKey="GlobalOptions" DownloadFolder="[AppDataFolder][|Manufacturer]\[|ProductName]\prerequisites" Options="2"/>
5858
</COMPONENT>
5959
<COMPONENT cid="caphyon.advinst.msicomp.BuildComponent">
60-
<ROW BuildKey="DefaultBuild" BuildName="DefaultBuild" BuildOrder="1" BuildType="0" PackageFileName="Text_Editor_1_0_7_Setup" Languages="en" InstallationType="4" UseLargeSchema="true"/>
60+
<ROW BuildKey="DefaultBuild" BuildName="DefaultBuild" BuildOrder="1" BuildType="0" PackageFileName="Text_Editor_1_0_8_Setup" Languages="en" InstallationType="4" UseLargeSchema="true"/>
6161
</COMPONENT>
6262
<COMPONENT cid="caphyon.advinst.msicomp.DictionaryComponent">
6363
<ROW Path="&lt;AI_DICTS&gt;ui.ail"/>

Text Editor/AboutForm.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Text Editor/Form1.Designer.cs

Lines changed: 29 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Text Editor/Form1.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ private void menuItem4_Click(object sender, EventArgs e)
5454
path = ofd.FileName;
5555
Task<string> text = sr.ReadToEndAsync();
5656
mainEditor.Text = text.Result;
57+
this.Text = this.Text.Replace("*", "");
5758
}
5859
}
5960
catch (Exception ex)
@@ -95,6 +96,7 @@ private async void menuItem5_Click(object sender, EventArgs e)
9596
using (StreamWriter sw = new StreamWriter(path))
9697
{
9798
await sw.WriteLineAsync(mainEditor.Text);//Write data to text file
99+
this.Text = this.Text.Replace("*", "");
98100
}
99101
}
100102
catch (Exception ex)
@@ -210,5 +212,34 @@ private void menuItem27_Click(object sender, EventArgs e)
210212
string strWorkPath = Path.GetDirectoryName(strExeFilePath);
211213
Help.ShowHelp(this, Path.Combine(strWorkPath, "textedit-help.chm"));
212214
}
215+
216+
private void mainEditor_TextChanged(object sender, EventArgs e)
217+
{
218+
if (!this.Text.Contains("*"))
219+
{
220+
this.Text = "*" + this.Text;
221+
}
222+
}
223+
224+
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
225+
{
226+
if (this.Text.Contains("*"))
227+
{
228+
229+
switch (e.CloseReason)
230+
{
231+
case CloseReason.UserClosing:
232+
if (MessageBox.Show("Your file has unsaved changes. Are you sure you want to exit?",
233+
"Unsaved changes",
234+
MessageBoxButtons.YesNo,
235+
MessageBoxIcon.Question) == DialogResult.No)
236+
{
237+
e.Cancel = true;
238+
this.menuItem5.PerformClick();
239+
}
240+
break;
241+
}
242+
}
243+
}
213244
}
214245
}

0 commit comments

Comments
 (0)