Skip to content

Commit 822d33f

Browse files
2.1.7.9 The user.xml settings file would become very large in size over time due to an error in handling settings. This version fixes the issue. Also changed the copyright year to 2019 and restructured the solution.
1 parent b55063c commit 822d33f

File tree

10 files changed

+46
-228
lines changed

10 files changed

+46
-228
lines changed

FormMain.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1678,7 +1678,7 @@ private void Click_toolStripMenuItemHideInterface(object sender, EventArgs e)
16781678
/// <param name="e"></param>
16791679
private void Click_toolStripMenuItemAbout(object sender, EventArgs e)
16801680
{
1681-
MessageBox.Show(Settings.Application.GetByKey("Name", defaultValue: Settings.ApplicationName).Value + " " + Settings.Application.GetByKey("Version", defaultValue: Settings.ApplicationVersion).Value + " (\"Clara\")\nDeveloped by Gavin Kendall (2008 - 2018)", "About", MessageBoxButtons.OK, MessageBoxIcon.Information);
1681+
MessageBox.Show(Settings.Application.GetByKey("Name", defaultValue: Settings.ApplicationName).Value + " " + Settings.Application.GetByKey("Version", defaultValue: Settings.ApplicationVersion).Value + " (\"Clara\")\nDeveloped by Gavin Kendall (2008 - 2019)", "About", MessageBoxButtons.OK, MessageBoxIcon.Information);
16821682
}
16831683

16841684
/// <summary>

Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("Gavin Kendall")]
1212
[assembly: AssemblyProduct("Auto Screen Capture")]
13-
[assembly: AssemblyCopyright("2008 - 2018 Gavin Kendall")]
13+
[assembly: AssemblyCopyright("2008 - 2019 Gavin Kendall")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
1616

@@ -32,6 +32,6 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.1.7.8")]
36-
[assembly: AssemblyFileVersion("2.1.7.8")]
35+
[assembly: AssemblyVersion("2.1.7.9")]
36+
[assembly: AssemblyFileVersion("2.1.7.9")]
3737
[assembly: NeutralResourcesLanguageAttribute("en-CA")]
File renamed without changes.

app.config

Lines changed: 0 additions & 212 deletions
This file was deleted.

app.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<assemblyIdentity
44
type="win32"
55
name="GavinKendall.AutoScreenCapture"
6-
version="2.1.7.8"/>
6+
version="2.1.7.9"/>
77
<asmv3:application>
88
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
99
<dpiAware>True/PM</dpiAware>

autoscreen.csproj

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
<Compile Include="image_format\ImageFormat.cs" />
115115
<Compile Include="image_format\ImageFormatCollection.cs" />
116116
<Compile Include="image_format\ImageFormatSpec.cs" />
117-
<Compile Include="Log.cs" />
117+
<Compile Include="log\Log.cs" />
118118
<Compile Include="modules\triggers\TriggerAction.cs" />
119119
<Compile Include="modules\triggers\TriggerActionType.cs" />
120120
<Compile Include="modules\triggers\TriggerCondition.cs" />
@@ -127,9 +127,9 @@
127127
<Compile Include="MacroParser.cs" />
128128
<Compile Include="modules\triggers\Trigger.cs" />
129129
<Compile Include="modules\triggers\TriggerCollection.cs" />
130-
<Compile Include="Setting.cs" />
131-
<Compile Include="SettingCollection.cs" />
132-
<Compile Include="Settings.cs" />
130+
<Compile Include="settings\Setting.cs" />
131+
<Compile Include="settings\SettingCollection.cs" />
132+
<Compile Include="settings\Settings.cs" />
133133
<EmbeddedResource Include="modules\editors\FormEditor.resx">
134134
<DependentUpon>FormEditor.cs</DependentUpon>
135135
</EmbeddedResource>
@@ -155,13 +155,10 @@
155155
<DependentUpon>Resources.resx</DependentUpon>
156156
<DesignTime>True</DesignTime>
157157
</Compile>
158-
<EmbeddedResource Include="app.config">
159-
<SubType>Designer</SubType>
160-
</EmbeddedResource>
161158
<None Include="app.manifest">
162159
<SubType>Designer</SubType>
163160
</None>
164-
<Compile Include="modules\screen\ScreenCapture.cs" />
161+
<Compile Include="ScreenCapture.cs" />
165162
<Compile Include="modules\slideshow\Slideshow.cs" />
166163
</ItemGroup>
167164
<ItemGroup>

Log.cs renamed to log/Log.cs

File renamed without changes.
File renamed without changes.

SettingCollection.cs renamed to settings/SettingCollection.cs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class SettingCollection : IEnumerable<Setting>
1818
{
1919
private readonly List<Setting> _settingList = new List<Setting>();
2020

21+
private const int MAX_FILE_SIZE = 5242880;
2122
private const string XML_FILE_INDENT_CHARS = " ";
2223
private const string XML_FILE_SETTING_NODE = "setting";
2324
private const string XML_FILE_SETTINGS_NODE = "settings";
@@ -46,7 +47,11 @@ IEnumerator<Setting> IEnumerable<Setting>.GetEnumerator()
4647

4748
public void Add(Setting setting)
4849
{
49-
_settingList.Add(setting);
50+
// Make sure we only add the setting to the list if it doesn't exist in the list yet.
51+
if (!KeyExists(setting.Key))
52+
{
53+
_settingList.Add(setting);
54+
}
5055
}
5156

5257
/// <summary>
@@ -73,13 +78,41 @@ public Setting GetByKey(string key, object defaultValue)
7378
return newSetting;
7479
}
7580

81+
/// <summary>
82+
/// Checks if the setting key exists.
83+
/// </summary>
84+
/// <param name="key">The setting key to check.</param>
85+
/// <returns>Returns true if the key exists. Returns false if the key does not exist.</returns>
86+
public bool KeyExists(string key)
87+
{
88+
foreach (Setting setting in _settingList)
89+
{
90+
if (setting.Key.Equals(key))
91+
{
92+
return true;
93+
}
94+
}
95+
96+
return false;
97+
}
98+
7699
/// <summary>
77100
/// Loads the settings.
78101
/// </summary>
79102
public void Load()
80103
{
81104
if (File.Exists(Filepath))
82105
{
106+
FileInfo fileInfo = new FileInfo(Filepath);
107+
108+
// Check the size of the settings file.
109+
// Delete the file if it's too big so we don't hang.
110+
if (fileInfo.Length > MAX_FILE_SIZE)
111+
{
112+
File.Delete(Filepath);
113+
return;
114+
}
115+
83116
XmlDocument xDoc = new XmlDocument();
84117
xDoc.Load(Filepath);
85118

Settings.cs renamed to settings/Settings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace AutoScreenCapture
77
public static class Settings
88
{
99
public static readonly string ApplicationName = "Auto Screen Capture";
10-
public static readonly string ApplicationVersion = "2.1.7.8";
10+
public static readonly string ApplicationVersion = "2.1.7.9";
1111

1212
public static SettingCollection Application;
1313
public static SettingCollection User;
@@ -40,7 +40,7 @@ public static void Initialize()
4040
{
4141
Application.Add(new Setting("Name", ApplicationName));
4242
Application.Add(new Setting("Version", ApplicationVersion));
43-
Application.Add(new Setting("DebugMode", true));
43+
Application.Add(new Setting("DebugMode", false));
4444

4545
Application.Save();
4646
}

0 commit comments

Comments
 (0)