completed the branch
This commit is contained in:
1 parent
fc3fd6b533
commit
f642f0e181
6 files changed
+64
-42
No files matched your search
@@ -63,6 +63,10 @@ Step 4:enjoy coding
|
||||
|
||||
## Latest examples
|
||||
|
||||
### RunningBlock
|
||||
|
||||

|
||||
|
||||
### ImageBlock
|
||||
|
||||

|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 509 KiB |
@@ -4,22 +4,24 @@
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
Background="{DynamicResource RegionBrush}"
|
||||
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs">
|
||||
<StackPanel Margin="32">
|
||||
<hc:RunningBlock Content="{Binding Source={x:Static langs:Lang.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}"/>
|
||||
<hc:RunningBlock Content="{Binding Source={x:Static langs:Lang.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=10}" Duration="0:0:10" Margin="0,16,0,0"/>
|
||||
<hc:RunningBlock Margin="0,16,0,0" Duration="0:0:20">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/1.gif"/>
|
||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/2.gif"/>
|
||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/3.gif"/>
|
||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/4.gif"/>
|
||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/5.gif"/>
|
||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/6.gif"/>
|
||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/7.gif"/>
|
||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/8.gif"/>
|
||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/9.gif"/>
|
||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/10.gif"/>
|
||||
</StackPanel>
|
||||
</hc:RunningBlock>
|
||||
</StackPanel>
|
||||
<hc:TransitioningContentControl>
|
||||
<StackPanel Margin="32" VerticalAlignment="Center">
|
||||
<hc:RunningBlock Content="{Binding Source={x:Static langs:Lang.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}"/>
|
||||
<hc:RunningBlock Content="{Binding Source={x:Static langs:Lang.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=10}" FontSize="20" FontWeight="Bold" Foreground="OrangeRed" Duration="0:0:10" Margin="0,16,0,0"/>
|
||||
<hc:RunningBlock Margin="0,16,0,0" Duration="0:0:20" IsRunning="{Binding IsMouseOver,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2BooleanReConverter}}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/1.gif" Margin="10,0"/>
|
||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/2.gif" Margin="10,0"/>
|
||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/3.gif" Margin="10,0"/>
|
||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/4.gif" Margin="10,0"/>
|
||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/5.gif" Margin="10,0"/>
|
||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/6.gif" Margin="10,0"/>
|
||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/7.gif" Margin="10,0"/>
|
||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/8.gif" Margin="10,0"/>
|
||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/9.gif" Margin="10,0"/>
|
||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/10.gif" Margin="10,0"/>
|
||||
</StackPanel>
|
||||
</hc:RunningBlock>
|
||||
</StackPanel>
|
||||
</hc:TransitioningContentControl>
|
||||
</UserControl>
|
||||
@@ -83,6 +83,8 @@ namespace HandyControl.Controls
|
||||
StartAnimate();
|
||||
}
|
||||
};
|
||||
|
||||
Unloaded += (s, e) => Dispose();
|
||||
}
|
||||
|
||||
public GifImage(string filename)
|
||||
|
||||
@@ -7,28 +7,26 @@ using HandyControl.Data;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
[TemplatePart(Name = ElementContent, Type = typeof(UIElement))]
|
||||
[TemplatePart(Name = ElementContent, Type = typeof(FrameworkElement))]
|
||||
[TemplatePart(Name = ElementPanel, Type = typeof(Panel))]
|
||||
public class RunningBlock : ContentControl
|
||||
{
|
||||
private const string ElementContent = "PART_ContentElement";
|
||||
|
||||
private const string ElementPanel = "PART_Panel";
|
||||
|
||||
protected Storyboard _storyboard;
|
||||
|
||||
private UIElement _elementContent;
|
||||
private FrameworkElement _elementContent;
|
||||
|
||||
private FrameworkElement _elementPanel;
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
||||
_elementContent = GetTemplateChild(ElementContent) as UIElement;
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register(
|
||||
"Orientation", typeof(Orientation), typeof(RunningBlock), new FrameworkPropertyMetadata(default(Orientation), FrameworkPropertyMetadataOptions.AffectsRender));
|
||||
|
||||
public Orientation Orientation
|
||||
{
|
||||
get => (Orientation) GetValue(OrientationProperty);
|
||||
set => SetValue(OrientationProperty, value);
|
||||
_elementContent = GetTemplateChild(ElementContent) as FrameworkElement;
|
||||
_elementPanel = GetTemplateChild(ElementPanel) as Panel;
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty DurationProperty = DependencyProperty.Register(
|
||||
@@ -63,11 +61,16 @@ namespace HandyControl.Controls
|
||||
|
||||
private void UpdateContent()
|
||||
{
|
||||
if (_elementContent == null) return;
|
||||
if (_elementContent == null || _elementPanel == null) return;
|
||||
|
||||
_storyboard?.Stop();
|
||||
_storyboard = new Storyboard();
|
||||
|
||||
var animation = new DoubleAnimation(-ActualWidth, ActualWidth, Duration)
|
||||
_elementPanel.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
|
||||
_elementPanel.Width = _elementPanel.DesiredSize.Width;
|
||||
_elementPanel.Height = _elementPanel.DesiredSize.Height;
|
||||
|
||||
var animation = new DoubleAnimation(-_elementContent.ActualWidth, ActualWidth, Duration)
|
||||
{
|
||||
RepeatBehavior = RepeatBehavior.Forever
|
||||
};
|
||||
|
||||
@@ -2,19 +2,30 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls">
|
||||
|
||||
<Style x:Key="RunningBlockBaseStyle" TargetType="controls:RunningBlock">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="BaseStyle.xaml"/>
|
||||
<ResourceDictionary Source="../../Basic/Sizes.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style x:Key="RunningBlockBaseStyle" BasedOn="{StaticResource BaseStyle}" TargetType="controls:RunningBlock">
|
||||
<Setter Property="controls:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Padding" Value="0,10"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls:RunningBlock">
|
||||
<controls:SimplePanel ClipToBounds="True">
|
||||
<ContentPresenter x:Name="PART_ContentElement" RenderTransformOrigin="0.5,0.5">
|
||||
<ContentPresenter.RenderTransform>
|
||||
<TransformGroup>
|
||||
<TranslateTransform X="0"/>
|
||||
</TransformGroup>
|
||||
</ContentPresenter.RenderTransform>
|
||||
</ContentPresenter>
|
||||
</controls:SimplePanel>
|
||||
<Border CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Padding="{TemplateBinding Padding}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" ClipToBounds="True">
|
||||
<controls:SimplePanel HorizontalAlignment="Left" x:Name="PART_Panel">
|
||||
<ContentPresenter x:Name="PART_ContentElement" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left">
|
||||
<ContentPresenter.RenderTransform>
|
||||
<TransformGroup>
|
||||
<TranslateTransform X="0"/>
|
||||
</TransformGroup>
|
||||
</ContentPresenter.RenderTransform>
|
||||
</ContentPresenter>
|
||||
</controls:SimplePanel>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
|
||||
Reference in new issue
Block a user