1 parent
24e2c84f46
commit
1633792553
4 files changed
+51
-33
No files matched your search
@@ -1,38 +1,39 @@
|
|||||||
<UserControl x:Class="HandyControlDemo.UserControl.RunningBlockDemoCtl"
|
<UserControl x:Class="HandyControlDemo.UserControl.RunningBlockDemoCtl"
|
||||||
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:hc="https://handyorg.github.io/handycontrol"
|
|
||||||
Background="{DynamicResource RegionBrush}"
|
|
||||||
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
|
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
|
||||||
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension">
|
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension"
|
||||||
|
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||||
|
Background="{DynamicResource RegionBrush}">
|
||||||
<hc:TransitioningContentControl>
|
<hc:TransitioningContentControl>
|
||||||
<hc:ScrollViewer IsInertiaEnabled="True">
|
<hc:ScrollViewer IsInertiaEnabled="True">
|
||||||
<StackPanel Margin="32" VerticalAlignment="Center">
|
<hc:UniformSpacingPanel Orientation="Vertical" ItemHorizontalAlignment="Left" Spacing="8" Margin="32" VerticalAlignment="Center">
|
||||||
<hc:RunningBlock Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}"/>
|
<hc:RunningBlock Width="500" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" />
|
||||||
<hc:RunningBlock Runaway="False" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" Margin="0,16,0,0"/>
|
<hc:RunningBlock Width="500" RunningDirection="StartToEnd" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" />
|
||||||
<hc:RunningBlock HorizontalAlignment="Left" Width="500" Speed="50" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" Margin="0,16,0,0"/>
|
<hc:RunningBlock Width="500" Runaway="False" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" />
|
||||||
<hc:RunningBlock HorizontalAlignment="Left" Width="300" FontSize="30" Speed="50" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" Margin="0,16,0,0"/>
|
<hc:RunningBlock HorizontalAlignment="Left" Width="500" Speed="50" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" />
|
||||||
<hc:RunningBlock HorizontalAlignment="Left" AutoRun="True" Width="100" Runaway="False" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" Duration="0:0:2" Margin="0,16,0,0"/>
|
<hc:RunningBlock HorizontalAlignment="Left" Width="300" FontSize="30" Speed="50" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" />
|
||||||
<hc:RunningBlock HorizontalAlignment="Left" AutoReverse="True" AutoRun="True" Width="100" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" Margin="0,16,0,0"/>
|
<hc:RunningBlock HorizontalAlignment="Left" AutoRun="True" Width="100" Runaway="False" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" Duration="0:0:2" />
|
||||||
<hc:RunningBlock HorizontalAlignment="Left" AutoRun="True" Width="200" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" Margin="0,16,0,0"/>
|
<hc:RunningBlock HorizontalAlignment="Left" AutoReverse="True" AutoRun="True" Width="100" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" />
|
||||||
<hc:RunningBlock Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=10}" FontSize="20" FontWeight="Bold" Foreground="OrangeRed" Duration="0:0:10" Margin="0,16,0,0"/>
|
<hc:RunningBlock HorizontalAlignment="Left" AutoRun="True" Width="200" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}" />
|
||||||
<hc:RunningBlock AutoReverse="True" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=10}" FontSize="20" FontWeight="Bold" Foreground="OrangeRed" Duration="0:0:10" Margin="0,16,0,0"/>
|
<hc:RunningBlock Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=10}" FontSize="20" FontWeight="Bold" Foreground="OrangeRed" Duration="0:0:10" />
|
||||||
<hc:RunningBlock Orientation="Vertical" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=10}" FontSize="20" FontWeight="Bold" Foreground="OrangeRed" Duration="0:0:4" Margin="0,16,0,0"/>
|
<hc:RunningBlock AutoReverse="True" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=10}" FontSize="20" FontWeight="Bold" Foreground="OrangeRed" Duration="0:0:10" />
|
||||||
<hc:RunningBlock Margin="0,16,0,0" Duration="0:0:20" IsRunning="{Binding IsMouseOver,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2BooleanReConverter}}">
|
<hc:RunningBlock Orientation="Vertical" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=10}" FontSize="20" FontWeight="Bold" Foreground="OrangeRed" Duration="0:0:4" />
|
||||||
<StackPanel Orientation="Horizontal">
|
<hc:RunningBlock Duration="0:0:20" IsRunning="{Binding IsMouseOver,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2BooleanReConverter}}">
|
||||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/1.gif" Margin="10,0" Width="30" Height="30"/>
|
<hc:UniformSpacingPanel Spacing="10" ItemWidth="30" ItemHeight="30">
|
||||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/2.gif" Margin="10,0" Width="30" Height="30"/>
|
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/1.gif" />
|
||||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/3.gif" Margin="10,0" Width="30" Height="30"/>
|
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/2.gif" />
|
||||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/4.gif" Margin="10,0" Width="30" Height="30"/>
|
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/3.gif" />
|
||||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/5.gif" Margin="10,0" Width="30" Height="30"/>
|
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/4.gif" />
|
||||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/6.gif" Margin="10,0" Width="30" Height="30"/>
|
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/5.gif" />
|
||||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/7.gif" Margin="10,0" Width="30" Height="30"/>
|
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/6.gif" />
|
||||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/8.gif" Margin="10,0" Width="30" Height="30"/>
|
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/7.gif" />
|
||||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/9.gif" Margin="10,0" Width="30" Height="30"/>
|
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/8.gif" />
|
||||||
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/10.gif" Margin="10,0" Width="30" Height="30"/>
|
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/9.gif" />
|
||||||
</StackPanel>
|
<hc:GifImage Uri="/HandyControlDemo;component/Resources/Img/QQ/10.gif" />
|
||||||
|
</hc:UniformSpacingPanel>
|
||||||
</hc:RunningBlock>
|
</hc:RunningBlock>
|
||||||
</StackPanel>
|
</hc:UniformSpacingPanel>
|
||||||
</hc:ScrollViewer>
|
</hc:ScrollViewer>
|
||||||
</hc:TransitioningContentControl>
|
</hc:TransitioningContentControl>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@@ -124,6 +124,15 @@ public class RunningBlock : ContentControl
|
|||||||
set => SetValue(AutoReverseProperty, ValueBoxes.BooleanBox(value));
|
set => SetValue(AutoReverseProperty, ValueBoxes.BooleanBox(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty RunningDirectionProperty = DependencyProperty.Register(
|
||||||
|
nameof(RunningDirection), typeof(RunningDirection), typeof(RunningBlock), new PropertyMetadata(RunningDirection.EndToStart));
|
||||||
|
|
||||||
|
public RunningDirection RunningDirection
|
||||||
|
{
|
||||||
|
get => (RunningDirection) GetValue(RunningDirectionProperty);
|
||||||
|
set => SetValue(RunningDirectionProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateContent()
|
private void UpdateContent()
|
||||||
{
|
{
|
||||||
if (_elementContent == null || _elementPanel == null) return;
|
if (_elementContent == null || _elementPanel == null) return;
|
||||||
@@ -182,11 +191,11 @@ public class RunningBlock : ContentControl
|
|||||||
? TimeSpan.FromSeconds(Math.Abs(to - from) / Speed)
|
? TimeSpan.FromSeconds(Math.Abs(to - from) / Speed)
|
||||||
: Duration;
|
: Duration;
|
||||||
|
|
||||||
var animation = new DoubleAnimation(from, to, duration)
|
var animation = RunningDirection is RunningDirection.EndToStart
|
||||||
{
|
? new DoubleAnimation(to, from, duration)
|
||||||
RepeatBehavior = RepeatBehavior.Forever,
|
: new DoubleAnimation(from, to, duration);
|
||||||
AutoReverse = AutoReverse
|
animation.RepeatBehavior = RepeatBehavior.Forever;
|
||||||
};
|
animation.AutoReverse = AutoReverse;
|
||||||
|
|
||||||
Storyboard.SetTargetProperty(animation, propertyPath);
|
Storyboard.SetTargetProperty(animation, propertyPath);
|
||||||
Storyboard.SetTarget(animation, _elementContent);
|
Storyboard.SetTarget(animation, _elementContent);
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace HandyControl.Data;
|
||||||
|
|
||||||
|
public enum RunningDirection
|
||||||
|
{
|
||||||
|
EndToStart,
|
||||||
|
StartToEnd
|
||||||
|
}
|
||||||
@@ -98,6 +98,7 @@
|
|||||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Text\SimpleText.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Controls\Text\SimpleText.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\GrowlShowMode.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\GrowlShowMode.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\LinearLayout.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\LinearLayout.cs" />
|
||||||
|
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\RunningDirection.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\EventToCommand.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\EventToCommand.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\IEventArgsConverter.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\IEventArgsConverter.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\MouseDragElementBehaviorEx.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\MouseDragElementBehaviorEx.cs" />
|
||||||
|
|||||||
Reference in new issue
Block a user