24 files changed
+295
-16
No files matched your search
@@ -63,6 +63,12 @@ Step 4:enjoy coding
|
|||||||
|
|
||||||
## Latest examples
|
## Latest examples
|
||||||
|
|
||||||
|
### ImageBlock
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
### Magnifier
|
### Magnifier
|
||||||
|
|
||||||

|

|
||||||
@@ -75,6 +81,8 @@ Step 4:enjoy coding
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## History publication
|
||||||
|
|
||||||
### Grid
|
### Grid
|
||||||
|
|
||||||

|

|
||||||
@@ -83,8 +91,6 @@ Step 4:enjoy coding
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
## History publication
|
|
||||||
|
|
||||||
### NotifyIcon
|
### NotifyIcon
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 220 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 158 KiB |
@@ -5,7 +5,7 @@
|
|||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
<AssemblyName>HandyControlDemo</AssemblyName>
|
<AssemblyName>HandyControlDemo</AssemblyName>
|
||||||
<RootNamespace>HandyControlDemo</RootNamespace>
|
<RootNamespace>HandyControlDemo</RootNamespace>
|
||||||
<Version>2.0.0</Version>
|
<Version>2.1.0</Version>
|
||||||
<ApplicationIcon>..\..\Shared\HandyControlDemo_Shared\Resources\Img\icon.ico</ApplicationIcon>
|
<ApplicationIcon>..\..\Shared\HandyControlDemo_Shared\Resources\Img\icon.ico</ApplicationIcon>
|
||||||
<Configurations>Debug;Release</Configurations>
|
<Configurations>Debug;Release</Configurations>
|
||||||
<Copyright>Copyright © HandyOrg 2018-2019</Copyright>
|
<Copyright>Copyright © HandyOrg 2018-2019</Copyright>
|
||||||
@@ -359,6 +359,12 @@
|
|||||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\VSO_Card_16x.png">
|
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\VSO_Card_16x.png">
|
||||||
<Link>Resources\Img\LeftMainContent\VSO_Card_16x.png</Link>
|
<Link>Resources\Img\LeftMainContent\VSO_Card_16x.png</Link>
|
||||||
</Resource>
|
</Resource>
|
||||||
|
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\ImageStack_16x.png">
|
||||||
|
<Link>Resources\Img\LeftMainContent\ImageStack_16x.png</Link>
|
||||||
|
</Resource>
|
||||||
|
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\Dance.png">
|
||||||
|
<Link>Resources\Img\Dance.png</Link>
|
||||||
|
</Resource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="..\..\Shared\HandyControlDemo_Shared\Properties\Langs\Lang.en.resx">
|
<EmbeddedResource Include="..\..\Shared\HandyControlDemo_Shared\Properties\Langs\Lang.en.resx">
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
<AssemblyName>HandyControl</AssemblyName>
|
<AssemblyName>HandyControl</AssemblyName>
|
||||||
<RootNamespace>HandyControl</RootNamespace>
|
<RootNamespace>HandyControl</RootNamespace>
|
||||||
<Version>2.0.0</Version>
|
<Version>2.1.0</Version>
|
||||||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
||||||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
||||||
|
|||||||
@@ -396,6 +396,12 @@
|
|||||||
<Generator>TextTemplatingFileGenerator</Generator>
|
<Generator>TextTemplatingFileGenerator</Generator>
|
||||||
<LastGenOutput>MessageToken.cs</LastGenOutput>
|
<LastGenOutput>MessageToken.cs</LastGenOutput>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\Dance.png">
|
||||||
|
<Link>Resources\Img\Dance.png</Link>
|
||||||
|
</Resource>
|
||||||
|
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\ImageStack_16x.png">
|
||||||
|
<Link>Resources\Img\LeftMainContent\ImageStack_16x.png</Link>
|
||||||
|
</Resource>
|
||||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\VSO_Card_16x.png">
|
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\VSO_Card_16x.png">
|
||||||
<Link>Resources\Img\LeftMainContent\VSO_Card_16x.png</Link>
|
<Link>Resources\Img\LeftMainContent\VSO_Card_16x.png</Link>
|
||||||
</Resource>
|
</Resource>
|
||||||
|
|||||||
@@ -458,6 +458,12 @@
|
|||||||
<Generator>TextTemplatingFileGenerator</Generator>
|
<Generator>TextTemplatingFileGenerator</Generator>
|
||||||
<LastGenOutput>MessageToken.cs</LastGenOutput>
|
<LastGenOutput>MessageToken.cs</LastGenOutput>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\Dance.png">
|
||||||
|
<Link>Resources\Img\Dance.png</Link>
|
||||||
|
</Resource>
|
||||||
|
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\ImageStack_16x.png">
|
||||||
|
<Link>Resources\Img\LeftMainContent\ImageStack_16x.png</Link>
|
||||||
|
</Resource>
|
||||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\VSO_Card_16x.png">
|
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\VSO_Card_16x.png">
|
||||||
<Link>Resources\Img\LeftMainContent\VSO_Card_16x.png</Link>
|
<Link>Resources\Img\LeftMainContent\VSO_Card_16x.png</Link>
|
||||||
</Resource>
|
</Resource>
|
||||||
|
|||||||
@@ -104,6 +104,8 @@
|
|||||||
|
|
||||||
public static readonly string MagnifierDemoCtl = nameof(MagnifierDemoCtl);
|
public static readonly string MagnifierDemoCtl = nameof(MagnifierDemoCtl);
|
||||||
|
|
||||||
|
public static readonly string ImageBlockDemoCtl = nameof(ImageBlockDemoCtl);
|
||||||
|
|
||||||
public static readonly string ButtonDemoCtl = nameof(ButtonDemoCtl);
|
public static readonly string ButtonDemoCtl = nameof(ButtonDemoCtl);
|
||||||
|
|
||||||
public static readonly string RepeatButtonDemoCtl = nameof(RepeatButtonDemoCtl);
|
public static readonly string RepeatButtonDemoCtl = nameof(RepeatButtonDemoCtl);
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ var controlList = new List<string>
|
|||||||
"RangeSliderDemoCtl",
|
"RangeSliderDemoCtl",
|
||||||
"ButtonGroupDemoCtl",
|
"ButtonGroupDemoCtl",
|
||||||
"CardDemoCtl",
|
"CardDemoCtl",
|
||||||
"MagnifierDemoCtl"
|
"MagnifierDemoCtl",
|
||||||
|
"ImageBlockDemoCtl"
|
||||||
};
|
};
|
||||||
var styleList = new List<string>
|
var styleList = new List<string>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -54,6 +54,9 @@
|
|||||||
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\CardDemoCtl.xaml.cs">
|
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\CardDemoCtl.xaml.cs">
|
||||||
<DependentUpon>CardDemoCtl.xaml</DependentUpon>
|
<DependentUpon>CardDemoCtl.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\ImageBlockDemoCtl.xaml.cs">
|
||||||
|
<DependentUpon>ImageBlockDemoCtl.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\MagnifierDemoCtl.xaml.cs">
|
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\MagnifierDemoCtl.xaml.cs">
|
||||||
<DependentUpon>MagnifierDemoCtl.xaml</DependentUpon>
|
<DependentUpon>MagnifierDemoCtl.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -423,6 +426,10 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="$(MSBuildThisFileDirectory)UserControl\Controls\ImageBlockDemoCtl.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="$(MSBuildThisFileDirectory)UserControl\Controls\MagnifierDemoCtl.xaml">
|
<Page Include="$(MSBuildThisFileDirectory)UserControl\Controls\MagnifierDemoCtl.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|||||||
@@ -13,5 +13,5 @@ using System.Windows;
|
|||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
|
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
|
||||||
[assembly: AssemblyVersion("2.0.0")]
|
[assembly: AssemblyVersion("2.1.0")]
|
||||||
#endif
|
#endif
|
||||||
@@ -690,6 +690,15 @@ namespace HandyControlDemo.Properties.Langs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 图片块 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
public static string ImageBlock {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ImageBlock", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 图片浏览器 的本地化字符串。
|
/// 查找类似 图片浏览器 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -630,4 +630,7 @@
|
|||||||
<data name="Magnifier" xml:space="preserve">
|
<data name="Magnifier" xml:space="preserve">
|
||||||
<value>Magnifier</value>
|
<value>Magnifier</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ImageBlock" xml:space="preserve">
|
||||||
|
<value>ImageBlock</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -630,4 +630,7 @@
|
|||||||
<data name="Magnifier" xml:space="preserve">
|
<data name="Magnifier" xml:space="preserve">
|
||||||
<value>放大镜</value>
|
<value>放大镜</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ImageBlock" xml:space="preserve">
|
||||||
|
<value>图片块</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 617 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 336 B |
@@ -4,10 +4,6 @@
|
|||||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||||
Background="{DynamicResource RegionBrush}">
|
Background="{DynamicResource RegionBrush}">
|
||||||
<hc:TransitioningContentControl>
|
<hc:TransitioningContentControl>
|
||||||
<hc:GifImage x:Name="GifImageMain" Margin="32" Width="400" Height="300">
|
<hc:GifImage x:Name="GifImageMain" Margin="32" Width="400" Height="300" Uri="/HandyControlDemo;component/Resources/Img/car_chase.gif"/>
|
||||||
<hc:GifImage.Source>
|
|
||||||
<BitmapImage UriSource="/HandyControlDemo;component/Resources/Img/car_chase.gif"/>
|
|
||||||
</hc:GifImage.Source>
|
|
||||||
</hc:GifImage>
|
|
||||||
</hc:TransitioningContentControl>
|
</hc:TransitioningContentControl>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<UserControl x:Class="HandyControlDemo.UserControl.ImageBlockDemoCtl"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
Background="{DynamicResource RegionBrush}"
|
||||||
|
xmlns:hc="https://handyorg.github.io/handycontrol">
|
||||||
|
<hc:TransitioningContentControl>
|
||||||
|
<UniformGrid Rows="3" Columns="4" Margin="32">
|
||||||
|
<hc:ImageBlock Source="/HandyControlDemo;component/Resources/Img/Dance.png" Interval="0:0:0.125" Columns="8" Rows="10" StartColumn="0" StartRow="0" Width="110" Height="128"/>
|
||||||
|
<hc:ImageBlock Source="/HandyControlDemo;component/Resources/Img/Dance.png" Interval="0:0:0.125" Columns="8" Rows="10" StartColumn="0" StartRow="1" Width="110" Height="128"/>
|
||||||
|
<hc:ImageBlock Source="/HandyControlDemo;component/Resources/Img/Dance.png" Interval="0:0:0.125" Columns="8" Rows="10" StartColumn="0" StartRow="2" Width="110" Height="128"/>
|
||||||
|
<hc:ImageBlock Source="/HandyControlDemo;component/Resources/Img/Dance.png" Interval="0:0:0.125" Columns="8" Rows="10" StartColumn="0" StartRow="3" Width="110" Height="128"/>
|
||||||
|
<hc:ImageBlock Source="/HandyControlDemo;component/Resources/Img/Dance.png" Interval="0:0:0.1" Columns="8" Rows="10" StartColumn="0" StartRow="4" EndColumn="7" EndRow="4" Width="110" Height="128" IsPlaying="True"/>
|
||||||
|
<hc:ImageBlock Source="/HandyControlDemo;component/Resources/Img/Dance.png" Interval="0:0:0.125" Columns="8" Rows="10" StartColumn="0" StartRow="5" EndColumn="7" EndRow="5" Width="110" Height="128" IsPlaying="True"/>
|
||||||
|
<hc:ImageBlock Source="/HandyControlDemo;component/Resources/Img/Dance.png" Interval="0:0:0.125" Columns="8" Rows="10" StartColumn="0" StartRow="6" Width="110" Height="128"/>
|
||||||
|
<hc:ImageBlock Source="/HandyControlDemo;component/Resources/Img/Dance.png" Interval="0:0:0.1" Columns="8" Rows="10" StartColumn="0" StartRow="7" EndColumn="7" EndRow="7" Width="110" Height="128" IsPlaying="True"/>
|
||||||
|
<hc:ImageBlock Source="/HandyControlDemo;component/Resources/Img/Dance.png" Interval="0:0:0.125" Columns="8" Rows="10" StartColumn="0" StartRow="8" Width="110" Height="128"/>
|
||||||
|
<hc:ImageBlock Source="/HandyControlDemo;component/Resources/Img/Dance.png" Interval="0:0:0.125" Columns="8" Rows="10" StartColumn="0" StartRow="9" Width="110" Height="128"/>
|
||||||
|
</UniformGrid>
|
||||||
|
</hc:TransitioningContentControl>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace HandyControlDemo.UserControl
|
||||||
|
{
|
||||||
|
public partial class ImageBlockDemoCtl
|
||||||
|
{
|
||||||
|
public ImageBlockDemoCtl()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -195,6 +195,11 @@
|
|||||||
</hc:StatusSwitchElement.CheckedElement>
|
</hc:StatusSwitchElement.CheckedElement>
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
<ListBox Name="ListBoxControl" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" BorderThickness="0" SelectionMode="Single" Style="{StaticResource ListBoxTransparent}">
|
<ListBox Name="ListBoxControl" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" BorderThickness="0" SelectionMode="Single" Style="{StaticResource ListBoxTransparent}">
|
||||||
|
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.ImageBlockDemoCtl}" Content="{x:Static langs:Lang.ImageBlock}">
|
||||||
|
<hc:EdgeElement.LeftContent>
|
||||||
|
<Image Source="../../Resources/Img/LeftMainContent/ImageStack_16x.png"/>
|
||||||
|
</hc:EdgeElement.LeftContent>
|
||||||
|
</ListBoxItem>
|
||||||
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.MagnifierDemoCtl}" Content="{x:Static langs:Lang.Magnifier}">
|
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.MagnifierDemoCtl}" Content="{x:Static langs:Lang.Magnifier}">
|
||||||
<hc:EdgeElement.LeftContent>
|
<hc:EdgeElement.LeftContent>
|
||||||
<Image Source="../../Resources/Img/LeftMainContent/Search_16x.png"/>
|
<Image Source="../../Resources/Img/LeftMainContent/Search_16x.png"/>
|
||||||
@@ -330,7 +335,7 @@
|
|||||||
<Image Source="../../Resources/Img/LeftMainContent/ColorWheel_16x.png"/>
|
<Image Source="../../Resources/Img/LeftMainContent/ColorWheel_16x.png"/>
|
||||||
</hc:EdgeElement.LeftContent>
|
</hc:EdgeElement.LeftContent>
|
||||||
</ListBoxItem>
|
</ListBoxItem>
|
||||||
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.GridDemoCtl}" Content="{x:Static langs:Lang.Grid}">
|
<ListBoxItem Tag="{x:Static data:MessageToken.GridDemoCtl}" Content="{x:Static langs:Lang.Grid}">
|
||||||
<hc:EdgeElement.LeftContent>
|
<hc:EdgeElement.LeftContent>
|
||||||
<Image Source="../../Resources/Img/LeftMainContent/GridPane_16x.png"/>
|
<Image Source="../../Resources/Img/LeftMainContent/GridPane_16x.png"/>
|
||||||
</hc:EdgeElement.LeftContent>
|
</hc:EdgeElement.LeftContent>
|
||||||
|
|||||||
@@ -33,6 +33,22 @@ namespace HandyControl.Controls
|
|||||||
VisibilityProperty.OverrideMetadata(typeof(GifImage), new PropertyMetadata(default(Visibility), OnVisibilityChanged));
|
VisibilityProperty.OverrideMetadata(typeof(GifImage), new PropertyMetadata(default(Visibility), OnVisibilityChanged));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty UriProperty = DependencyProperty.Register(
|
||||||
|
"Uri", typeof(Uri), typeof(GifImage), new PropertyMetadata(default(Uri), OnUriChanged));
|
||||||
|
|
||||||
|
private static void OnUriChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
var ctl = (GifImage) d;
|
||||||
|
var v = (Uri)e.NewValue;
|
||||||
|
ctl.Source = new BitmapImage(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Uri Uri
|
||||||
|
{
|
||||||
|
get => (Uri) GetValue(UriProperty);
|
||||||
|
set => SetValue(UriProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
private static void OnVisibilityChanged(DependencyObject s, DependencyPropertyChangedEventArgs e)
|
private static void OnVisibilityChanged(DependencyObject s, DependencyPropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
var ctl = (GifImage)s;
|
var ctl = (GifImage)s;
|
||||||
@@ -56,10 +72,14 @@ namespace HandyControl.Controls
|
|||||||
if (DesignerProperties.GetIsInDesignMode(this)) return;
|
if (DesignerProperties.GetIsInDesignMode(this)) return;
|
||||||
if (_isLoaded) return;
|
if (_isLoaded) return;
|
||||||
_isLoaded = true;
|
_isLoaded = true;
|
||||||
if (Source is BitmapImage image)
|
if (Uri != null)
|
||||||
{
|
{
|
||||||
var uri = image.UriSource;
|
GetGifStreamFromPack(Uri);
|
||||||
GetGifStreamFromPack(uri);
|
StartAnimate();
|
||||||
|
}
|
||||||
|
else if (Source is BitmapImage image)
|
||||||
|
{
|
||||||
|
GetGifStreamFromPack(image.UriSource);
|
||||||
StartAnimate();
|
StartAnimate();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,178 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
using HandyControl.Data;
|
||||||
|
|
||||||
|
namespace HandyControl.Controls
|
||||||
|
{
|
||||||
|
public class ImageBlock : FrameworkElement
|
||||||
|
{
|
||||||
|
private readonly DispatcherTimer _dispatcherTimer;
|
||||||
|
|
||||||
|
private int _indexMax;
|
||||||
|
|
||||||
|
private int _indexMin;
|
||||||
|
|
||||||
|
private int _currentIndex;
|
||||||
|
|
||||||
|
public ImageBlock()
|
||||||
|
{
|
||||||
|
_dispatcherTimer = new DispatcherTimer
|
||||||
|
{
|
||||||
|
Interval = Interval
|
||||||
|
};
|
||||||
|
_dispatcherTimer.Tick += DispatcherTimer_Tick;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPositionsChanged()
|
||||||
|
{
|
||||||
|
_indexMin = StartRow * Columns + StartColumn;
|
||||||
|
_indexMax = EndRow * Columns + EndColumn;
|
||||||
|
_currentIndex = _indexMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnPositionsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
var ctl = (ImageBlock)d;
|
||||||
|
ctl.OnPositionsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DispatcherTimer_Tick(object sender, EventArgs e) => InvalidateVisual();
|
||||||
|
|
||||||
|
public static readonly DependencyProperty StartColumnProperty = DependencyProperty.Register(
|
||||||
|
"StartColumn", typeof(int), typeof(ImageBlock), new FrameworkPropertyMetadata(ValueBoxes.Int0Box,
|
||||||
|
FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender, OnPositionsChanged));
|
||||||
|
|
||||||
|
public int StartColumn
|
||||||
|
{
|
||||||
|
get => (int) GetValue(StartColumnProperty);
|
||||||
|
set => SetValue(StartColumnProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty StartRowProperty = DependencyProperty.Register(
|
||||||
|
"StartRow", typeof(int), typeof(ImageBlock), new FrameworkPropertyMetadata(ValueBoxes.Int0Box,
|
||||||
|
FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender, OnPositionsChanged));
|
||||||
|
|
||||||
|
public int StartRow
|
||||||
|
{
|
||||||
|
get => (int) GetValue(StartRowProperty);
|
||||||
|
set => SetValue(StartRowProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty EndColumnProperty = DependencyProperty.Register(
|
||||||
|
"EndColumn", typeof(int), typeof(ImageBlock), new FrameworkPropertyMetadata(ValueBoxes.Int0Box,
|
||||||
|
FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender, OnPositionsChanged));
|
||||||
|
|
||||||
|
public int EndColumn
|
||||||
|
{
|
||||||
|
get => (int) GetValue(EndColumnProperty);
|
||||||
|
set => SetValue(EndColumnProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty EndRowProperty = DependencyProperty.Register(
|
||||||
|
"EndRow", typeof(int), typeof(ImageBlock), new FrameworkPropertyMetadata(ValueBoxes.Int0Box,
|
||||||
|
FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender, OnPositionsChanged));
|
||||||
|
|
||||||
|
public int EndRow
|
||||||
|
{
|
||||||
|
get => (int) GetValue(EndRowProperty);
|
||||||
|
set => SetValue(EndRowProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty IsPlayingProperty = DependencyProperty.Register(
|
||||||
|
"IsPlaying", typeof(bool), typeof(ImageBlock), new FrameworkPropertyMetadata(ValueBoxes.FalseBox,
|
||||||
|
FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender, OnIsPlayingChanged));
|
||||||
|
|
||||||
|
private static void OnIsPlayingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
var ctl = (ImageBlock)d;
|
||||||
|
if ((bool) e.NewValue)
|
||||||
|
{
|
||||||
|
ctl._dispatcherTimer.Start();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ctl._dispatcherTimer.Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsPlaying
|
||||||
|
{
|
||||||
|
get => (bool) GetValue(IsPlayingProperty);
|
||||||
|
set => SetValue(IsPlayingProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty ColumnsProperty = DependencyProperty.Register(
|
||||||
|
"Columns", typeof(int), typeof(ImageBlock), new FrameworkPropertyMetadata(ValueBoxes.Int1Box,
|
||||||
|
FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender), obj => (int)obj >= 1);
|
||||||
|
|
||||||
|
public int Columns
|
||||||
|
{
|
||||||
|
get => (int) GetValue(ColumnsProperty);
|
||||||
|
set => SetValue(ColumnsProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty RowsProperty = DependencyProperty.Register(
|
||||||
|
"Rows", typeof(int), typeof(ImageBlock), new FrameworkPropertyMetadata(ValueBoxes.Int1Box,
|
||||||
|
FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender), obj => (int)obj >= 1);
|
||||||
|
|
||||||
|
public int Rows
|
||||||
|
{
|
||||||
|
get => (int) GetValue(RowsProperty);
|
||||||
|
set => SetValue(RowsProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty IntervalProperty = DependencyProperty.Register(
|
||||||
|
"Interval", typeof(TimeSpan), typeof(ImageBlock), new PropertyMetadata(TimeSpan.FromSeconds(1), OnIntervalChanged));
|
||||||
|
|
||||||
|
private static void OnIntervalChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
var ctl = (ImageBlock) d;
|
||||||
|
ctl._dispatcherTimer.Interval = (TimeSpan) e.NewValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimeSpan Interval
|
||||||
|
{
|
||||||
|
get => (TimeSpan) GetValue(IntervalProperty);
|
||||||
|
set => SetValue(IntervalProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty SourceProperty = DependencyProperty.Register(
|
||||||
|
"Source", typeof(ImageSource), typeof(ImageBlock), new FrameworkPropertyMetadata(default(ImageSource),
|
||||||
|
FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender));
|
||||||
|
|
||||||
|
public ImageSource Source
|
||||||
|
{
|
||||||
|
get => (ImageSource)GetValue(SourceProperty);
|
||||||
|
set => SetValue(SourceProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnRender(DrawingContext dc)
|
||||||
|
{
|
||||||
|
if (Source != null && Source is BitmapSource source)
|
||||||
|
{
|
||||||
|
// ReSharper disable once AssignNullToNotNullAttribute
|
||||||
|
var croppedBitmap = new CroppedBitmap(source, CalDisplayRect());
|
||||||
|
dc.DrawImage(croppedBitmap, new Rect(0, 0, RenderSize.Width, RenderSize.Height));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Int32Rect CalDisplayRect()
|
||||||
|
{
|
||||||
|
if (_currentIndex > _indexMax)
|
||||||
|
{
|
||||||
|
_currentIndex = _indexMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
var x = (int) (_currentIndex % Columns * RenderSize.Width);
|
||||||
|
// ReSharper disable once PossibleLossOfFraction
|
||||||
|
var y = (int) (_currentIndex / Columns * RenderSize.Height);
|
||||||
|
|
||||||
|
var rect = new Int32Rect(x, y, (int)RenderSize.Width, (int)RenderSize.Height);
|
||||||
|
_currentIndex++;
|
||||||
|
return rect;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\PanelElement.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\PanelElement.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\PasswordBoxAttach.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\PasswordBoxAttach.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\RectangleAttach.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\RectangleAttach.cs" />
|
||||||
|
<Compile Include="$(MSBuildThisFileDirectory)Controls\Image\ImageBlock.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Magnifier.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Magnifier.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\ButtonGroup.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\ButtonGroup.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Card.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Card.cs" />
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ using System.Runtime.InteropServices;
|
|||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
[assembly: AssemblyVersion("2.0.0")]
|
[assembly: AssemblyVersion("2.1.0")]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[assembly: XmlnsDefinition("https://handyorg.github.io/handycontrol", "HandyControl.Controls")]
|
[assembly: XmlnsDefinition("https://handyorg.github.io/handycontrol", "HandyControl.Controls")]
|
||||||
|
|||||||
Reference in new issue
Block a user