本文整理汇总了C#中System.Windows.Media.Animation.ThicknessAnimation类的典型用法代码示例。如果您正苦于以下问题:C# ThicknessAnimation类的具体用法?C# ThicknessAnimation怎么用?C# ThicknessAnimation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ThicknessAnimation类属于System.Windows.Media.Animation命名空间,在下文中一共展示了ThicknessAnimation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Show
/// <summary>
/// 动态显示内容
/// </summary>
/// <param name="target"></param>
/// <param name="duration"></param>
public static void Show(ContentControl target, double duration = .8)
{
ThicknessAnimation animtion = new ThicknessAnimation()
{
From = new Thickness(target.Margin.Left + 80, target.Margin.Top, target.Margin.Right, target.Margin.Bottom),
To = new Thickness(160, 0, 0, 0),
Duration = TimeSpan.FromSeconds(duration),
FillBehavior = FillBehavior.HoldEnd,
AccelerationRatio = .5,
EasingFunction = be
};
DoubleAnimation animtion2 = new DoubleAnimation()
{
From = 0,
To = 1,
Duration = TimeSpan.FromSeconds(duration),
FillBehavior = FillBehavior.HoldEnd,
AccelerationRatio = .5,
EasingFunction = be
};
target.BeginAnimation(ContentControl.MarginProperty, animtion);
target.BeginAnimation(ContentControl.OpacityProperty, animtion2);
}
示例2: FadeInAnimation
private static Storyboard FadeInAnimation(int interval, params FrameworkElement[] controls)
{
Storyboard fadeInAnimation = new Storyboard();
int counter = 0;
foreach (var control in controls)
{
control.BeginAnimation(OpacityProperty, null);
control.BeginAnimation(MarginProperty, null);
control.Opacity = 0;
control.Margin = new Thickness(0, control.Margin.Top, 0, 0);
DoubleAnimation da = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(300));
ThicknessAnimation ta = new ThicknessAnimation(new Thickness(-10, control.Margin.Top, 10, 0), new Thickness(0, control.Margin.Top, 0, 0), TimeSpan.FromMilliseconds(400));
Storyboard.SetTarget(da, control);
Storyboard.SetTarget(ta, control);
Storyboard.SetTargetProperty(da, new PropertyPath(OpacityProperty));
Storyboard.SetTargetProperty(ta, new PropertyPath(MarginProperty));
fadeInAnimation.Children.Add(da);
fadeInAnimation.Children.Add(ta);
da.BeginTime = TimeSpan.FromMilliseconds(counter * interval);
ta.BeginTime = TimeSpan.FromMilliseconds(counter * interval);
counter++;
}
fadeInAnimation.Completed += (s, e) =>
{
foreach (var c in controls)
{
c.Opacity = 1;
}
};
return fadeInAnimation;
}
示例3: Flush
public void Flush()
{
var thicknessAnimationUsingKeyFrames = new ThicknessAnimationUsingKeyFrames();
thicknessAnimationUsingKeyFrames.KeyFrames = new ThicknessKeyFrameCollection();
double delta = (Width - Height) / 2;
var thicknessAnimation = new ThicknessAnimation()
{
From = new Thickness(delta, 0, delta, 0),
To = new Thickness(delta - 500, -500, delta - 500, -500),
Duration = new Duration(TimeSpan.FromSeconds(1)),
AutoReverse = true
};
thicknessAnimation.Completed += new EventHandler(animation_Completed);
_flushEllipse = new Ellipse()
{
Fill = new SolidColorBrush(Colors.LightBlue),
Stroke = new SolidColorBrush(Colors.Orange),
StrokeThickness = 5,
Opacity = 0.5
};
Children.Add(_flushEllipse);
_flushEllipse.BeginAnimation(Ellipse.MarginProperty, thicknessAnimation);
}
示例4: txt_PreviewMouseUp
private void txt_PreviewMouseUp(object sender, MouseButtonEventArgs e)
{
DoubleAnimation title_width_animation = new DoubleAnimation();
ThicknessAnimation title_margin_animation = new ThicknessAnimation();
DoubleAnimation content_width_animation = new DoubleAnimation();
DoubleAnimation content_height_animation = new DoubleAnimation();
ThicknessAnimation content_margin_animation = new ThicknessAnimation();
DoubleAnimation txt_width_animation = new DoubleAnimation();
ThicknessAnimation txt_margin_animation = new ThicknessAnimation();
if (txt.Width < 720 || txt.ActualWidth < 720)
{
title_width_animation.To = SystemParameters.PrimaryScreenWidth;
title_margin_animation.To = new Thickness(0, 10, 0, 0);
content_height_animation.To = SystemParameters.PrimaryScreenHeight - 105;
content_width_animation.To = SystemParameters.PrimaryScreenWidth;
content_margin_animation.To = new Thickness(0, 10, 0, 0);
txt_width_animation.To = SystemParameters.PrimaryScreenWidth;
txt_margin_animation.From = new Thickness(0, 0, 0, 0);
txt_margin_animation.To = new Thickness(0, SystemParameters.PrimaryScreenHeight-txt.ActualHeight - 110, 0, 0);
}
else
{
title_width_animation.To = 392;
title_margin_animation.To = new Thickness(0, 200, 0, 0);
content_height_animation.To = 533;
content_width_animation.To = 392;
content_margin_animation.To = new Thickness(0, 10, 0, 0);
txt_margin_animation.From = new Thickness(0, 0, 0, 0);
txt_margin_animation.To = new Thickness(0, SystemParameters.PrimaryScreenHeight-txt.ActualHeight -110, 0, 0);
//txt_width_animation.To = SystemParameters.PrimaryScreenWidth;
}
title_width_animation.Duration = TimeSpan.FromSeconds(0.5);
title_margin_animation.Duration = TimeSpan.FromSeconds(0.5);
content_height_animation.Duration = TimeSpan.FromSeconds(0.5);
content_width_animation.Duration = TimeSpan.FromSeconds(0.5);
content_margin_animation.Duration = TimeSpan.FromSeconds(0.5);
txt_width_animation.Duration = TimeSpan.FromSeconds(0.5);
txt_margin_animation.Duration = TimeSpan.FromSeconds(500);
txt.BeginAnimation(StackPanel.WidthProperty, title_width_animation);
txt.BeginAnimation(StackPanel.MarginProperty, title_margin_animation);
//content.BeginAnimation(StackPanel.HeightProperty, content_height_animation);
//content.BeginAnimation(StackPanel.WidthProperty, title_width_animation);
//content.BeginAnimation(StackPanel.MarginProperty, content_margin_animation);
txt.BeginAnimation(TextBlock.WidthProperty, txt_width_animation);
txt.BeginAnimation(TextBlock.MarginProperty, txt_margin_animation);
}
示例5: Button_Click_1
private void Button_Click_1(object sender, RoutedEventArgs e)
{
Ellipse ellipse1 = new Ellipse();
ellipse1.Width = 50;
ellipse1.Height = 20;
ellipse1.ToolTip = "Touch Me / Потискай меня";
ellipse1.StrokeThickness = 2;
ellipse1.Stroke = Brushes.Black;
ellipse1.Fill = Brushes.Red;
Mygrid.Children.Add(ellipse1);
Ellipse ellipse2 = new Ellipse();
ellipse2.Width = 50;
ellipse2.Height = 20;
ellipse2.ToolTip = "Touch Me / Потискай меня";
ellipse2.StrokeThickness = 2;
ellipse2.Stroke = Brushes.Red;
ellipse2.Fill = Brushes.Green;
Mygrid.Children.Add(ellipse2);
Random rand1 = new Random((int)DateTime.Now.Ticks);
Random rand2 = new Random((int)DateTime.Now.Ticks);
ThicknessAnimation TA1 = new ThicknessAnimation(); //Анимация перемещения
TA1.From = ellipse1.Margin = new Thickness(10, 100, 0, 0); //Координаты начального положения
TA1.To = ellipse1.Margin = new Thickness(1400, 100, 0, 0); //Координаты конечного положения
TA1.Duration = TimeSpan.FromSeconds(rand1.Next(10, 20)); //Время анимации
ellipse1.BeginAnimation(MarginProperty, TA1); //Запуск анимации
ThicknessAnimation TA2 = new ThicknessAnimation(); //Анимация перемещения
TA2.From = ellipse2.Margin = new Thickness(10, 200, 0, 0); //Координаты начального положения
TA2.To = ellipse2.Margin = new Thickness(1400, 200, 0, 0); //Координаты конечного положения
TA2.Duration = TimeSpan.FromSeconds(rand2.Next(10, 20)); //Время анимации
ellipse2.BeginAnimation(MarginProperty, TA2); //Запуск анимации
}
示例6: AvatarBounce
private void AvatarBounce()
{
var bounce = new BounceEase { Bounces = 3, Bounciness = 10 };
var a = new ThicknessAnimation(new Thickness(10, -800, 0, 810), new Thickness(10, 10, 0, 0),
new Duration(new TimeSpan(0, 0, 1))) {EasingFunction = bounce};
Avi.BeginAnimation(MarginProperty, a);
}
示例7: AnimationUp
private void AnimationUp(Grid grid)
{
ThicknessAnimation ta = new ThicknessAnimation();
ta.From = grid.Margin;
ta.To = new Thickness(grid.Margin.Left, RowHeight + SpaceBetweenGrids, 0, 0);
ta.Duration = new Duration(TimeSpan.FromSeconds(0.5));
grid.BeginAnimation(Grid.MarginProperty, ta);
}
示例8: BtnBack_Click
private void BtnBack_Click(object sender, RoutedEventArgs e)
{
ThicknessAnimation ta = new ThicknessAnimation(new Thickness(-618, 0, 1003, 0), new Duration(TimeSpan.FromMilliseconds(350)));
ExponentialEase ee = new ExponentialEase();
ee.EasingMode = EasingMode.EaseOut;
ta.EasingFunction = ee;
ta.Completed += ta_Completed;
this.OptGrid.BeginAnimation(MarginProperty, ta);
}
示例9: DockPanel_MouseEnter
private void DockPanel_MouseEnter(object sender, MouseEventArgs e) {
var ta = new ThicknessAnimation();
/*
ta.From = MenuCanvas.Margin;
ta.To = new Thickness(0,15,-360,0);
ta.Duration = new Duration(TimeSpan.FromMilliseconds(500));
MenuCanvas.BeginAnimation(MarginProperty, ta);
*/
}
示例10: Beweeg
public void Beweeg(Point target)
{
var thickness = new Thickness(target.X, target.Y, 0, 0);
var moveAnimation = new ThicknessAnimation(Margin, thickness, TimeSpan.FromMilliseconds(500))
{
FillBehavior = FillBehavior.Stop
};
moveAnimation.Completed += (sender, args) => Margin = thickness;
BeginAnimation(MarginProperty, moveAnimation);
}
示例11: CreateSlideInAnimation
static AnimationTimeline CreateSlideInAnimation(FrameworkElement frameworkElement)
{
var parent = frameworkElement.Parent as FrameworkElement;
var marginAnimation = new ThicknessAnimation();
marginAnimation.From = new Thickness(parent.ActualWidth, 0, 0, 0);
marginAnimation.To = new Thickness(0);
marginAnimation.Duration = duration;
return marginAnimation;
}
示例12: StartLeaveAnimation
private void StartLeaveAnimation() {
var ta=new ThicknessAnimation();
/*
ta.From=MenuCanvas.Margin;
ta.To=new Thickness(0, 15, -410, 0);
ta.Duration=new Duration(TimeSpan.FromMilliseconds(500));
MenuCanvas.BeginAnimation(MarginProperty, ta);
*/
}
示例13: HideMessage
public void HideMessage()
{
ThicknessAnimation ta1 = new ThicknessAnimation();
ta1.To = new Thickness(848, 55, 0, 0);
ta1.Duration = new Duration(TimeSpan.FromSeconds(2));
DoubleAnimation da1 = new DoubleAnimation();
da1.To = 0;
da1.Duration = new Duration(TimeSpan.FromSeconds(2));
PopupContainer.BeginAnimation(Grid.MarginProperty, ta1);
PopupContainer.BeginAnimation(Grid.OpacityProperty, da1);
}
示例14: SideBarAnimation
private static void SideBarAnimation(Panel sideBar, int from, int to, ThicknessAnimation ta)
{
DoubleAnimation da = new DoubleAnimation();
da.From = from;
da.To = to;
da.Duration = TimeSpan.FromSeconds(0.4);
sideBar.BeginAnimation(TextBlock.OpacityProperty, da);
ta.Duration = TimeSpan.FromSeconds(0.2);
sideBar.BeginAnimation(TextBlock.MarginProperty, ta);
}
示例15: Animation
static Animation()
{
ca = new ColorAnimation();
ta = new ThicknessAnimation();
da = new DoubleAnimation();
sbOnce = new Storyboard();
sbForever = new Storyboard();
sbForever.RepeatBehavior = RepeatBehavior.Forever;
sbForever.Children.Add(new DoubleAnimation());
sb = sbOnce;
sb.Children.Add(new DoubleAnimation());
}