Add a progress window.

master
Glenn Maynard 6 years ago
parent 42a99e775b
commit 159a9a4da2
  1. 15
      smx-config/ProgressWindow.xaml
  2. 45
      smx-config/ProgressWindow.xaml.cs
  3. 7
      smx-config/SMXConfig.csproj

@ -0,0 +1,15 @@
<Window x:Class="smx_config.ProgressWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Icon="Resources/window icon.png"
Background="#DDD"
Height="100" Width="325" ResizeMode="NoResize">
<ProgressBar Name="ProgressBar"
Width="300" Height="50"
Value="0"
Maximum="100"
/>
</Window>

@ -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();
}
}
}

@ -105,6 +105,9 @@
<Compile Include="DiagnosticsWidgets.cs" /> <Compile Include="DiagnosticsWidgets.cs" />
<Compile Include="DoubleSlider.cs" /> <Compile Include="DoubleSlider.cs" />
<Compile Include="Helpers.cs" /> <Compile Include="Helpers.cs" />
<Compile Include="ProgressWindow.xaml.cs">
<DependentUpon>ProgressWindow.xaml</DependentUpon>
</Compile>
<Compile Include="SMXJSON.cs" /> <Compile Include="SMXJSON.cs" />
<Compile Include="SMX.cs" /> <Compile Include="SMX.cs" />
<Compile Include="Widgets.cs" /> <Compile Include="Widgets.cs" />
@ -120,6 +123,10 @@
<DependentUpon>MainWindow.xaml</DependentUpon> <DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Page Include="ProgressWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs"> <Compile Include="Properties\AssemblyInfo.cs">

Loading…
Cancel
Save