Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Oct 21, 2020
2 parents 828fee0 + 7f2733d commit 8561290
Show file tree
Hide file tree
Showing 35 changed files with 482 additions and 471 deletions.
2 changes: 1 addition & 1 deletion GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
assembly-versioning-scheme: Major
assembly-file-versioning-scheme: MajorMinorPatchTag
mode: ContinuousDeployment
next-version: 2.2.0
next-version: 2.3.0
branches:
master:
regex: ^main
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ Does your company use MahApps.Metro? Ask your manager or marketing team if your
* [Papercut](https://github.com/jaben/papercut) by [@Jaben](https://github.com/Jaben) Simple Desktop SMTP Server / Email Receiver
* [SimpleMP](https://github.com/punker76/simple-music-player) by [@punker76](https://github.com/punker76) Simple Music Player - SimpleMP - Keeps it simple and plays your music
* [Solutionizer](https://github.com/thoemmi/Solutionizer) by [@thoemmi](https://github.com/thoemmi) Creating ad-hoc solutions for Visual Studio
* [WinReform](https://github.com/AKruimink/WinReform) by [@AKruimink](https://github.com/AKruimink) A simple tool to help resize and relocate stubborn windows.
* [Xamarin Inspector](https://docs.microsoft.com/en-us/xamarin/tools/inspector/) Visualize and debug your live app
* [Xamarin Workbooks](https://docs.microsoft.com/en-us/xamarin/tools/workbooks/) Workbooks is an interactive programming environment that’s perfect for experimentation, learning, and documentation: an educational tool for learning the myriad of .NET platforms, APIs, and libraries. [Source](https://github.com/Microsoft/workbooks)

Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.Props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<!-- Add the references for all projects and targets -->
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2019.*" PrivateAssets="All" />
<PackageReference Include="JetBrains.Annotations" Version="2020.*" PrivateAssets="All" />
<PackageReference Include="WpfAnalyzers" Version="2.4.*" PrivateAssets="All" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Costura.Fody" Version="4.*" />
<PackageReference Include="Costura.Fody" Version="4.*" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<None Include="app.manifest" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:materialDesignConverters="clr-namespace:MaterialDesignThemes.Wpf.Converters;assembly=MaterialDesignThemes.Wpf"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:metroDemo="clr-namespace:MetroDemo"
d:DataContext="{d:DesignInstance metroDemo:MainWindowViewModel}"
Expand Down Expand Up @@ -51,8 +50,6 @@
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>

<materialDesignConverters:BrushRoundConverter x:Key="BrushRoundConverter" />

<Style x:Key="MahApps.Styles.ListBoxItem.HamburgerMenuItem.Ripple"
BasedOn="{StaticResource MahApps.Styles.ListBoxItem.HamburgerMenuItem}"
TargetType="{x:Type ListBoxItem}">
Expand Down Expand Up @@ -82,7 +79,7 @@
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
Feedback="{TemplateBinding Foreground, Converter={StaticResource BrushRoundConverter}}"
Feedback="{DynamicResource MahApps.Brushes.Gray.MouseOver}"
Focusable="False"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>
Expand All @@ -107,13 +104,15 @@
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsSelected" Value="True" />
</MultiTrigger.Conditions>
<Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource Self}, Path=(mah:ItemHelper.HoverSelectedForegroundBrush), Mode=OneWay}" />
<Setter TargetName="Border" Property="Background" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.HoverSelectedBackgroundBrush), Mode=OneWay}" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsSelected" Value="False" />
</MultiTrigger.Conditions>
<Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource Self}, Path=(mah:ItemHelper.HoverForegroundBrush), Mode=OneWay}" />
<Setter TargetName="Border" Property="Background" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(mah:ItemHelper.HoverBackgroundBrush), Mode=OneWay}" />
</MultiTrigger>

