diff --git a/App.xaml.cs b/App.xaml.cs index 7d75616..1f49957 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -96,12 +96,12 @@ private void RunCheck(object sender1, StartupEventArgs e1) var set = DesktopNote.Properties.Settings.Default; for (int i = set.Doc_Location.Count - 1; i >= 0; i--) { - if (string.IsNullOrWhiteSpace(set.Doc_Location[i])) - foreach (System.Configuration.SettingsPropertyValue propval in set.PropertyValues) - { - if (propval.Property.PropertyType == typeof(StringCollection)) - ((StringCollection)propval.PropertyValue).RemoveAt(i); - } + if (!string.IsNullOrWhiteSpace(set.Doc_Location[i])) continue; + foreach (System.Configuration.SettingsPropertyValue propval in set.PropertyValues) + { + if (propval.Property.PropertyType == typeof(StringCollection)) + ((StringCollection)propval.PropertyValue).RemoveAt(i); + } } set.Save(); diff --git a/Win_Format.xaml.cs b/Win_Format.xaml.cs index b641822..65ee114 100644 --- a/Win_Format.xaml.cs +++ b/Win_Format.xaml.cs @@ -240,17 +240,16 @@ public static void NewNote(int refidx = -1) int newidx = 0; foreach (System.Configuration.SettingsPropertyValue propval in set.PropertyValues) { - if (propval.Property.PropertyType == typeof(StringCollection)) + if (propval.Property.PropertyType != typeof(StringCollection)) continue; + var strCol = (StringCollection)propval.PropertyValue; + if (refidx == -1)//create from default { - if (refidx == -1)//create from default - { - var defval = XElement.Parse((string)propval.Property.DefaultValue).Element("string").Value; - newidx = ((StringCollection)propval.PropertyValue).Add(defval); - } - else//create from specified index - { - newidx = ((StringCollection)propval.PropertyValue).Add(((StringCollection)propval.PropertyValue)[refidx]); - } + var defval = XElement.Parse((string)propval.Property.DefaultValue).Element("string").Value; + newidx = strCol.Add(defval); + } + else//create from specified index + { + newidx = strCol.Add(strCol[refidx]); } } @@ -286,16 +285,18 @@ private void Button_Close_Click(object sender, RoutedEventArgs e) case MessageBoxResult.Yes: System.IO.File.Delete(MainWin.CurrentSetting.Doc_Location); System.IO.File.Delete(MainWin.CurrentSetting.Bak_Location); - set.Doc_Location[MainWin.CurrentSetting.SettingIndex] = "";//deletion will be done after restart + set.Doc_Location[MainWin.CurrentSetting.SettingIndex] = "";//mark setting item to be removed after restart set.Save(); - App.MainWindows[MainWin.CurrentSetting.SettingIndex] = null; + App.MainWindows.Remove(MainWin); + //App.MainWindows[MainWin.CurrentSetting.SettingIndex] = null; MainWin.Close(); FadeOut(); break; case MessageBoxResult.No: - set.Doc_Location[MainWin.CurrentSetting.SettingIndex] = "";//deletion will be done after restart + set.Doc_Location[MainWin.CurrentSetting.SettingIndex] = "";//mark setting item to be removed after restart set.Save(); - App.MainWindows[MainWin.CurrentSetting.SettingIndex] = null; + App.MainWindows.Remove(MainWin); + //App.MainWindows[MainWin.CurrentSetting.SettingIndex] = null; MainWin.Close(); FadeOut(); break; diff --git a/bin/Release/DesktopNote.exe b/bin/Release/DesktopNote.exe index 63c471f..6f73a56 100644 Binary files a/bin/Release/DesktopNote.exe and b/bin/Release/DesktopNote.exe differ