Skip to content

Commit

Permalink
Merge pull request #122 from HandyOrg/add-ImageBlock
Browse files Browse the repository at this point in the history
Add image block
  • Loading branch information
NaBian authored Jul 18, 2019
2 parents 4f9cc3a + 029c814 commit e722fa6
Show file tree
Hide file tree
Showing 24 changed files with 295 additions and 16 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ Step 4:enjoy coding

## Latest examples

### ImageBlock

![ImageBlock](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/ImageBlock.gif)

![ImageBlock](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/ImageBlock.png)

### Magnifier

![Magnifier](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/Magnifier.png)
Expand All @@ -75,6 +81,8 @@ Step 4:enjoy coding

![ButtonGroup](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/ButtonGroup.png)

## History publication

### Grid

![Grid](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/Grid.gif)
Expand All @@ -83,8 +91,6 @@ Step 4:enjoy coding

![SideMenu](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/SideMenu.png)

## History publication

### NotifyIcon

![NotifyIcon](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/NotifyIcon.png)
Expand Down
Binary file added Resources/ImageBlock.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/ImageBlock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<UseWPF>true</UseWPF>
<AssemblyName>HandyControlDemo</AssemblyName>
<RootNamespace>HandyControlDemo</RootNamespace>
<Version>2.0.0</Version>
<Version>2.1.0</Version>
<ApplicationIcon>..\..\Shared\HandyControlDemo_Shared\Resources\Img\icon.ico</ApplicationIcon>
<Configurations>Debug;Release</Configurations>
<Copyright>Copyright © HandyOrg 2018-2019</Copyright>
Expand Down Expand Up @@ -359,6 +359,12 @@
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\VSO_Card_16x.png">
<Link>Resources\Img\LeftMainContent\VSO_Card_16x.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\Dance.png">
<Link>Resources\Img\Dance.png</Link>
</Resource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\..\Shared\HandyControlDemo_Shared\Properties\Langs\Lang.en.resx">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<UseWPF>true</UseWPF>
<AssemblyName>HandyControl</AssemblyName>
<RootNamespace>HandyControl</RootNamespace>
<Version>2.0.0</Version>
<Version>2.1.0</Version>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,12 @@
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>MessageToken.cs</LastGenOutput>
</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">
<Link>Resources\Img\LeftMainContent\VSO_Card_16x.png</Link>
</Resource>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,12 @@
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>MessageToken.cs</LastGenOutput>
</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">
<Link>Resources\Img\LeftMainContent\VSO_Card_16x.png</Link>
</Resource>
Expand Down
2 changes: 2 additions & 0 deletions src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public class MessageToken

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 RepeatButtonDemoCtl = nameof(RepeatButtonDemoCtl);
Expand Down
3 changes: 2 additions & 1 deletion src/Shared/HandyControlDemo_Shared/Data/MessageToken.tt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ var controlList = new List<string>
"RangeSliderDemoCtl",
"ButtonGroupDemoCtl",
"CardDemoCtl",
"MagnifierDemoCtl"
"MagnifierDemoCtl",
"ImageBlockDemoCtl"
};
var styleList = new List<string>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\CardDemoCtl.xaml.cs">
<DependentUpon>CardDemoCtl.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\ImageBlockDemoCtl.xaml.cs">
<DependentUpon>ImageBlockDemoCtl.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\MagnifierDemoCtl.xaml.cs">
<DependentUpon>MagnifierDemoCtl.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -423,6 +426,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)UserControl\Controls\ImageBlockDemoCtl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)UserControl\Controls\MagnifierDemoCtl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
[assembly: AssemblyVersion("2.0.0")]
[assembly: AssemblyVersion("2.1.0")]
#endif

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,7 @@
<data name="Magnifier" xml:space="preserve">
<value>Magnifier</value>
</data>
<data name="ImageBlock" xml:space="preserve">
<value>ImageBlock</value>
</data>
</root>
3 changes: 3 additions & 0 deletions src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,7 @@
<data name="Magnifier" xml:space="preserve">
<value>放大镜</value>
</data>
<data name="ImageBlock" xml:space="preserve">
<value>图片块</value>
</data>
</root>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
xmlns:hc="https://handyorg.github.io/handycontrol"
Background="{DynamicResource RegionBrush}">
<hc:TransitioningContentControl>
<hc:GifImage x:Name="GifImageMain" Margin="32" Width="400" Height="300">
<hc:GifImage.Source>
<BitmapImage UriSource="/HandyControlDemo;component/Resources/Img/car_chase.gif"/>
</hc:GifImage.Source>
</hc:GifImage>
<hc:GifImage x:Name="GifImageMain" Margin="32" Width="400" Height="300" Uri="/HandyControlDemo;component/Resources/Img/car_chase.gif"/>
</hc:TransitioningContentControl>
</UserControl>
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace HandyControlDemo.UserControl
{
public partial class ImageBlockDemoCtl
{
public ImageBlockDemoCtl()
{
InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@
</hc:StatusSwitchElement.CheckedElement>
</ToggleButton>
<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}">
<hc:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/LeftMainContent/Search_16x.png"/>
Expand Down Expand Up @@ -330,7 +335,7 @@
<Image Source="../../Resources/Img/LeftMainContent/ColorWheel_16x.png"/>
</hc:EdgeElement.LeftContent>
</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>
<Image Source="../../Resources/Img/LeftMainContent/GridPane_16x.png"/>
</hc:EdgeElement.LeftContent>
Expand Down
26 changes: 23 additions & 3 deletions src/Shared/HandyControl_Shared/Controls/Image/GifImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ static GifImage()
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)
{
var ctl = (GifImage)s;
Expand All @@ -56,10 +72,14 @@ public GifImage()
if (DesignerProperties.GetIsInDesignMode(this)) return;
if (_isLoaded) return;
_isLoaded = true;
if (Source is BitmapImage image)
if (Uri != null)
{
GetGifStreamFromPack(Uri);
StartAnimate();
}
else if (Source is BitmapImage image)
{
var uri = image.UriSource;
GetGifStreamFromPack(uri);
GetGifStreamFromPack(image.UriSource);
StartAnimate();
}
};
Expand Down
Loading

0 comments on commit e722fa6

Please sign in to comment.