From 381d159efbda52041b3db7a0a0e1dacb8da5d71e Mon Sep 17 00:00:00 2001 From: chuongmep <31106432+chuongmep@users.noreply.github.com> Date: Sun, 16 Oct 2022 13:09:15 +0800 Subject: [PATCH] keep size change form --- AddInManager/App.config | 21 +++ AddInManager/Model/SettingBindingExtension.cs | 32 +++++ AddInManager/Properties/App.Designer.cs | 62 +++++++++ AddInManager/Properties/App.settings | 15 ++ AddInManager/Properties/Settings.Designer.cs | 26 ---- AddInManager/Properties/Settings.settings | 6 - AddInManager/RevitAddinManager.csproj | 8 +- AddInManager/Themes/Styles/Default.xaml | 131 +++++++++++------- AddInManager/View/FrmAddInManager.xaml | 7 +- AddInManager/View/FrmAddInManager.xaml.cs | 27 ++++ 10 files changed, 244 insertions(+), 91 deletions(-) create mode 100644 AddInManager/App.config create mode 100644 AddInManager/Model/SettingBindingExtension.cs create mode 100644 AddInManager/Properties/App.Designer.cs create mode 100644 AddInManager/Properties/App.settings delete mode 100644 AddInManager/Properties/Settings.Designer.cs delete mode 100644 AddInManager/Properties/Settings.settings diff --git a/AddInManager/App.config b/AddInManager/App.config new file mode 100644 index 0000000..26e0202 --- /dev/null +++ b/AddInManager/App.config @@ -0,0 +1,21 @@ + + + + +
+ + + + + + 400 + + + 600 + + + Default + + + + \ No newline at end of file diff --git a/AddInManager/Model/SettingBindingExtension.cs b/AddInManager/Model/SettingBindingExtension.cs new file mode 100644 index 0000000..22f0447 --- /dev/null +++ b/AddInManager/Model/SettingBindingExtension.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace RevitAddinManager.Model +{ + /// + /// source : https://thomaslevesque.com/2008/11/18/wpf-binding-to-application-settings-using-a-markup-extension/ + /// + public class SettingBindingExtension : Binding + { + public SettingBindingExtension() + { + Initialize(); + } + + public SettingBindingExtension(string path) + : base(path) + { + Initialize(); + } + + private void Initialize() + { + this.Source = Properties.App.Default; + this.Mode = BindingMode.OneTime; + } + } +} diff --git a/AddInManager/Properties/App.Designer.cs b/AddInManager/Properties/App.Designer.cs new file mode 100644 index 0000000..07dee16 --- /dev/null +++ b/AddInManager/Properties/App.Designer.cs @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// +// 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 RevitAddinManager.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")] + internal sealed partial class App : global::System.Configuration.ApplicationSettingsBase { + + private static App defaultInstance = ((App)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new App()))); + + public static App Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("400")] + public double AppWidth { + get { + return ((double)(this["AppWidth"])); + } + set { + this["AppWidth"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("600")] + public double AppHeight { + get { + return ((double)(this["AppHeight"])); + } + set { + this["AppHeight"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("Default")] + public string ThemName { + get { + return ((string)(this["ThemName"])); + } + set { + this["ThemName"] = value; + } + } + } +} diff --git a/AddInManager/Properties/App.settings b/AddInManager/Properties/App.settings new file mode 100644 index 0000000..3e8293f --- /dev/null +++ b/AddInManager/Properties/App.settings @@ -0,0 +1,15 @@ + + + + + + 400 + + + 600 + + + Default + + + \ No newline at end of file diff --git a/AddInManager/Properties/Settings.Designer.cs b/AddInManager/Properties/Settings.Designer.cs deleted file mode 100644 index 4e43697..0000000 --- a/AddInManager/Properties/Settings.Designer.cs +++ /dev/null @@ -1,26 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 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 RevitAddinManager.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.1.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - } -} diff --git a/AddInManager/Properties/Settings.settings b/AddInManager/Properties/Settings.settings deleted file mode 100644 index 049245f..0000000 --- a/AddInManager/Properties/Settings.settings +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/AddInManager/RevitAddinManager.csproj b/AddInManager/RevitAddinManager.csproj index 02585f9..7c88010 100644 --- a/AddInManager/RevitAddinManager.csproj +++ b/AddInManager/RevitAddinManager.csproj @@ -84,10 +84,10 @@ - + True True - Settings.settings + App.settings True @@ -104,9 +104,9 @@ - + SettingsSingleFileGenerator - Settings.Designer.cs + App.Designer.cs MSBuild:Compile diff --git a/AddInManager/Themes/Styles/Default.xaml b/AddInManager/Themes/Styles/Default.xaml index 51dfc83..6aad9c5 100644 --- a/AddInManager/Themes/Styles/Default.xaml +++ b/AddInManager/Themes/Styles/Default.xaml @@ -1,10 +1,10 @@ - + - + @@ -14,23 +14,38 @@ - - + + - - - - + + + + - - + + - + @@ -48,7 +63,7 @@ - + @@ -57,39 +72,56 @@ - - - - - - + + + + + + - + - - + + - + @@ -109,10 +141,8 @@ - - + + @@ -123,8 +153,7 @@ - + @@ -137,11 +166,9 @@ - + - + diff --git a/AddInManager/View/FrmAddInManager.xaml b/AddInManager/View/FrmAddInManager.xaml index 576aeaa..217d4a7 100644 --- a/AddInManager/View/FrmAddInManager.xaml +++ b/AddInManager/View/FrmAddInManager.xaml @@ -9,14 +9,15 @@ xmlns:model="clr-namespace:RevitAddinManager.Model" xmlns:viewModel="clr-namespace:RevitAddinManager.ViewModel" Title="Revit Add In Manager" - Width="400" - Height="600" + Width="{model:SettingBinding AppWidth}" + Height="{model:SettingBinding AppHeight}" MinWidth="400" MinHeight="400" d:DataContext="{d:DesignInstance viewModel:AddInManagerViewModel}" FocusManager.FocusedElement="{Binding ElementName=tbxSearch}" Icon="../Resources/dev.ico" PreviewKeyDown="CloseFormEvent" + SizeChanged="FrmSizeChanged" mc:Ignorable="d"> @@ -102,7 +103,7 @@ - + + { + dispatcher?.Stop(); + action.Invoke(); + }, Dispatcher.CurrentDispatcher); + dispatcher?.Start(); + return dispatcher; + } } \ No newline at end of file