Expand All @@ -138,8 +137,9 @@
<Setter Property="mah:ItemHelper.DisabledForegroundBrush" Value="{DynamicResource MahApps.Brushes.Gray}" />
<Setter Property="mah:ItemHelper.DisabledSelectedBackgroundBrush" Value="Transparent" />
<Setter Property="mah:ItemHelper.DisabledSelectedForegroundBrush" Value="{DynamicResource MahApps.Brushes.Gray}" />
<Setter Property="mah:ItemHelper.HoverBackgroundBrush" Value="{DynamicResource MahApps.Brushes.Gray9}" />
<Setter Property="mah:ItemHelper.HoverSelectedBackgroundBrush" Value="{DynamicResource MahApps.Brushes.Gray9}" />
<Setter Property="mah:ItemHelper.HoverBackgroundBrush" Value="{DynamicResource MahApps.Brushes.Gray.SemiTransparent}" />
<Setter Property="mah:ItemHelper.HoverSelectedBackgroundBrush" Value="{DynamicResource MahApps.Brushes.Gray.SemiTransparent}" />
<Setter Property="mah:ItemHelper.HoverSelectedForegroundBrush" Value="{DynamicResource MahApps.Brushes.AccentBase}" />
<Setter Property="mah:ItemHelper.SelectedBackgroundBrush" Value="Transparent" />
<Setter Property="mah:ItemHelper.SelectedForegroundBrush" Value="{DynamicResource MahApps.Brushes.AccentBase}" />
</Style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="MahApps.Metro.IconPacks" Version="4.*" />
<PackageReference Include="MaterialDesignThemes" Version="2.*" />
<PackageReference Include="MaterialDesignColors" Version="1.*" />
<PackageReference Include="MaterialDesignThemes" Version="3.0.*" Condition=" '$(TargetFramework)' == 'netcoreapp3.0' " />
<PackageReference Include="MaterialDesignThemes" Version="3.*" Condition=" '$(TargetFramework)' != 'netcoreapp3.0' " />
<PackageReference Include="MaterialDesignColors" Version="1.2.2" Condition=" '$(TargetFramework)' == 'netcoreapp3.0' " />
<PackageReference Include="MaterialDesignColors" Version="1.*" Condition=" '$(TargetFramework)' != 'netcoreapp3.0' " />
<PackageReference Include="NHotkey.Wpf" Version="2.*" />
<PackageReference Include="Fody" Version="6.*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Costura.Fody" Version="4.*" />
<PackageReference Include="Costura.Fody" Version="4.*" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<None Include="app.manifest" />
Expand Down
35 changes: 1 addition & 34 deletions src/MahApps.Metro/Automation/Peers/MetroWindowAutomationPeer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
using System.Windows;
using System.Windows.Automation.Peers;
using JetBrains.Annotations;
using MahApps.Metro.Controls;

namespace MahApps.Metro.Automation.Peers
{
public class MetroWindowAutomationPeer : FrameworkElementAutomationPeer
public class MetroWindowAutomationPeer : WindowAutomationPeer
{
public MetroWindowAutomationPeer([NotNull] Window owner)
: base(owner)
Expand All @@ -20,37 +19,5 @@ protected override string GetClassNameCore()
{
return "MetroWindow";
}

protected override string GetNameCore()
{
string name = base.GetNameCore();

if (name == string.Empty)
{
MetroWindow window = (MetroWindow)this.Owner;

name = window.GetWindowText();
if (name == null)
{
name = string.Empty;
}
}

return name;
}

protected override AutomationControlType GetAutomationControlTypeCore()
{
return AutomationControlType.Window;
}

protected override Rect GetBoundingRectangleCore()
{
MetroWindow window = (MetroWindow)this.Owner;

Rect bounds = window.GetWindowBoundingRectangle();

return bounds;
}
}
}
20 changes: 20 additions & 0 deletions src/MahApps.Metro/Controls/DataGridNumericUpDownColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ private NumericUpDown GenerateNumericUpDown(bool isEditing, DataGridCell cell)
SyncColumnProperty(this, numericUpDown, MinimumProperty, NumericUpDown.MinimumProperty);
SyncColumnProperty(this, numericUpDown, MaximumProperty, NumericUpDown.MaximumProperty);
SyncColumnProperty(this, numericUpDown, NumericInputModeProperty, NumericUpDown.NumericInputModeProperty);
SyncColumnProperty(this, numericUpDown, DecimalPointCorrectionProperty, NumericUpDown.DecimalPointCorrectionProperty);
SyncColumnProperty(this, numericUpDown, IntervalProperty, NumericUpDown.IntervalProperty);
SyncColumnProperty(this, numericUpDown, DelayProperty, NumericUpDown.DelayProperty);
SyncColumnProperty(this, numericUpDown, SpeedupProperty, NumericUpDown.SpeedupProperty);
Expand Down Expand Up @@ -293,6 +294,22 @@ public NumericInput NumericInputMode
set { this.SetValue(NumericInputModeProperty, value); }
}

