Merge pull request #146 from HandyOrg/add-Sprite

Add sprite
This commit is contained in:
NaBian authored and GitHub committed 2019-08-13 23:37:27 +08:00
commit b0283f269c
28 files changed
+234 -25

No files matched your search

@@ -399,6 +399,9 @@
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\PolygonHexagon_16x.png">
<Link>Resources\Img\LeftMainContent\PolygonHexagon_16x.png</Link>
</Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\HandyControl.png">
<Link>Resources\Img\LeftMainContent\HandyControl.png</Link>
</Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\Dance.png">
<Link>Resources\Img\Dance.png</Link>
</Resource>
@@ -417,6 +417,9 @@
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>MessageToken.cs</LastGenOutput>
</Content>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\HandyControl.png">
<Link>Resources\Img\LeftMainContent\HandyControl.png</Link>
</Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\PolygonHexagon_16x.png">
<Link>Resources\Img\LeftMainContent\PolygonHexagon_16x.png</Link>
</Resource>
@@ -480,6 +480,9 @@
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>MessageToken.cs</LastGenOutput>
</Content>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\HandyControl.png">
<Link>Resources\Img\LeftMainContent\HandyControl.png</Link>
</Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\PolygonHexagon_16x.png">
<Link>Resources\Img\LeftMainContent\PolygonHexagon_16x.png</Link>
</Resource>
@@ -110,6 +110,8 @@
public static readonly string HoneycombPanelDemoCtl = nameof(HoneycombPanelDemoCtl);
public static readonly string SpriteDemoCtl = nameof(SpriteDemoCtl);
public static readonly string ButtonDemoCtl = nameof(ButtonDemoCtl);
public static readonly string RepeatButtonDemoCtl = nameof(RepeatButtonDemoCtl);
@@ -57,7 +57,8 @@ var controlList = new List<string>
"MagnifierDemoCtl",
"ImageBlockDemoCtl",
"RunningBlockDemoCtl",
"HoneycombPanelDemoCtl"
"HoneycombPanelDemoCtl",
"SpriteDemoCtl"
};
var styleList = new List<string>
{
@@ -177,6 +177,9 @@
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\SideMenuDemoCtl.xaml.cs">
<DependentUpon>SideMenuDemoCtl.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\SpriteDemoCtl.xaml.cs">
<DependentUpon>SpriteDemoCtl.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\StepBarDemoCtl.xaml.cs">
<DependentUpon>StepBarDemoCtl.xaml</DependentUpon>
</Compile>
@@ -325,6 +328,7 @@
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\PaginationDemoViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\SearchBarDemoViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\SideMenuDemoViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\SpriteDemoViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\StepBarDemoViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\TabControlDemoViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\WindowDemoViewModel.cs" />
@@ -336,6 +340,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Window\AboutWindow.xaml.cs">
<DependentUpon>AboutWindow.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Main\AppSprite.xaml.cs">
<DependentUpon>AppSprite.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Window\BlurWindow.xaml.cs">
<DependentUpon>BlurWindow.xaml</DependentUpon>
</Compile>
@@ -596,6 +603,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)UserControl\Controls\SpriteDemoCtl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)UserControl\Controls\StepBarDemoCtl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -780,6 +791,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)UserControl\Main\AppSprite.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Window\BlurWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -987,6 +987,15 @@ namespace HandyControlDemo.Properties.Langs {
}
}
/// <summary>
/// 查找类似 打开精灵 的本地化字符串。
/// </summary>
public static string OpenSprite {
get {
return ResourceManager.GetString("OpenSprite", resourceCulture);
}
}
/// <summary>
/// 查找类似 轮廓文本 的本地化字符串。
/// </summary>
@@ -1365,6 +1374,15 @@ namespace HandyControlDemo.Properties.Langs {
}
}
/// <summary>
/// 查找类似 精灵 的本地化字符串。
/// </summary>
public static string Sprite {
get {
return ResourceManager.GetString("Sprite", resourceCulture);
}
}
/// <summary>
/// 查找类似 步骤 的本地化字符串。
/// </summary>
@@ -645,4 +645,10 @@
<data name="RemoveItem" xml:space="preserve">
<value>Remove an item</value>
</data>
<data name="Sprite" xml:space="preserve">
<value>Sprite</value>
</data>
<data name="OpenSprite" xml:space="preserve">
<value>Open sprite</value>
</data>
</root>
@@ -645,4 +645,10 @@
<data name="RemoveItem" xml:space="preserve">
<value>删除项</value>
</data>
<data name="Sprite" xml:space="preserve">
<value>精灵</value>
</data>
<data name="OpenSprite" xml:space="preserve">
<value>打开精灵</value>
</data>
</root>
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

