Skip to content

Commit

Permalink
quick fix to problems with multiple windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl Chang committed Oct 18, 2018
1 parent c714c2a commit c301239
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
12 changes: 6 additions & 6 deletions App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
29 changes: 15 additions & 14 deletions Win_Format.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}

Expand Down Expand Up @@ -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;
Expand Down
Binary file modified bin/Release/DesktopNote.exe
Binary file not shown.

0 comments on commit c301239

Please sign in to comment.