/// <summary>Identifies the <see cref="DecimalPointCorrection"/> dependency property.</summary>
public static readonly DependencyProperty DecimalPointCorrectionProperty
= DependencyProperty.Register(nameof(DecimalPointCorrection),
typeof(DecimalPointCorrectionMode),
typeof(DataGridNumericUpDownColumn),
new PropertyMetadata(default(DecimalPointCorrectionMode)));

/// <summary>
/// Gets or sets the decimal-point correction mode. The default is <see cref="DecimalPointCorrectionMode.Inherits"/>
/// </summary>
public DecimalPointCorrectionMode DecimalPointCorrection
{
get => (DecimalPointCorrectionMode)this.GetValue(DecimalPointCorrectionProperty);
set => this.SetValue(DecimalPointCorrectionProperty, value);
}

/// <summary>Identifies the <see cref="Interval"/> dependency property.</summary>
public static readonly DependencyProperty IntervalProperty =
NumericUpDown.IntervalProperty.AddOwner(
Expand Down Expand Up @@ -566,6 +583,9 @@ protected override void RefreshCellContent(FrameworkElement element, string prop
case nameof(this.NumericInputMode):
SyncColumnProperty(this, numericUpDown, NumericInputModeProperty, NumericUpDown.NumericInputModeProperty);
break;
case nameof(this.DecimalPointCorrection):
SyncColumnProperty(this, numericUpDown, DecimalPointCorrectionProperty, NumericUpDown.DecimalPointCorrectionProperty);
break;
case nameof(this.Interval):
SyncColumnProperty(this, numericUpDown, IntervalProperty, NumericUpDown.IntervalProperty);
break;
Expand Down
62 changes: 62 additions & 0 deletions src/MahApps.Metro/Controls/Helper/ItemHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,37 @@ public static void SetHoverBackgroundBrush(UIElement element, Brush value)
element.SetValue(HoverBackgroundBrushProperty, value);
}

/// <summary>
/// Gets or sets the foreground brush which will be used for an mouse hovered item.
/// </summary>
public static readonly DependencyProperty HoverForegroundBrushProperty
= DependencyProperty.RegisterAttached("HoverForegroundBrush",
typeof(Brush),
typeof(ItemHelper),
new FrameworkPropertyMetadata(default(Brush), FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits));

/// <summary>
/// Gets the foreground brush which will be used for an mouse hovered item.
/// </summary>
[Category(AppName.MahApps)]
[AttachedPropertyBrowsableForType(typeof(ListBoxItem))]
[AttachedPropertyBrowsableForType(typeof(TreeViewItem))]
public static Brush GetHoverForegroundBrush(UIElement element)
{
return (Brush)element.GetValue(HoverForegroundBrushProperty);
}

/// <summary>
/// Sets the foreground brush which will be used for an mouse hovered item.
/// </summary>
[Category(AppName.MahApps)]
[AttachedPropertyBrowsableForType(typeof(ListBoxItem))]
[AttachedPropertyBrowsableForType(typeof(TreeViewItem))]
public static void SetHoverForegroundBrush(UIElement element, Brush value)
{
element.SetValue(HoverForegroundBrushProperty, value);
}

/// <summary>
/// Gets or sets the background brush which will be used for an mouse hovered and selected item.
/// </summary>
Expand Down Expand Up @@ -197,6 +228,37 @@ public static void SetHoverSelectedBackgroundBrush(UIElement element, Brush valu
element.SetValue(HoverSelectedBackgroundBrushProperty, value);
}

/// <summary>
/// Gets or sets the foreground brush which will be used for an mouse hovered and selected item.
/// </summary>
public static readonly DependencyProperty HoverSelectedForegroundBrushProperty
= DependencyProperty.RegisterAttached("HoverSelectedForegroundBrush",
typeof(Brush),
typeof(ItemHelper),
new FrameworkPropertyMetadata(default(Brush), FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits));

/// <summary>
/// Gets the foreground brush which will be used for an mouse hovered and selected item.
/// </summary>
[Category(AppName.MahApps)]
[AttachedPropertyBrowsableForType(typeof(ListBoxItem))]
[AttachedPropertyBrowsableForType(typeof(TreeViewItem))]
public static Brush GetHoverSelectedForegroundBrush(UIElement element)
{
return (Brush)element.GetValue(HoverSelectedForegroundBrushProperty);
}

/// <summary>
/// Sets the foreground brush which will be used for an mouse hovered and selected item.
/// </summary>
[Category(AppName.MahApps)]
[AttachedPropertyBrowsableForType(typeof(ListBoxItem))]
[AttachedPropertyBrowsableForType(typeof(TreeViewItem))]
public static void SetHoverSelectedForegroundBrush(UIElement element, Brush value)
{
element.SetValue(HoverSelectedForegroundBrushProperty, value);
}

/// <summary>
/// Gets or sets the background brush which will be used for selected disabled items.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/MahApps.Metro/Controls/Helper/TextBoxHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,11 @@ public static void ButtonClicked(object sender, RoutedEventArgs e)
var commandParameter = GetButtonCommandParameter(parent) ?? parent;
if (command != null && command.CanExecute(commandParameter))
{
if (parent is TextBox textBox)
{
textBox.GetBindingExpression(TextBox.TextProperty)?.UpdateSource();
}

command.Execute(commandParameter);
}

Expand Down
9 changes: 7 additions & 2 deletions src/MahApps.Metro/Controls/TimePicker/TimePicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Globalization;
using System.Windows;
using System.Windows.Threading;

Expand Down Expand Up @@ -51,9 +52,13 @@ protected override void SetSelectedDateTime()
return;
}