@@ -94,4 +94,8 @@
<Setter Property="FontSize" Value="14"/>
</Style>
<Style TargetType="hc:Sprite" BasedOn="{StaticResource {x:Type hc:Sprite}}">
<Setter Property="Padding" Value="25"/>
</Style>
</ResourceDictionary>
@@ -0,0 +1,12 @@
<UserControl x:Class="HandyControlDemo.UserControl.SpriteDemoCtl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
DataContext="{Binding SpriteDemo,Source={StaticResource Locator}}"
Width="300"
Background="{DynamicResource RegionBrush}">
<hc:TransitioningContentControl>
<Button Margin="32" Command="{Binding OpenCmd}" Content="{x:Static langs:Lang.OpenSprite}"/>
</hc:TransitioningContentControl>
</UserControl>
@@ -0,0 +1,10 @@
namespace HandyControlDemo.UserControl
{
public partial class SpriteDemoCtl
{
public SpriteDemoCtl()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,9 @@
<hc:SimplePanel x:Class="HandyControlDemo.UserControl.AppSprite"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol">
<Border Background="White" CornerRadius="20" Effect="{StaticResource EffectShadow4}">
<Path Width="70" Height="70" Data="{StaticResource LogoGeometry}" Fill="#f06632"/>
</Border>
<Button Command="hc:ControlCommands.CloseWindow" CommandParameter="{Binding RelativeSource={RelativeSource Self}}" Visibility="{Binding IsMouseOver,RelativeSource={RelativeSource AncestorType=hc:SimplePanel},Converter={StaticResource Boolean2VisibilityConverter}}" Width="22" Height="22" Style="{StaticResource ButtonIcon}" Foreground="White" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,-8,-8,0"/>
</hc:SimplePanel>
@@ -0,0 +1,10 @@
namespace HandyControlDemo.UserControl
{
public partial class AppSprite
{
public AppSprite()
{
InitializeComponent();
}
}
}
@@ -330,7 +330,7 @@
<Image Source="../../Resources/Img/LeftMainContent/Dynamic_16x.png"/>
</hc:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.CardDemoCtl}" Content="{x:Static langs:Lang.Card}">
<ListBoxItem Tag="{x:Static data:MessageToken.CardDemoCtl}" Content="{x:Static langs:Lang.Card}">
<hc:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/LeftMainContent/VSO_Card_16x.png"/>
</hc:EdgeElement.LeftContent>
@@ -445,6 +445,11 @@
<Image Source="../../Resources/Img/LeftMainContent/ScrollBox_16x.png"/>
</hc:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.SpriteDemoCtl}" Content="{x:Static langs:Lang.Sprite}">
<hc:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/LeftMainContent/HandyControl.png"/>
</hc:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem Tag="{x:Static data:MessageToken.DialogDemoCtl}" Content="{x:Static langs:Lang.Dialog}">
<hc:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/LeftMainContent/Dialog_16x.png"/>
@@ -0,0 +1,18 @@
using System;
using GalaSoft.MvvmLight;
using HandyControl.Controls;
using HandyControlDemo.UserControl;
#if netle40
using GalaSoft.MvvmLight.Command;
#else
using GalaSoft.MvvmLight.CommandWpf;
# endif
namespace HandyControlDemo
{
public class SpriteDemoViewModel : ViewModelBase
{
public RelayCommand OpenCmd => new Lazy<RelayCommand>(() =>
new RelayCommand(()=> Sprite.Show(new AppSprite()))).Value;
}
}
@@ -39,6 +39,7 @@ namespace HandyControlDemo.ViewModel
SimpleIoc.Default.Register<TabControlDemoViewModel>();
SimpleIoc.Default.Register<NoUserViewModel>();
SimpleIoc.Default.Register<CardDemoViewModel>();
SimpleIoc.Default.Register<SpriteDemoViewModel>();
}
public static ViewModelLocator Instance => new Lazy<ViewModelLocator>(() =>
@@ -90,6 +91,8 @@ namespace HandyControlDemo.ViewModel
public CardDemoViewModel CardDemo => new CardDemoViewModel(ServiceLocator.Current.GetInstance<DataService>());
public SpriteDemoViewModel SpriteDemo => ServiceLocator.Current.GetInstance<SpriteDemoViewModel>();
#endregion
}
}
@@ -1,6 +1,9 @@
using System.Windows;
using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Interop;
using HandyControl.Data;
using HandyControl.Tools.Interop;
namespace HandyControl.Controls
{
@@ -21,7 +24,7 @@ namespace HandyControl.Controls
{
if ((bool)e.NewValue)
{
ctl.MouseLeftButtonDown += DragElement_MouseLeftButtonDown; ;
ctl.MouseLeftButtonDown += DragElement_MouseLeftButtonDown;
}
else
{
@@ -69,5 +72,40 @@ namespace HandyControl.Controls
public static bool GetIgnoreAltF4(DependencyObject element)
=> (bool) element.GetValue(IgnoreAltF4Property);
public static readonly DependencyProperty ShowInTaskManagerProperty = DependencyProperty.RegisterAttached(
"ShowInTaskManager", typeof(bool), typeof(WindowAttach), new PropertyMetadata(ValueBoxes.TrueBox, OnShowInTaskManagerChanged));
private static void OnShowInTaskManagerChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is System.Windows.Window window)
{
if ((bool)e.NewValue)
{
window.SourceInitialized -= Window_SourceInitialized;
}
else
{
window.SourceInitialized += Window_SourceInitialized;
}
}
}
private static void Window_SourceInitialized(object sender, EventArgs e)
{
if (sender is System.Windows.Window window)
{
var _ = new WindowInteropHelper(window)
{
Owner = NativeMethods.GetDesktopWindow()
};
}
}
public static void SetShowInTaskManager(DependencyObject element, bool value)
=> element.SetValue(ShowInTaskManagerProperty, value);
public static bool GetShowInTaskManager(DependencyObject element)
=> (bool) element.GetValue(ShowInTaskManagerProperty);
}
}
@@ -1,8 +1,5 @@
using System;
using System.Windows;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Interop;
using HandyControl.Tools.Interop;
namespace HandyControl.Controls
{
@@ -26,16 +23,6 @@ namespace HandyControl.Controls
GrowlPanel = GetTemplateChild(ElementGrowPanel) as Panel;
}
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
var _ = new WindowInteropHelper(this)
{
Owner = NativeMethods.GetDesktopWindow()
};
}
public void Init()
{
var desktopWorkingArea = SystemParameters.WorkArea;
@@ -0,0 +1,7 @@
namespace HandyControl.Controls
{
public class Sprite : System.Windows.Window
{
}
}
@@ -35,18 +35,28 @@ namespace HandyControl.Controls
set => SetValue(OffsetAngleProperty, value);
}
// ReSharper disable once RedundantAssignment
protected override Size MeasureOverride(Size availableSize)
{
if (Children.Count == 0) return new Size(Diameter, Diameter);
availableSize = new Size(Diameter, Diameter);
var newSize = new Size(Diameter, Diameter);
foreach (UIElement element in Children)
{
element.Measure(newSize);
}
return newSize;
}
protected override Size ArrangeOverride(Size finalSize)
{
var i = 0;
var perDeg = 360.0 / Children.Count;
var radius = Diameter / 2;
foreach (UIElement element in Children)
{
element.Measure(availableSize);
var centerX = element.DesiredSize.Width / 2.0;
var centerY = element.DesiredSize.Height / 2.0;
var angle = perDeg * i++ + OffsetAngle;
@@ -60,11 +70,12 @@ namespace HandyControl.Controls
var r = Math.PI * angle / 180.0;
var x = radius * Math.Cos(r);
var y = radius * Math.Sin(r);
var rectX = x + availableSize.Width / 2 - centerX;
var rectY = y + availableSize.Height / 2 - centerY;
var rectX = x + finalSize.Width / 2 - centerX;
var rectY = y + finalSize.Height / 2 - centerY;
element.Arrange(new Rect(rectX, rectY, element.DesiredSize.Width, element.DesiredSize.Height));
}
return availableSize;
return finalSize;
}
}
}
@@ -93,7 +93,7 @@ namespace HandyControl.Controls
child.Arrange(_stuffer.Move());
}
return base.ArrangeOverride(finalSize);
return finalSize;
}
private class HoneycombStuffer
@@ -24,12 +24,14 @@
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Magnifier.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\ButtonGroup.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Card.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Sprite.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\ToggleBlock.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Panel\HoneycombPanel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Slider\RangeSlider\RangeTrack.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Slider\RangeSlider\RangeThumb.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Slider\RangeSlider\TwoWayRangeBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\RunningBlock.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\Commands\CloseWindowCommand.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\Commands\OpenLinkCommand.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\BorderCircularClipConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\Number2PercentageConverter.cs" />
@@ -762,6 +764,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Themes\Styles\Sprite.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Themes\Styles\StepBar.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -0,0 +1,24 @@
using System;
using System.Windows;
using System.Windows.Input;
namespace HandyControl.Interactivity
{
public class CloseWindowCommand : ICommand
{
public bool CanExecute(object parameter) => true;
public void Execute(object parameter)
{
if (parameter is DependencyObject dependencyObject)
{
if (Window.GetWindow(dependencyObject) is Window window)
{
window.Close();
}
}
}
public event EventHandler CanExecuteChanged;
}
}
@@ -156,5 +156,10 @@ namespace HandyControl.Interactivity
/// 前置主窗口
/// </summary>
public static PushMainWindow2TopCommand PushMainWindow2Top { get; } = new PushMainWindow2TopCommand();
/// <summary>
/// 关闭窗口
/// </summary>
public static CloseWindowCommand CloseWindow { get; } = new CloseWindowCommand();
}
}
@@ -11,6 +11,8 @@
</ResourceDictionary.MergedDictionaries>
<Style TargetType="controls:GrowlWindow">
<Setter Property="controls:WindowAttach.IgnoreAltF4" Value="True"/>
<Setter Property="controls:WindowAttach.ShowInTaskManager" Value="False"/>
<Setter Property="Width" Value="340"/>
<Setter Property="MaxWidth" Value="340"/>
<Setter Property="Background" Value="Transparent"/>
@@ -71,6 +71,7 @@
<ResourceDictionary Source="Magnifier.xaml"/>
<ResourceDictionary Source="ToggleBlock.xaml"/>
<ResourceDictionary Source="RunningBlock.xaml"/>
<ResourceDictionary Source="Sprite.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>