add Watermark

This commit is contained in:
NaBian committed 2020-04-30 01:22:27 +08:00
1 parent 507a80a3ee
commit 2ced600571
42 files changed
+356 -268

No files matched your search

@@ -34,8 +34,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AvalonEdit" Version="6.0.1" /> <PackageReference Include="AvalonEdit" Version="6.0.1" />
<PackageReference Include="CommonServiceLocator" Version="2.0.2" /> <PackageReference Include="MvvmLightLibsStd10" Version="5.4.1.1" />
<PackageReference Include="MvvmLightLibs" Version="5.4.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" /> <PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="System.Management" Version="4.6.0" /> <PackageReference Include="System.Management" Version="4.6.0" />
</ItemGroup> </ItemGroup>
@@ -43,6 +43,9 @@
<PropertyGroup> <PropertyGroup>
<ApplicationIcon>..\..\Shared\HandyControlDemo_Shared\Resources\Img\icon.ico</ApplicationIcon> <ApplicationIcon>..\..\Shared\HandyControlDemo_Shared\Resources\Img\icon.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
@@ -220,7 +223,7 @@
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\Flag\ru.png"> <Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\Flag\ru.png">
<Link>Resources\Img\Flag\ru.png</Link> <Link>Resources\Img\Flag\ru.png</Link>
</Resource> </Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\Flag\tr.png"> <Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\Flag\tr.png">
<Link>Resources\Img\Flag\tr.png</Link> <Link>Resources\Img\Flag\tr.png</Link>
</Resource> </Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\icon-white.ico"> <Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\icon-white.ico">
@@ -424,7 +427,7 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="..\..\Shared\HandyControlDemo_Shared\Properties\Langs\Lang.tr.resx"> <EmbeddedResource Include="..\..\Shared\HandyControlDemo_Shared\Properties\Langs\Lang.tr.resx">
<Link>Properties\Langs\Lang.tr.resx</Link> <Link>Properties\Langs\Lang.tr.resx</Link>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="..\..\Shared\HandyControlDemo_Shared\Properties\Langs\Lang.en.resx"> <EmbeddedResource Include="..\..\Shared\HandyControlDemo_Shared\Properties\Langs\Lang.en.resx">
@@ -585,4 +588,19 @@
</ItemGroup> </ItemGroup>
<Import Project="..\..\Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems" Label="Shared" /> <Import Project="..\..\Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>if not exist Langs md Langs
rd /s /q Langs\en
rd /s /q Langs\fa
rd /s /q Langs\fr
rd /s /q Langs\ko-KR
rd /s /q Langs\ru
rd /s /q Langs\tr
move en Langs
move fa Langs
move fr Langs
move ko-KR Langs
move ru Langs
move tr Langs</PostBuildEvent>
</PropertyGroup>
</Project> </Project>
@@ -113,6 +113,9 @@
<PropertyGroup> <PropertyGroup>
<ApplicationIcon>..\..\Shared\HandyControlDemo_Shared\Resources\Img\icon.ico</ApplicationIcon> <ApplicationIcon>..\..\Shared\HandyControlDemo_Shared\Resources\Img\icon.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
@@ -141,7 +144,7 @@
<PackageReference Include="AvalonEdit"> <PackageReference Include="AvalonEdit">
<Version>6.0.1</Version> <Version>6.0.1</Version>
</PackageReference> </PackageReference>
<PackageReference Include="MvvmLightLibs"> <PackageReference Include="MvvmLightLibsStd10">
<Version>5.4.1.1</Version> <Version>5.4.1.1</Version>
</PackageReference> </PackageReference>
<PackageReference Include="Newtonsoft.Json"> <PackageReference Include="Newtonsoft.Json">
@@ -298,7 +301,7 @@
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\Flag\ru.png"> <Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\Flag\ru.png">
<Link>Resources\Img\Flag\ru.png</Link> <Link>Resources\Img\Flag\ru.png</Link>
</Resource> </Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\Flag\tr.png"> <Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\Flag\tr.png">
<Link>Resources\Img\Flag\tr.png</Link> <Link>Resources\Img\Flag\tr.png</Link>
</Resource> </Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\icon-white.ico"> <Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\icon-white.ico">
@@ -492,7 +495,7 @@
</Resource> </Resource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="..\..\Shared\HandyControlDemo_Shared\Properties\Langs\Lang.tr.resx"> <EmbeddedResource Include="..\..\Shared\HandyControlDemo_Shared\Properties\Langs\Lang.tr.resx">
<Link>Properties\Langs\Lang.tr.resx</Link> <Link>Properties\Langs\Lang.tr.resx</Link>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="..\..\Shared\HandyControlDemo_Shared\Properties\Langs\Lang.en.resx"> <EmbeddedResource Include="..\..\Shared\HandyControlDemo_Shared\Properties\Langs\Lang.en.resx">
@@ -656,4 +659,19 @@
</ItemGroup> </ItemGroup>
<Import Project="..\..\Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems" Label="Shared" /> <Import Project="..\..\Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>if not exist Langs md Langs
rd /s /q Langs\en
rd /s /q Langs\fa
rd /s /q Langs\fr
rd /s /q Langs\ko-KR
rd /s /q Langs\ru
rd /s /q Langs\tr
move en Langs
move fa Langs
move fr Langs
move ko-KR Langs
move ru Langs
move tr Langs</PostBuildEvent>
</PropertyGroup>
</Project> </Project>
+1 -1
View File
@@ -27,7 +27,7 @@
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
<langs:LangProvider x:Key="DemoLangs"/> <langs:LangProvider x:Key="DemoLangs"/>
<viewModel:ViewModelLocator x:Key="Locator" d:IsDataSource="True"/> <viewModel:ViewModelLocator x:Key="Locator" d:IsDataSource="True"/>
<hc:EnumDataProvider x:Key="DemoTypes" Type="data:DemoType" MethodName=""/> <hc:EnumDataProvider x:Key="DemoTypes" Type="data:DemoType"/>
<hc:EnumDataProvider x:Key="ShowAnimations" Type="hc:ShowAnimation"/> <hc:EnumDataProvider x:Key="ShowAnimations" Type="hc:ShowAnimation"/>
<hc:EnumDataProvider x:Key="HatchStyles" Type="hc:HatchStyle"/> <hc:EnumDataProvider x:Key="HatchStyles" Type="hc:HatchStyle"/>
</ResourceDictionary> </ResourceDictionary>
@@ -93,7 +93,6 @@ namespace HandyControlDemo
skins0.MergedDictionaries.Add(ResourceHelper.GetSkin(skin)); skins0.MergedDictionaries.Add(ResourceHelper.GetSkin(skin));
skins0.MergedDictionaries.Add(ResourceHelper.GetSkin(typeof(App).Assembly, "Resources/Themes", skin)); skins0.MergedDictionaries.Add(ResourceHelper.GetSkin(typeof(App).Assembly, "Resources/Themes", skin));
var skins1 = Resources.MergedDictionaries[1]; var skins1 = Resources.MergedDictionaries[1];
skins1.MergedDictionaries.Clear(); skins1.MergedDictionaries.Clear();
skins1.MergedDictionaries.Add(new ResourceDictionary skins1.MergedDictionaries.Add(new ResourceDictionary
@@ -1,3 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<configuration> <configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Langs"/>
</assemblyBinding>
</runtime>
</configuration> </configuration>
@@ -8,121 +8,19 @@
<DrawingBrush o:Freeze="True" Opacity=".1" x:Key="CloudDrawingBrush" RenderOptions.CacheInvalidationThresholdMinimum="0.5" RenderOptions.CacheInvalidationThresholdMaximum="2.0" RenderOptions.CachingHint="Cache" Viewport="0,0,314,157" ViewportUnits="Absolute" Stretch="Uniform" TileMode="Tile"> <DrawingBrush o:Freeze="True" Opacity=".1" x:Key="CloudDrawingBrush" RenderOptions.CacheInvalidationThresholdMinimum="0.5" RenderOptions.CacheInvalidationThresholdMaximum="2.0" RenderOptions.CachingHint="Cache" Viewport="0,0,314,157" ViewportUnits="Absolute" Stretch="Uniform" TileMode="Tile">
<DrawingBrush.Drawing> <DrawingBrush.Drawing>
<DrawingGroup o:Freeze="True"> <ImageDrawing o:Freeze="True" ImageSource="/HandyControlDemo;component/Resources/Img/cloud.png" Rect="0,0,314,157"/>
<ImageDrawing ImageSource="/HandyControlDemo;component/Resources/Img/cloud.png" Rect="0,0,314,157"/>
</DrawingGroup>
</DrawingBrush.Drawing> </DrawingBrush.Drawing>
</DrawingBrush> </DrawingBrush>
<DrawingBrush o:Freeze="True" x:Key="MainContentForegroundDrawingBrush" RenderOptions.CacheInvalidationThresholdMinimum="0.5" RenderOptions.CacheInvalidationThresholdMaximum="2.0" RenderOptions.CachingHint="Cache" Viewport="0,0,16,16" ViewportUnits="Absolute" Stretch="None" TileMode="Tile"> <DrawingBrush o:Freeze="True" x:Key="MainContentForegroundDrawingBrush" RenderOptions.CacheInvalidationThresholdMinimum="0.5" RenderOptions.CacheInvalidationThresholdMaximum="2.0" RenderOptions.CachingHint="Cache" Viewport="0,0,16,16" ViewportUnits="Absolute" Stretch="None" TileMode="Tile">
<DrawingBrush.Drawing> <DrawingBrush.Drawing>
<DrawingGroup o:Freeze="True"> <GeometryDrawing o:Freeze="True" Brush="{DynamicResource MainContentForegroundBrush}">
<GeometryDrawing o:Freeze="True" Brush="{DynamicResource MainContentForegroundBrush}">
<GeometryDrawing.Geometry>
<GeometryGroup o:Freeze="True">
<RectangleGeometry o:Freeze="True" Rect="0,0,8,8" />
<RectangleGeometry o:Freeze="True" Rect="8,8,8,8" />
</GeometryGroup>
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
<DrawingBrush o:Freeze="True" x:Key="GitHubDrawingBrush" RenderOptions.CacheInvalidationThresholdMinimum="0.5" RenderOptions.CacheInvalidationThresholdMaximum="2.0" RenderOptions.CachingHint="Cache" Viewport="0,0,200,100" ViewportUnits="Absolute" Stretch="Uniform" TileMode="Tile">
<DrawingBrush.Transform>
<TransformGroup o:Freeze="True">
<RotateTransform o:Freeze="True" Angle="20"/>
</TransformGroup>
</DrawingBrush.Transform>
<DrawingBrush.Drawing>
<DrawingGroup o:Freeze="True">
<GeometryDrawing o:Freeze="True" Brush="{DynamicResource DarkMaskBrush}" Geometry="{StaticResource GitHubStrGeometry}"/>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
<DrawingBrush o:Freeze="True" x:Key="QqDrawingBrush" RenderOptions.CacheInvalidationThresholdMinimum="0.5" RenderOptions.CacheInvalidationThresholdMaximum="2.0" RenderOptions.CachingHint="Cache" Viewport="0,0,100,200" ViewportUnits="Absolute" Stretch="Uniform" TileMode="Tile">
<DrawingBrush.Transform>
<TransformGroup o:Freeze="True">
<RotateTransform o:Freeze="True" Angle="20"/>
</TransformGroup>
</DrawingBrush.Transform>
<DrawingBrush.Drawing>
<DrawingGroup o:Freeze="True">
<GeometryDrawing o:Freeze="True" Brush="{DynamicResource DarkMaskBrush}" Geometry="{StaticResource QqGeometry}"/>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
<DrawingBrush o:Freeze="True" x:Key="BlogDrawingBrush" RenderOptions.CacheInvalidationThresholdMinimum="0.5" RenderOptions.CacheInvalidationThresholdMaximum="2.0" RenderOptions.CachingHint="Cache" Viewport="0,0,160,100" ViewportUnits="Absolute" Stretch="Uniform" TileMode="Tile">
<DrawingBrush.Transform>
<TransformGroup o:Freeze="True">
<RotateTransform o:Freeze="True" Angle="20"/>
</TransformGroup>
</DrawingBrush.Transform>
<DrawingBrush.Drawing>
<GeometryDrawing o:Freeze="True">
<GeometryDrawing.Geometry> <GeometryDrawing.Geometry>
<RectangleGeometry o:Freeze="True" Rect="0,0,160,100"></RectangleGeometry> <GeometryGroup o:Freeze="True">
<RectangleGeometry o:Freeze="True" Rect="0,0,8,8" />
<RectangleGeometry o:Freeze="True" Rect="8,8,8,8" />
</GeometryGroup>
</GeometryDrawing.Geometry> </GeometryDrawing.Geometry>
<GeometryDrawing.Brush>
<VisualBrush o:Freeze="True" RenderOptions.CachingHint="Cache" RenderOptions.CacheInvalidationThresholdMinimum="0.5" RenderOptions.CacheInvalidationThresholdMaximum="2.0" >
<VisualBrush.Visual>
<StackPanel>
<TextBlock Text="Blog" Foreground="{DynamicResource DarkMaskBrush}"/>
</StackPanel>
</VisualBrush.Visual>
</VisualBrush>
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingBrush.Drawing>
</DrawingBrush>
<DrawingBrush o:Freeze="True" x:Key="WebsiteDrawingBrush" RenderOptions.CacheInvalidationThresholdMinimum="0.5" RenderOptions.CacheInvalidationThresholdMaximum="2.0" RenderOptions.CachingHint="Cache" Viewport="0,0,320,100" ViewportUnits="Absolute" Stretch="Uniform" TileMode="Tile">
<DrawingBrush.Transform>
<TransformGroup o:Freeze="True">
<RotateTransform o:Freeze="True" Angle="20"/>
</TransformGroup>
</DrawingBrush.Transform>
<DrawingBrush.Drawing>
<GeometryDrawing o:Freeze="True">
<GeometryDrawing.Geometry>
<RectangleGeometry o:Freeze="True" Rect="0,0,320,100"></RectangleGeometry>
</GeometryDrawing.Geometry>
<GeometryDrawing.Brush>
<VisualBrush o:Freeze="True" RenderOptions.CachingHint="Cache" RenderOptions.CacheInvalidationThresholdMinimum="0.5" RenderOptions.CacheInvalidationThresholdMaximum="2.0">
<VisualBrush.Visual>
<StackPanel>
<TextBlock Text="Website" Foreground="{DynamicResource DarkMaskBrush}"/>
</StackPanel>
</VisualBrush.Visual>
</VisualBrush>
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingBrush.Drawing>
</DrawingBrush>
<DrawingBrush o:Freeze="True" x:Key="ProjectDrawingBrush" RenderOptions.CacheInvalidationThresholdMinimum="0.5" RenderOptions.CacheInvalidationThresholdMaximum="2.0" RenderOptions.CachingHint="Cache" Viewport="0,0,240,100" ViewportUnits="Absolute" Stretch="Uniform" TileMode="Tile">
<DrawingBrush.Transform>
<TransformGroup o:Freeze="True">
<RotateTransform o:Freeze="True" Angle="20"/>
</TransformGroup>
</DrawingBrush.Transform>
<DrawingBrush.Drawing>
<GeometryDrawing o:Freeze="True">
<GeometryDrawing.Geometry>
<RectangleGeometry o:Freeze="True" Rect="0,0,240,100"></RectangleGeometry>
</GeometryDrawing.Geometry>
<GeometryDrawing.Brush>
<VisualBrush o:Freeze="True" RenderOptions.CachingHint="Cache" RenderOptions.CacheInvalidationThresholdMinimum="0.5" RenderOptions.CacheInvalidationThresholdMaximum="2.0" >
<VisualBrush.Visual>
<StackPanel>
<TextBlock Text="Project" Foreground="{DynamicResource DarkMaskBrush}"/>
</StackPanel>
</VisualBrush.Visual>
</VisualBrush>
</GeometryDrawing.Brush>
</GeometryDrawing> </GeometryDrawing>
</DrawingBrush.Drawing> </DrawingBrush.Drawing>
</DrawingBrush> </DrawingBrush>
@@ -16,7 +16,7 @@
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Image Source="{Binding Source,RelativeSource={RelativeSource AncestorType=UserControl}}" Height="120" Width="120" Stretch="Uniform" Margin="10"/> <Image Source="{Binding Source,RelativeSource={RelativeSource AncestorType=UserControl}}" Height="120" Width="120" Stretch="Uniform" Margin="10"/>
<TextBlock TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" Margin="0,0,0,10" Grid.Row="1" Style="{StaticResource TextBlockDefault}" Text="{Binding DisplayName,RelativeSource={RelativeSource AncestorType=UserControl}}"></TextBlock> <TextBlock TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" Margin="0,0,0,10" Grid.Row="1" Style="{StaticResource TextBlockDefault}" Text="{Binding DisplayName,RelativeSource={RelativeSource AncestorType=UserControl}}"/>
</Grid> </Grid>
</Border> </Border>
</Button> </Button>
@@ -2,13 +2,16 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:userControl="clr-namespace:HandyControlDemo.UserControl" xmlns:userControl="clr-namespace:HandyControlDemo.UserControl"
xmlns:hc="https://handyorg.github.io/handycontrol"
DataContext="{Binding BlogsView,Source={StaticResource Locator}}" DataContext="{Binding BlogsView,Source={StaticResource Locator}}"
Background="{DynamicResource SecondaryRegionBrush}"> Background="{DynamicResource SecondaryRegionBrush}">
<ListBox Background="{DynamicResource BlogDrawingBrush}" ItemContainerStyle="{StaticResource ListBoxItemCustom}" BorderThickness="0" ItemsSource="{Binding DataList}" ItemsPanel="{StaticResource FluidMoveBehaviorWrapPanelItemsPanelTemplate}"> <hc:Watermark Mark="Blog" FontSize="80" MarkMargin="30,0">
<ListBox.ItemTemplate> <ListBox Background="Transparent" ItemContainerStyle="{StaticResource ListBoxItemCustom}" BorderThickness="0" ItemsSource="{Binding DataList}" ItemsPanel="{StaticResource FluidMoveBehaviorWrapPanelItemsPanelTemplate}">
<DataTemplate> <ListBox.ItemTemplate>
<userControl:Avatar DisplayName="{Binding DisplayName}" Link="{Binding Link}" Source="{Binding AvatarUri}"/> <DataTemplate>
</DataTemplate> <userControl:Avatar DisplayName="{Binding DisplayName}" Link="{Binding Link}" Source="{Binding AvatarUri}"/>
</ListBox.ItemTemplate> </DataTemplate>
</ListBox> </ListBox.ItemTemplate>
</ListBox>
</hc:Watermark>
</UserControl> </UserControl>
@@ -2,13 +2,16 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:userControl="clr-namespace:HandyControlDemo.UserControl" xmlns:userControl="clr-namespace:HandyControlDemo.UserControl"
xmlns:hc="https://handyorg.github.io/handycontrol"
DataContext="{Binding ContributorsView,Source={StaticResource Locator}}" DataContext="{Binding ContributorsView,Source={StaticResource Locator}}"
Background="{DynamicResource SecondaryRegionBrush}"> Background="{DynamicResource SecondaryRegionBrush}">
<ListBox Background="{DynamicResource GitHubDrawingBrush}" ItemContainerStyle="{StaticResource ListBoxItemCustom}" BorderThickness="0" ItemsSource="{Binding DataList}" ItemsPanel="{StaticResource FluidMoveBehaviorWrapPanelItemsPanelTemplate}"> <hc:Watermark Mark="{StaticResource GitHubStrGeometry}" MarkMargin="30,0" MarkWidth="200" MarkHeight="100">
<ListBox.ItemTemplate> <ListBox Background="Transparent" ItemContainerStyle="{StaticResource ListBoxItemCustom}" BorderThickness="0" ItemsSource="{Binding DataList}" ItemsPanel="{StaticResource FluidMoveBehaviorWrapPanelItemsPanelTemplate}">
<DataTemplate> <ListBox.ItemTemplate>
<userControl:Avatar DisplayName="{Binding DisplayName}" Link="{Binding Link}" Source="{Binding AvatarUri}"/> <DataTemplate>
</DataTemplate> <userControl:Avatar DisplayName="{Binding DisplayName}" Link="{Binding Link}" Source="{Binding AvatarUri}"/>
</ListBox.ItemTemplate> </DataTemplate>
</ListBox> </ListBox.ItemTemplate>
</ListBox>
</hc:Watermark>
</UserControl> </UserControl>
@@ -19,15 +19,15 @@ namespace HandyControlDemo.UserControl
private void ButtonLangs_OnClick(object sender, RoutedEventArgs e) private void ButtonLangs_OnClick(object sender, RoutedEventArgs e)
{ {
if (e.OriginalSource is Button button && button.Tag is string tag) if (e.OriginalSource is Button button && button.Tag is string langName)
{ {
PopupConfig.IsOpen = false; PopupConfig.IsOpen = false;
if (tag.Equals(GlobalData.Config.Lang)) return; if (langName.Equals(GlobalData.Config.Lang)) return;
ConfigHelper.Instance.SetLang(tag); ConfigHelper.Instance.SetLang(langName);
LangProvider.Culture = new CultureInfo(tag); LangProvider.Culture = new CultureInfo(langName);
Messenger.Default.Send<object>(null, "LangUpdated"); Messenger.Default.Send<object>(null, "LangUpdated");
GlobalData.Config.Lang = tag; GlobalData.Config.Lang = langName;
GlobalData.Save(); GlobalData.Save();
} }
} }
@@ -2,13 +2,16 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:userControl="clr-namespace:HandyControlDemo.UserControl" xmlns:userControl="clr-namespace:HandyControlDemo.UserControl"
xmlns:hc="https://handyorg.github.io/handycontrol"
DataContext="{Binding ProjectsView,Source={StaticResource Locator}}" DataContext="{Binding ProjectsView,Source={StaticResource Locator}}"
Background="{DynamicResource SecondaryRegionBrush}"> Background="{DynamicResource SecondaryRegionBrush}">
<ListBox Background="{DynamicResource ProjectDrawingBrush}" ItemContainerStyle="{StaticResource ListBoxItemCustom}" BorderThickness="0" ItemsSource="{Binding DataList}" ItemsPanel="{StaticResource FluidMoveBehaviorWrapPanelItemsPanelTemplate}"> <hc:Watermark Mark="Project" FontSize="80" MarkMargin="30,0">
<ListBox.ItemTemplate> <ListBox Background="Transparent" ItemContainerStyle="{StaticResource ListBoxItemCustom}" BorderThickness="0" ItemsSource="{Binding DataList}" ItemsPanel="{StaticResource FluidMoveBehaviorWrapPanelItemsPanelTemplate}">
<DataTemplate> <ListBox.ItemTemplate>
<userControl:Avatar DisplayName="{Binding DisplayName}" Link="{Binding Link}" Source="{Binding AvatarUri}"/> <DataTemplate>
</DataTemplate> <userControl:Avatar DisplayName="{Binding DisplayName}" Link="{Binding Link}" Source="{Binding AvatarUri}"/>
</ListBox.ItemTemplate> </DataTemplate>
</ListBox> </ListBox.ItemTemplate>
</ListBox>
</hc:Watermark>
</UserControl> </UserControl>
@@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:hc="https://handyorg.github.io/handycontrol"
Background="{DynamicResource SecondaryRegionBrush}"> Background="{DynamicResource SecondaryRegionBrush}">
<Border Background="{DynamicResource QqDrawingBrush}"> <hc:Watermark Mark="{StaticResource QqGeometry}" MarkWidth="200" MarkHeight="200" MarkMargin="30">
<WrapPanel HorizontalAlignment="Center" VerticalAlignment="Center" hc:PanelElement.FluidMoveBehavior="{StaticResource BehaviorXY200}"> <WrapPanel HorizontalAlignment="Center" VerticalAlignment="Center" hc:PanelElement.FluidMoveBehavior="{StaticResource BehaviorXY200}">
<Border Margin="16" Height="274" Effect="{StaticResource EffectShadow5}" Width="200" CornerRadius="10"> <Border Margin="16" Height="274" Effect="{StaticResource EffectShadow5}" Width="200" CornerRadius="10">
<Border.Background> <Border.Background>
@@ -16,5 +16,5 @@
</Border.Background> </Border.Background>
</Border> </Border>
</WrapPanel> </WrapPanel>
</Border> </hc:Watermark>
</UserControl> </UserControl>
@@ -2,13 +2,16 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:userControl="clr-namespace:HandyControlDemo.UserControl" xmlns:userControl="clr-namespace:HandyControlDemo.UserControl"
xmlns:hc="https://handyorg.github.io/handycontrol"
DataContext="{Binding WebsitesView,Source={StaticResource Locator}}" DataContext="{Binding WebsitesView,Source={StaticResource Locator}}"
Background="{DynamicResource SecondaryRegionBrush}"> Background="{DynamicResource SecondaryRegionBrush}">
<ListBox Background="{DynamicResource WebsiteDrawingBrush}" ItemContainerStyle="{StaticResource ListBoxItemCustom}" BorderThickness="0" ItemsSource="{Binding DataList}" ItemsPanel="{StaticResource FluidMoveBehaviorWrapPanelItemsPanelTemplate}"> <hc:Watermark Mark="Website" FontSize="80" MarkMargin="30,0">
<ListBox.ItemTemplate> <ListBox Background="Transparent" ItemContainerStyle="{StaticResource ListBoxItemCustom}" BorderThickness="0" ItemsSource="{Binding DataList}" ItemsPanel="{StaticResource FluidMoveBehaviorWrapPanelItemsPanelTemplate}">
<DataTemplate> <ListBox.ItemTemplate>
<userControl:Avatar DisplayName="{Binding DisplayName}" Link="{Binding Link}" Source="{Binding AvatarUri}"/> <DataTemplate>
</DataTemplate> <userControl:Avatar DisplayName="{Binding DisplayName}" Link="{Binding Link}" Source="{Binding AvatarUri}"/>
</ListBox.ItemTemplate> </DataTemplate>
</ListBox> </ListBox.ItemTemplate>
</ListBox>
</hc:Watermark>
</UserControl> </UserControl>
@@ -7,11 +7,7 @@ using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
#if netle40
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
#endif
using GalaSoft.MvvmLight.Messaging; using GalaSoft.MvvmLight.Messaging;
using HandyControl.Controls; using HandyControl.Controls;
using HandyControl.Data; using HandyControl.Data;
@@ -1,10 +1,6 @@
using System; using System;
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
#if netle40
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
#endif
using HandyControl.Tools.Extension; using HandyControl.Tools.Extension;
namespace HandyControlDemo.ViewModel namespace HandyControlDemo.ViewModel
@@ -1,10 +1,6 @@
using System; using System;
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
#if netle40
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
#endif
namespace HandyControlDemo.ViewModel namespace HandyControlDemo.ViewModel
{ {
@@ -1,9 +1,5 @@
using System; using System;
#if netle40
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
#endif
using HandyControlDemo.Data; using HandyControlDemo.Data;
using HandyControlDemo.Service; using HandyControlDemo.Service;
@@ -1,11 +1,9 @@
using System; using System;
using System.Windows; using System.Windows;
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
#if netle40
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
#else #if !netle40
using System.Threading.Tasks; using System.Threading.Tasks;
using GalaSoft.MvvmLight.CommandWpf;
#endif #endif
using HandyControl.Controls; using HandyControl.Controls;
using HandyControl.Tools.Extension; using HandyControl.Tools.Extension;
@@ -1,10 +1,6 @@
using System; using System;
using System.Windows; using System.Windows;
#if netle40
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
# endif
using HandyControl.Controls; using HandyControl.Controls;
using HandyControl.Data; using HandyControl.Data;
using HandyControlDemo.Window; using HandyControlDemo.Window;
@@ -1,9 +1,5 @@
using System; using System;
#if netle40
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
# endif
using HandyControl.Controls; using HandyControl.Controls;
namespace HandyControlDemo.ViewModel namespace HandyControlDemo.ViewModel
@@ -1,8 +1,4 @@
#if netle40 using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
# endif
using System; using System;
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
using HandyControl.Controls; using HandyControl.Controls;
@@ -1,10 +1,6 @@
using System; using System;
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
#if netle40
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
# endif
using HandyControl.Controls; using HandyControl.Controls;
using HandyControl.Data; using HandyControl.Data;
using HandyControlDemo.Data; using HandyControlDemo.Data;
@@ -1,11 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
#if netle40
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
# endif
using HandyControl.Data; using HandyControl.Data;
using HandyControlDemo.Data; using HandyControlDemo.Data;
using HandyControlDemo.Service; using HandyControlDemo.Service;
@@ -1,10 +1,6 @@
using System; using System;
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
#if netle40
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
# endif
using HandyControl.Controls; using HandyControl.Controls;
namespace HandyControlDemo.ViewModel namespace HandyControlDemo.ViewModel
@@ -2,11 +2,7 @@
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
using HandyControl.Controls; using HandyControl.Controls;
using HandyControl.Data; using HandyControl.Data;
#if netle40
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
# endif
namespace HandyControlDemo.ViewModel namespace HandyControlDemo.ViewModel
{ {
@@ -1,11 +1,7 @@
using System; using System;
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
using HandyControl.Controls; using HandyControl.Controls;
#if netle40
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
# endif
namespace HandyControlDemo.ViewModel namespace HandyControlDemo.ViewModel
{ {
@@ -1,11 +1,7 @@
using System; using System;
using HandyControl.Controls; using HandyControl.Controls;
using HandyControlDemo.UserControl; using HandyControlDemo.UserControl;
#if netle40
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
# endif
namespace HandyControlDemo.ViewModel namespace HandyControlDemo.ViewModel
{ {
@@ -1,11 +1,7 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Windows.Controls; using System.Windows.Controls;
#if netle40
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
# endif
using HandyControl.Controls; using HandyControl.Controls;
using HandyControlDemo.Data; using HandyControlDemo.Data;
using HandyControlDemo.Service; using HandyControlDemo.Service;
@@ -4,11 +4,7 @@ using HandyControl.Controls;
using HandyControl.Data; using HandyControl.Data;
using HandyControlDemo.Data; using HandyControlDemo.Data;
using HandyControlDemo.Service; using HandyControlDemo.Service;
#if netle40
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
#endif
namespace HandyControlDemo.ViewModel namespace HandyControlDemo.ViewModel
{ {
@@ -1,10 +1,6 @@
using System; using System;
using System.Windows; using System.Windows;
#if netle40
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
# endif
using HandyControlDemo.Tools; using HandyControlDemo.Tools;
namespace HandyControlDemo.ViewModel namespace HandyControlDemo.ViewModel
@@ -1,11 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Controls; using System.Windows.Controls;
#if netle40
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
#endif
using GalaSoft.MvvmLight.Messaging; using GalaSoft.MvvmLight.Messaging;
using HandyControl.Controls; using HandyControl.Controls;
using HandyControlDemo.Data; using HandyControlDemo.Data;
@@ -1,10 +1,6 @@
using System; using System;
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
#if netle40
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
#endif
using GalaSoft.MvvmLight.Messaging; using GalaSoft.MvvmLight.Messaging;
using HandyControlDemo.Data; using HandyControlDemo.Data;
using HandyControlDemo.Tools; using HandyControlDemo.Tools;
@@ -1,6 +1,5 @@
using System; using System;
using System.Windows; using System.Windows;
using CommonServiceLocator;
using GalaSoft.MvvmLight.Ioc; using GalaSoft.MvvmLight.Ioc;
using HandyControlDemo.Data; using HandyControlDemo.Data;
using HandyControlDemo.Service; using HandyControlDemo.Service;
@@ -11,10 +10,8 @@ namespace HandyControlDemo.ViewModel
{ {
public ViewModelLocator() public ViewModelLocator()
{ {
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
SimpleIoc.Default.Register<DataService>(); SimpleIoc.Default.Register<DataService>();
var dataService = ServiceLocator.Current.GetInstance<DataService>(); var dataService = SimpleIoc.Default.GetInstance<DataService>();
SimpleIoc.Default.Register<MainViewModel>(); SimpleIoc.Default.Register<MainViewModel>();
SimpleIoc.Default.Register(() => new GrowlDemoViewModel(), "GrowlDemo"); SimpleIoc.Default.Register(() => new GrowlDemoViewModel(), "GrowlDemo");
@@ -49,57 +46,57 @@ namespace HandyControlDemo.ViewModel
#region Vm #region Vm
public MainViewModel Main => ServiceLocator.Current.GetInstance<MainViewModel>(); public MainViewModel Main => SimpleIoc.Default.GetInstance<MainViewModel>();
public GrowlDemoViewModel GrowlDemo => ServiceLocator.Current.GetInstance<GrowlDemoViewModel>("GrowlDemo"); public GrowlDemoViewModel GrowlDemo => SimpleIoc.Default.GetInstance<GrowlDemoViewModel>("GrowlDemo");
public GrowlDemoViewModel GrowlDemoWithToken => ServiceLocator.Current.GetInstance<GrowlDemoViewModel>("GrowlDemoWithToken"); public GrowlDemoViewModel GrowlDemoWithToken => SimpleIoc.Default.GetInstance<GrowlDemoViewModel>("GrowlDemoWithToken");
public ImageBrowserDemoViewModel ImageBrowserDemo => ServiceLocator.Current.GetInstance<ImageBrowserDemoViewModel>(); public ImageBrowserDemoViewModel ImageBrowserDemo => SimpleIoc.Default.GetInstance<ImageBrowserDemoViewModel>();
public ComboBoxDemoViewModel ComboBoxDemo => ServiceLocator.Current.GetInstance<ComboBoxDemoViewModel>(); public ComboBoxDemoViewModel ComboBoxDemo => SimpleIoc.Default.GetInstance<ComboBoxDemoViewModel>();
public WindowDemoViewModel WindowDemo => ServiceLocator.Current.GetInstance<WindowDemoViewModel>(); public WindowDemoViewModel WindowDemo => SimpleIoc.Default.GetInstance<WindowDemoViewModel>();
public ItemsDisplayViewModel ContributorsView => ServiceLocator.Current.GetInstance<ItemsDisplayViewModel>("Contributors"); public ItemsDisplayViewModel ContributorsView => SimpleIoc.Default.GetInstance<ItemsDisplayViewModel>("Contributors");
public ItemsDisplayViewModel BlogsView => ServiceLocator.Current.GetInstance<ItemsDisplayViewModel>("Blogs"); public ItemsDisplayViewModel BlogsView => SimpleIoc.Default.GetInstance<ItemsDisplayViewModel>("Blogs");
public ItemsDisplayViewModel ProjectsView => ServiceLocator.Current.GetInstance<ItemsDisplayViewModel>("Projects"); public ItemsDisplayViewModel ProjectsView => SimpleIoc.Default.GetInstance<ItemsDisplayViewModel>("Projects");
public ItemsDisplayViewModel WebsitesView => ServiceLocator.Current.GetInstance<ItemsDisplayViewModel>("Websites"); public ItemsDisplayViewModel WebsitesView => SimpleIoc.Default.GetInstance<ItemsDisplayViewModel>("Websites");
public StepBarDemoViewModel StepBarDemo => ServiceLocator.Current.GetInstance<StepBarDemoViewModel>(); public StepBarDemoViewModel StepBarDemo => SimpleIoc.Default.GetInstance<StepBarDemoViewModel>();
public PaginationDemoViewModel PaginationDemo => ServiceLocator.Current.GetInstance<PaginationDemoViewModel>(); public PaginationDemoViewModel PaginationDemo => SimpleIoc.Default.GetInstance<PaginationDemoViewModel>();
public ChatBoxViewModel ChatBox => new ChatBoxViewModel(); public ChatBoxViewModel ChatBox => new ChatBoxViewModel();
public CoverViewModel CoverView => ServiceLocator.Current.GetInstance<CoverViewModel>(); public CoverViewModel CoverView => SimpleIoc.Default.GetInstance<CoverViewModel>();
public DialogDemoViewModel DialogDemo => ServiceLocator.Current.GetInstance<DialogDemoViewModel>(); public DialogDemoViewModel DialogDemo => SimpleIoc.Default.GetInstance<DialogDemoViewModel>();
public SearchBarDemoViewModel SearchBarDemo => ServiceLocator.Current.GetInstance<SearchBarDemoViewModel>(); public SearchBarDemoViewModel SearchBarDemo => SimpleIoc.Default.GetInstance<SearchBarDemoViewModel>();
public NotifyIconDemoViewModel NotifyIconDemo => ServiceLocator.Current.GetInstance<NotifyIconDemoViewModel>(); public NotifyIconDemoViewModel NotifyIconDemo => SimpleIoc.Default.GetInstance<NotifyIconDemoViewModel>();
public InteractiveDialogViewModel InteractiveDialog => ServiceLocator.Current.GetInstance<InteractiveDialogViewModel>(); public InteractiveDialogViewModel InteractiveDialog => SimpleIoc.Default.GetInstance<InteractiveDialogViewModel>();
public BadgeDemoViewModel BadgeDemo => ServiceLocator.Current.GetInstance<BadgeDemoViewModel>(); public BadgeDemoViewModel BadgeDemo => SimpleIoc.Default.GetInstance<BadgeDemoViewModel>();
public SideMenuDemoViewModel SideMenuDemo => ServiceLocator.Current.GetInstance<SideMenuDemoViewModel>(); public SideMenuDemoViewModel SideMenuDemo => SimpleIoc.Default.GetInstance<SideMenuDemoViewModel>();
public TabControlDemoViewModel TabControlDemo => new TabControlDemoViewModel(ServiceLocator.Current.GetInstance<DataService>()); public TabControlDemoViewModel TabControlDemo => new TabControlDemoViewModel(SimpleIoc.Default.GetInstance<DataService>());
public NoUserViewModel NoUser => ServiceLocator.Current.GetInstance<NoUserViewModel>(); public NoUserViewModel NoUser => SimpleIoc.Default.GetInstance<NoUserViewModel>();
public CardDemoViewModel CardDemo => new CardDemoViewModel(ServiceLocator.Current.GetInstance<DataService>()); public CardDemoViewModel CardDemo => new CardDemoViewModel(SimpleIoc.Default.GetInstance<DataService>());
public SpriteDemoViewModel SpriteDemo => ServiceLocator.Current.GetInstance<SpriteDemoViewModel>(); public SpriteDemoViewModel SpriteDemo => SimpleIoc.Default.GetInstance<SpriteDemoViewModel>();
public NotificationDemoViewModel NotificationDemo => ServiceLocator.Current.GetInstance<NotificationDemoViewModel>(); public NotificationDemoViewModel NotificationDemo => SimpleIoc.Default.GetInstance<NotificationDemoViewModel>();
public SplitButtonDemoViewModel SplitButtonDemo => ServiceLocator.Current.GetInstance<SplitButtonDemoViewModel>(); public SplitButtonDemoViewModel SplitButtonDemo => SimpleIoc.Default.GetInstance<SplitButtonDemoViewModel>();
#endregion #endregion
} }
@@ -19,40 +19,40 @@
Width="800"> Width="800">
<hc:Window.NonClientAreaContent> <hc:Window.NonClientAreaContent>
<StackPanel Orientation="Horizontal" Height="69"> <StackPanel Orientation="Horizontal" Height="69">
<Path Data="{StaticResource LogoGeometry}" Width="40" Height="40" Stretch="Uniform" Fill="#F76B1C" Margin="20,0,0,0"></Path> <Path Data="{StaticResource LogoGeometry}" Width="40" Height="40" Stretch="Uniform" Fill="#F76B1C" Margin="20,0,0,0"/>
<Button Style="{StaticResource ButtonCustom}" Margin="32,0,0,0"> <Button Style="{StaticResource ButtonCustom}" Margin="32,0,0,0">
<Border Width="30" Height="30" BorderThickness="1" CornerRadius="6" BorderBrush="#B7B5B7" Background="{StaticResource MenuButtonBorderBrush}"> <Border Width="30" Height="30" BorderThickness="1" CornerRadius="6" BorderBrush="#B7B5B7" Background="{StaticResource MenuButtonBorderBrush}">
<Path Margin="5" Fill="#ED41FF" Stretch="Uniform" Data="{StaticResource ErrorGeometry}"></Path> <Path Margin="5" Fill="#ED41FF" Stretch="Uniform" Data="{StaticResource ErrorGeometry}"/>
</Border> </Border>
</Button> </Button>
<Button Style="{StaticResource ButtonCustom}" Margin="10,0,0,0"> <Button Style="{StaticResource ButtonCustom}" Margin="10,0,0,0">
<Border Width="30" Height="30" BorderThickness="1" CornerRadius="6" BorderBrush="#B7B5B7" Background="{DynamicResource MenuButtonBorderBrush}"> <Border Width="30" Height="30" BorderThickness="1" CornerRadius="6" BorderBrush="#B7B5B7" Background="{DynamicResource MenuButtonBorderBrush}">
<Path Margin="6" Fill="#ED41FF" Stretch="Uniform" Data="{StaticResource AskGeometry}"></Path> <Path Margin="6" Fill="#ED41FF" Stretch="Uniform" Data="{StaticResource AskGeometry}"/>
</Border> </Border>
</Button> </Button>
<Button Style="{StaticResource ButtonCustom}" Margin="10,0,0,0"> <Button Style="{StaticResource ButtonCustom}" Margin="10,0,0,0">
<Border Width="30" Height="30" BorderThickness="1" CornerRadius="6" BorderBrush="#B7B5B7" Background="{DynamicResource MenuButtonBorderBrush}"> <Border Width="30" Height="30" BorderThickness="1" CornerRadius="6" BorderBrush="#B7B5B7" Background="{DynamicResource MenuButtonBorderBrush}">
<Path Margin="6" Fill="#ED41FF" Stretch="Uniform" Data="{StaticResource InfoGeometry}"></Path> <Path Margin="6" Fill="#ED41FF" Stretch="Uniform" Data="{StaticResource InfoGeometry}"/>
</Border> </Border>
</Button> </Button>
<Button Style="{StaticResource ButtonCustom}" Margin="32,0,0,0"> <Button Style="{StaticResource ButtonCustom}" Margin="32,0,0,0">
<Border Width="30" Height="30" BorderThickness="1" CornerRadius="6" BorderBrush="#B7B5B7" Background="{DynamicResource MenuButtonBorderBrush}"> <Border Width="30" Height="30" BorderThickness="1" CornerRadius="6" BorderBrush="#B7B5B7" Background="{DynamicResource MenuButtonBorderBrush}">
<Path Margin="5" Fill="#8EC915" Stretch="Uniform" Data="{StaticResource ErrorGeometry}"></Path> <Path Margin="5" Fill="#8EC915" Stretch="Uniform" Data="{StaticResource ErrorGeometry}"/>
</Border> </Border>
</Button> </Button>
<Button Style="{StaticResource ButtonCustom}" Margin="10,0,0,0"> <Button Style="{StaticResource ButtonCustom}" Margin="10,0,0,0">
<Border Width="30" Height="30" BorderThickness="1" CornerRadius="6" BorderBrush="#B7B5B7" Background="{DynamicResource MenuButtonBorderBrush}"> <Border Width="30" Height="30" BorderThickness="1" CornerRadius="6" BorderBrush="#B7B5B7" Background="{DynamicResource MenuButtonBorderBrush}">
<Path Margin="6" Fill="#8EC915" Stretch="Uniform" Data="{StaticResource AskGeometry}"></Path> <Path Margin="6" Fill="#8EC915" Stretch="Uniform" Data="{StaticResource AskGeometry}"/>
</Border> </Border>
</Button> </Button>
<Button Style="{StaticResource ButtonCustom}" Margin="10,0,0,0"> <Button Style="{StaticResource ButtonCustom}" Margin="10,0,0,0">
<Border Width="30" Height="30" BorderThickness="1" CornerRadius="6" BorderBrush="#B7B5B7" Background="{DynamicResource MenuButtonBorderBrush}"> <Border Width="30" Height="30" BorderThickness="1" CornerRadius="6" BorderBrush="#B7B5B7" Background="{DynamicResource MenuButtonBorderBrush}">
<Path Margin="6" Fill="#8EC915" Stretch="Uniform" Data="{StaticResource AllGeometry}"></Path> <Path Margin="6" Fill="#8EC915" Stretch="Uniform" Data="{StaticResource AllGeometry}"/>
</Border> </Border>
</Button> </Button>
<Button Style="{StaticResource ButtonCustom}" Margin="10,0,0,0"> <Button Style="{StaticResource ButtonCustom}" Margin="10,0,0,0">
<Border Width="30" Height="30" BorderThickness="1" CornerRadius="6" BorderBrush="#B7B5B7" Background="{DynamicResource MenuButtonBorderBrush}"> <Border Width="30" Height="30" BorderThickness="1" CornerRadius="6" BorderBrush="#B7B5B7" Background="{DynamicResource MenuButtonBorderBrush}">
<Path Margin="6" Fill="#8EC915" Stretch="Uniform" Data="{StaticResource InfoGeometry}"></Path> <Path Margin="6" Fill="#8EC915" Stretch="Uniform" Data="{StaticResource InfoGeometry}"/>
</Border> </Border>
</Button> </Button>
</StackPanel> </StackPanel>
@@ -0,0 +1,164 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Shapes;
using HandyControl.Data;
namespace HandyControl.Controls
{
[TemplatePart(Name = ElementRoot, Type = typeof(Border))]
[ContentProperty(nameof(Content))]
public class Watermark : Control
{
private const string ElementRoot = "PART_Root";
private Border _borderRoot;
private DrawingBrush _brush;
public static readonly DependencyProperty AngleProperty = DependencyProperty.Register(
"Angle", typeof(double), typeof(Watermark), new FrameworkPropertyMetadata(ValueBoxes.Double0Box, FrameworkPropertyMetadataOptions.AffectsRender));
public double Angle
{
get => (double) GetValue(AngleProperty);
set => SetValue(AngleProperty, value);
}
public static readonly DependencyProperty ContentProperty = DependencyProperty.Register(
"Content", typeof(object), typeof(Watermark), new PropertyMetadata(default));
public object Content
{
get => GetValue(ContentProperty);
set => SetValue(ContentProperty, value);
}
public static readonly DependencyProperty MarkProperty = DependencyProperty.Register(
"Mark", typeof(object), typeof(Watermark), new FrameworkPropertyMetadata(default, FrameworkPropertyMetadataOptions.AffectsRender));
public object Mark
{
get => GetValue(MarkProperty);
set => SetValue(MarkProperty, value);
}
public static readonly DependencyProperty MarkWidthProperty = DependencyProperty.Register(
"MarkWidth", typeof(double), typeof(Watermark), new FrameworkPropertyMetadata(ValueBoxes.Double0Box, FrameworkPropertyMetadataOptions.AffectsRender));
public double MarkWidth
{
get => (double) GetValue(MarkWidthProperty);
set => SetValue(MarkWidthProperty, value);
}
public static readonly DependencyProperty MarkHeightProperty = DependencyProperty.Register(
"MarkHeight", typeof(double), typeof(Watermark), new FrameworkPropertyMetadata(ValueBoxes.Double0Box, FrameworkPropertyMetadataOptions.AffectsRender));
public double MarkHeight
{
get => (double) GetValue(MarkHeightProperty);
set => SetValue(MarkHeightProperty, value);
}
public static readonly DependencyProperty MarkBrushProperty = DependencyProperty.Register(
"MarkBrush", typeof(Brush), typeof(Watermark), new FrameworkPropertyMetadata(default(Brush), FrameworkPropertyMetadataOptions.AffectsRender));
public Brush MarkBrush
{
get => (Brush) GetValue(MarkBrushProperty);
set => SetValue(MarkBrushProperty, value);
}
public static readonly DependencyProperty AutoSizeEnabledProperty = DependencyProperty.Register(
"AutoSizeEnabled", typeof(bool), typeof(Watermark), new PropertyMetadata(ValueBoxes.TrueBox));
public bool AutoSizeEnabled
{
get => (bool) GetValue(AutoSizeEnabledProperty);
set => SetValue(AutoSizeEnabledProperty, value);
}
public static readonly DependencyProperty MarkMarginProperty = DependencyProperty.Register(
"MarkMargin", typeof(Thickness), typeof(Watermark), new PropertyMetadata(default(Thickness)));
public Thickness MarkMargin
{
get => (Thickness) GetValue(MarkMarginProperty);
set => SetValue(MarkMarginProperty, value);
}
public override void OnApplyTemplate() => _borderRoot = GetTemplateChild(ElementRoot) as Border;
private void EnsureBrush()
{
var presenter = new ContentPresenter();
if (Mark is Geometry geometry)
{
presenter.Content = new Path
{
Width = MarkWidth,
Height = MarkHeight,
Fill = MarkBrush,
Stretch = Stretch.Uniform,
Data = geometry
};
}
else if (Mark is string str)
{
presenter.Content = new TextBlock
{
Text = str,
FontSize = FontSize
};
}
else
{
presenter.Content = Mark;
}
Size markSize;
if (AutoSizeEnabled)
{
presenter.Measure(new Size(double.MaxValue, double.MaxValue));
markSize = presenter.DesiredSize;
}
else
{
markSize = new Size(MarkWidth, MarkHeight);
}
_brush = new DrawingBrush
{
ViewportUnits = BrushMappingMode.Absolute,
Stretch = Stretch.Uniform,
TileMode = TileMode.Tile,
Transform = new RotateTransform(Angle),
Drawing = new GeometryDrawing
{
Brush = new VisualBrush(new Border
{
Background = Brushes.Transparent,
Padding = MarkMargin,
Child = presenter
}),
Geometry = new RectangleGeometry(new Rect(markSize))
},
Viewport = new Rect(markSize)
};
RenderOptions.SetCacheInvalidationThresholdMinimum(_brush, 0.5);
RenderOptions.SetCacheInvalidationThresholdMaximum(_brush, 2);
RenderOptions.SetCachingHint(_brush, CachingHint.Cache);
if (_borderRoot != null)
{
_borderRoot.Background = _brush;
}
}
protected override void OnRender(DrawingContext drawingContext) => EnsureBrush();
}
}
@@ -36,6 +36,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Card.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Card.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Notification.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Notification.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Poptip.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Poptip.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Watermark.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Screenshot\Screenshot.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\Screenshot\Screenshot.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Sprite.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Sprite.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Block\ToggleBlock.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\Block\ToggleBlock.cs" />
@@ -414,6 +415,14 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="$(MSBuildThisFileDirectory)Themes\Styles\Watermark.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Themes\Styles\Base\WatermarkBaseStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Themes\Styles\Base\ComboBoxBaseStyle.xaml"> <Page Include="$(MSBuildThisFileDirectory)Themes\Styles\Base\ComboBoxBaseStyle.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -85,7 +85,7 @@
<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="{DynamicResource DarkDefaultBrush}"/> <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">
@@ -125,7 +125,7 @@
<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="{DynamicResource DarkDefaultBrush}"/> <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">
@@ -0,0 +1,20 @@
<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">
<Style x:Key="WatermarkBaseStyle" TargetType="controls:Watermark">
<Setter Property="MarkBrush" Value="{DynamicResource DarkMaskBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource DarkMaskBrush}"/>
<Setter Property="Angle" Value="20"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:Watermark">
<Border Name="PART_Root">
<ContentPresenter/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
@@ -86,6 +86,7 @@
<ResourceDictionary Source="Frame.xaml"/> <ResourceDictionary Source="Frame.xaml"/>
<ResourceDictionary Source="BlendEffectBox.xaml"/> <ResourceDictionary Source="BlendEffectBox.xaml"/>
<ResourceDictionary Source="Screenshot.xaml"/> <ResourceDictionary Source="Screenshot.xaml"/>
<ResourceDictionary Source="Watermark.xaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>
@@ -0,0 +1,10 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:controls="clr-namespace:HandyControl.Controls">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Base/WatermarkBaseStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style BasedOn="{StaticResource WatermarkBaseStyle}" TargetType="controls:Watermark"/>
</ResourceDictionary>
@@ -49,6 +49,18 @@ namespace HandyControl.Tools
key == Key.RightCtrl || key == Key.RightAlt || key == Key.RightShift || key == Key.RWin; key == Key.RightCtrl || key == Key.RightAlt || key == Key.RightShift || key == Key.RWin;
} }
public static void Init(List<KeyBinding> list)
{
CommandDic.Clear();
if (list == null) return;
KeyBindingCollection = new ObservableCollection<KeyBinding>(list);
if (KeyBindingCollection.Count == 0) return;
AddKeyBindings(KeyBindingCollection);
KeyboardHook.Start();
}
private static void AddKeyBindings(IEnumerable<KeyBinding> keyBindings) private static void AddKeyBindings(IEnumerable<KeyBinding> keyBindings)
{ {
foreach (var item in keyBindings) foreach (var item in keyBindings)