Skip to content

Commit

Permalink
Merge pull request #55 from WPFDevelopersOrg/dev
Browse files Browse the repository at this point in the history
dev pull requese master
  • Loading branch information
yanjinhuagood authored Jul 9, 2023
2 parents e44312b + a6fdb62 commit b65b8d2
Show file tree
Hide file tree
Showing 52 changed files with 1,416 additions and 342 deletions.
20 changes: 16 additions & 4 deletions src/WPFDevelopers.Net40/Themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converts="clr-namespace:WPFDevelopers.Converts"
xmlns:shell="clr-namespace:Microsoft.Windows.Shell"
xmlns:wpfdev="clr-namespace:WPFDevelopers.Net40">
xmlns:wd="clr-namespace:WPFDevelopers.Net40">
<converts:ObjectNullToVisibilityConverter x:Key="ObjectNullToVisibilityConverter" />
<Style BasedOn="{x:Null}" TargetType="{x:Type wpfdev:Window}">
<Style BasedOn="{x:Null}" TargetType="{x:Type wd:Window}">
<Setter Property="Foreground" Value="{DynamicResource WD.WindowForegroundColorBrush}" />
<Setter Property="Background" Value="{DynamicResource WD.BackgroundSolidColorBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource WD.WindowBorderBrushSolidColorBrush}" />
Expand All @@ -19,12 +19,12 @@
<Setter Property="FontFamily" Value="{DynamicResource WD.NormalFontFamily}" />
<Setter Property="shell:WindowChrome.WindowChrome">
<Setter.Value>
<shell:WindowChrome CaptionHeight="{Binding TitleHeight, RelativeSource={RelativeSource AncestorType=wpfdev:Window}}" GlassFrameThickness="0,0,0,.1" />
<shell:WindowChrome CaptionHeight="{Binding TitleHeight, RelativeSource={RelativeSource AncestorType=wd:Window}}" GlassFrameThickness="0,0,0,.1" />
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type wpfdev:Window}">
<ControlTemplate TargetType="{x:Type wd:Window}">
<Border
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Expand All @@ -35,6 +35,7 @@
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid
x:Name="PART_GridChrome"
Grid.Row="0"
Height="{TemplateBinding TitleHeight}"
Background="{TemplateBinding BorderBrush}">
Expand Down Expand Up @@ -138,6 +139,13 @@
</Button>
</WrapPanel>
</Grid>
<ContentPresenter
x:Name="PART_TitleToolBar"
Grid.Row="0"
shell:WindowChrome.IsHitTestVisibleInChrome="True"
Content="{Binding TitleBar, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
Focusable="False"
Visibility="Collapsed" />
<AdornerDecorator Grid.Row="1" KeyboardNavigation.IsTabStop="False">
<ContentPresenter x:Name="MainContentPresenter" ClipToBounds="True" />
</AdornerDecorator>
Expand All @@ -159,6 +167,10 @@
<Trigger Property="WindowStyle" Value="ToolWindow">
<Setter TargetName="PART_MinAndMax" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="NoChrome" Value="True">
<Setter TargetName="PART_GridChrome" Property="Visibility" Value="Collapsed" />
<Setter TargetName="PART_TitleToolBar" Property="Visibility" Value="Visible" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="ResizeMode" Value="CanResizeWithGrip" />
Expand Down
166 changes: 137 additions & 29 deletions src/WPFDevelopers.Net40/Themes/Theme.xaml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/WPFDevelopers.Net40/WPFDevelopers.Net40.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Copyright>Copyright © WPFDevelopersOrg 2022</Copyright>
<AssemblyVersion>1.1.0.1</AssemblyVersion>
<FileVersion>1.1.0.1</FileVersion>
<Version>1.1.0.1</Version>
<AssemblyVersion>1.1.0.2</AssemblyVersion>
<FileVersion>1.1.0.2</FileVersion>
<Version>1.1.0.2</Version>
<RepositoryUrl>https://github.com/WPFDevelopersOrg/WPFDevelopers</RepositoryUrl>
<Configurations>Debug;Release;Debug-.NET40;Release-.NET40</Configurations>
</PropertyGroup>
Expand Down
27 changes: 20 additions & 7 deletions src/WPFDevelopers.Net40/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using Microsoft.Windows.Shell;
using WPFDevelopers.Helpers;

