From fe866c2773778bb7853a1f34e906f24940e06b82 Mon Sep 17 00:00:00 2001 From: idietmoran Date: Sat, 6 Oct 2018 14:18:36 -0400 Subject: [PATCH 1/5] fixed issue where crash would occur if settings was missing --- Indexer.sln | 6 +- ...erSettings.xml => DefaultUserSettings.xml} | 18 +-- IndexerGUI/IndexerGUI.csproj | 19 ++- IndexerGUI/MainWindow.xaml.cs | 3 + IndexerGUI/Properties/Resources.Designer.cs | 80 +++++++++++ IndexerGUI/Properties/Resources.resx | 124 ++++++++++++++++++ IndexerGUI/UserSettings.cs | 4 +- 7 files changed, 235 insertions(+), 19 deletions(-) rename IndexerGUI/{UserSettings.xml => DefaultUserSettings.xml} (98%) create mode 100644 IndexerGUI/Properties/Resources.Designer.cs create mode 100644 IndexerGUI/Properties/Resources.resx diff --git a/Indexer.sln b/Indexer.sln index e761100..025c803 100644 --- a/Indexer.sln +++ b/Indexer.sln @@ -197,16 +197,14 @@ Global {4221929B-B870-3304-9145-D3D9703FE5A0}.Release|Win32.Build.0 = Release|Win32 {4221929B-B870-3304-9145-D3D9703FE5A0}.Release|x86.ActiveCfg = Release|Win32 {4221929B-B870-3304-9145-D3D9703FE5A0}.Release|x86.Build.0 = Release|Win32 - {F889066E-EA03-481A-9817-34E60885A21B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F889066E-EA03-481A-9817-34E60885A21B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F889066E-EA03-481A-9817-34E60885A21B}.Debug|Any CPU.ActiveCfg = Debug|x86 {F889066E-EA03-481A-9817-34E60885A21B}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 {F889066E-EA03-481A-9817-34E60885A21B}.Debug|Mixed Platforms.Build.0 = Debug|x86 {F889066E-EA03-481A-9817-34E60885A21B}.Debug|Win32.ActiveCfg = Debug|x86 {F889066E-EA03-481A-9817-34E60885A21B}.Debug|Win32.Build.0 = Debug|x86 {F889066E-EA03-481A-9817-34E60885A21B}.Debug|x86.ActiveCfg = Debug|x86 {F889066E-EA03-481A-9817-34E60885A21B}.Debug|x86.Build.0 = Debug|x86 - {F889066E-EA03-481A-9817-34E60885A21B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F889066E-EA03-481A-9817-34E60885A21B}.Release|Any CPU.Build.0 = Release|Any CPU + {F889066E-EA03-481A-9817-34E60885A21B}.Release|Any CPU.ActiveCfg = Release|x86 {F889066E-EA03-481A-9817-34E60885A21B}.Release|Mixed Platforms.ActiveCfg = Release|x86 {F889066E-EA03-481A-9817-34E60885A21B}.Release|Mixed Platforms.Build.0 = Release|x86 {F889066E-EA03-481A-9817-34E60885A21B}.Release|Win32.ActiveCfg = Release|x86 diff --git a/IndexerGUI/UserSettings.xml b/IndexerGUI/DefaultUserSettings.xml similarity index 98% rename from IndexerGUI/UserSettings.xml rename to IndexerGUI/DefaultUserSettings.xml index 4ef259f..b545d44 100644 --- a/IndexerGUI/UserSettings.xml +++ b/IndexerGUI/DefaultUserSettings.xml @@ -1,10 +1,10 @@ - - false - false - true - Collapsed - false - - 700 - 1000 + + false + false + true + Collapsed + false + + 700 + 1000 \ No newline at end of file diff --git a/IndexerGUI/IndexerGUI.csproj b/IndexerGUI/IndexerGUI.csproj index aed6d88..463761d 100644 --- a/IndexerGUI/IndexerGUI.csproj +++ b/IndexerGUI/IndexerGUI.csproj @@ -1,4 +1,4 @@ - + @@ -77,7 +77,7 @@ app.manifest - Icons\IndexerLogo.ico + Icons\IndexerLogo.ico OnBuildSuccess @@ -132,6 +132,11 @@ + + True + True + Resources.resx + RegexSyntaxWindow.xaml @@ -226,7 +231,7 @@ - + Designer PreserveNewest @@ -264,6 +269,12 @@ CLIInterop + + + ResXFileCodeGenerator + Resources.Designer.cs + + @@ -280,4 +291,4 @@ --> - + \ No newline at end of file diff --git a/IndexerGUI/MainWindow.xaml.cs b/IndexerGUI/MainWindow.xaml.cs index 08528e2..b651485 100644 --- a/IndexerGUI/MainWindow.xaml.cs +++ b/IndexerGUI/MainWindow.xaml.cs @@ -321,6 +321,9 @@ private void InitPart2() Height = settings.WndHeight; Width = settings.WndWidth; FiltersVisibility = settings.FiltersVisibility; + ExcludeHiddenAndSystem = settings.ExcludeHiddenAndSystem; + ExcludeFiles = settings.ExcludeFiles; + ExcludeFolders = settings.ExcludeFolders; var initialDirPath = CmdArgumentsParser.FilterDirPath; if (string.IsNullOrWhiteSpace(initialDirPath)) diff --git a/IndexerGUI/Properties/Resources.Designer.cs b/IndexerGUI/Properties/Resources.Designer.cs new file mode 100644 index 0000000..54fed44 --- /dev/null +++ b/IndexerGUI/Properties/Resources.Designer.cs @@ -0,0 +1,80 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Indexer.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Indexer.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to <UserSettings xmlns="http://schemas.datacontract.org/2004/07/Indexer" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> + /// <ExcludeFiles>false</ExcludeFiles> + /// <ExcludeFolders>false</ExcludeFolders> + /// <ExcludeHiddenAndSystem>true</ExcludeHiddenAndSystem> + /// <FiltersVisibility>Collapsed</FiltersVisibility> + /// <IsFiltersExpanded>false</IsFiltersExpanded> + /// <SelectedDrives xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"></SelectedDrives> + /// <WndHeight>700</WndHeight> + /// <WndWidth>1000 [rest of string was truncated]";. + /// + internal static string DefaultUserSettings { + get { + return ResourceManager.GetString("DefaultUserSettings", resourceCulture); + } + } + } +} diff --git a/IndexerGUI/Properties/Resources.resx b/IndexerGUI/Properties/Resources.resx new file mode 100644 index 0000000..9085961 --- /dev/null +++ b/IndexerGUI/Properties/Resources.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\DefaultUserSettings.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + \ No newline at end of file diff --git a/IndexerGUI/UserSettings.cs b/IndexerGUI/UserSettings.cs index b01c9b9..2c49470 100644 --- a/IndexerGUI/UserSettings.cs +++ b/IndexerGUI/UserSettings.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Runtime.Serialization; using System.Windows; +using Indexer.Properties; namespace Indexer { @@ -30,8 +31,7 @@ private UserSettings() { if (!File.Exists(SerializationPath)) { - Log.Instance.Error("User settings file does not exist in: " + SerializationPath); - return; + File.WriteAllText(SerializationPath, Resources.DefaultUserSettings); } var saved = (UserSettings) serializer.ReadObject(File.OpenRead(SerializationPath)); From f626af5dfb8a5df44ffde6e1ad05402a79d5245d Mon Sep 17 00:00:00 2001 From: Dimitri Date: Tue, 9 Oct 2018 09:51:40 -0400 Subject: [PATCH 2/5] Removed UserSettings.xml from installer --- Installer/IndexerInstaller.nsi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Installer/IndexerInstaller.nsi b/Installer/IndexerInstaller.nsi index d8f955d..0f2c88c 100644 --- a/Installer/IndexerInstaller.nsi +++ b/Installer/IndexerInstaller.nsi @@ -106,7 +106,6 @@ Section "Bare minimum" Section1 file "${APPNAME}.exe" file "CLIInterop.dll" file "IndexerLogo.ico" - file "UserSettings.xml" file "AddExplorerContextMenu.exe" file "CloseRunningApp.exe" file "AddDirToPathVarialble.exe" @@ -286,4 +285,4 @@ Section "uninstall" delete "$INSTDIR\Uninstall ${APPNAME}.exe" rmDir /r /REBOOTOK '$INSTDIR' -SectionEnd \ No newline at end of file +SectionEnd From 1202a4e0fac14802e7bc27a5af4a72d0b42affbe Mon Sep 17 00:00:00 2001 From: Dimitri Date: Tue, 9 Oct 2018 09:52:59 -0400 Subject: [PATCH 3/5] Removed UserSettings.xml --- installerPickingUpScript.cmd | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/installerPickingUpScript.cmd b/installerPickingUpScript.cmd index 901d2df..7dae6ff 100644 --- a/installerPickingUpScript.cmd +++ b/installerPickingUpScript.cmd @@ -5,7 +5,6 @@ copy /y IndexerGUI\Icons\IndexerLogo.ico Installer copy /y IndexerGUI\Icons\icon_v3_2.ico Installer copy /y CLIInterop\Release\CLIInterop.dll Installer copy /y "IndexerGUI\bin\Release\Indexer++.exe" "Installer\Indexer++ Beta.exe" -copy /y IndexerGUI\bin\Release\UserSettings.xml Installer copy /y ifind\Release\ifind.exe Installer copy /y BasicRE2Syntax.txt Installer copy /y LICENSE Installer @@ -47,4 +46,4 @@ makensis.exe Installer\IndexerInstaller.nsi %signToolPath% sign /n %owner% /t %timestampUrl% /fd sha1 /v "Installer\Indexer++ Beta Installer.exe" %signToolPath% verify /pa "Installer\Indexer++ Beta Installer.exe" -pause \ No newline at end of file +pause From 65579f9f974575a09080040abb7d5550dda6fe32 Mon Sep 17 00:00:00 2001 From: idietmoran Date: Tue, 9 Oct 2018 21:34:29 -0400 Subject: [PATCH 4/5] added saving window position (#36) --- IndexerGUI/DefaultUserSettings.xml | 2 ++ IndexerGUI/Helper.cs | 2 ++ IndexerGUI/MainWindow.xaml.cs | 4 ++++ IndexerGUI/UserSettings.cs | 13 +++++++++++++ 4 files changed, 21 insertions(+) diff --git a/IndexerGUI/DefaultUserSettings.xml b/IndexerGUI/DefaultUserSettings.xml index b545d44..eadd771 100644 --- a/IndexerGUI/DefaultUserSettings.xml +++ b/IndexerGUI/DefaultUserSettings.xml @@ -7,4 +7,6 @@ 700 1000 + 500 + 500 \ No newline at end of file diff --git a/IndexerGUI/Helper.cs b/IndexerGUI/Helper.cs index 1c4c968..7a00102 100644 --- a/IndexerGUI/Helper.cs +++ b/IndexerGUI/Helper.cs @@ -75,6 +75,8 @@ public static bool MakeIndexerMainWndVisible() return false; } mainWindow.Show(); + mainWindow.Left = UserSettings.Instance.ScreenCoord().X; + mainWindow.Top = UserSettings.Instance.ScreenCoord().Y; return true; } diff --git a/IndexerGUI/MainWindow.xaml.cs b/IndexerGUI/MainWindow.xaml.cs index b651485..01b1687 100644 --- a/IndexerGUI/MainWindow.xaml.cs +++ b/IndexerGUI/MainWindow.xaml.cs @@ -324,6 +324,8 @@ private void InitPart2() ExcludeHiddenAndSystem = settings.ExcludeHiddenAndSystem; ExcludeFiles = settings.ExcludeFiles; ExcludeFolders = settings.ExcludeFolders; + this.Left = settings.ScreenCoord().X; + this.Top = settings.ScreenCoord().Y; var initialDirPath = CmdArgumentsParser.FilterDirPath; if (string.IsNullOrWhiteSpace(initialDirPath)) @@ -468,6 +470,8 @@ private void MainWindow_OnClosing(object sender, CancelEventArgs cancelEventArgs { Log.Instance.Debug("MainWindow_OnClosing called."); + UserSettings.Instance.XPos = this.Left; + UserSettings.Instance.YPos = this.Top; UserSettings.Instance.Save(this); if (SystemConfigFlagsWrapper.Instance().PipeManager) diff --git a/IndexerGUI/UserSettings.cs b/IndexerGUI/UserSettings.cs index 2c49470..011357c 100644 --- a/IndexerGUI/UserSettings.cs +++ b/IndexerGUI/UserSettings.cs @@ -45,6 +45,8 @@ private UserSettings() ExcludeHiddenAndSystem = saved.ExcludeHiddenAndSystem; ExcludeFolders = saved.ExcludeFolders; ExcludeFiles = saved.ExcludeFiles; + YPos = saved.YPos; + XPos = saved.XPos; } catch (Exception ex) { @@ -75,6 +77,17 @@ private UserSettings() [DataMember] public bool ExcludeFiles { get; set; } + [DataMember] + public double XPos { get; set; } + + [DataMember] + public double YPos { get; set; } + + public Point ScreenCoord() + { + return new Point(XPos, YPos); + } + public void Save(MainWindow w) { WndHeight = w.Height; From df0c5e70c878b6a470c43461093498b60ec8dbdd Mon Sep 17 00:00:00 2001 From: Dimitri Apostal Date: Mon, 21 Oct 2019 16:05:13 -0400 Subject: [PATCH 5/5] Added data binding for position and height / width --- IndexerGUI/Helper.cs | 2 -- IndexerGUI/MainWindow.xaml | 6 +++++- IndexerGUI/MainWindow.xaml.cs | 4 ++-- IndexerGUI/UserSettings.cs | 7 ++----- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/IndexerGUI/Helper.cs b/IndexerGUI/Helper.cs index 7a00102..1c4c968 100644 --- a/IndexerGUI/Helper.cs +++ b/IndexerGUI/Helper.cs @@ -75,8 +75,6 @@ public static bool MakeIndexerMainWndVisible() return false; } mainWindow.Show(); - mainWindow.Left = UserSettings.Instance.ScreenCoord().X; - mainWindow.Top = UserSettings.Instance.ScreenCoord().Y; return true; } diff --git a/IndexerGUI/MainWindow.xaml b/IndexerGUI/MainWindow.xaml index 9895287..822f27d 100644 --- a/IndexerGUI/MainWindow.xaml +++ b/IndexerGUI/MainWindow.xaml @@ -22,7 +22,11 @@ StateChanged="Window_StateChanged" LostKeyboardFocus="Window_LostKeyboardFocus" GotKeyboardFocus="Window_GotKeyboardFocus" - mc:Ignorable="d"> + mc:Ignorable="d" + Top="{Binding Top, Source=indexer:UserSettings.XPos, Mode=TwoWay}" + Left="{Binding Left, Source=indexer:UserSettings.YPos, Mode=TwoWay}" + Height="{Binding Height, Source=indexer:UserSettings.WndHeight, Mode=TwoWay}" + Width="{Binding Height, Source=indexer:UserSettings.WndWidth, Mode=TwoWay}"> diff --git a/IndexerGUI/MainWindow.xaml.cs b/IndexerGUI/MainWindow.xaml.cs index 01b1687..f361714 100644 --- a/IndexerGUI/MainWindow.xaml.cs +++ b/IndexerGUI/MainWindow.xaml.cs @@ -324,8 +324,8 @@ private void InitPart2() ExcludeHiddenAndSystem = settings.ExcludeHiddenAndSystem; ExcludeFiles = settings.ExcludeFiles; ExcludeFolders = settings.ExcludeFolders; - this.Left = settings.ScreenCoord().X; - this.Top = settings.ScreenCoord().Y; + Left = settings.XPos; + Top = settings.YPos; var initialDirPath = CmdArgumentsParser.FilterDirPath; if (string.IsNullOrWhiteSpace(initialDirPath)) diff --git a/IndexerGUI/UserSettings.cs b/IndexerGUI/UserSettings.cs index 011357c..c8a9355 100644 --- a/IndexerGUI/UserSettings.cs +++ b/IndexerGUI/UserSettings.cs @@ -83,11 +83,6 @@ private UserSettings() [DataMember] public double YPos { get; set; } - public Point ScreenCoord() - { - return new Point(XPos, YPos); - } - public void Save(MainWindow w) { WndHeight = w.Height; @@ -96,6 +91,8 @@ public void Save(MainWindow w) ExcludeHiddenAndSystem = w.ExcludeHiddenAndSystem; ExcludeFolders = w.ExcludeFolders; ExcludeFiles = w.ExcludeFiles; + XPos = w.Top; + YPos = w.Left; SelectedDrives.Clear();