Skip to content

Commit

Permalink
Merge branch 'development' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
pomianowski authored Mar 13, 2024
2 parents e7e0f07 + ad3215d commit 5969812
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Wpf.Ui/Appearance/ApplicationThemeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ systemTheme is SystemTheme.HC1 or SystemTheme.HC2 or SystemTheme.HCBlack or Syst
themeToSet = ApplicationTheme.HighContrast;
}

Apply(themeToSet);
Apply(themeToSet, updateAccent: updateAccent);
}

/// <summary>
Expand Down
7 changes: 3 additions & 4 deletions src/Wpf.Ui/Controls/ComboBox/ComboBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<Thickness x:Key="ComboBoxBorderThemeThickness">1,1,1,1</Thickness>
<Thickness x:Key="ComboBoxAccentBorderThemeThickness">0,0,0,2</Thickness>
<Thickness x:Key="ComboBoxChevronMargin">8,0,10,0</Thickness>
<Thickness x:Key="ComboBoxItemMargin">3,2,3,0</Thickness>
<Thickness x:Key="ComboBoxItemMargin">6,4,6,0</Thickness>
<Thickness x:Key="ComboBoxItemContentMargin">10,8,8,8</Thickness>
<system:Double x:Key="ComboBoxChevronSize">11.0</system:Double>
<system:Double x:Key="ComboBoxPopupMinHeight">32.0</system:Double>
Expand Down Expand Up @@ -92,7 +92,6 @@
<!-- Universal WPF UI focus -->
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForeground}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Margin" Value="{StaticResource ComboBoxItemMargin}" />
<Setter Property="Padding" Value="{StaticResource ComboBoxItemContentMargin}" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Border.CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
Expand All @@ -101,10 +100,10 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
<Grid>
<Grid Background="Transparent">
<Border
Name="ContentBorder"
Margin="{TemplateBinding Margin}"
Margin="{DynamicResource ComboBoxItemMargin}"
Padding="0"
VerticalAlignment="Stretch"
CornerRadius="{TemplateBinding Border.CornerRadius}"
Expand Down
13 changes: 2 additions & 11 deletions src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<Setter Property="Height" Value="30" />
<Setter Property="MouseOverBackground" Value="{Binding Path=ButtonsBackground, RelativeSource={RelativeSource AncestorType={x:Type controls:TitleBar}}}" />
<Setter Property="ButtonsForeground" Value="{Binding Path=ButtonsForeground, RelativeSource={RelativeSource AncestorType={x:Type controls:TitleBar}}}" />
<Setter Property="MouseOverButtonsForeground" Value="{Binding Path=MouseOverButtonsForeground, RelativeSource={RelativeSource AncestorType={x:Type controls:TitleBar}}}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
<Setter Property="SnapsToDevicePixels" Value="True" />
Expand Down Expand Up @@ -45,9 +46,6 @@
</Viewbox>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="LayoutRoot" Property="Background" Value="{Binding Path=MouseOverBackground, RelativeSource={RelativeSource TemplatedParent}}" />
</Trigger>
<Trigger Property="ButtonType" Value="{x:Static controls:TitleBarButtonType.Help}">
<Setter Property="CommandParameter" Value="{x:Static controls:TitleBarButtonType.Help}" />
<Setter TargetName="ViewBox" Property="Width" Value="13" />
Expand All @@ -74,14 +72,6 @@
<Setter Property="CommandParameter" Value="{x:Static controls:TitleBarButtonType.Close}" />
<Setter TargetName="CanvasPath" Property="Data" Value="M36,41.1,6.15,71a3.44,3.44,0,0,1-2.53,1A3.55,3.55,0,0,1,0,68.38a3.44,3.44,0,0,1,1.05-2.53L30.9,36,1.05,6.15A3.49,3.49,0,0,1,0,3.59,3.51,3.51,0,0,1,.28,2.18,3.42,3.42,0,0,1,1.05,1,3.82,3.82,0,0,1,2.21.28,3.58,3.58,0,0,1,3.62,0,3.44,3.44,0,0,1,6.15,1.05L36,30.9,65.85,1.05a3.49,3.49,0,0,1,2.56-1A3.39,3.39,0,0,1,69.8.28,3.8,3.8,0,0,1,71,1.05a3.8,3.8,0,0,1,.77,1.15A3.39,3.39,0,0,1,72,3.59a3.49,3.49,0,0,1-1,2.56L41.1,36,71,65.85a3.44,3.44,0,0,1,1,2.53,3.58,3.58,0,0,1-.28,1.41A3.82,3.82,0,0,1,71,71a3.42,3.42,0,0,1-1.14.77,3.66,3.66,0,0,1-4-.77Z" />
</Trigger>

<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="ButtonType" Value="{x:Static controls:TitleBarButtonType.Close}" />
<Condition Property="IsMouseOver" Value="True" />
</MultiTrigger.Conditions>
<Setter Property="Foreground" Value="#FFFFFFFF" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
Expand Down Expand Up @@ -193,6 +183,7 @@
x:Name="PART_CloseButton"
Grid.Column="4"
ButtonType="Close"
MouseOverButtonsForeground="White"
MouseOverBackground="{DynamicResource PaletteRedBrush}" />
</Grid>
</Grid>
Expand Down
26 changes: 25 additions & 1 deletion src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ internal class TitleBarButton : Wpf.Ui.Controls.Button
)
);

/// <summary>
/// Property for <see cref="MouseOverButtonsForeground"/>.
/// </summary>
public static readonly DependencyProperty MouseOverButtonsForegroundProperty = DependencyProperty.Register(
nameof(MouseOverButtonsForeground),
typeof(Brush),
typeof(TitleBarButton),
new FrameworkPropertyMetadata(
SystemColors.ControlTextBrush,
FrameworkPropertyMetadataOptions.Inherits
)
);

