From a2576d387da147d7e6c3e9f7214c35b8c62195c7 Mon Sep 17 00:00:00 2001 From: NeVeSpl Date: Sat, 19 Oct 2024 09:43:06 +0200 Subject: [PATCH] ui adjustment - remember position of the main window --- sources/RevitDBExplorer/Command.cs | 5 ++++ sources/RevitDBExplorer/MainWindow.xaml | 2 +- sources/RevitDBExplorer/MainWindow.xaml.cs | 2 ++ .../Properties/AppSettings.Designer.cs | 26 ++++++++++++++++++- .../Properties/AppSettings.settings | 6 +++++ .../UIComponents/List/ListView.xaml | 17 ++++++------ sources/RevitDBExplorer/app.config | 6 +++++ 7 files changed, 54 insertions(+), 10 deletions(-) diff --git a/sources/RevitDBExplorer/Command.cs b/sources/RevitDBExplorer/Command.cs index 331cdba5..8d30a0ee 100644 --- a/sources/RevitDBExplorer/Command.cs +++ b/sources/RevitDBExplorer/Command.cs @@ -2,10 +2,12 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Windows; using Autodesk.Revit.Attributes; using Autodesk.Revit.DB; using Autodesk.Revit.UI; using RevitDBExplorer.Domain.Selectors; +using RevitDBExplorer.Properties; namespace RevitDBExplorer { @@ -20,6 +22,9 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme var source = SelectorFactory.Create(Selector.CurrentSelection); source.ReadFromTheSource(commandData.Application); var window = new MainWindow(source, commandData.Application.MainWindowHandle); + window.WindowStartupLocation = WindowStartupLocation.Manual; + window.Top = AppSettings.Default.MainWindowTop; + window.Left = AppSettings.Default.MainWindowLeft; window.Show(); windows.Add(new WeakReference(window)); diff --git a/sources/RevitDBExplorer/MainWindow.xaml b/sources/RevitDBExplorer/MainWindow.xaml index a390c824..42f30212 100644 --- a/sources/RevitDBExplorer/MainWindow.xaml +++ b/sources/RevitDBExplorer/MainWindow.xaml @@ -196,7 +196,7 @@ - + diff --git a/sources/RevitDBExplorer/MainWindow.xaml.cs b/sources/RevitDBExplorer/MainWindow.xaml.cs index 8bdff208..47aab31e 100644 --- a/sources/RevitDBExplorer/MainWindow.xaml.cs +++ b/sources/RevitDBExplorer/MainWindow.xaml.cs @@ -392,6 +392,8 @@ private void SaveUserSettings() { AppSettings.Default.MainWindowHeight = Height; AppSettings.Default.MainWindowWidth = Width; + AppSettings.Default.MainWindowTop = Top; + AppSettings.Default.MainWindowLeft = Left; AppSettings.Default.FirstColumnWidth = Workspaces.GetFirstColumnWidth(); AppSettings.Default.Save(); } diff --git a/sources/RevitDBExplorer/Properties/AppSettings.Designer.cs b/sources/RevitDBExplorer/Properties/AppSettings.Designer.cs index 8641c303..7c097733 100644 --- a/sources/RevitDBExplorer/Properties/AppSettings.Designer.cs +++ b/sources/RevitDBExplorer/Properties/AppSettings.Designer.cs @@ -12,7 +12,7 @@ namespace RevitDBExplorer.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.7.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.11.0.0")] internal sealed partial class AppSettings : global::System.Configuration.ApplicationSettingsBase { private static AppSettings defaultInstance = ((AppSettings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new AppSettings()))); @@ -118,5 +118,29 @@ public bool OpenLinksInNewWindow { this["OpenLinksInNewWindow"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("200")] + public double MainWindowTop { + get { + return ((double)(this["MainWindowTop"])); + } + set { + this["MainWindowTop"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("200")] + public double MainWindowLeft { + get { + return ((double)(this["MainWindowLeft"])); + } + set { + this["MainWindowLeft"] = value; + } + } } } diff --git a/sources/RevitDBExplorer/Properties/AppSettings.settings b/sources/RevitDBExplorer/Properties/AppSettings.settings index b301861d..9adff8d8 100644 --- a/sources/RevitDBExplorer/Properties/AppSettings.settings +++ b/sources/RevitDBExplorer/Properties/AppSettings.settings @@ -26,5 +26,11 @@ False + + 200 + + + 200 + \ No newline at end of file diff --git a/sources/RevitDBExplorer/UIComponents/List/ListView.xaml b/sources/RevitDBExplorer/UIComponents/List/ListView.xaml index 63146943..35736489 100644 --- a/sources/RevitDBExplorer/UIComponents/List/ListView.xaml +++ b/sources/RevitDBExplorer/UIComponents/List/ListView.xaml @@ -123,14 +123,15 @@ - + + + diff --git a/sources/RevitDBExplorer/app.config b/sources/RevitDBExplorer/app.config index ca5419e6..d0194a54 100644 --- a/sources/RevitDBExplorer/app.config +++ b/sources/RevitDBExplorer/app.config @@ -51,6 +51,12 @@ False + + 200 + + + 200 + \ No newline at end of file