fixed a bug of window

This commit is contained in:
NaBian committed 2019-07-21 21:47:49 +08:00
1 parent b84db8512f
commit 2c0573518b
38 files changed
+540 -592

No files matched your search

@@ -9,8 +9,8 @@
<ApplicationIcon>..\..\Shared\HandyControlDemo_Shared\Resources\Img\icon.ico</ApplicationIcon>
<Configurations>Debug;Release</Configurations>
<Copyright>Copyright © HandyOrg 2018-2019</Copyright>
<FileVersion>2.0.0.0</FileVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<FileVersion>2.1.0.0</FileVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@@ -5,7 +5,7 @@
<AssemblyName>HandyControl</AssemblyName>
<RootNamespace>HandyControl</RootNamespace>
<Version>2.1.0</Version>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Copyright>Copyright © HandyOrg 2018-2019</Copyright>
@@ -14,7 +14,6 @@
<Setter Property="MinWidth" Value="335"/>
<Setter Property="MaxWidth" Value="476"/>
<Setter Property="MaxHeight" Value="680"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="ResizeMode" Value="NoResize"/>
<Setter Property="SizeToContent" Value="WidthAndHeight"/>
<Setter Property="Template">
@@ -32,9 +31,6 @@
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel WindowChrome.IsHitTestVisibleInChrome="True" UseLayoutRounding="True" VerticalAlignment="Top" Grid.Column="1" HorizontalAlignment="Right" Orientation="Horizontal">
<Button Background="{TemplateBinding OtherButtonBackground}" Foreground="{TemplateBinding OtherButtonForeground}" Command="SystemCommands.MinimizeWindowCommand" IsTabStop="False" Name="ButtonMin" Height="29" Style="{StaticResource ButtonIcon}" Width="45" controls:IconElement.Geometry="{StaticResource WindowMinGeometry}" BorderThickness="1,0,1,0" controls:IconElement.Width="10" controls:IconElement.Height="10"/>
<Button Background="{TemplateBinding OtherButtonBackground}" Foreground="{TemplateBinding OtherButtonForeground}" Command="SystemCommands.MaximizeWindowCommand" IsTabStop="False" Name="ButtonMax" Height="29" Style="{StaticResource ButtonIcon}" Width="46" controls:IconElement.Geometry="{StaticResource WindowMaxGeometry}" BorderThickness="1,0,1,0" controls:IconElement.Width="10" controls:IconElement.Height="10"/>
<Button Background="{TemplateBinding OtherButtonBackground}" Foreground="{TemplateBinding OtherButtonForeground}" Command="SystemCommands.RestoreWindowCommand" IsTabStop="False" Name="ButtonRestore" Height="29" Style="{StaticResource ButtonIcon}" Width="46" controls:IconElement.Geometry="{StaticResource WindowRestoreGeometry}" BorderThickness="1,0,1,0" controls:IconElement.Width="10" controls:IconElement.Height="10"/>
<Button Background="{TemplateBinding CloseButtonBackground}" Foreground="{TemplateBinding CloseButtonForeground}" Command="SystemCommands.CloseWindowCommand" IsTabStop="False" Name="ButtonClose" Height="29" Style="{StaticResource ButtonIcon}" Width="46" controls:IconElement.Geometry="{StaticResource CloseGeometry}" BorderThickness="1,0,0,0" controls:IconElement.Width="10" controls:IconElement.Height="10"/>
</StackPanel>
<Grid Grid.Column="0">
@@ -43,8 +39,24 @@
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Image Name="Icon" Margin="10,0,0,0" Source="{TemplateBinding Icon}" VerticalAlignment="Center" Width="16" Height="16"/>
<TextBlock Name="Title" Grid.Column="1" Text="{TemplateBinding Title}" Padding="10,0,0,0" VerticalAlignment="Center"/>
<Button Name="ButtonIcon" Visibility="{TemplateBinding Icon,Converter={StaticResource Object2VisibilityConverter}}" Command="{x:Static SystemCommands.ShowSystemMenuCommand}" Background="Transparent" Margin="10,0,0,0" WindowChrome.IsHitTestVisibleInChrome="True" Style="{StaticResource ButtonCustom}" VerticalAlignment="Center">
<interactivity:Interaction.Triggers>
<interactivity:EventTrigger EventName="MouseDoubleClick">
<interactivity:InvokeCommandAction Command="{x:Static SystemCommands.CloseWindowCommand}" />
</interactivity:EventTrigger>
</interactivity:Interaction.Triggers>
<Image IsHitTestVisible="False" Source="{TemplateBinding Icon}" VerticalAlignment="Center" Width="16" Height="16"/>
</Button>
<TextBlock Grid.Column="1" Text="{TemplateBinding Title}" Padding="10,0,0,0" VerticalAlignment="Center">
<TextBlock.Visibility>
<MultiBinding Converter="{StaticResource BooleanArr2VisibilityConverter}">
<MultiBinding.Bindings>
<Binding Path="ShowTitle" RelativeSource="{RelativeSource TemplatedParent}"/>
<Binding Path="Title" RelativeSource="{RelativeSource TemplatedParent}" Converter="{StaticResource Object2BooleanConverter}"/>
</MultiBinding.Bindings>
</MultiBinding>
</TextBlock.Visibility>
</TextBlock>
<ContentPresenter WindowChrome.IsHitTestVisibleInChrome="True" Grid.Column="2" x:Name="ContentPresenterMain" Content="{TemplateBinding NonClientAreaContent}"/>
</Grid>
</Grid>
@@ -74,45 +86,9 @@
<Trigger Property="IsActive" Value="False">
<Setter Property="Opacity" Value=".8" TargetName="ContentPresenterMain"/>
</Trigger>
<Trigger Property="Icon" Value="{x:Null}">
<Setter Property="Visibility" Value="Collapsed" TargetName="Icon"/>
</Trigger>
<Trigger Property="WindowState" Value="Maximized">
<Setter Property="Padding" Value="8"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Visible" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="WindowState" Value="Normal">
<Setter Property="Visibility" Value="Visible" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="ResizeMode" Value="NoResize">
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMin"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="ResizeMode" Value="CanMinimize">
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonClose">
<Setter Property="Background" TargetName="ButtonClose" Value="{Binding CloseButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonClose" Value="{Binding CloseButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonMax">
<Setter Property="Background" TargetName="ButtonMax" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMax" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonRestore">
<Setter Property="Background" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonMin">
<Setter Property="Background" TargetName="ButtonMin" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMin" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="ShowTitle" Value="False">
<Setter Property="Visibility" Value="Collapsed" TargetName="Title"/>
<Setter Property="Background" TargetName="ButtonClose" Value="{Binding CloseButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonClose" Value="{Binding CloseButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@@ -1,7 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls"
xmlns:interactivity="clr-namespace:HandyControl.Interactivity">
xmlns:interactivity="clr-namespace:HandyControl.Interactivity"
xmlns:tools="https://handyorg.github.io/handycontrol">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Button.xaml"/>
@@ -56,6 +57,8 @@
</Style>
<Style x:Key="WindowWin10" TargetType="controls:Window">
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="#262e2f"/>
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ReverseTextBrush}"/>
@@ -68,7 +71,7 @@
<Setter Property="CloseButtonHoverForeground" Value="White"/>
<Setter Property="OtherButtonBackground" Value="Transparent"/>
<Setter Property="OtherButtonForeground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="OtherButtonHoverBackground" Value="#e5e5e5"/>
<Setter Property="OtherButtonHoverBackground" Value="{DynamicResource DarkMaskBrush}"/>
<Setter Property="OtherButtonHoverForeground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="Template">
<Setter.Value>
@@ -96,8 +99,24 @@
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Image Name="Icon" Margin="10,0,0,0" Source="{TemplateBinding Icon}" VerticalAlignment="Center" Width="16" Height="16"/>
<TextBlock Name="Title" Grid.Column="1" Text="{TemplateBinding Title}" Padding="10,0,0,0" VerticalAlignment="Center"/>
<Button Name="ButtonIcon" Visibility="{TemplateBinding Icon,Converter={StaticResource Object2VisibilityConverter}}" Command="{x:Static SystemCommands.ShowSystemMenuCommand}" Background="Transparent" Margin="10,0,0,0" WindowChrome.IsHitTestVisibleInChrome="True" Style="{StaticResource ButtonCustom}" VerticalAlignment="Center">
<interactivity:Interaction.Triggers>
<interactivity:EventTrigger EventName="MouseDoubleClick">
<interactivity:InvokeCommandAction Command="{x:Static SystemCommands.CloseWindowCommand}" />
</interactivity:EventTrigger>
</interactivity:Interaction.Triggers>
<Image IsHitTestVisible="False" Source="{TemplateBinding Icon}" VerticalAlignment="Center" Width="16" Height="16"/>
</Button>
<TextBlock Grid.Column="1" Text="{TemplateBinding Title}" Padding="10,0,0,0" VerticalAlignment="Center">
<TextBlock.Visibility>
<MultiBinding Converter="{StaticResource BooleanArr2VisibilityConverter}">
<MultiBinding.Bindings>
<Binding Path="ShowTitle" RelativeSource="{RelativeSource TemplatedParent}"/>
<Binding Path="Title" RelativeSource="{RelativeSource TemplatedParent}" Converter="{StaticResource Object2BooleanConverter}"/>
</MultiBinding.Bindings>
</MultiBinding>
</TextBlock.Visibility>
</TextBlock>
<ContentPresenter WindowChrome.IsHitTestVisibleInChrome="True" Grid.Column="2" x:Name="ContentPresenterMain" Content="{TemplateBinding NonClientAreaContent}"/>
</Grid>
</Grid>
@@ -112,11 +131,8 @@
<Setter Property="Opacity" Value=".8" TargetName="ContentPresenterMain"/>
<Setter Property="Opacity" Value=".8" TargetName="ButtonPanel"/>
</Trigger>
<Trigger Property="Icon" Value="{x:Null}">
<Setter Property="Visibility" Value="Collapsed" TargetName="Icon"/>
</Trigger>
<Trigger Property="WindowState" Value="Maximized">
<Setter Property="Padding" Value="8"/>
<Setter Property="Padding" Value="{x:Static tools:VisualHelper.WindowMaximizedPadding}"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Visible" TargetName="ButtonRestore"/>
</Trigger>
@@ -134,23 +150,20 @@
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonClose">
<Setter Property="Background" TargetName="ButtonClose" Value="{Binding CloseButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonClose" Value="{Binding CloseButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Background" TargetName="ButtonClose" Value="{Binding CloseButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonClose" Value="{Binding CloseButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonMax">
<Setter Property="Background" TargetName="ButtonMax" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMax" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Background" TargetName="ButtonMax" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMax" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonRestore">
<Setter Property="Background" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Background" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonMin">
<Setter Property="Background" TargetName="ButtonMin" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMin" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="ShowTitle" Value="False">
<Setter Property="Visibility" Value="Collapsed" TargetName="Title"/>
<Setter Property="Background" TargetName="ButtonMin" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMin" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
@@ -73,15 +73,6 @@
<Compile Include="..\..\Shared\HandyControlDemo_Shared\Properties\AssemblyInfo.cs">
<Link>Properties\AssemblyInfo.cs</Link>
</Compile>
<Compile Include="UserControl\Main\NoUserContent.xaml.cs">
<DependentUpon>NoUserContent.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Page Include="UserControl\Main\NoUserContent.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Shared\HandyControlDemo_Shared\Properties\Langs\Lang.Designer.cs">
@@ -436,6 +427,7 @@
<Link>Resources\Img\LeftMainContent\RepeatButton_16x.png</Link>
</Resource>
</ItemGroup>
<ItemGroup />
<Import Project="..\..\Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -1,111 +0,0 @@
<Grid x:Class="HandyControlDemo.UserControl.NoUserContent"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
Height="29"
DataContext="{Binding NoUser,Source={StaticResource Locator}}"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:data="clr-namespace:HandyControlDemo.Data"
xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel VerticalAlignment="Stretch" Orientation="Horizontal">
<Button Margin="4,0,0,0" Width="28" Height="29" Style="{StaticResource ButtonCustom}">
<hc:Interaction.Triggers>
<hc:EventTrigger EventName="Click">
<hc:InvokeCommandAction Command="{x:Static shell:SystemCommands.ShowSystemMenuCommand}" />
</hc:EventTrigger>
<hc:EventTrigger EventName="MouseDoubleClick">
<hc:InvokeCommandAction Command="{x:Static shell:SystemCommands.CloseWindowCommand}" />
</hc:EventTrigger>
</hc:Interaction.Triggers>
<Path Height="16" Fill="White" Stretch="Uniform" Data="{StaticResource LogoGeometry}"/>
</Button>
<Menu Margin="10,0,0,0" Background="Transparent">
<MenuItem Height="29" Foreground="White" Header="{x:Static langs:Lang.Repository}">
<MenuItem Command="hc:ControlCommands.OpenLink" CommandParameter="https://github.com/NaBian/HandyControl" Header="GitHub">
<MenuItem.Icon>
<Path Data="{StaticResource GithubGeometry}" Fill="{DynamicResource PrimaryTextBrush}"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Command="hc:ControlCommands.OpenLink" CommandParameter="https://www.nuget.org/packages/HandyControl" Header="NuGet">
<MenuItem.Icon>
<Path Data="{StaticResource NugetGeometry}" Fill="#30a5dd"/>
</MenuItem.Icon>
</MenuItem>
</MenuItem>
<MenuItem Height="29" Foreground="White" Header="{x:Static langs:Lang.About}">
<MenuItem Command="{Binding OpenViewCmd}" CommandParameter="{x:Static data:MessageToken.ContributorsView}" Header="{x:Static langs:Lang.Contributors}">
<MenuItem.Icon>
<Path Data="{StaticResource ContributorsGeometry}" Fill="#ef6c00"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Command="{Binding OpenViewCmd}" CommandParameter="{x:Static data:MessageToken.QQGroupView}" Header="{x:Static langs:Lang.QQGroup}">
<MenuItem.Icon>
<Path Data="{StaticResource QqGeometry}" Fill="{DynamicResource PrimaryBrush}"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Command="hc:ControlCommands.OpenLink" CommandParameter="mailto:836904362@qq.com" Header="{x:Static langs:Lang.Email}">
<MenuItem.Icon>
<Path Data="{StaticResource EmailGeometry}" Fill="{DynamicResource WarningBrush}"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Command="hc:ControlCommands.OpenLink" CommandParameter="https://gitter.im/HandyControl/Lobby" Header="{x:Static langs:Lang.Chatroom}">
<MenuItem.Icon>
<Path Data="{StaticResource GitterGeometry}" Fill="#e52e64"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Command="hc:ControlCommands.OpenLink" CommandParameter="https://www.cnblogs.com/nabian" Header="{x:Static langs:Lang.Blog}">
<MenuItem.Icon>
<Path Data="{StaticResource CnblogsGeometry}" Fill="{DynamicResource PrimaryTextBrush}"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="{x:Static langs:Lang.About}" Click="MenuAbout_OnClick">
<MenuItem.Icon>
<Path Data="{StaticResource InfoGeometry}" Fill="{DynamicResource SuccessBrush}"/>
</MenuItem.Icon>
</MenuItem>
</MenuItem>
<MenuItem Height="29" Foreground="White" Header="{x:Static langs:Lang.Recommendation}">
<MenuItem Header="{x:Static langs:Lang.Project}" Command="{Binding OpenViewCmd}" CommandParameter="{x:Static data:MessageToken.ProjectsView}" >
<MenuItem.Icon>
<Path Data="{StaticResource ProjectGeometry}" Fill="{DynamicResource PrimaryTextBrush}"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="{x:Static langs:Lang.Blog}" Command="{Binding OpenViewCmd}" CommandParameter="{x:Static data:MessageToken.BlogsView}" >
<MenuItem.Icon>
<Path Data="{StaticResource BlogGeometry}" Fill="{DynamicResource PrimaryBrush}"/>
</MenuItem.Icon>
</MenuItem>
</MenuItem>
</Menu>
</StackPanel>
<Button Grid.Column="1" Click="ButtonConfig_OnClick" Name="ButtonConfig" Style="{StaticResource ButtonIcon}" hc:IconElement.Geometry="{StaticResource ConfigGeometry}"/>
<Popup AllowsTransparency="True" Grid.Column="1" PlacementTarget="{Binding ElementName=ButtonConfig}" HorizontalOffset="-25" Name="PopupConfig" VerticalOffset="6" StaysOpen="False">
<Border Background="{DynamicResource SecondaryRegionBrush}" CornerRadius="4" Margin="16" Effect="{StaticResource EffectShadow2}">
<StackPanel Orientation="Horizontal">
<StackPanel Button.Click="ButtonLangs_OnClick" Margin="10,10,0,10">
<Button Tag="zh-cn" Style="{StaticResource ButtonCustom}">
<Image Width="32" Source="/HandyControlDemo;component/Resources/Img/Flag/cn.png"/>
</Button>
<Button Tag="en" Style="{StaticResource ButtonCustom}" Margin="0,10,0,0">
<Image Width="32" Source="/HandyControlDemo;component/Resources/Img/Flag/en.png"/>
</Button>
</StackPanel>
<StackPanel Button.Click="ButtonSkins_OnClick" Margin="10,10,10,10">
<Button Tag="{x:Static hc:SkinType.Default}" Style="{StaticResource ButtonCustom}">
<Border Background="White" Width="32" Height="21" CornerRadius="2" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}"/>
</Button>
<Button Tag="{x:Static hc:SkinType.Dark}" Style="{StaticResource ButtonCustom}" Margin="0,10,0,0">
<Border Background="Black" Width="32" Height="21" CornerRadius="2" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}"/>
</Button>
<Button Tag="{x:Static hc:SkinType.Violet}" Style="{StaticResource ButtonCustom}" Margin="0,10,0,0">
<Border Background="DarkViolet" Width="32" Height="21" CornerRadius="2" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}"/>
</Button>
</StackPanel>
</StackPanel>
</Border>
</Popup>
</Grid>
@@ -1,61 +0,0 @@
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using HandyControl.Controls;
using HandyControl.Data;
using HandyControlDemo.Data;
using HandyControlDemo.Window;
namespace HandyControlDemo.UserControl
{
public partial class NoUserContent
{
public NoUserContent()
{
InitializeComponent();
}
private void ButtonLangs_OnClick(object sender, RoutedEventArgs e)
{
if (e.OriginalSource is Button button && button.Tag is string tag)
{
PopupConfig.IsOpen = false;
if (tag.Equals(GlobalData.Config.Lang)) return;
Growl.Ask(Properties.Langs.Lang.ChangeLangAsk, b =>
{
if (!b) return true;
GlobalData.Config.Lang = tag;
GlobalData.Save();
var processModule = Process.GetCurrentProcess().MainModule;
if (processModule != null)
Process.Start(processModule.FileName);
Application.Current.Shutdown();
return true;
});
}
}
private void ButtonConfig_OnClick(object sender, RoutedEventArgs e) => PopupConfig.IsOpen = true;
private void ButtonSkins_OnClick(object sender, RoutedEventArgs e)
{
if (e.OriginalSource is Button button && button.Tag is SkinType tag)
{
PopupConfig.IsOpen = false;
if (tag.Equals(GlobalData.Config.Skin)) return;
GlobalData.Config.Skin = tag;
GlobalData.Save();
((App)Application.Current).UpdateSkin(tag);
}
}
private void MenuAbout_OnClick(object sender, RoutedEventArgs e)
{
new AboutWindow
{
Owner = Application.Current.MainWindow
}.ShowDialog();
}
}
}
@@ -15,7 +15,6 @@
<Setter Property="MinWidth" Value="335"/>
<Setter Property="MaxWidth" Value="476"/>
<Setter Property="MaxHeight" Value="680"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="ResizeMode" Value="NoResize"/>
<Setter Property="SizeToContent" Value="WidthAndHeight"/>
<Setter Property="Template">
@@ -33,9 +32,6 @@
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel shell:WindowChrome.IsHitTestVisibleInChrome="True" UseLayoutRounding="True" VerticalAlignment="Top" Grid.Column="1" HorizontalAlignment="Right" Orientation="Horizontal">
<Button Background="{TemplateBinding OtherButtonBackground}" Foreground="{TemplateBinding OtherButtonForeground}" Command="shell:SystemCommands.MinimizeWindowCommand" IsTabStop="False" Name="ButtonMin" Height="29" Style="{StaticResource ButtonIcon}" Width="45" controls:IconElement.Geometry="{StaticResource WindowMinGeometry}" BorderThickness="1,0,1,0" controls:IconElement.Width="10" controls:IconElement.Height="10"/>
<Button Background="{TemplateBinding OtherButtonBackground}" Foreground="{TemplateBinding OtherButtonForeground}" Command="shell:SystemCommands.MaximizeWindowCommand" IsTabStop="False" Name="ButtonMax" Height="29" Style="{StaticResource ButtonIcon}" Width="46" controls:IconElement.Geometry="{StaticResource WindowMaxGeometry}" BorderThickness="1,0,1,0" controls:IconElement.Width="10" controls:IconElement.Height="10"/>
<Button Background="{TemplateBinding OtherButtonBackground}" Foreground="{TemplateBinding OtherButtonForeground}" Command="shell:SystemCommands.RestoreWindowCommand" IsTabStop="False" Name="ButtonRestore" Height="29" Style="{StaticResource ButtonIcon}" Width="46" controls:IconElement.Geometry="{StaticResource WindowRestoreGeometry}" BorderThickness="1,0,1,0" controls:IconElement.Width="10" controls:IconElement.Height="10"/>
<Button Background="{TemplateBinding CloseButtonBackground}" Foreground="{TemplateBinding CloseButtonForeground}" Command="shell:SystemCommands.CloseWindowCommand" IsTabStop="False" Name="ButtonClose" Height="29" Style="{StaticResource ButtonIcon}" Width="46" controls:IconElement.Geometry="{StaticResource CloseGeometry}" BorderThickness="1,0,0,0" controls:IconElement.Width="10" controls:IconElement.Height="10"/>
</StackPanel>
<Grid Grid.Column="0">
@@ -44,9 +40,25 @@
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Image Name="Icon" Margin="10,0,0,0" Source="{TemplateBinding Icon}" VerticalAlignment="Center" Width="16" Height="16"/>
<TextBlock Name="Title" Grid.Column="1" Text="{TemplateBinding Title}" Padding="10,0,0,0" VerticalAlignment="Center"/>
<ContentPresenter shell:WindowChrome.IsHitTestVisibleInChrome="True" Grid.Column="2" x:Name="ContentPresenterMain" Content="{TemplateBinding NonClientAreaContent}"/>
<Button Name="ButtonIcon" Visibility="{TemplateBinding Icon,Converter={StaticResource Object2VisibilityConverter}}" Command="{x:Static shell:SystemCommands.ShowSystemMenuCommand}" Background="Transparent" Margin="10,0,0,0" shell:WindowChrome.IsHitTestVisibleInChrome="True" Style="{StaticResource ButtonCustom}" VerticalAlignment="Center">
<interactivity:Interaction.Triggers>
<interactivity:EventTrigger EventName="MouseDoubleClick">
<interactivity:InvokeCommandAction Command="{x:Static shell:SystemCommands.CloseWindowCommand}" />
</interactivity:EventTrigger>
</interactivity:Interaction.Triggers>
<Image IsHitTestVisible="False" Source="{TemplateBinding Icon}" VerticalAlignment="Center" Width="16" Height="16"/>
</Button>
<TextBlock Grid.Column="1" Text="{TemplateBinding Title}" Padding="10,0,0,0" VerticalAlignment="Center">
<TextBlock.Visibility>
<MultiBinding Converter="{StaticResource BooleanArr2VisibilityConverter}">
<MultiBinding.Bindings>
<Binding Path="ShowTitle" RelativeSource="{RelativeSource TemplatedParent}"/>
<Binding Path="Title" RelativeSource="{RelativeSource TemplatedParent}" Converter="{StaticResource Object2BooleanConverter}"/>
</MultiBinding.Bindings>
</MultiBinding>
</TextBlock.Visibility>
</TextBlock>
<ContentPresenter shell:WindowChrome.IsHitTestVisibleInChrome="True" Grid.Column="2" x:Name="ContentPresenterMain" Content="{TemplateBinding NonClientAreaContent}"/>
</Grid>
</Grid>
<Grid Grid.Row="1">
@@ -75,45 +87,9 @@
<Trigger Property="IsActive" Value="False">
<Setter Property="Opacity" Value=".8" TargetName="ContentPresenterMain"/>
</Trigger>
<Trigger Property="Icon" Value="{x:Null}">
<Setter Property="Visibility" Value="Collapsed" TargetName="Icon"/>
</Trigger>
<Trigger Property="WindowState" Value="Maximized">
<Setter Property="Padding" Value="8"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Visible" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="WindowState" Value="Normal">
<Setter Property="Visibility" Value="Visible" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="ResizeMode" Value="NoResize">
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMin"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="ResizeMode" Value="CanMinimize">
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonClose">
<Setter Property="Background" TargetName="ButtonClose" Value="{Binding CloseButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonClose" Value="{Binding CloseButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonMax">
<Setter Property="Background" TargetName="ButtonMax" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMax" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonRestore">
<Setter Property="Background" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonMin">
<Setter Property="Background" TargetName="ButtonMin" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMin" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="ShowTitle" Value="False">
<Setter Property="Visibility" Value="Collapsed" TargetName="Title"/>
<Setter Property="Background" TargetName="ButtonClose" Value="{Binding CloseButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonClose" Value="{Binding CloseButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@@ -2,7 +2,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls"
xmlns:interactivity="clr-namespace:HandyControl.Interactivity"
xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell">
xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell"
xmlns:tools="clr-namespace:HandyControl.Tools">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Button.xaml"/>
@@ -57,6 +58,8 @@
</Style>
<Style x:Key="WindowWin10" BasedOn="{x:Null}" TargetType="controls:Window">
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="#262e2f"/>
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="UseLayoutRounding" Value="True"/>
@@ -68,7 +71,7 @@
<Setter Property="CloseButtonHoverForeground" Value="White"/>
<Setter Property="OtherButtonBackground" Value="Transparent"/>
<Setter Property="OtherButtonForeground" Value="{DynamicResource ReverseTextBrush}"/>
<Setter Property="OtherButtonHoverBackground" Value="#e5e5e5"/>
<Setter Property="OtherButtonHoverBackground" Value="{DynamicResource DarkMaskBrush}"/>
<Setter Property="OtherButtonHoverForeground" Value="{DynamicResource ReverseTextBrush}"/>
<Setter Property="Template">
<Setter.Value>
@@ -96,8 +99,24 @@
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Image Name="Icon" Margin="10,0,0,0" Source="{TemplateBinding Icon}" VerticalAlignment="Center" Width="16" Height="16"/>
<TextBlock Name="Title" Grid.Column="1" Text="{TemplateBinding Title}" Padding="10,0,0,0" VerticalAlignment="Center"/>
<Button Name="ButtonIcon" Visibility="{TemplateBinding Icon,Converter={StaticResource Object2VisibilityConverter}}" Command="{x:Static shell:SystemCommands.ShowSystemMenuCommand}" Background="Transparent" Margin="10,0,0,0" shell:WindowChrome.IsHitTestVisibleInChrome="True" Style="{StaticResource ButtonCustom}" VerticalAlignment="Center">
<interactivity:Interaction.Triggers>
<interactivity:EventTrigger EventName="MouseDoubleClick">
<interactivity:InvokeCommandAction Command="{x:Static shell:SystemCommands.CloseWindowCommand}" />
</interactivity:EventTrigger>
</interactivity:Interaction.Triggers>
<Image IsHitTestVisible="False" Name="Icon" Source="{TemplateBinding Icon}" VerticalAlignment="Center" Width="16" Height="16"/>
</Button>
<TextBlock Grid.Column="1" Text="{TemplateBinding Title}" Padding="10,0,0,0" VerticalAlignment="Center">
<TextBlock.Visibility>
<MultiBinding Converter="{StaticResource BooleanArr2VisibilityConverter}">
<MultiBinding.Bindings>
<Binding Path="ShowTitle" RelativeSource="{RelativeSource TemplatedParent}"/>
<Binding Path="Title" RelativeSource="{RelativeSource TemplatedParent}" Converter="{StaticResource Object2BooleanConverter}"/>
</MultiBinding.Bindings>
</MultiBinding>
</TextBlock.Visibility>
</TextBlock>
<ContentPresenter shell:WindowChrome.IsHitTestVisibleInChrome="True" Grid.Column="2" x:Name="ContentPresenterMain" Content="{TemplateBinding NonClientAreaContent}"/>
</Grid>
</Grid>
@@ -112,11 +131,8 @@
<Setter Property="Opacity" Value=".8" TargetName="ContentPresenterMain"/>
<Setter Property="Opacity" Value=".8" TargetName="ButtonPanel"/>
</Trigger>
<Trigger Property="Icon" Value="{x:Null}">
<Setter Property="Visibility" Value="Collapsed" TargetName="Icon"/>
</Trigger>
<Trigger Property="WindowState" Value="Maximized">
<Setter Property="Padding" Value="8"/>
<Setter Property="Padding" Value="{x:Static tools:VisualHelper.WindowMaximizedPadding}"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Visible" TargetName="ButtonRestore"/>
</Trigger>
@@ -134,23 +150,20 @@
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonClose">
<Setter Property="Background" TargetName="ButtonClose" Value="{Binding CloseButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonClose" Value="{Binding CloseButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Background" TargetName="ButtonClose" Value="{Binding CloseButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonClose" Value="{Binding CloseButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonMax">
<Setter Property="Background" TargetName="ButtonMax" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMax" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Background" TargetName="ButtonMax" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMax" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonRestore">
<Setter Property="Background" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Background" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonMin">
<Setter Property="Background" TargetName="ButtonMin" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMin" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="ShowTitle" Value="False">
<Setter Property="Visibility" Value="Collapsed" TargetName="Title"/>
<Setter Property="Background" TargetName="ButtonMin" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMin" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
@@ -149,9 +149,6 @@
<DesignTime>True</DesignTime>
<DependentUpon>Lang.resx</DependentUpon>
</Compile>
<Compile Include="UserControl\Main\NoUserContent.xaml.cs">
<DependentUpon>NoUserContent.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\1.jpg">
@@ -431,12 +428,6 @@
<Link>Resources\Img\under_construction.gif</Link>
</Resource>
</ItemGroup>
<ItemGroup>
<Page Include="UserControl\Main\NoUserContent.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\..\Shared\HandyControlDemo_Shared\Properties\Langs\Lang.en.resx">
<Link>Properties\Langs\Lang.en.resx</Link>
@@ -500,6 +491,7 @@
<Link>Resources\fabric-icons.ttf</Link>
</Resource>
</ItemGroup>
<ItemGroup />
<Import Project="..\..\Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -1,110 +0,0 @@
<Grid x:Class="HandyControlDemo.UserControl.NoUserContent"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
Height="29"
DataContext="{Binding NoUser,Source={StaticResource Locator}}"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:data="clr-namespace:HandyControlDemo.Data">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel VerticalAlignment="Stretch" Orientation="Horizontal">
<Button Margin="4,0,0,0" Width="28" Height="29" Style="{StaticResource ButtonCustom}">
<hc:Interaction.Triggers>
<hc:EventTrigger EventName="Click">
<hc:InvokeCommandAction Command="{x:Static SystemCommands.ShowSystemMenuCommand}" />
</hc:EventTrigger>
<hc:EventTrigger EventName="MouseDoubleClick">
<hc:InvokeCommandAction Command="{x:Static SystemCommands.CloseWindowCommand}" />
</hc:EventTrigger>
</hc:Interaction.Triggers>
<Path Height="16" Fill="White" Stretch="Uniform" Data="{StaticResource LogoGeometry}"/>
</Button>
<Menu Margin="10,0,0,0" Background="Transparent">
<MenuItem Height="29" Foreground="White" Header="{x:Static langs:Lang.Repository}">
<MenuItem Command="hc:ControlCommands.OpenLink" CommandParameter="https://github.com/NaBian/HandyControl" Header="GitHub">
<MenuItem.Icon>
<Path Data="{StaticResource GithubGeometry}" Fill="{DynamicResource PrimaryTextBrush}"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Command="hc:ControlCommands.OpenLink" CommandParameter="https://www.nuget.org/packages/HandyControl" Header="NuGet">
<MenuItem.Icon>
<Path Data="{StaticResource NugetGeometry}" Fill="#30a5dd"/>
</MenuItem.Icon>
</MenuItem>
</MenuItem>
<MenuItem Height="29" Foreground="White" Header="{x:Static langs:Lang.About}">
<MenuItem Command="{Binding OpenViewCmd}" CommandParameter="{x:Static data:MessageToken.ContributorsView}" Header="{x:Static langs:Lang.Contributors}">
<MenuItem.Icon>
<Path Data="{StaticResource ContributorsGeometry}" Fill="#ef6c00"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Command="{Binding OpenViewCmd}" CommandParameter="{x:Static data:MessageToken.QQGroupView}" Header="{x:Static langs:Lang.QQGroup}">
<MenuItem.Icon>
<Path Data="{StaticResource QqGeometry}" Fill="{DynamicResource PrimaryBrush}"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Command="hc:ControlCommands.OpenLink" CommandParameter="mailto:836904362@qq.com" Header="{x:Static langs:Lang.Email}">
<MenuItem.Icon>
<Path Data="{StaticResource EmailGeometry}" Fill="{DynamicResource WarningBrush}"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Command="hc:ControlCommands.OpenLink" CommandParameter="https://gitter.im/HandyControl/Lobby" Header="{x:Static langs:Lang.Chatroom}">
<MenuItem.Icon>
<Path Data="{StaticResource GitterGeometry}" Fill="#e52e64"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Command="hc:ControlCommands.OpenLink" CommandParameter="https://www.cnblogs.com/nabian" Header="{x:Static langs:Lang.Blog}">
<MenuItem.Icon>
<Path Data="{StaticResource CnblogsGeometry}" Fill="{DynamicResource PrimaryTextBrush}"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="{x:Static langs:Lang.About}" Click="MenuAbout_OnClick">
<MenuItem.Icon>
<Path Data="{StaticResource InfoGeometry}" Fill="{DynamicResource SuccessBrush}"/>
</MenuItem.Icon>
</MenuItem>
</MenuItem>
<MenuItem Height="29" Foreground="White" Header="{x:Static langs:Lang.Recommendation}">
<MenuItem Header="{x:Static langs:Lang.Project}" Command="{Binding OpenViewCmd}" CommandParameter="{x:Static data:MessageToken.ProjectsView}" >
<MenuItem.Icon>
<Path Data="{StaticResource ProjectGeometry}" Fill="{DynamicResource PrimaryTextBrush}"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="{x:Static langs:Lang.Blog}" Command="{Binding OpenViewCmd}" CommandParameter="{x:Static data:MessageToken.BlogsView}" >
<MenuItem.Icon>
<Path Data="{StaticResource BlogGeometry}" Fill="{DynamicResource PrimaryBrush}"/>
</MenuItem.Icon>
</MenuItem>
</MenuItem>
</Menu>
</StackPanel>
<Button Grid.Column="1" Click="ButtonConfig_OnClick" Name="ButtonConfig" Style="{StaticResource ButtonIcon}" hc:IconElement.Geometry="{StaticResource ConfigGeometry}"/>
<Popup AllowsTransparency="True" Grid.Column="1" PlacementTarget="{Binding ElementName=ButtonConfig}" HorizontalOffset="-25" Name="PopupConfig" VerticalOffset="6" StaysOpen="False">
<Border Background="{DynamicResource SecondaryRegionBrush}" CornerRadius="4" Margin="16" Effect="{StaticResource EffectShadow2}">
<StackPanel Orientation="Horizontal">
<StackPanel Button.Click="ButtonLangs_OnClick" Margin="10,10,0,10">
<Button Tag="zh-cn" Style="{StaticResource ButtonCustom}">
<Image Width="32" Source="/HandyControlDemo;component/Resources/Img/Flag/cn.png"/>
</Button>
<Button Tag="en" Style="{StaticResource ButtonCustom}" Margin="0,10,0,0">
<Image Width="32" Source="/HandyControlDemo;component/Resources/Img/Flag/en.png"/>
</Button>
</StackPanel>
<StackPanel Button.Click="ButtonSkins_OnClick" Margin="10,10,10,10">
<Button Tag="{x:Static hc:SkinType.Default}" Style="{StaticResource ButtonCustom}">
<Border Background="White" Width="32" Height="21" CornerRadius="2" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}"/>
</Button>
<Button Tag="{x:Static hc:SkinType.Dark}" Style="{StaticResource ButtonCustom}" Margin="0,10,0,0">
<Border Background="Black" Width="32" Height="21" CornerRadius="2" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}"/>
</Button>
<Button Tag="{x:Static hc:SkinType.Violet}" Style="{StaticResource ButtonCustom}" Margin="0,10,0,0">
<Border Background="DarkViolet" Width="32" Height="21" CornerRadius="2" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}"/>
</Button>
</StackPanel>
</StackPanel>
</Border>
</Popup>
</Grid>
@@ -1,60 +0,0 @@
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using HandyControl.Controls;
using HandyControl.Data;
using HandyControlDemo.Data;
using HandyControlDemo.Window;
namespace HandyControlDemo.UserControl
{
public partial class NoUserContent
{
public NoUserContent()
{
InitializeComponent();
}
private void ButtonLangs_OnClick(object sender, RoutedEventArgs e)
{
if (e.OriginalSource is Button button && button.Tag is string tag)
{
PopupConfig.IsOpen = false;
if (tag.Equals(GlobalData.Config.Lang)) return;
Growl.Ask(Properties.Langs.Lang.ChangeLangAsk, b =>
{
if (!b) return true;
GlobalData.Config.Lang = tag;
GlobalData.Save();
var processModule = Process.GetCurrentProcess().MainModule;
if (processModule != null)
Process.Start(processModule.FileName);
Application.Current.Shutdown();
return true;
});
}
}
private void ButtonConfig_OnClick(object sender, RoutedEventArgs e) => PopupConfig.IsOpen = true;
private void ButtonSkins_OnClick(object sender, RoutedEventArgs e)
{
if (e.OriginalSource is Button button && button.Tag is SkinType tag)
{
PopupConfig.IsOpen = false;
if (tag.Equals(GlobalData.Config.Skin)) return;
GlobalData.Config.Skin = tag;
GlobalData.Save();
((App)Application.Current).UpdateSkin(tag);
}
}
private void MenuAbout_OnClick(object sender, RoutedEventArgs e)
{
new AboutWindow
{
Owner = Application.Current.MainWindow
}.ShowDialog();
}
}
}
@@ -14,7 +14,6 @@
<Setter Property="MinWidth" Value="335"/>
<Setter Property="MaxWidth" Value="476"/>
<Setter Property="MaxHeight" Value="680"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="ResizeMode" Value="NoResize"/>
<Setter Property="SizeToContent" Value="WidthAndHeight"/>
<Setter Property="Template">
@@ -32,9 +31,6 @@
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel WindowChrome.IsHitTestVisibleInChrome="True" UseLayoutRounding="True" VerticalAlignment="Top" Grid.Column="1" HorizontalAlignment="Right" Orientation="Horizontal">
<Button Background="{TemplateBinding OtherButtonBackground}" Foreground="{TemplateBinding OtherButtonForeground}" Command="SystemCommands.MinimizeWindowCommand" IsTabStop="False" Name="ButtonMin" Height="29" Style="{StaticResource ButtonIcon}" Width="45" controls:IconElement.Geometry="{StaticResource WindowMinGeometry}" BorderThickness="1,0,1,0" controls:IconElement.Width="10" controls:IconElement.Height="10"/>
<Button Background="{TemplateBinding OtherButtonBackground}" Foreground="{TemplateBinding OtherButtonForeground}" Command="SystemCommands.MaximizeWindowCommand" IsTabStop="False" Name="ButtonMax" Height="29" Style="{StaticResource ButtonIcon}" Width="46" controls:IconElement.Geometry="{StaticResource WindowMaxGeometry}" BorderThickness="1,0,1,0" controls:IconElement.Width="10" controls:IconElement.Height="10"/>
<Button Background="{TemplateBinding OtherButtonBackground}" Foreground="{TemplateBinding OtherButtonForeground}" Command="SystemCommands.RestoreWindowCommand" IsTabStop="False" Name="ButtonRestore" Height="29" Style="{StaticResource ButtonIcon}" Width="46" controls:IconElement.Geometry="{StaticResource WindowRestoreGeometry}" BorderThickness="1,0,1,0" controls:IconElement.Width="10" controls:IconElement.Height="10"/>
<Button Background="{TemplateBinding CloseButtonBackground}" Foreground="{TemplateBinding CloseButtonForeground}" Command="SystemCommands.CloseWindowCommand" IsTabStop="False" Name="ButtonClose" Height="29" Style="{StaticResource ButtonIcon}" Width="46" controls:IconElement.Geometry="{StaticResource CloseGeometry}" BorderThickness="1,0,0,0" controls:IconElement.Width="10" controls:IconElement.Height="10"/>
</StackPanel>
<Grid Grid.Column="0">
@@ -43,8 +39,24 @@
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Image Name="Icon" Margin="10,0,0,0" Source="{TemplateBinding Icon}" VerticalAlignment="Center" Width="16" Height="16"/>
<TextBlock Name="Title" Grid.Column="1" Text="{TemplateBinding Title}" Padding="10,0,0,0" VerticalAlignment="Center"/>
<Button Name="ButtonIcon" Visibility="{TemplateBinding Icon,Converter={StaticResource Object2VisibilityConverter}}" Command="{x:Static SystemCommands.ShowSystemMenuCommand}" Background="Transparent" Margin="10,0,0,0" WindowChrome.IsHitTestVisibleInChrome="True" Style="{StaticResource ButtonCustom}" VerticalAlignment="Center">
<interactivity:Interaction.Triggers>
<interactivity:EventTrigger EventName="MouseDoubleClick">
<interactivity:InvokeCommandAction Command="{x:Static SystemCommands.CloseWindowCommand}" />
</interactivity:EventTrigger>
</interactivity:Interaction.Triggers>
<Image IsHitTestVisible="False" Source="{TemplateBinding Icon}" VerticalAlignment="Center" Width="16" Height="16"/>
</Button>
<TextBlock Grid.Column="1" Text="{TemplateBinding Title}" Padding="10,0,0,0" VerticalAlignment="Center">
<TextBlock.Visibility>
<MultiBinding Converter="{StaticResource BooleanArr2VisibilityConverter}">
<MultiBinding.Bindings>
<Binding Path="ShowTitle" RelativeSource="{RelativeSource TemplatedParent}"/>
<Binding Path="Title" RelativeSource="{RelativeSource TemplatedParent}" Converter="{StaticResource Object2BooleanConverter}"/>
</MultiBinding.Bindings>
</MultiBinding>
</TextBlock.Visibility>
</TextBlock>
<ContentPresenter WindowChrome.IsHitTestVisibleInChrome="True" Grid.Column="2" x:Name="ContentPresenterMain" Content="{TemplateBinding NonClientAreaContent}"/>
</Grid>
</Grid>
@@ -74,45 +86,9 @@
<Trigger Property="IsActive" Value="False">
<Setter Property="Opacity" Value=".8" TargetName="ContentPresenterMain"/>
</Trigger>
<Trigger Property="Icon" Value="{x:Null}">
<Setter Property="Visibility" Value="Collapsed" TargetName="Icon"/>
</Trigger>
<Trigger Property="WindowState" Value="Maximized">
<Setter Property="Padding" Value="8"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Visible" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="WindowState" Value="Normal">
<Setter Property="Visibility" Value="Visible" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="ResizeMode" Value="NoResize">
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMin"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="ResizeMode" Value="CanMinimize">
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonClose">
<Setter Property="Background" TargetName="ButtonClose" Value="{Binding CloseButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonClose" Value="{Binding CloseButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonMax">
<Setter Property="Background" TargetName="ButtonMax" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMax" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonRestore">
<Setter Property="Background" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonMin">
<Setter Property="Background" TargetName="ButtonMin" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMin" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="ShowTitle" Value="False">
<Setter Property="Visibility" Value="Collapsed" TargetName="Title"/>
<Setter Property="Background" TargetName="ButtonClose" Value="{Binding CloseButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonClose" Value="{Binding CloseButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@@ -1,7 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls"
xmlns:interactivity="clr-namespace:HandyControl.Interactivity">
xmlns:interactivity="clr-namespace:HandyControl.Interactivity"
xmlns:tools="clr-namespace:HandyControl.Tools">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Button.xaml"/>
@@ -56,6 +57,8 @@
</Style>
<Style x:Key="WindowWin10" TargetType="controls:Window">
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="#262e2f"/>
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ReverseTextBrush}"/>
@@ -68,7 +71,7 @@
<Setter Property="CloseButtonHoverForeground" Value="White"/>
<Setter Property="OtherButtonBackground" Value="Transparent"/>
<Setter Property="OtherButtonForeground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="OtherButtonHoverBackground" Value="#e5e5e5"/>
<Setter Property="OtherButtonHoverBackground" Value="{DynamicResource DarkMaskBrush}"/>
<Setter Property="OtherButtonHoverForeground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="Template">
<Setter.Value>
@@ -96,8 +99,24 @@
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Image Name="Icon" Margin="10,0,0,0" Source="{TemplateBinding Icon}" VerticalAlignment="Center" Width="16" Height="16"/>
<TextBlock Name="Title" Grid.Column="1" Text="{TemplateBinding Title}" Padding="10,0,0,0" VerticalAlignment="Center"/>
<Button Name="ButtonIcon" Visibility="{TemplateBinding Icon,Converter={StaticResource Object2VisibilityConverter}}" Command="{x:Static SystemCommands.ShowSystemMenuCommand}" Background="Transparent" Margin="10,0,0,0" WindowChrome.IsHitTestVisibleInChrome="True" Style="{StaticResource ButtonCustom}" VerticalAlignment="Center">
<interactivity:Interaction.Triggers>
<interactivity:EventTrigger EventName="MouseDoubleClick">
<interactivity:InvokeCommandAction Command="{x:Static SystemCommands.CloseWindowCommand}" />
</interactivity:EventTrigger>
</interactivity:Interaction.Triggers>
<Image IsHitTestVisible="False" Source="{TemplateBinding Icon}" VerticalAlignment="Center" Width="16" Height="16"/>
</Button>
<TextBlock Grid.Column="1" Text="{TemplateBinding Title}" Padding="10,0,0,0" VerticalAlignment="Center">
<TextBlock.Visibility>
<MultiBinding Converter="{StaticResource BooleanArr2VisibilityConverter}">
<MultiBinding.Bindings>
<Binding Path="ShowTitle" RelativeSource="{RelativeSource TemplatedParent}"/>
<Binding Path="Title" RelativeSource="{RelativeSource TemplatedParent}" Converter="{StaticResource Object2BooleanConverter}"/>
</MultiBinding.Bindings>
</MultiBinding>
</TextBlock.Visibility>
</TextBlock>
<ContentPresenter WindowChrome.IsHitTestVisibleInChrome="True" Grid.Column="2" x:Name="ContentPresenterMain" Content="{TemplateBinding NonClientAreaContent}"/>
</Grid>
</Grid>
@@ -112,11 +131,8 @@
<Setter Property="Opacity" Value=".8" TargetName="ContentPresenterMain"/>
<Setter Property="Opacity" Value=".8" TargetName="ButtonPanel"/>
</Trigger>
<Trigger Property="Icon" Value="{x:Null}">
<Setter Property="Visibility" Value="Collapsed" TargetName="Icon"/>
</Trigger>
<Trigger Property="WindowState" Value="Maximized">
<Setter Property="Padding" Value="8"/>
<Setter Property="Padding" Value="{x:Static tools:VisualHelper.WindowMaximizedPadding}"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Visible" TargetName="ButtonRestore"/>
</Trigger>
@@ -134,23 +150,20 @@
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonClose">
<Setter Property="Background" TargetName="ButtonClose" Value="{Binding CloseButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonClose" Value="{Binding CloseButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Background" TargetName="ButtonClose" Value="{Binding CloseButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonClose" Value="{Binding CloseButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonMax">
<Setter Property="Background" TargetName="ButtonMax" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMax" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Background" TargetName="ButtonMax" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMax" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonRestore">
<Setter Property="Background" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Background" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonMin">
<Setter Property="Background" TargetName="ButtonMin" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMin" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="ShowTitle" Value="False">
<Setter Property="Visibility" Value="Collapsed" TargetName="Title"/>
<Setter Property="Background" TargetName="ButtonMin" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMin" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
@@ -26,7 +26,7 @@
<SubType>Code</SubType>
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Service\DataService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Service\Data\DataService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\String2BrushConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\StringRepeatConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\AssemblyHelper.cs" />
@@ -204,6 +204,9 @@
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Main\BlogsView.xaml.cs">
<DependentUpon>BlogsView.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Main\NoUserContent.xaml.cs">
<DependentUpon>NoUserContent.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Main\ProjectsView.xaml.cs">
<DependentUpon>ProjectsView.xaml</DependentUpon>
</Compile>
@@ -626,6 +629,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)UserControl\Main\NoUserContent.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)UserControl\Main\ProjectsView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -797,4 +804,7 @@
<Generator>MSBuild:Compile</Generator>
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<Folder Include="$(MSBuildThisFileDirectory)Service\Data\" />
</ItemGroup>
</Project>
@@ -7,22 +7,17 @@
xmlns:userControl="clr-namespace:HandyControlDemo.UserControl"
xmlns:data="clr-namespace:HandyControlDemo.Data"
mc:Ignorable="d"
BorderThickness="1"
BorderBrush="#262e2f"
NonClientAreaBackground="#262e2f"
OtherButtonHoverBackground="#888580"
CloseButtonForeground="White"
OtherButtonHoverForeground="White"
OtherButtonForeground="White"
Style="{StaticResource WindowBlur}"
Title="MainWindow"
Title="HandyControlDemo"
ShowTitle="False"
ResizeMode="CanResizeWithGrip"
WindowStartupLocation="CenterScreen"
hc:GlobalShortcut.Host="True"
DataContext="{Binding Main,Source={StaticResource Locator}}"
hc:Dialog.Token="{x:Static data:MessageToken.MainWindow}"
d:DesignHeight="800"
d:DesignWidth="1400">
d:DesignWidth="1400"
Icon="/HandyControlDemo;component/Resources/Img/icon.ico">
<hc:GlobalShortcut.KeyBindings>
<KeyBinding Modifiers="Control+Alt" Key="I" Command="{Binding Main.GlobalShortcutInfoCmd, Source={StaticResource Locator}}"/>
<KeyBinding Modifiers="Control+Alt" Key="E" Command="{Binding Main.GlobalShortcutWarningCmd, Source={StaticResource Locator}}"/>
@@ -86,6 +86,7 @@
<Setter Property="OtherButtonHoverForeground" Value="White"/>
<Setter Property="NonClientAreaForeground" Value="White"/>
<Setter Property="CloseButtonForeground" Value="White"/>
<Setter Property="Icon" Value="/HandyControlDemo;component/Resources/Img/icon.ico"/>
</Style>
<Style x:Key="TextBlockFabricIcons" TargetType="TextBlock">
@@ -11,19 +11,8 @@
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel VerticalAlignment="Stretch" Orientation="Horizontal">
<Button Margin="4,0,0,0" Width="28" Height="29" Style="{StaticResource ButtonCustom}">
<hc:Interaction.Triggers>
<hc:EventTrigger EventName="Click">
<hc:InvokeCommandAction Command="{x:Static SystemCommands.ShowSystemMenuCommand}" />
</hc:EventTrigger>
<hc:EventTrigger EventName="MouseDoubleClick">
<hc:InvokeCommandAction Command="{x:Static SystemCommands.CloseWindowCommand}" />
</hc:EventTrigger>
</hc:Interaction.Triggers>
<Path Height="16" Fill="White" Stretch="Uniform" Data="{StaticResource LogoGeometry}"/>
</Button>
<Menu Margin="10,0,0,0" Background="Transparent">
<MenuItem Height="29" Foreground="White" Header="{x:Static langs:Lang.Repository}">
<MenuItem Height="29" Header="{x:Static langs:Lang.Repository}">
<MenuItem Command="hc:ControlCommands.OpenLink" CommandParameter="https://github.com/NaBian/HandyControl" Header="GitHub">
<MenuItem.Icon>
<Path Data="{StaticResource GithubGeometry}" Fill="{DynamicResource PrimaryTextBrush}"/>
@@ -35,7 +24,7 @@
</MenuItem.Icon>
</MenuItem>
</MenuItem>
<MenuItem Height="29" Foreground="White" Header="{x:Static langs:Lang.About}">
<MenuItem Height="29" Header="{x:Static langs:Lang.About}">
<MenuItem Command="{Binding OpenViewCmd}" CommandParameter="{x:Static data:MessageToken.ContributorsView}" Header="{x:Static langs:Lang.Contributors}">
<MenuItem.Icon>
<Path Data="{StaticResource ContributorsGeometry}" Fill="#ef6c00"/>
@@ -67,7 +56,7 @@
</MenuItem.Icon>
</MenuItem>
</MenuItem>
<MenuItem Height="29" Foreground="White" Header="{x:Static langs:Lang.Recommendation}">
<MenuItem Height="29" Header="{x:Static langs:Lang.Recommendation}">
<MenuItem Header="{x:Static langs:Lang.Project}" Command="{Binding OpenViewCmd}" CommandParameter="{x:Static data:MessageToken.ProjectsView}" >
<MenuItem.Icon>
<Path Data="{StaticResource ProjectGeometry}" Fill="{DynamicResource PrimaryTextBrush}"/>
@@ -81,7 +70,7 @@
</MenuItem>
</Menu>
</StackPanel>
<Button Grid.Column="1" Click="ButtonConfig_OnClick" Name="ButtonConfig" Style="{StaticResource ButtonIcon}" hc:IconElement.Geometry="{StaticResource ConfigGeometry}"/>
<Button Grid.Column="1" Click="ButtonConfig_OnClick" Name="ButtonConfig" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource PrimaryTextBrush}" hc:IconElement.Geometry="{StaticResource ConfigGeometry}"/>
<Popup AllowsTransparency="True" Grid.Column="1" PlacementTarget="{Binding ElementName=ButtonConfig}" HorizontalOffset="-25" Name="PopupConfig" VerticalOffset="6" StaysOpen="False">
<Border Background="{DynamicResource SecondaryRegionBrush}" CornerRadius="4" Margin="16" Effect="{StaticResource EffectShadow2}">
<StackPanel Orientation="Horizontal">
@@ -39,7 +39,7 @@ namespace HandyControlDemo.ViewModel
public PaginationDemoViewModel(DataService dataService)
{
_totalDataList = dataService.GetDemoDataList(100);
_totalDataList = dataService.GetDemoDataList(10);
DataList = _totalDataList.Take(10).ToList();
}
@@ -8,7 +8,6 @@
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
Title="{x:Static langs:Lang.Title}"
ShowTitle="True"
Style="{StaticResource WindowBlur}"
Height="450"
Width="800"
@@ -6,7 +6,6 @@
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
mc:Ignorable="d"
ShowTitle="True"
Background="{DynamicResource MainContentBackgroundBrush}"
WindowStartupLocation="CenterScreen"
Style="{StaticResource WindowWin10}"
@@ -8,12 +8,12 @@
mc:Ignorable="d"
OtherButtonForeground="{DynamicResource ReverseTextBrush}"
CloseButtonForeground="{DynamicResource ReverseTextBrush}"
OtherButtonHoverBackground="{DynamicResource ReverseTextBrush}"
NonClientAreaBackground="{DynamicResource ToolBarBackground}"
NonClientAreaHeight="69"
Background="{DynamicResource MainContentBackgroundBrush}"
WindowStartupLocation="CenterScreen"
Style="{StaticResource WindowWin10}"
ShowTitle="False"
Title="{x:Static langs:Lang.Title}"
Height="450"
Width="800">
@@ -70,7 +70,7 @@ namespace HandyControl.Controls
new PropertyMetadata(ValueBoxes.TrueBox, OnShowNonClientAreaChanged));
public static readonly DependencyProperty ShowTitleProperty = DependencyProperty.Register(
"ShowTitle", typeof(bool), typeof(Window), new PropertyMetadata(ValueBoxes.FalseBox));
"ShowTitle", typeof(bool), typeof(Window), new PropertyMetadata(ValueBoxes.TrueBox));
public static readonly DependencyProperty IsFullScreenProperty = DependencyProperty.Register(
"IsFullScreen", typeof(bool), typeof(Window),
@@ -94,11 +94,20 @@ namespace HandyControl.Controls
public Window()
{
#if netle40
var chrome = new WindowChrome
{
CornerRadius = new CornerRadius(),
GlassFrameThickness = new Thickness(0, 0, 0, 1)
};
#else
var chrome = new WindowChrome
{
CornerRadius = new CornerRadius(),
GlassFrameThickness = new Thickness(0, 0, 0, 1),
UseAeroCaptionButtons = false
};
#endif
BindingOperations.SetBinding(chrome, WindowChrome.CaptionHeightProperty,
new Binding(NonClientAreaHeightProperty.Name) {Source = this});
WindowChrome.SetWindowChrome(this, chrome);
@@ -33,6 +33,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\RectangleCircularConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\FrameworkElementExtension.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\StringExtension.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\ValueExtension.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\GlobalShortcut.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\StatusSwitchElement.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\TipElement.cs" />
@@ -107,8 +108,8 @@
<Compile Include="$(MSBuildThisFileDirectory)Controls\TabControl\TabItem.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\TabControl\TabPanel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Text\OutlineText.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Text\Tag\Tag.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Text\Tag\TagPanel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Tag\Tag.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Tag\TagPanel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Time\CalendarWithClock.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Time\Clock\Clock.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Time\Clock\ListClock.cs" />
@@ -255,6 +256,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\ConfigHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\CreateParams.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\DesignerHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\DpiHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\ExternDllHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\IconHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\ResourceHelper.cs" />
@@ -12,7 +12,19 @@ namespace HandyControl.Interactivity
{
if (parameter is string link)
{
Process.Start(link);
link = link.Replace("&", "^&");
try
{
Process.Start(new ProcessStartInfo("cmd", $"/c start {link}")
{
UseShellExecute = false,
CreateNoWindow = true
});
}
catch
{
// ignored
}
}
}
@@ -203,7 +203,7 @@
</controls:SimplePanel>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="PathIcon" Property="Data" Value="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=(controls:IconSwitchElement.GeometrySelected)}"/>
<Setter TargetName="PathIcon" Property="Data" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(controls:IconSwitchElement.GeometrySelected)}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@@ -17,7 +17,7 @@
</ContentControl>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="PathIcon" Property="Data" Value="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=(controls:IconSwitchElement.GeometrySelected)}"/>
<Setter TargetName="PathIcon" Property="Data" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(controls:IconSwitchElement.GeometrySelected)}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@@ -91,7 +91,7 @@
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="PathIcon" Property="Data" Value="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=(controls:IconSwitchElement.GeometrySelected)}"/>
<Setter TargetName="PathIcon" Property="Data" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(controls:IconSwitchElement.GeometrySelected)}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@@ -0,0 +1,9 @@
using System.Windows;
namespace HandyControl.Tools.Extension
{
public static class ValueExtension
{
public static Thickness Add(this Thickness a, Thickness b) => new Thickness(a.Left + b.Left, a.Top + b.Top, a.Right + b.Right, a.Bottom + b.Bottom);
}
}
@@ -0,0 +1,26 @@
using System;
using System.Windows;
using System.Windows.Media;
namespace HandyControl.Tools
{
internal class DpiHelper
{
[ThreadStatic]
private static Matrix _transformToDip;
public static Point DevicePixelsToLogical(Point devicePoint, double dpiScaleX, double dpiScaleY)
{
_transformToDip = Matrix.Identity;
_transformToDip.Scale(1d / dpiScaleX, 1d / dpiScaleY);
return _transformToDip.Transform(devicePoint);
}
public static Size DeviceSizeToLogical(Size deviceSize, double dpiScaleX, double dpiScaleY)
{
Point pt = DevicePixelsToLogical(new Point(deviceSize.Width, deviceSize.Height), dpiScaleX, dpiScaleY);
return new Size(pt.X, pt.Y);
}
}
}
@@ -1,6 +1,13 @@
using System.Linq;
using System;
using System.Collections;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security;
using System.Windows;
using System.Windows.Media;
using HandyControl.Tools.Interop;
using HandyControl.Tools.Extension;
namespace HandyControl.Tools
{
@@ -50,5 +57,131 @@ namespace HandyControl.Tools
/// </summary>
/// <returns></returns>
public static Window GetActiveWindow() => Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive);
private static readonly BitArray _cacheValid = new BitArray((int)CacheSlot.NumSlots);
private static bool _setDpiX = true;
private static bool _dpiInitialized;
private static readonly object _dpiLock = new object();
private static int _dpi;
internal static int Dpi
{
[SecurityCritical, SecuritySafeCritical]
get
{
if (!_dpiInitialized)
{
lock (_dpiLock)
{
if (!_dpiInitialized)
{
var desktopWnd = new HandleRef(null, IntPtr.Zero);
// Win32Exception will get the Win32 error code so we don't have to
var dc = UnsafeNativeMethods.GetDC(desktopWnd);
// Detecting error case from unmanaged call, required by PREsharp to throw a Win32Exception
if (dc == IntPtr.Zero)
{
throw new Win32Exception();
}
try
{
_dpi = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(null, dc), NativeMethods.LOGPIXELSY);
_dpiInitialized = true;
}
finally
{
UnsafeNativeMethods.ReleaseDC(desktopWnd, new HandleRef(null, dc));
}
}
}
}
return _dpi;
}
}
private static int _dpiX;
internal static int DpiX
{
[SecurityCritical, SecuritySafeCritical]
get
{
if (_setDpiX)
{
lock (_cacheValid)
{
if (_setDpiX)
{
_setDpiX = false;
var desktopWnd = new HandleRef(null, IntPtr.Zero);
var dc = UnsafeNativeMethods.GetDC(desktopWnd);
if (dc == IntPtr.Zero)
{
throw new Win32Exception();
}
try
{
_dpiX = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(null, dc), NativeMethods.LOGPIXELSX);
_cacheValid[(int)CacheSlot.DpiX] = true;
}
finally
{
UnsafeNativeMethods.ReleaseDC(desktopWnd, new HandleRef(null, dc));
}
}
}
}
return _dpiX;
}
}
private static Thickness _windowResizeBorderThickness;
internal static Thickness WindowResizeBorderThickness
{
[SecurityCritical]
get
{
lock (_cacheValid)
{
while (!_cacheValid[(int)CacheSlot.WindowResizeBorderThickness])
{
_cacheValid[(int)CacheSlot.WindowResizeBorderThickness] = true;
var frameSize = new Size(NativeMethods.GetSystemMetrics(SM.CXSIZEFRAME), NativeMethods.GetSystemMetrics(SM.CYSIZEFRAME));
var frameSizeInDips = DpiHelper.DeviceSizeToLogical(frameSize, DpiX / 96.0, Dpi / 96.0);
_windowResizeBorderThickness = new Thickness(frameSizeInDips.Width, frameSizeInDips.Height, frameSizeInDips.Width, frameSizeInDips.Height);
}
}
return _windowResizeBorderThickness;
}
}
public static Thickness WindowMaximizedPadding
{
get
{
#if netle40
return WindowResizeBorderThickness;
#elif Core
var hdc = UnsafeNativeMethods.GetDC(IntPtr.Zero);
var scale = UnsafeNativeMethods.GetDeviceCaps(hdc, NativeMethods.DESKTOPVERTRES) / (float)UnsafeNativeMethods.GetDeviceCaps(hdc, NativeMethods.VERTRES);
UnsafeNativeMethods.ReleaseDC(IntPtr.Zero, hdc);
return WindowResizeBorderThickness.Add(new Thickness(4 * scale));
#else
return WindowResizeBorderThickness.Add(new Thickness(4));
#endif
}
}
}
}
@@ -2,6 +2,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
namespace HandyControl.Tools.Interop
{
@@ -55,7 +56,15 @@ namespace HandyControl.Tools.Interop
MEM_COMMIT = 0x1000,
MEM_RELEASE = 0x8000,
PAGE_READWRITE = 0x04,
TBSTATE_HIDDEN = 0x08;
TBSTATE_HIDDEN = 0x08,
VERTRES = 10,
HORZRES = 8,
DESKTOPVERTRES = 117,
DESKTOPHORZRES = 118,
LOGPIXELSX = 88,
LOGPIXELSY = 90,
CXFRAME = 32,
CXSIZEFRAME = CXFRAME;
[Flags]
public enum ProcessAccess
@@ -205,5 +214,10 @@ namespace HandyControl.Tools.Interop
[DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
public static extern bool GetCursorPos(out POINT pt);
[SecurityCritical]
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport(ExternDll.User32)]
public static extern int GetSystemMetrics(SM nIndex);
}
}
@@ -87,7 +87,142 @@ namespace HandyControl.Tools.Interop
TABLETPC = 86,
MEDIACENTER = 87,
REMOTESESSION = 0x1000,
REMOTECONTROL = 0x2001,
REMOTECONTROL = 0x2001
}
internal enum CacheSlot
{
DpiX,
FocusBorderWidth,
FocusBorderHeight,
HighContrast,
MouseVanish,
DropShadow,
FlatMenu,
WorkAreaInternal,
WorkArea,
IconMetrics,
KeyboardCues,
KeyboardDelay,
KeyboardPreference,
KeyboardSpeed,
SnapToDefaultButton,
WheelScrollLines,
MouseHoverTime,
MouseHoverHeight,
MouseHoverWidth,
MenuDropAlignment,
MenuFade,
MenuShowDelay,
ComboBoxAnimation,
ClientAreaAnimation,
CursorShadow,
GradientCaptions,
HotTracking,
ListBoxSmoothScrolling,
MenuAnimation,
SelectionFade,
StylusHotTracking,
ToolTipAnimation,
ToolTipFade,
UIEffects,
MinimizeAnimation,
Border,
CaretWidth,
ForegroundFlashCount,
DragFullWindows,
NonClientMetrics,
ThinHorizontalBorderHeight,
ThinVerticalBorderWidth,
CursorWidth,
CursorHeight,
ThickHorizontalBorderHeight,
ThickVerticalBorderWidth,
MinimumHorizontalDragDistance,
MinimumVerticalDragDistance,
FixedFrameHorizontalBorderHeight,
FixedFrameVerticalBorderWidth,
FocusHorizontalBorderHeight,
FocusVerticalBorderWidth,
FullPrimaryScreenWidth,
FullPrimaryScreenHeight,
HorizontalScrollBarButtonWidth,
HorizontalScrollBarHeight,
HorizontalScrollBarThumbWidth,
IconWidth,
IconHeight,
IconGridWidth,
IconGridHeight,
MaximizedPrimaryScreenWidth,
MaximizedPrimaryScreenHeight,
MaximumWindowTrackWidth,
MaximumWindowTrackHeight,
MenuCheckmarkWidth,
MenuCheckmarkHeight,
MenuButtonWidth,
MenuButtonHeight,
MinimumWindowWidth,
MinimumWindowHeight,
MinimizedWindowWidth,
MinimizedWindowHeight,
MinimizedGridWidth,
MinimizedGridHeight,
MinimumWindowTrackWidth,
MinimumWindowTrackHeight,
PrimaryScreenWidth,
PrimaryScreenHeight,
WindowCaptionButtonWidth,
WindowCaptionButtonHeight,
ResizeFrameHorizontalBorderHeight,
ResizeFrameVerticalBorderWidth,
SmallIconWidth,
SmallIconHeight,
SmallWindowCaptionButtonWidth,
SmallWindowCaptionButtonHeight,
VirtualScreenWidth,
VirtualScreenHeight,
VerticalScrollBarWidth,
VerticalScrollBarButtonHeight,
WindowCaptionHeight,
KanjiWindowHeight,
MenuBarHeight,
VerticalScrollBarThumbHeight,
IsImmEnabled,
IsMediaCenter,
IsMenuDropRightAligned,
IsMiddleEastEnabled,
IsMousePresent,
IsMouseWheelPresent,
IsPenWindows,
IsRemotelyControlled,
IsRemoteSession,
ShowSounds,
IsSlowMachine,
SwapButtons,
IsTabletPC,
VirtualScreenLeft,
VirtualScreenTop,
PowerLineStatus,
IsGlassEnabled,
UxThemeName,
UxThemeColor,
WindowCornerRadius,
WindowGlassColor,
WindowGlassBrush,
WindowNonClientFrameThickness,
WindowResizeBorderThickness,
NumSlots
}
internal static class Win32Constant
@@ -215,5 +215,11 @@ namespace HandyControl.Tools.Interop
[DllImport(ExternDll.User32, SetLastError = true)]
public static extern int ReleaseDC(IntPtr window, IntPtr dc);
[DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
[DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
public static extern IntPtr GetDC(IntPtr ptr);
}
}