Skip to content

Commit 8f28aba

Browse files
authored
Merge pull request #4300 from batzen/features/ControlzEx6
Update ControlzEx to version 6.0
2 parents 05906a2 + 32e0430 commit 8f28aba

27 files changed

+358
-384
lines changed

src/Directory.Build.Targets

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,14 @@
1818
<Page Update="@(Page)" SubType="Designer" Generator="MSBuild:Compile" />
1919
</ItemGroup>
2020

21+
<Target Name="RemoveDuplicateAnalyzers" BeforeTargets="CoreCompile">
22+
<!-- Work around https://github.com/dotnet/wpf/issues/6792 -->
23+
24+
<ItemGroup>
25+
<FilteredAnalyzer Include="@(Analyzer->Distinct())" />
26+
<Analyzer Remove="@(Analyzer)" />
27+
<Analyzer Include="@(FilteredAnalyzer)" />
28+
</ItemGroup>
29+
</Target>
30+
2131
</Project>

src/MahApps.Metro.Samples/MahApps.Metro.Demo/ExampleWindows/CleanWindowDemo.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Title="CleanWindowDemo"
88
Width="800"
99
Height="400"
10-
GlowBrush="{DynamicResource MahApps.Brushes.Accent}"
10+
GlowColor="{DynamicResource MahApps.Colors.Accent}"
1111
Icon="..\mahapps.metro.logo2.ico"
1212
ResizeMode="CanResizeWithGrip"
1313
ShowIconOnTitleBar="True"

src/MahApps.Metro.Samples/MahApps.Metro.Demo/ExampleWindows/SizeToContentDemo.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
55
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
66
Title="SizeToContent Demo"
7-
GlowBrush="{DynamicResource MahApps.Brushes.Accent}"
7+
GlowColor="{DynamicResource MahApps.Colors.Accent}"
88
SizeToContent="WidthAndHeight"
99
WindowStartupLocation="CenterOwner">
1010
<Grid Width="50"

src/MahApps.Metro.Samples/MahApps.Metro.Demo/MainWindow.xaml

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
xmlns:local="clr-namespace:MetroDemo"
88
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
99
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
10-
xmlns:theming="urn:controlzex"
10+
xmlns:controlzEx="urn:controlzex"
1111
Title="MahApps.Metro - Demo Application"
1212
Width="1024"
1313
Height="768"
@@ -18,9 +18,9 @@
1818
d:DesignWidth="800"
1919
mah:DialogParticipation.Register="{Binding}"
2020
Closing="MetroWindow_Closing"
21-
GlowBrush="{DynamicResource MahApps.Brushes.Accent}"
21+
GlowColor="{DynamicResource MahApps.Colors.Accent}"
2222
Icon="mahapps.metro.logo2.ico"
23-
NonActiveGlowBrush="#CDFF0000"
23+
NonActiveGlowColor="#CDFF0000"
2424
ResizeMode="CanResizeWithGrip"
2525
ShowIconOnTitleBar="True"
2626
WindowStartupLocation="CenterScreen"
@@ -37,9 +37,9 @@
3737
<ResourceDictionary>
3838
<ObjectDataProvider x:Key="SyncModePreferenceEnumValues"
3939
MethodName="GetValues"
40-
ObjectType="{x:Type theming:ThemeSyncMode}">
40+
ObjectType="{x:Type controlzEx:ThemeSyncMode}">
4141
<ObjectDataProvider.MethodParameters>
42-
<x:Type TypeName="theming:ThemeSyncMode" />
42+
<x:Type TypeName="controlzEx:ThemeSyncMode" />
4343
</ObjectDataProvider.MethodParameters>
4444
</ObjectDataProvider>
4545

@@ -106,6 +106,14 @@
106106
Style="{DynamicResource MahApps.Styles.Button.Dialogs}" />
107107
</StackPanel>
108108
</UserControl>
109+
110+
<ObjectDataProvider x:Key="CornerPreferenceEnumValues"
111+
MethodName="GetValues"
112+
ObjectType="{x:Type controlzEx:WindowCornerPreference}">
113+
<ObjectDataProvider.MethodParameters>
114+
<x:Type TypeName="controlzEx:WindowCornerPreference" />
115+
</ObjectDataProvider.MethodParameters>
116+
</ObjectDataProvider>
109117
</ResourceDictionary>
110118
</Window.Resources>
111119