/// <summary>
/// Sets or gets the
/// </summary>
Expand All @@ -53,11 +66,20 @@ public Brush ButtonsForeground
get => (Brush)GetValue(ButtonsForegroundProperty);
set => SetValue(ButtonsForegroundProperty, value);
}
/// <summary>
/// Foreground of the navigation buttons while mouse over.
/// </summary>
public Brush MouseOverButtonsForeground
{
get => (Brush)GetValue(MouseOverButtonsForegroundProperty);
set => SetValue(MouseOverButtonsForegroundProperty, value);
}

public bool IsHovered { get; private set; }

private User32.WM_NCHITTEST _returnValue;
private Brush _defaultBackgroundBrush = Brushes.Transparent; //Should it be transparent?
private Brush _cacheButtonsForeground = SystemColors.ControlTextBrush; // cache ButtonsForeground while mouse over

private bool _isClickedDown;

Expand All @@ -70,6 +92,8 @@ public void Hover()
return;

Background = MouseOverBackground;
_cacheButtonsForeground = ButtonsForeground;
ButtonsForeground = MouseOverButtonsForeground;
IsHovered = true;
}

Expand All @@ -82,6 +106,7 @@ public void RemoveHover()
return;

Background = _defaultBackgroundBrush;
ButtonsForeground = _cacheButtonsForeground;

IsHovered = false;
_isClickedDown = false;
Expand Down Expand Up @@ -119,7 +144,6 @@ internal bool ReactToHwndHook(User32.WM msg, IntPtr lParam, out IntPtr returnInt

RemoveHover();
return false;

case User32.WM.NCMOUSELEAVE: // Mouse leaves the window
RemoveHover();
return false;
Expand Down
24 changes: 24 additions & 0 deletions src/Wpf.Ui/INavigationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,44 @@ public interface INavigationService
/// <returns><see langword="true"/> if the operation succeeds. <see langword="false"/> otherwise.</returns>
bool Navigate(Type pageType);

/// <summary>
/// Lets you navigate to the selected page based on it's type, Should be used with <see cref="IPageService"/>.
/// </summary>
/// <param name="pageType"><see langword="Type"/> of the page.</param>
/// <param name="dataContext">DataContext <see cref="Object"/></param>
/// <returns><see langword="true"/> if the operation succeeds. <see langword="false"/> otherwise.</returns>
bool Navigate(Type pageType, object? dataContext);

/// <summary>
/// Lets you navigate to the selected page based on it's tag. Should be used with <see cref="IPageService"/>.
/// </summary>
/// <param name="pageIdOrTargetTag">Id or tag of the page.</param>
/// <returns><see langword="true"/> if the operation succeeds. <see langword="false"/> otherwise.</returns>
bool Navigate(string pageIdOrTargetTag);

/// <summary>
/// Lets you navigate to the selected page based on it's tag. Should be used with <see cref="IPageService"/>.
/// </summary>
/// <param name="pageIdOrTargetTag">Id or tag of the page.</param>
/// <param name="dataContext">DataContext <see cref="Object"/></param>
/// <returns><see langword="true"/> if the operation succeeds. <see langword="false"/> otherwise.</returns>
bool Navigate(string pageIdOrTargetTag, object? dataContext);

/// <summary>
/// Synchronously adds an element to the navigation stack and navigates current navigation Frame to the
/// </summary>
/// <param name="pageType">Type of control to be synchronously added to the navigation stack</param>
/// <returns><see langword="true"/> if the operation succeeds. <see langword="false"/> otherwise.</returns>
bool NavigateWithHierarchy(Type pageType);

/// <summary>
/// Synchronously adds an element to the navigation stack and navigates current navigation Frame to the
/// </summary>
/// <param name="pageType">Type of control to be synchronously added to the navigation stack</param>
/// <param name="dataContext">DataContext <see cref="Object"/></param>
/// <returns><see langword="true"/> if the operation succeeds. <see langword="false"/> otherwise.</returns>
bool NavigateWithHierarchy(Type pageType, object? dataContext);

/// <summary>
/// Provides direct access to the control responsible for navigation.
/// </summary>
Expand Down
24 changes: 24 additions & 0 deletions src/Wpf.Ui/NavigationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ public bool Navigate(Type pageType)
return NavigationControl!.Navigate(pageType);
}

/// <inheritdoc />
public bool Navigate(Type pageType, object? dataContext)
{
ThrowIfNavigationControlIsNull();

return NavigationControl!.Navigate(pageType, dataContext);
}

/// <inheritdoc />
public bool Navigate(string pageTag)
{
Expand All @@ -88,6 +96,14 @@ public bool Navigate(string pageTag)
return NavigationControl!.Navigate(pageTag);
}

/// <inheritdoc />
public bool Navigate(string pageTag, object? dataContext)
{
ThrowIfNavigationControlIsNull();

return NavigationControl!.Navigate(pageTag, dataContext);
}

/// <inheritdoc />
public bool GoBack()
{
Expand All @@ -104,6 +120,14 @@ public bool NavigateWithHierarchy(Type pageType)
return NavigationControl!.NavigateWithHierarchy(pageType);
}

/// <inheritdoc />
public bool NavigateWithHierarchy(Type pageType, object? dataContext)
{
ThrowIfNavigationControlIsNull();

return NavigationControl!.NavigateWithHierarchy(pageType, dataContext);
}

private void ThrowIfNavigationControlIsNull()
{
if (NavigationControl is null)
Expand Down

0 comments on commit 5969812

Please sign in to comment.