if (TimeSpan.TryParse(this.textBox.Text, this.SpecificCultureInfo, out var timeSpan))
const DateTimeStyles dateTimeParseStyle = DateTimeStyles.AllowWhiteSpaces
& DateTimeStyles.AssumeLocal
& DateTimeStyles.NoCurrentDateDefault;

if (DateTime.TryParse(this.textBox.Text, this.SpecificCultureInfo, dateTimeParseStyle, out var timeSpan))
{
this.SetCurrentValue(SelectedDateTimeProperty, this.SelectedDateTime.GetValueOrDefault().Date + timeSpan);
this.SetCurrentValue(SelectedDateTimeProperty, this.SelectedDateTime.GetValueOrDefault().Date + timeSpan.TimeOfDay);
}
else
{
Expand Down
27 changes: 2 additions & 25 deletions src/MahApps.Metro/Controls/WinApiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,31 +53,8 @@ internal static string GetWindowText(this Window window)
&& source.RootVisual is null == false
&& source.Handle != IntPtr.Zero)
{
int size = NativeMethods.GetWindowTextLength(source.Handle);
if (size == 0)
{
var lastError = Win32Error.GetLastError();
if (lastError != Win32Error.ERROR_SUCCESS)
{
throw new Win32Exception(lastError.Error);
}

return string.Empty;
}

var builder = new StringBuilder(size + 1);
var finalLength = NativeMethods.GetWindowText(source.Handle, builder, builder.Capacity);
if (finalLength == 0)
{
var lastError = Win32Error.GetLastError();
if (lastError != Win32Error.ERROR_SUCCESS)
{
throw new Win32Exception(lastError.Error);
}

return string.Empty;
}

var builder = new StringBuilder(512);
NativeMethods.GetWindowText(source.Handle, builder, builder.Capacity);
return builder.ToString();
}

Expand Down
Loading

0 comments on commit 8561290

Please sign in to comment.