@@ -168,7 +176,7 @@
168176
ItemsSource="{Binding Source={StaticResource SyncModePreferenceEnumValues}}" />
169177
<MenuItem Header="Use HSL colors?"
170178
IsCheckable="True"
171-
IsChecked="{Binding Options.UseHSL, Source={x:Static theming:RuntimeThemeGenerator.Current}, Mode=TwoWay}" />
179+
IsChecked="{Binding Options.UseHSL, Source={x:Static controlzEx:RuntimeThemeGenerator.Current}, Mode=TwoWay}" />
172180

173181
<MenuItem Command="{Binding DataContext.SyncThemeNowCommand, RelativeSource={RelativeSource AncestorType=Window}}" Header="Sync now" />
174182
</MenuItem>
@@ -218,6 +226,29 @@
218226
<MenuItem Command="{Binding ShowCustomDialogCommand}" Header="Show CustomDialog via VM" />
219227
</MenuItem>
220228
<MenuItem Header="Window">
229+
<MenuItem Header="Chrome">
230+
<MenuItem>
231+
<MenuItem.Template>
232+
<ControlTemplate>
233+
<StackPanel Orientation="Horizontal">
234+
<Label Content="CornerPreference" />
235+
<ComboBox VerticalAlignment="Center"
236+
ItemsSource="{Binding Source={StaticResource CornerPreferenceEnumValues}}"
237+
SelectedItem="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=CornerPreference, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
238+
</StackPanel>
239+
</ControlTemplate>
240+
</MenuItem.Template>
241+
</MenuItem>
242+
</MenuItem>
243+
<MenuItem Header="Glow">
244+
<MenuItem Header="PreferDWMBorderColor"
245+
IsCheckable="True"
246+
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=PreferDWMBorderColor}" />
247+
<MenuItem Header="DWMSupportsBorderColor"
248+
IsEnabled="False"
249+
IsCheckable="True"
250+
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=DWMSupportsBorderColor}" />
251+
</MenuItem>
221252
<MenuItem Header="ShowTitleBar"
222253
IsCheckable="True"
223254
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=ShowTitleBar}" />

src/MahApps.Metro.Samples/MahApps.Metro.Demo/MainWindow.xaml.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,8 @@ private void MenuWindowWithBorderOnClick(object sender, RoutedEventArgs e)
586586
{
587587
var w = this.GetTestWindow();
588588
w.Content = new TextBlock { Text = "MetroWindow with Border", FontSize = 28, FontWeight = FontWeights.Light, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center };
589+
w.GlowColor = null;
590+
w.NonActiveGlowColor = null;
589591
w.Show();
590592
}
591593

@@ -595,7 +597,7 @@ private void MenuWindowWithGlowOnClick(object sender, RoutedEventArgs e)
595597
w.Content = new Button { Content = "MetroWindow with Glow", ToolTip = "And test tool tip", FontSize = 28, FontWeight = FontWeights.Light, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center };
596598
w.BorderThickness = new Thickness(1);
597599
w.BorderBrush = null;
598-
w.SetResourceReference(GlowBrushProperty, "MahApps.Brushes.Accent");
600+
w.SetResourceReference(GlowColorProperty, "MahApps.Colors.Accent");
599601
w.Show();
600602
}
601603

@@ -605,7 +607,7 @@ private void MenuWindowWithShadowOnClick(object sender, RoutedEventArgs e)
605607
w.Content = new TextBlock { Text = "Window with drop shadow", FontSize = 28, FontWeight = FontWeights.Light, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center };
606608
w.BorderThickness = new Thickness(0);
607609
w.BorderBrush = null;
608-
w.GlowBrush = Brushes.Black;
610+
w.GlowColor = Colors.Black;
609611
w.Show();
610612
}
611613
}

src/MahApps.Metro/Behaviors/BorderlessWindowBehavior.cs

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/MahApps.Metro/Behaviors/WindowsSettingBehavior.cs

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44

55
using System;
66
using System.Diagnostics;
7+
using System.Runtime.InteropServices;
78
using System.Windows;
89
using System.Windows.Interop;
9-
using ControlzEx.Native;
10-
using ControlzEx.Standard;
10+
using Windows.Win32;
11+
using Windows.Win32.Foundation;
12+
using Windows.Win32.Graphics.Gdi;
13+
using Windows.Win32.UI.WindowsAndMessaging;
1114
using MahApps.Metro.Controls;
1215
using Microsoft.Xaml.Behaviors;
1316

