From 91745f290c2f4b18549934ecf65e15d36b2fc6c2 Mon Sep 17 00:00:00 2001 From: walterlv Date: Tue, 15 Feb 2022 11:02:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=20UI=20=E6=94=B9=E6=88=90=20Windows?= =?UTF-8?q?=2011=20=E7=9A=84=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WindowDebugger/App.xaml | 22 +- WindowDebugger/App.xaml.cs | 7 + WindowDebugger/MainWindow.xaml | 165 +++-------- WindowDebugger/MainWindow.xaml.cs | 60 +--- WindowDebugger/Themes/Core.xaml | 33 --- WindowDebugger/Themes/FDS/Button.xaml | 67 ----- WindowDebugger/Themes/FDS/ListBox.xaml | 48 ---- WindowDebugger/Themes/FDS/ScrollBar.xaml | 271 ------------------ WindowDebugger/Themes/FDS/ScrollViewer.xaml | 52 ---- WindowDebugger/Themes/FDS/TabControl.xaml | 218 -------------- WindowDebugger/Themes/FDS/Window.xaml | 23 -- WindowDebugger/Themes/Windows11/WPFUIFix.xaml | 128 +++++++++ WindowDebugger/Views/DWMTab.xaml | 158 ---------- WindowDebugger/Views/OperationsTab.xaml | 36 --- WindowDebugger/Views/OthersTab.xaml | 62 ---- WindowDebugger/Views/Pages/AboutPage.xaml | 35 +++ WindowDebugger/Views/Pages/AboutPage.xaml.cs | 34 +++ WindowDebugger/Views/Pages/WindowsPage.xaml | 112 ++++++++ .../Views/Pages/WindowsPage.xaml.cs | 90 ++++++ .../Views/{ => Tabs}/ClassStylesTab.xaml | 61 ++-- .../Views/{ => Tabs}/ClassStylesTab.xaml.cs | 2 +- WindowDebugger/Views/Tabs/DWMTab.xaml | 150 ++++++++++ .../Views/{ => Tabs}/DWMTab.xaml.cs | 2 +- WindowDebugger/Views/Tabs/OperationsTab.xaml | 55 ++++ .../Views/{ => Tabs}/OperationsTab.xaml.cs | 2 +- WindowDebugger/Views/Tabs/OthersTab.xaml | 61 ++++ .../Views/{ => Tabs}/OthersTab.xaml.cs | 2 +- WindowDebugger/Views/Tabs/WindowInfoTab.xaml | 143 +++++++++ .../Views/{ => Tabs}/WindowInfoTab.xaml.cs | 2 +- .../Views/{ => Tabs}/WindowStylesExTab.xaml | 67 +++-- .../{ => Tabs}/WindowStylesExTab.xaml.cs | 2 +- .../Views/{ => Tabs}/WindowStylesTab.xaml | 67 +++-- .../Views/{ => Tabs}/WindowStylesTab.xaml.cs | 2 +- WindowDebugger/Views/WindowInfoTab.xaml | 122 -------- WindowDebugger/WindowDebugger.csproj | 5 +- 35 files changed, 997 insertions(+), 1369 deletions(-) delete mode 100644 WindowDebugger/Themes/Core.xaml delete mode 100644 WindowDebugger/Themes/FDS/Button.xaml delete mode 100644 WindowDebugger/Themes/FDS/ListBox.xaml delete mode 100644 WindowDebugger/Themes/FDS/ScrollBar.xaml delete mode 100644 WindowDebugger/Themes/FDS/ScrollViewer.xaml delete mode 100644 WindowDebugger/Themes/FDS/TabControl.xaml delete mode 100644 WindowDebugger/Themes/FDS/Window.xaml create mode 100644 WindowDebugger/Themes/Windows11/WPFUIFix.xaml delete mode 100644 WindowDebugger/Views/DWMTab.xaml delete mode 100644 WindowDebugger/Views/OperationsTab.xaml delete mode 100644 WindowDebugger/Views/OthersTab.xaml create mode 100644 WindowDebugger/Views/Pages/AboutPage.xaml create mode 100644 WindowDebugger/Views/Pages/AboutPage.xaml.cs create mode 100644 WindowDebugger/Views/Pages/WindowsPage.xaml create mode 100644 WindowDebugger/Views/Pages/WindowsPage.xaml.cs rename WindowDebugger/Views/{ => Tabs}/ClassStylesTab.xaml (63%) rename WindowDebugger/Views/{ => Tabs}/ClassStylesTab.xaml.cs (97%) create mode 100644 WindowDebugger/Views/Tabs/DWMTab.xaml rename WindowDebugger/Views/{ => Tabs}/DWMTab.xaml.cs (99%) create mode 100644 WindowDebugger/Views/Tabs/OperationsTab.xaml rename WindowDebugger/Views/{ => Tabs}/OperationsTab.xaml.cs (98%) create mode 100644 WindowDebugger/Views/Tabs/OthersTab.xaml rename WindowDebugger/Views/{ => Tabs}/OthersTab.xaml.cs (94%) create mode 100644 WindowDebugger/Views/Tabs/WindowInfoTab.xaml rename WindowDebugger/Views/{ => Tabs}/WindowInfoTab.xaml.cs (98%) rename WindowDebugger/Views/{ => Tabs}/WindowStylesExTab.xaml (71%) rename WindowDebugger/Views/{ => Tabs}/WindowStylesExTab.xaml.cs (98%) rename WindowDebugger/Views/{ => Tabs}/WindowStylesTab.xaml (70%) rename WindowDebugger/Views/{ => Tabs}/WindowStylesTab.xaml.cs (98%) delete mode 100644 WindowDebugger/Views/WindowInfoTab.xaml diff --git a/WindowDebugger/App.xaml b/WindowDebugger/App.xaml index fb54d06..3b4ec07 100644 --- a/WindowDebugger/App.xaml +++ b/WindowDebugger/App.xaml @@ -5,15 +5,23 @@ StartupUri="MainWindow.xaml"> + - - - - - - - + + + + + - - - - - - - - - - - + xmlns:pages="clr-namespace:WindowDebugger.Views.Pages" + xmlns:win11="clr-namespace:WPFUI.Controls;assembly=WPFUI" + mc:Ignorable="d" + Width="1200" Height="800" MinWidth="800" MinHeight="550" + Title="WindowDebugger" + Style="{StaticResource UiWindow}" Background="Transparent" Icon="/icon.ico" + SourceInitialized="Window_SourceInitialized" + ContentRendered="Window_ContentRendered"> + + + + + - - + + - - - - - - - - - - - - + + - - - + + + + + + + + + - - - - - - - diff --git a/WindowDebugger/MainWindow.xaml.cs b/WindowDebugger/MainWindow.xaml.cs index 51abf9d..90f4131 100644 --- a/WindowDebugger/MainWindow.xaml.cs +++ b/WindowDebugger/MainWindow.xaml.cs @@ -1,4 +1,5 @@ -using System.ComponentModel; +using System; +using System.ComponentModel; using System.Linq; using System.Windows; using System.Windows.Interop; @@ -12,66 +13,21 @@ namespace WindowDebugger /// public partial class MainWindow : Window { - ViewModel Model => ViewModel.Instance; public MainWindow() { + WPFUI.Background.Manager.Apply(this); InitializeComponent(); } - private void Window_Loaded(object sender, RoutedEventArgs e) + private void Window_SourceInitialized(object sender, EventArgs e) { - _ = UpdateHelper.CheckUpdate(); - RefreshWindowList(null, null); + var hwnd = new WindowInteropHelper(this).Handle; + WPFUI.Background.Manager.Apply(WPFUI.Background.BackgroundType.Mica, hwnd); } - private void RefreshWindowList(object sender, RoutedEventArgs e) + private void Window_ContentRendered(object sender, EventArgs e) { - var selectedNew = Model.SelectedWindow; - var selected = default(WindowItem); - - Model.RefreshWindowList(); - - if (selectedNew != null) - { - selected = Model.Windows.FirstOrDefault(x => x.WindowHandle == selectedNew.WindowHandle); - } - - Model.SelectedWindow = selected ?? Model.Windows.FirstOrDefault(x => x.WindowHandle == new WindowInteropHelper(this).Handle); - if (Model.SelectedWindow != null) - { - WindowList.ScrollIntoView(WindowList.Items[WindowList.Items.Count - 1]); - WindowList.ScrollIntoView(Model.SelectedWindow); - } - } - - private void RefreshCurrent(object sender, RoutedEventArgs e) - { - Model.SelectedWindow?.RefreshItem(); - Model.SelectedWindow?.RefreshScreenShot(); - } - - private void TabControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) - { - if (e.OldValue is WindowItem olditem) - { - olditem.PropertyChanged -= WindowItem_PropertyChanged; - } - if (e.NewValue is WindowItem newitem) - { - newitem.PropertyChanged += WindowItem_PropertyChanged; - } - } - - private void WindowItem_PropertyChanged(object sender, PropertyChangedEventArgs e) - { - if (sender is WindowItem item && e.PropertyName == nameof(WindowItem.ErrorString)) - { - if (item.ErrorString != null) - { - MessageBox.Show(this, item.ErrorString); - item.ErrorString = null; - } - } + RootNavigation.Navigate("windows", false); } } } diff --git a/WindowDebugger/Themes/Core.xaml b/WindowDebugger/Themes/Core.xaml deleted file mode 100644 index 7843c13..0000000 --- a/WindowDebugger/Themes/Core.xaml +++ /dev/null @@ -1,33 +0,0 @@ - - - #1570a6 - #3396cf - #065280 - Black - #999999 - White - White - #6FA7C8 - #232323 - #323232 - #262526 - #323232 - #3f3f42 - #6f6f73 - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/WindowDebugger/Themes/FDS/Button.xaml b/WindowDebugger/Themes/FDS/Button.xaml deleted file mode 100644 index 5a05f77..0000000 --- a/WindowDebugger/Themes/FDS/Button.xaml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/WindowDebugger/Themes/FDS/ListBox.xaml b/WindowDebugger/Themes/FDS/ListBox.xaml deleted file mode 100644 index 5bc4ab9..0000000 --- a/WindowDebugger/Themes/FDS/ListBox.xaml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/WindowDebugger/Themes/FDS/TabControl.xaml b/WindowDebugger/Themes/FDS/TabControl.xaml deleted file mode 100644 index f424c01..0000000 --- a/WindowDebugger/Themes/FDS/TabControl.xaml +++ /dev/null @@ -1,218 +0,0 @@ - - - - #FFE8EDF9 - #FFC5CBF9 - #FF7381F9 - - #FFE8EDF9 - #FFC5CBF9 - #FF888888 - - #FFC5CBF9 - #FFDDDDDD - - White - #FF7381F9 - #FF211AA9 - - #FF3843C4 - #FF211AA9 - - - #FF444444 - sc#1, 0.004391443, 0.002428215, 0.242281124 - - - #FFCCCCCC - #FF888888 - #FF444444 - - #FF888888 - #FF444444 - - #FFAAAAAA - #FF888888 - - Black - - - #FFC5CBF9 - Black - #FFC5CBF9 - - #FF3843C4 - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/WindowDebugger/Themes/FDS/Window.xaml b/WindowDebugger/Themes/FDS/Window.xaml deleted file mode 100644 index 8be3dcd..0000000 --- a/WindowDebugger/Themes/FDS/Window.xaml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/WindowDebugger/Themes/Windows11/WPFUIFix.xaml b/WindowDebugger/Themes/Windows11/WPFUIFix.xaml new file mode 100644 index 0000000..e6c25ba --- /dev/null +++ b/WindowDebugger/Themes/Windows11/WPFUIFix.xaml @@ -0,0 +1,128 @@ + + + + + + + \ No newline at end of file diff --git a/WindowDebugger/Views/DWMTab.xaml b/WindowDebugger/Views/DWMTab.xaml deleted file mode 100644 index 73e6e04..0000000 --- a/WindowDebugger/Views/DWMTab.xaml +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - true - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/WindowDebugger/Views/OthersTab.xaml b/WindowDebugger/Views/OthersTab.xaml deleted file mode 100644 index 7dd64b2..0000000 --- a/WindowDebugger/Views/OthersTab.xaml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/WindowDebugger/Views/Pages/AboutPage.xaml b/WindowDebugger/Views/Pages/AboutPage.xaml new file mode 100644 index 0000000..c3fe5e5 --- /dev/null +++ b/WindowDebugger/Views/Pages/AboutPage.xaml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + diff --git a/WindowDebugger/Views/Pages/AboutPage.xaml.cs b/WindowDebugger/Views/Pages/AboutPage.xaml.cs new file mode 100644 index 0000000..e0e033e --- /dev/null +++ b/WindowDebugger/Views/Pages/AboutPage.xaml.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace WindowDebugger.Views.Pages; +/// +/// AboutPage.xaml 的交互逻辑 +/// +public partial class AboutPage : Page +{ + public AboutPage() + { + InitializeComponent(); + } + + private void AboutPage_Loaded(object sender, RoutedEventArgs e) + { + VersionRun.Text = Assembly.GetExecutingAssembly() + .GetCustomAttribute()?.InformationalVersion + ?? "0.0.0"; + } +} diff --git a/WindowDebugger/Views/Pages/WindowsPage.xaml b/WindowDebugger/Views/Pages/WindowsPage.xaml new file mode 100644 index 0000000..f1f6445 --- /dev/null +++ b/WindowDebugger/Views/Pages/WindowsPage.xaml @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WindowDebugger/Views/Pages/WindowsPage.xaml.cs b/WindowDebugger/Views/Pages/WindowsPage.xaml.cs new file mode 100644 index 0000000..1ab3317 --- /dev/null +++ b/WindowDebugger/Views/Pages/WindowsPage.xaml.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Interop; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +using WindowDebugger.ViewModels; + +namespace WindowDebugger.Views.Pages; +/// +/// WindowsPage.xaml 的交互逻辑 +/// +public partial class WindowsPage : Page +{ + public WindowsPage() + { + InitializeComponent(); + } + + ViewModel Model => ViewModel.Instance; + + private void Page_Loaded(object sender, RoutedEventArgs e) + { + _ = UpdateHelper.CheckUpdate(); + RefreshWindowList(null, null); + } + + private void RefreshWindowList(object sender, RoutedEventArgs e) + { + var selectedNew = Model.SelectedWindow; + var selected = default(WindowItem); + + Model.RefreshWindowList(); + + if (selectedNew != null) + { + selected = Model.Windows.FirstOrDefault(x => x.WindowHandle == selectedNew.WindowHandle); + } + + var hwnd = ((HwndSource)HwndSource.FromVisual(this)).Handle; + + Model.SelectedWindow = selected ?? Model.Windows.FirstOrDefault(x => x.WindowHandle == hwnd); + if (Model.SelectedWindow != null) + { + WindowList.ScrollIntoView(WindowList.Items[WindowList.Items.Count - 1]); + WindowList.ScrollIntoView(Model.SelectedWindow); + } + } + + private void RefreshCurrent(object sender, RoutedEventArgs e) + { + Model.SelectedWindow?.RefreshItem(); + Model.SelectedWindow?.RefreshScreenShot(); + } + + private void TabControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) + { + if (e.OldValue is WindowItem olditem) + { + olditem.PropertyChanged -= WindowItem_PropertyChanged; + } + if (e.NewValue is WindowItem newitem) + { + newitem.PropertyChanged += WindowItem_PropertyChanged; + } + } + + private void WindowItem_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (sender is WindowItem item && e.PropertyName == nameof(WindowItem.ErrorString)) + { + if (item.ErrorString != null) + { + MessageBox.Show(Window.GetWindow(this), item.ErrorString); + item.ErrorString = null; + } + } + } +} diff --git a/WindowDebugger/Views/ClassStylesTab.xaml b/WindowDebugger/Views/Tabs/ClassStylesTab.xaml similarity index 63% rename from WindowDebugger/Views/ClassStylesTab.xaml rename to WindowDebugger/Views/Tabs/ClassStylesTab.xaml index c97ec2d..9109a4c 100644 --- a/WindowDebugger/Views/ClassStylesTab.xaml +++ b/WindowDebugger/Views/Tabs/ClassStylesTab.xaml @@ -1,58 +1,71 @@ - - + - + - - + + - - - - - - - + + + + + + + + + + + + + + + - + - + - - + + - -