Expand All @@ -12,9 +13,16 @@ namespace WPFDevelopers.Net40
public class Window : System.Windows.Window
{
private WindowStyle _windowStyle;

public static readonly DependencyProperty TitleHeightProperty =
DependencyProperty.Register("TitleHeight", typeof(double), typeof(Window), new PropertyMetadata(50d));

public static readonly DependencyProperty NoChromeProperty =
DependencyProperty.Register("NoChrome", typeof(bool), typeof(Window), new PropertyMetadata(false));

public static readonly DependencyProperty TitleBarProperty =
DependencyProperty.Register("TitleBar", typeof(object), typeof(Window), new PropertyMetadata(null));

static Window()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(Window), new FrameworkPropertyMetadata(typeof(Window)));
Expand Down Expand Up @@ -43,6 +51,18 @@ public double TitleHeight
set => SetValue(TitleHeightProperty, value);
}

public bool NoChrome
{
get => (bool)GetValue(NoChromeProperty);
set => SetValue(NoChromeProperty, value);
}

public object TitleBar
{
get => (object)GetValue(TitleBarProperty);
set => SetValue(TitleBarProperty, value);
}

private void Window_Loaded(object sender, RoutedEventArgs e)
{
hWnd = new WindowInteropHelper(this).Handle;
Expand Down Expand Up @@ -70,23 +90,16 @@ private void CanMinimizeWindow(object sender, CanExecuteRoutedEventArgs e)

private void CloseWindow(object sender, ExecutedRoutedEventArgs e)
{
//Close();
SystemCommands.CloseWindow(this);
}

private void MaximizeWindow(object sender, ExecutedRoutedEventArgs e)
{
SystemCommands.MaximizeWindow(this);
//var window = sender as Window;
//window.WindowState = WindowState.Maximized;
//WindowState = WindowState.Maximized;
}

private void MinimizeWindow(object sender, ExecutedRoutedEventArgs e)
{
//SystemCommands.MinimizeWindow(this);
//WindowStyle = WindowStyle.SingleBorderWindow;
//WindowState = WindowState.Minimized;
SendMessage(hWnd, ApiCodes.WM_SYSCOMMAND, new IntPtr(ApiCodes.SC_MINIMIZE), IntPtr.Zero);
}

Expand Down
20 changes: 16 additions & 4 deletions src/WPFDevelopers.Net45x/Themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converts="clr-namespace:WPFDevelopers.Converts"
xmlns:wpfdev="clr-namespace:WPFDevelopers.Net45x">
xmlns:wd="clr-namespace:WPFDevelopers.Net45x">
<converts:ObjectNullToVisibilityConverter x:Key="ObjectNullToVisibilityConverter" />
<Style
x:Key="WPFDevelopersWindow"
BasedOn="{x:Null}"
TargetType="{x:Type wpfdev:Window}">
TargetType="{x:Type wd:Window}">
<Setter Property="Foreground" Value="{DynamicResource WD.WindowForegroundColorBrush}" />
<Setter Property="Background" Value="{DynamicResource WD.BackgroundSolidColorBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource WD.WindowBorderBrushSolidColorBrush}" />
Expand All @@ -23,14 +23,14 @@
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>
<WindowChrome
CaptionHeight="{Binding TitleHeight, RelativeSource={RelativeSource AncestorType=wpfdev:Window}}"
CaptionHeight="{Binding TitleHeight, RelativeSource={RelativeSource AncestorType=wd:Window}}"
GlassFrameThickness="0,0,0,.1"
UseAeroCaptionButtons="False" />
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type wpfdev:Window}">
<ControlTemplate TargetType="{x:Type wd:Window}">
<Border
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Expand All @@ -41,6 +41,7 @@
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid
x:Name="PART_GridChrome"
Grid.Row="0"
Height="{TemplateBinding TitleHeight}"
Background="{TemplateBinding BorderBrush}">
Expand Down Expand Up @@ -144,6 +145,13 @@
</Button>
</WrapPanel>
</Grid>
<ContentPresenter
x:Name="PART_TitleToolBar"
Grid.Row="0"
Content="{Binding TitleBar, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
Focusable="False"
Visibility="Collapsed"
WindowChrome.IsHitTestVisibleInChrome="True" />
<AdornerDecorator Grid.Row="1" KeyboardNavigation.IsTabStop="False">
<ContentPresenter x:Name="MainContentPresenter" ClipToBounds="True" />
</AdornerDecorator>
Expand All @@ -165,6 +173,10 @@
<Trigger Property="WindowStyle" Value="ToolWindow">
<Setter TargetName="PART_MinAndMax" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="NoChrome" Value="True">
<Setter TargetName="PART_GridChrome" Property="Visibility" Value="Collapsed" />
<Setter TargetName="PART_TitleToolBar" Property="Visibility" Value="Visible" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="ResizeMode" Value="CanResizeWithGrip" />
Expand Down
Loading

0 comments on commit b65b8d2

Please sign in to comment.