fixed a bug of menu

This commit is contained in:
NaBian committed 2018-10-30 21:01:57 +08:00
1 parent 969f58e501
commit ed47b6f852
8 files changed
+89 -22

No files matched your search

+6 -7
View File
@@ -3,7 +3,6 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Animation; using System.Windows.Media.Animation;
@@ -51,7 +50,7 @@ namespace HandyControl.Controls
private Grid _gridTop; private Grid _gridTop;
private Grid _canvasMain; private Grid _gridMain;
private Canvas _canvasSmallImg; private Canvas _canvasSmallImg;
@@ -304,7 +303,7 @@ namespace HandyControl.Controls
base.OnApplyTemplate(); base.OnApplyTemplate();
_gridTop = GetTemplateChild(ElementGridTop) as Grid; _gridTop = GetTemplateChild(ElementGridTop) as Grid;
_canvasMain = GetTemplateChild(ElementGridMain) as Grid; _gridMain = GetTemplateChild(ElementGridMain) as Grid;
_canvasSmallImg = GetTemplateChild(ElementCanvasSmallImg) as Canvas; _canvasSmallImg = GetTemplateChild(ElementCanvasSmallImg) as Canvas;
_borderMove = GetTemplateChild(ElementBorderMove) as Border; _borderMove = GetTemplateChild(ElementBorderMove) as Border;
_imageMain = GetTemplateChild(ElementImageMain) as Image; _imageMain = GetTemplateChild(ElementImageMain) as Image;
@@ -639,10 +638,10 @@ namespace HandyControl.Controls
DragMove(); DragMove();
return; return;
} }
_imgMouseDownPoint = Mouse.GetPosition(_canvasMain); _imgMouseDownPoint = Mouse.GetPosition(_gridMain);
_imgMouseDownMargin = ImageMargin; _imgMouseDownMargin = ImageMargin;
_imgIsMouseLeftButtonDown = true; _imgIsMouseLeftButtonDown = true;
e.Handled = true; //e.Handled = true;
} }
protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e) protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e)
@@ -734,7 +733,7 @@ namespace HandyControl.Controls
ImageScale = tempScale; ImageScale = tempScale;
var posCanvas = Mouse.GetPosition(_canvasMain); var posCanvas = Mouse.GetPosition(_gridMain);
var posImg = new Point(posCanvas.X - _imgActualMargin.Left, posCanvas.Y - _imgActualMargin.Top); var posImg = new Point(posCanvas.X - _imgActualMargin.Left, posCanvas.Y - _imgActualMargin.Top);
var marginX = .5 * _scaleInternalWidth; var marginX = .5 * _scaleInternalWidth;
@@ -823,7 +822,7 @@ namespace HandyControl.Controls
/// </summary> /// </summary>
private void MoveImg() private void MoveImg()
{ {
_imgCurrentPoint = Mouse.GetPosition(_canvasMain); _imgCurrentPoint = Mouse.GetPosition(_gridMain);
ShowCloseButton = _imgCurrentPoint.Y < 200; ShowCloseButton = _imgCurrentPoint.Y < 200;
ShowBorderBottom = _imgCurrentPoint.Y > ActualHeight - 200; ShowBorderBottom = _imgCurrentPoint.Y > ActualHeight - 200;
+3 -2
View File
@@ -2,7 +2,8 @@
{ {
public enum SkinType public enum SkinType
{ {
Default = 0, Default,
Dark Dark,
Violet
} }
} }
+8
View File
@@ -169,6 +169,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Themes\Basic\Colors\ColorsViolet.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Basic\Converters.xaml"> <Page Include="Themes\Basic\Converters.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -197,6 +201,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Themes\SkinViolet.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\Base\CheckBoxBaseStyle.xaml"> <Page Include="Themes\Styles\Base\CheckBoxBaseStyle.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -0,0 +1,43 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Color x:Key="PrimaryColor">#ba68c8</Color>
<Color x:Key="DarkPrimaryColor">#7b1fa2</Color>
<Color x:Key="DangerColor">#ff8792</Color>
<Color x:Key="DarkDangerColor">#ff4c9f</Color>
<Color x:Key="WarningColor">#ffd180</Color>
<Color x:Key="DarkWarningColor">#ff9100</Color>
<Color x:Key="InfoColor">#4dd0e1</Color>
<Color x:Key="DarkInfoColor">#00bcd4</Color>
<Color x:Key="SuccessColor">#A5D6A7</Color>
<Color x:Key="DarkSuccessColor">#4CAF50</Color>
<Color x:Key="PrimaryTextColor">#212121</Color>
<Color x:Key="SecondaryTextColor">#757575</Color>
<Color x:Key="ThirdlyTextColor">#bdbdbd</Color>
<Color x:Key="ReverseTextColor">#212121</Color>
<Color x:Key="TextIconColor">White</Color>
<Color x:Key="BorderColor">#e0e0e0</Color>
<Color x:Key="SecondaryBorderColor">#757575</Color>
<Color x:Key="BackgroundColor">#eeeeee</Color>
<Color x:Key="RegionColor">#ffffff</Color>
<Color x:Key="SecondaryRegionColor">#eeeeee</Color>
<Color x:Key="ThirdlyRegionColor">White</Color>
<Color x:Key="TitleColor">#ba68c8</Color>
<Color x:Key="SecondaryTitleColor">#7b1fa2</Color>
<Color x:Key="DefaultColor">White</Color>
<Color x:Key="DarkDefaultColor">#f5f5f5</Color>
<Color x:Key="AccentColor">#ff5722</Color>
<Color x:Key="DarkAccentColor">#d43f3a</Color>
<Color x:Key="DarkMaskColor">#20000000</Color>
<Color x:Key="DarkOpacityColor">#40000000</Color>
</ResourceDictionary>
+7
View File
@@ -0,0 +1,7 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Basic/Colors/ColorsViolet.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
@@ -96,10 +96,6 @@
<Setter Property="Background" TargetName="templateRoot" Value="{DynamicResource RegionBrush}"/> <Setter Property="Background" TargetName="templateRoot" Value="{DynamicResource RegionBrush}"/>
<Setter Property="TextElement.Foreground" TargetName="menuHeaderContainer" Value="{DynamicResource PrimaryTextBrush}"/> <Setter Property="TextElement.Foreground" TargetName="menuHeaderContainer" Value="{DynamicResource PrimaryTextBrush}"/>
</Trigger> </Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="TextElement.Foreground" TargetName="templateRoot" Value="#FF707070"/>
<Setter Property="Fill" TargetName="Glyph" Value="#FF707070"/>
</Trigger>
</ControlTemplate.Triggers> </ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>
@@ -134,17 +130,13 @@
<Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/> <Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
</Trigger> </Trigger>
<Trigger Property="IsHighlighted" Value="True"> <Trigger Property="IsHighlighted" Value="True">
<Setter Property="Background" TargetName="templateRoot" Value="White"/> <Setter Property="Background" TargetName="templateRoot" Value="{DynamicResource SecondaryRegionBrush}"/>
<Setter Property="TextElement.Foreground" TargetName="menuHeaderContainer" Value="{DynamicResource PrimaryTextBrush}"/> <Setter Property="TextElement.Foreground" TargetName="menuHeaderContainer" Value="{DynamicResource PrimaryTextBrush}"/>
</Trigger> </Trigger>
<Trigger Property="IsSubmenuOpen" Value="True"> <Trigger Property="IsSubmenuOpen" Value="True">
<Setter Property="Background" TargetName="templateRoot" Value="White"/> <Setter Property="Background" TargetName="templateRoot" Value="White"/>
<Setter Property="TextElement.Foreground" TargetName="menuHeaderContainer" Value="{DynamicResource PrimaryTextBrush}"/> <Setter Property="TextElement.Foreground" TargetName="menuHeaderContainer" Value="{DynamicResource PrimaryTextBrush}"/>
</Trigger> </Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="TextElement.Foreground" TargetName="templateRoot" Value="#FF707070"/>
<Setter Property="Fill" TargetName="Glyph" Value="#FF707070"/>
</Trigger>
<MultiTrigger> <MultiTrigger>
<MultiTrigger.Conditions> <MultiTrigger.Conditions>
<Condition Property="IsHighlighted" Value="True"/> <Condition Property="IsHighlighted" Value="True"/>
@@ -202,7 +194,7 @@
<Setter Property="Background" Value="{DynamicResource DarkDefaultBrush}"/> <Setter Property="Background" Value="{DynamicResource DarkDefaultBrush}"/>
</Trigger> </Trigger>
<Trigger Property="IsEnabled" Value="False"> <Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="#FF707070"/> <Setter Property="Opacity" Value=".4"/>
</Trigger> </Trigger>
</Style.Triggers> </Style.Triggers>
</Style> </Style>
+17 -3
View File
@@ -59,9 +59,23 @@ namespace HandyControl.Tools
/// <param name="themePath"></param> /// <param name="themePath"></param>
/// <param name="skin"></param> /// <param name="skin"></param>
/// <returns></returns> /// <returns></returns>
public static ResourceDictionary GetSkin(Assembly assembly, string themePath, SkinType skin) => new ResourceDictionary public static ResourceDictionary GetSkin(Assembly assembly, string themePath, SkinType skin)
{ {
Source = new Uri($"pack://application:,,,/{assembly.GetName().Name};component/{themePath}/Skin{skin.ToString()}.xaml") try
}; {
var uri = new Uri($"pack://application:,,,/{assembly.GetName().Name};component/{themePath}/Skin{skin.ToString()}.xaml");
return new ResourceDictionary
{
Source = uri
};
}
catch
{
return new ResourceDictionary
{
Source = new Uri($"pack://application:,,,/{assembly.GetName().Name};component/{themePath}/Skin{SkinType.Default.ToString()}.xaml")
};
}
}
} }
} }
@@ -74,6 +74,9 @@
<Button Tag="{x:Static enum:SkinType.Dark}" Style="{StaticResource ButtonCustom}" Margin="0,10,0,0"> <Button Tag="{x:Static enum:SkinType.Dark}" Style="{StaticResource ButtonCustom}" Margin="0,10,0,0">
<Border Background="Black" Width="32" Height="21" CornerRadius="2" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}"/> <Border Background="Black" Width="32" Height="21" CornerRadius="2" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}"/>
</Button> </Button>
<Button Tag="{x:Static enum: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>
</StackPanel> </StackPanel>
</Border> </Border>