Skip to content

Commit

Permalink
another critical bugfix. Settings get wiped on certain conditions if …
Browse files Browse the repository at this point in the history
…validation fails.....
  • Loading branch information
t0815 committed Oct 30, 2023
1 parent c4d0941 commit 749eac6
Show file tree
Hide file tree
Showing 12 changed files with 552 additions and 487 deletions.
2 changes: 1 addition & 1 deletion MyCBZ/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<applicationSettings>
<Win_CBZ.Win_CBZSettings>
<setting name="Version" serializeAs="String">
<value>0.14.70b</value>
<value>0.14.71b</value>
</setting>
<setting name="RenamerPlaceholders" serializeAs="Xml">
<value>
Expand Down
6 changes: 6 additions & 0 deletions MyCBZ/Exceptions/MetaDataValidationException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,11 @@ public MetaDataValidationException(MetaDataEntry item, String message, bool show
Item = item;
RemoveEntry = removeEntry;
}

public MetaDataValidationException(String key, String value, String message, bool showErrorDialog = false, bool removeEntry = false) : base(message, showErrorDialog)
{
Item = new MetaDataEntry(key, value);
RemoveEntry = removeEntry;
}
}
}
766 changes: 396 additions & 370 deletions MyCBZ/Forms/MainForm.Designer.cs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions MyCBZ/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2692,6 +2692,9 @@ private void SettingsToolStripMenuItem_Click(object sender, EventArgs e)

Win_CBZSettings.Default.ValidateTags = settingsDialog.ValidateTagsSetting;
Win_CBZSettings.Default.TagValidationIgnoreCase = settingsDialog.TagValidationIgnoreCase;
} else
{
//
}
}

Expand Down
8 changes: 4 additions & 4 deletions MyCBZ/Forms/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGU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BUAHaAfQBAAHSAfoBAAHS
AfoBAAHSAfoBAAHSAfoBUAHaAvQB+AH5DwADJQO+3gADvQMlDAAB+gL7AS4B1wH3AQAB0gH6AcwB7QL0
Expand Down Expand Up @@ -490,7 +490,7 @@ The Page with Type 'FrontCover' should be at index 1.
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAK
AwAAAk1TRnQBSQFMAgEBAgEAAUABDgFAAQ4BEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA
AwAAAk1TRnQBSQFMAgEBAgEAAWABDgFgAQ4BEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA
AwABEAMAAQEBAAEYBgABDCEAA/cD2QPEA78D0gPtA/6lAAP+A7kDLA8lA38D/RIAA+cBUgFUAVUD+g8A
A7gBtgK4bwAD+wOGBiUDSQOrA60DfwYlA0QD4wwAA+YDUAMlA30D+gYAA/0DtAMrAyUDumkAA/4DYwkl
A5sGAAPfCSUDRAP9BgAD5wwlA0YD+gMAA7QMJQG2ArhmAAPUDCUDmwYAA98MJQN/A/4DAAPoAzUMJQN9
Expand All @@ -514,7 +514,7 @@ The Page with Type 'FrontCover' should be at index 1.
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAQ
DAAAAk1TRnQBSQFMAgEBBAEAAdgBDgHYAQ4BEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
DAAAAk1TRnQBSQFMAgEBBAEAAfgBDgH4AQ4BEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAASADAAEBAQABCAYAAQgYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
Expand Down
199 changes: 99 additions & 100 deletions MyCBZ/Forms/SettingsDialog.Designer.cs

Large diffs are not rendered by default.

41 changes: 36 additions & 5 deletions MyCBZ/Forms/SettingsDialog.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
Expand All @@ -8,7 +9,9 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Forms;
using Win_CBZ.Data;

namespace Win_CBZ.Forms
{
Expand All @@ -29,16 +32,26 @@ public SettingsDialog()

if (Win_CBZSettings.Default.CustomDefaultProperties != null)
{
CustomDefaultKeys.Lines = Win_CBZSettings.Default.CustomDefaultProperties.OfType<String>().ToArray();
NewDefaults = Win_CBZSettings.Default.CustomDefaultProperties.OfType<String>().ToArray();
}

if (Win_CBZSettings.Default.ValidKnownTags != null)
{
ValidTags.Lines = Win_CBZSettings.Default.ValidKnownTags.OfType<String>().ToArray();
NewValidTagList = Win_CBZSettings.Default.ValidKnownTags.OfType<String>().ToArray();
}

CheckBoxValidateTags.Checked = Win_CBZSettings.Default.ValidateTags;
CheckBoxTagValidationIgnoreCase.Checked = !Win_CBZSettings.Default.TagValidationIgnoreCase;
ValidateTagsSetting = Win_CBZSettings.Default.ValidateTags;
TagValidationIgnoreCase = Win_CBZSettings.Default.TagValidationIgnoreCase;

// ----------------------------------------

ValidTags.Lines = NewValidTagList;
CustomDefaultKeys.Lines = NewDefaults;

CheckBoxValidateTags.Checked = ValidateTagsSetting;
CheckBoxTagValidationIgnoreCase.Checked = !TagValidationIgnoreCase;

DialogResult = DialogResult.Cancel;
}

