Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added saving window position #46

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Indexer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 11 additions & 9 deletions IndexerGUI/UserSettings.xml → IndexerGUI/DefaultUserSettings.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<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</WndWidth>
<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</WndWidth>
<Xpos>500</Xpos>
<Ypos>500</Ypos>
</UserSettings>
2 changes: 2 additions & 0 deletions IndexerGUI/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
19 changes: 15 additions & 4 deletions IndexerGUI/IndexerGUI.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -77,7 +77,7 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Icons\IndexerLogo.ico</ApplicationIcon>
<ApplicationIcon>Icons\IndexerLogo.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
Expand Down Expand Up @@ -132,6 +132,11 @@
<Compile Include="Converters\IconSizeToIntegerConverter.cs" />
<Compile Include="Controls\AutoScalingImage.cs" />
<Compile Include="Converters\IconSizeToWrapPanelItemWidthConvertor.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="RegexSyntaxWindow.xaml.cs">
<DependentUpon>RegexSyntaxWindow.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -226,7 +231,7 @@
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\Indexer++Logo.png" />
<Content Include="UserSettings.xml">
<Content Include="DefaultUserSettings.xml">
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -264,6 +269,12 @@
<Name>CLIInterop</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
Expand All @@ -280,4 +291,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
7 changes: 7 additions & 0 deletions IndexerGUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ private void InitPart2()
Height = settings.WndHeight;
Width = settings.WndWidth;
FiltersVisibility = settings.FiltersVisibility;
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))
Expand Down Expand Up @@ -465,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)
Expand Down
80 changes: 80 additions & 0 deletions IndexerGUI/Properties/Resources.Designer.cs

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

124 changes: 124 additions & 0 deletions IndexerGUI/Properties/Resources.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema

Version 2.0

The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.

Example:

... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>

There are any number of "resheader" rows that contain simple
name/value pairs.

Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.

The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:

Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.

mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="DefaultUserSettings" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\DefaultUserSettings.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
</root>
17 changes: 15 additions & 2 deletions IndexerGUI/UserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Linq;
using System.Runtime.Serialization;
using System.Windows;
using Indexer.Properties;

namespace Indexer
{
Expand All @@ -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));
Expand All @@ -45,6 +45,8 @@ private UserSettings()
ExcludeHiddenAndSystem = saved.ExcludeHiddenAndSystem;
ExcludeFolders = saved.ExcludeFolders;
ExcludeFiles = saved.ExcludeFiles;
YPos = saved.YPos;
XPos = saved.XPos;
}
catch (Exception ex)
{
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions Installer/IndexerInstaller.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -286,4 +285,4 @@ Section "uninstall"
delete "$INSTDIR\Uninstall ${APPNAME}.exe"
rmDir /r /REBOOTOK '$INSTDIR'

SectionEnd
SectionEnd
Loading