From 159a9a4da21998ee04c14a4f02dda58d02eb413e Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 8 Nov 2018 18:36:46 -0600 Subject: [PATCH] Add a progress window. --- smx-config/ProgressWindow.xaml | 15 +++++++++++ smx-config/ProgressWindow.xaml.cs | 45 +++++++++++++++++++++++++++++++ smx-config/SMXConfig.csproj | 7 +++++ 3 files changed, 67 insertions(+) create mode 100644 smx-config/ProgressWindow.xaml create mode 100644 smx-config/ProgressWindow.xaml.cs diff --git a/smx-config/ProgressWindow.xaml b/smx-config/ProgressWindow.xaml new file mode 100644 index 0000000..0b91671 --- /dev/null +++ b/smx-config/ProgressWindow.xaml @@ -0,0 +1,15 @@ + + + diff --git a/smx-config/ProgressWindow.xaml.cs b/smx-config/ProgressWindow.xaml.cs new file mode 100644 index 0000000..62a4869 --- /dev/null +++ b/smx-config/ProgressWindow.xaml.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Interop; + +namespace smx_config +{ + public partial class ProgressWindow: Window + { + private const int GWL_STYLE = -16; + private const int WS_SYSMENU = 0x80000; + [DllImport("user32.dll", SetLastError = true)] + private static extern int GetWindowLong(IntPtr hWnd, int nIndex); + [DllImport("user32.dll")] + private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); + + public ProgressWindow() + { + InitializeComponent(); + + // Hide the window close button, since we can't easily cancel. + Loaded += delegate(object sender, RoutedEventArgs e) { + var hwnd = new WindowInteropHelper(this).Handle; + SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU); + }; + } + + public void SetTotal(int total) + { + ProgressBar.Maximum = total; + } + + public void SetProgress(int progress) + { + ProgressBar.Value = progress; + } + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + } + } +} diff --git a/smx-config/SMXConfig.csproj b/smx-config/SMXConfig.csproj index 9e628f8..22c309a 100644 --- a/smx-config/SMXConfig.csproj +++ b/smx-config/SMXConfig.csproj @@ -105,6 +105,9 @@ + + ProgressWindow.xaml + @@ -120,6 +123,10 @@ MainWindow.xaml Code + + MSBuild:Compile + Designer +