private void ButtonCancel_Click(object sender, EventArgs e)
Expand All @@ -61,6 +74,23 @@ private void SettingsDialog_FormClosing(object sender, FormClosingEventArgs e)
Program.ProjectModel.MetaData.MakeDefaultKeys(Program.ProjectModel.MetaData.CustomDefaultProperties);

Program.ProjectModel.MetaData.ValidateDefaults();

if (CheckBoxValidateTags.Checked)
{
List<String> test = new List<String>(ValidTags.Lines);
String[] duplicateTags = DataValidation.ValidateDuplicateStrings(test.ToArray());
if (duplicateTags.Length > 0)
{
//ApplicationMessage.ShowWarning("Validateion Error! Duplicate Tags [" + duplicateTags.Select(r => r + ", ") + "] not allowed!", "Validation Error", ApplicationMessage.DialogType.MT_WARNING, ApplicationMessage.DialogButtons.MB_OK);
MessageLogger.Instance.Log(LogMessageEvent.LOGMESSAGE_TYPE_WARNING, "Validateion Error! Duplicate Tags [" + String.Join(",", duplicateTags) + "] not allowed!");

throw new MetaDataValidationException("", "", "Validateion Error! Duplicate Tags [" + String.Join(",", duplicateTags) + "] not allowed!");
}
}

// -------------- DANGER! All validation goes above this line --------------------


if (Win_CBZSettings.Default.CustomDefaultProperties != null)
{
Win_CBZSettings.Default.CustomDefaultProperties.Clear();
Expand All @@ -86,9 +116,10 @@ private void SettingsDialog_FormClosing(object sender, FormClosingEventArgs e)
}
catch (MetaDataValidationException mv)
{
DialogResult = DialogResult.Cancel;
e.Cancel = true;
MessageLogger.Instance.Log(LogMessageEvent.LOGMESSAGE_TYPE_ERROR, mv.Message);
ApplicationMessage.ShowException(mv);
ApplicationMessage.ShowWarning(mv.Message, "Validation Error", ApplicationMessage.DialogType.MT_WARNING, ApplicationMessage.DialogButtons.MB_OK);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions MyCBZ/Win_CBZSettings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion MyCBZ/Win_CBZSettings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Value Profile="(Default)">%APPDATA%\CBZMage\Temp\</Value>
</Setting>
<Setting Name="Version" Type="System.String" Scope="Application">
<Value Profile="(Default)">0.14.70b</Value>
<Value Profile="(Default)">0.14.71b</Value>
</Setting>
<Setting Name="RenamerPlaceholders" Type="System.Collections.Specialized.StringCollection" Scope="Application">
<Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
Expand Down
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Microsoft Visual Studio [Community] 2022 (64-Bit)

## Latest Release

v0.14.70b released!
v0.14.71b released!

## Third party components

Expand Down
6 changes: 3 additions & 3 deletions Win_CBZ-Setup/Win_CBZ-Setup.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -434,15 +434,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Win_CBZ"
"ProductCode" = "8:{E5C5DFCD-821B-42BE-A467-F10EB6A6B89B}"
"PackageCode" = "8:{3137D366-6AE1-4C64-8793-3860CE383F47}"
"ProductCode" = "8:{88E93F51-F31F-4181-92C5-EBB0D109DB11}"
"PackageCode" = "8:{7C2B7900-5DB4-4AC3-AE55-FD0B31211593}"
"UpgradeCode" = "8:{66FAEF81-1CAE-4971-9E0F-796310EFEA5E}"
"AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:FALSE"
"ProductVersion" = "8:0.14.70"
"ProductVersion" = "8:0.14.71"
"Manufacturer" = "8:Trash_s0Ft"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"
Expand Down
Binary file added Win_CBZ-Setup/Win_CBZ_Setup_Win64.zip
Binary file not shown.

0 comments on commit 749eac6

Please sign in to comment.