1 parent
8b6fd84a8b
commit
7648f20605
4 files changed
+60
-68
No files matched your search
@@ -9,6 +9,8 @@
|
|||||||
<StackPanel Margin="32" VerticalAlignment="Center">
|
<StackPanel Margin="32" VerticalAlignment="Center">
|
||||||
<hc:RunningBlock 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=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 Runaway="False" 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}" 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}" 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" 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" 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}" 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}" 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}" 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}" Margin="0,16,0,0"/>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Windows.Controls;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Animation;
|
using System.Windows.Media.Animation;
|
||||||
using HandyControl.Data;
|
using HandyControl.Data;
|
||||||
|
using HandyControl.Expression.Drawing;
|
||||||
|
|
||||||
namespace HandyControl.Controls
|
namespace HandyControl.Controls
|
||||||
{
|
{
|
||||||
@@ -65,6 +66,15 @@ namespace HandyControl.Controls
|
|||||||
set => SetValue(DurationProperty, value);
|
set => SetValue(DurationProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty SpeedProperty = DependencyProperty.Register(
|
||||||
|
"Speed", typeof(double), typeof(RunningBlock), new FrameworkPropertyMetadata(double.NaN, FrameworkPropertyMetadataOptions.AffectsRender));
|
||||||
|
|
||||||
|
public double Speed
|
||||||
|
{
|
||||||
|
get => (double) GetValue(SpeedProperty);
|
||||||
|
set => SetValue(SpeedProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty IsRunningProperty = DependencyProperty.Register(
|
public static readonly DependencyProperty IsRunningProperty = DependencyProperty.Register(
|
||||||
"IsRunning", typeof(bool), typeof(RunningBlock), new PropertyMetadata(ValueBoxes.TrueBox, (o, args) =>
|
"IsRunning", typeof(bool), typeof(RunningBlock), new PropertyMetadata(ValueBoxes.TrueBox, (o, args) =>
|
||||||
{
|
{
|
||||||
@@ -150,11 +160,18 @@ namespace HandyControl.Controls
|
|||||||
propertyPath = new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.Y)");
|
propertyPath = new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.Y)");
|
||||||
}
|
}
|
||||||
|
|
||||||
var animation = new DoubleAnimation(from, to, Duration)
|
var duration = double.IsNaN(Speed)
|
||||||
|
? Duration
|
||||||
|
: !MathHelper.IsVerySmall(Speed)
|
||||||
|
? TimeSpan.FromSeconds((to - from) / Speed)
|
||||||
|
: Duration;
|
||||||
|
|
||||||
|
var animation = new DoubleAnimation(from, to, duration)
|
||||||
{
|
{
|
||||||
RepeatBehavior = RepeatBehavior.Forever,
|
RepeatBehavior = RepeatBehavior.Forever,
|
||||||
AutoReverse = AutoReverse
|
AutoReverse = AutoReverse
|
||||||
};
|
};
|
||||||
|
|
||||||
Storyboard.SetTargetProperty(animation, propertyPath);
|
Storyboard.SetTargetProperty(animation, propertyPath);
|
||||||
Storyboard.SetTarget(animation, _elementContent);
|
Storyboard.SetTarget(animation, _elementContent);
|
||||||
|
|
||||||
@@ -163,10 +180,6 @@ namespace HandyControl.Controls
|
|||||||
_storyboard.Begin();
|
_storyboard.Begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnRender(DrawingContext drawingContext)
|
protected override void OnRender(DrawingContext drawingContext) => UpdateContent();
|
||||||
{
|
|
||||||
base.OnRender(drawingContext);
|
|
||||||
UpdateContent();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,14 +17,16 @@
|
|||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<ControlTemplate TargetType="controls:RunningBlock">
|
<ControlTemplate TargetType="controls:RunningBlock">
|
||||||
<Border CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Padding="{TemplateBinding Padding}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
|
<Border CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Padding="{TemplateBinding Padding}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
|
||||||
<controls:SimplePanel HorizontalAlignment="Left" x:Name="PART_Panel" ClipToBounds="True">
|
<controls:SimplePanel ClipToBounds="True">
|
||||||
<ContentPresenter x:Name="PART_ContentElement" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left">
|
<controls:SimplePanel HorizontalAlignment="Left" x:Name="PART_Panel">
|
||||||
<ContentPresenter.RenderTransform>
|
<ContentPresenter x:Name="PART_ContentElement" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left">
|
||||||
<TransformGroup>
|
<ContentPresenter.RenderTransform>
|
||||||
<TranslateTransform/>
|
<TransformGroup>
|
||||||
</TransformGroup>
|
<TranslateTransform/>
|
||||||
</ContentPresenter.RenderTransform>
|
</TransformGroup>
|
||||||
</ContentPresenter>
|
</ContentPresenter.RenderTransform>
|
||||||
|
</ContentPresenter>
|
||||||
|
</controls:SimplePanel>
|
||||||
</controls:SimplePanel>
|
</controls:SimplePanel>
|
||||||
</Border>
|
</Border>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
|
|||||||
@@ -37,15 +37,12 @@ namespace HandyControl.Tools.Converter
|
|||||||
{
|
{
|
||||||
if (source == null) throw GetConvertFromException(null);
|
if (source == null) throw GetConvertFromException(null);
|
||||||
|
|
||||||
switch (source)
|
return source switch
|
||||||
{
|
{
|
||||||
case string s:
|
string s => FromString(s, cultureInfo),
|
||||||
return FromString(s, cultureInfo);
|
double d => new ColLayout((int) d),
|
||||||
case double d:
|
_ => new ColLayout(Convert.ToInt32(source, cultureInfo))
|
||||||
return new ColLayout((int)d);
|
};
|
||||||
default:
|
|
||||||
return new ColLayout(Convert.ToInt32(source, cultureInfo));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[SecurityCritical]
|
[SecurityCritical]
|
||||||
@@ -108,53 +105,31 @@ namespace HandyControl.Tools.Converter
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (i)
|
return i switch
|
||||||
{
|
{
|
||||||
case 1:
|
1 => new ColLayout(lengths[0]),
|
||||||
return new ColLayout(lengths[0]);
|
2 => new ColLayout {Xs = lengths[0], Sm = lengths[1]},
|
||||||
case 2:
|
3 => new ColLayout {Xs = lengths[0], Sm = lengths[1], Md = lengths[2]},
|
||||||
return new ColLayout
|
4 => new ColLayout {Xs = lengths[0], Sm = lengths[1], Md = lengths[2], Lg = lengths[3]},
|
||||||
{
|
5 => new ColLayout
|
||||||
Xs = lengths[0],
|
{
|
||||||
Sm = lengths[1]
|
Xs = lengths[0],
|
||||||
};
|
Sm = lengths[1],
|
||||||
case 3:
|
Md = lengths[2],
|
||||||
return new ColLayout
|
Lg = lengths[3],
|
||||||
{
|
Xl = lengths[4]
|
||||||
Xs = lengths[0],
|
},
|
||||||
Sm = lengths[1],
|
6 => new ColLayout
|
||||||
Md = lengths[2]
|
{
|
||||||
};
|
Xs = lengths[0],
|
||||||
case 4:
|
Sm = lengths[1],
|
||||||
return new ColLayout
|
Md = lengths[2],
|
||||||
{
|
Lg = lengths[3],
|
||||||
Xs = lengths[0],
|
Xl = lengths[4],
|
||||||
Sm = lengths[1],
|
Xxl = lengths[5]
|
||||||
Md = lengths[2],
|
},
|
||||||
Lg = lengths[3]
|
_ => throw new FormatException("InvalidStringColLayout")
|
||||||
};
|
};
|
||||||
case 5:
|
|
||||||
return new ColLayout
|
|
||||||
{
|
|
||||||
Xs = lengths[0],
|
|
||||||
Sm = lengths[1],
|
|
||||||
Md = lengths[2],
|
|
||||||
Lg = lengths[3],
|
|
||||||
Xl = lengths[4]
|
|
||||||
};
|
|
||||||
case 6:
|
|
||||||
return new ColLayout
|
|
||||||
{
|
|
||||||
Xs = lengths[0],
|
|
||||||
Sm = lengths[1],
|
|
||||||
Md = lengths[2],
|
|
||||||
Lg = lengths[3],
|
|
||||||
Xl = lengths[4],
|
|
||||||
Xxl = lengths[5]
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new FormatException("InvalidStringColLayout");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user