@@ -108,7 +111,6 @@ private void CleanUp(string fromWhere)
108111
});
109112
}
110113

111-
#pragma warning disable 618
112114
private void LoadWindowState()
113115
{
114116
var window = this.AssociatedObject;
@@ -141,7 +143,7 @@ private void LoadWindowState()
141143

142144
try
143145
{
144-
var wp = settings.Placement;
146+
var wp = settings.Placement.ToWINDOWPLACEMENT();
145147
WinApiHelper.SetWindowPlacement(window, wp);
146148
}
147149
catch (Exception ex)
@@ -165,29 +167,48 @@ private void SaveWindowState()
165167
}
166168

167169
var windowHandle = new WindowInteropHelper(window).EnsureHandle();
168-
var wp = NativeMethods.GetWindowPlacement(windowHandle);
170+
var wp = new WINDOWPLACEMENT
171+
{
172+
length = (uint)Marshal.SizeOf<WINDOWPLACEMENT>()
173+
};
174+
unsafe
175+
{
176+
PInvoke.GetWindowPlacement((HWND)windowHandle, &wp);
177+
}
169178

170179
// check for saveable values
171-
if (wp.showCmd != SW.HIDE && wp.length > 0)
180+
if (wp.showCmd != SHOW_WINDOW_CMD.SW_HIDE && wp.length > 0)
172181
{
173-
if (wp.showCmd == SW.NORMAL)
182+
if (wp.showCmd == SHOW_WINDOW_CMD.SW_NORMAL)
174183
{
175-
if (UnsafeNativeMethods.GetWindowRect(windowHandle, out var rect))
184+
unsafe
176185
{
177-
var monitor = NativeMethods.MonitorFromWindow(windowHandle, MonitorOptions.MONITOR_DEFAULTTONEAREST);
178-
if (monitor != IntPtr.Zero)
186+
var rect = new RECT();
187+
PInvoke.GetWindowRect(new HWND(windowHandle), &rect);
188+
if (rect.left != 0
189+
|| rect.top != 0
190+
|| rect.right != 0
191+
|| rect.bottom != 0)
179192
{
180-
var monitorInfo = NativeMethods.GetMonitorInfo(monitor);
181-
rect.Offset(monitorInfo.rcMonitor.Left - monitorInfo.rcWork.Left, monitorInfo.rcMonitor.Top - monitorInfo.rcWork.Top);
193+
var monitor = PInvoke.MonitorFromWindow(new HWND(windowHandle), MONITOR_FROM_FLAGS.MONITOR_DEFAULTTONEAREST);
194+
if (monitor != IntPtr.Zero)
195+
{
196+
var monitorInfo = new MONITORINFO
197+
{
198+
cbSize = (uint)Marshal.SizeOf<MONITORINFO>()
199+
};
200+
PInvoke.GetMonitorInfo(monitor, &monitorInfo);
201+
rect.Offset(monitorInfo.rcMonitor.left - monitorInfo.rcWork.left, monitorInfo.rcMonitor.top - monitorInfo.rcWork.top);
202+
}
203+
204+
wp.rcNormalPosition = rect;
182205
}
183-
184-
wp.normalPosition = rect;
185206
}
186207
}
187208

188-
if (!wp.normalPosition.IsEmpty)
209+
if (!wp.rcNormalPosition.IsEmpty())
189210
{
190-
settings.Placement = wp;
211+
settings.Placement = WindowPlacementSetting.FromWINDOWPLACEMENT(wp);
191212
}
192213
}
193214

@@ -200,6 +221,5 @@ private void SaveWindowState()
200221
Trace.TraceError($"{this}: The settings could not be saved! {e}");
201222
}
202223
}
203-
#pragma warning restore 618
204224
}
205225
}

src/MahApps.Metro/Controls/ContentControlEx.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Windows;
66
using System.Windows.Controls;
77
using System.Windows.Data;
8-
using ControlzEx.Windows.Shell;
8+
using ControlzEx;
99
using MahApps.Metro.ValueBoxes;
1010

1111
namespace MahApps.Metro.Controls

src/MahApps.Metro/Controls/ContentPresenterEx.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Windows;
66
using System.Windows.Controls;
77
using System.Windows.Data;
8-
using ControlzEx.Windows.Shell;
8+
using ControlzEx;
99

1010
namespace MahApps.Metro.Controls
1111
{

0 commit comments

Comments
 (0)