Files
aistudio-wpf-diagram/AIStudio.Wpf.DiagramDesigner/ViewModels/AdditionViewModel/AnimationViewModel.cs

122 lines
2.9 KiB
C#
Raw Normal View History

2023-04-29 15:29:22 +08:00
using System;
using System.Windows.Media;
namespace AIStudio.Wpf.DiagramDesigner
{
[Serializable]
public class AnimationViewModel : BindableBase, IAnimationViewModel
{
2023-04-29 18:36:50 +08:00
private LineAnimation _animation = LineAnimation.None;
2023-04-29 15:29:22 +08:00
[CanDo]
2023-04-29 18:36:50 +08:00
public LineAnimation Animation
2023-04-29 15:29:22 +08:00
{
get
{
2023-04-29 18:36:50 +08:00
return _animation;
2023-04-29 15:29:22 +08:00
}
set
{
2023-04-29 18:36:50 +08:00
SetProperty(ref _animation, value);
2023-04-29 15:29:22 +08:00
}
}
private double _duration = 1;
[CanDo]
public double Duration
{
get
{
return _duration;
}
set
{
SetProperty(ref _duration, value);
}
2023-04-29 18:36:50 +08:00
}
2023-04-29 15:29:22 +08:00
private Color _color = Colors.Red;
[CanDo]
public Color Color
{
get
{
return _color;
}
set
{
if (!SetProperty(ref _color, value))
{
RaisePropertyChanged(nameof(Color));
}
}
}
2023-04-29 18:36:50 +08:00
private ISharpPath _animationPath = SharpPath.Circle;
public ISharpPath AnimationPath
2023-04-29 15:29:22 +08:00
{
get
{
2023-04-29 18:36:50 +08:00
return _animationPath;
2023-04-29 15:29:22 +08:00
}
set
{
2023-04-29 18:36:50 +08:00
if (_animationPath != value)
{
if (_animationPath != null && _animationPath is SharpPath _sharpPath1)
{
_sharpPath1.PropertyChanged -= AnimationViewModel_PropertyChanged;
}
SetProperty(ref _animationPath, value);
if (_animationPath != null && _animationPath is SharpPath _sharpPath2)
{
_sharpPath2.PropertyChanged += AnimationViewModel_PropertyChanged;
}
}
else
{
RaisePropertyChanged(nameof(AnimationPath));
}
2023-04-29 15:29:22 +08:00
}
}
2023-05-01 00:10:55 +08:00
private bool _repeat = true;
public bool Repeat
{
get
{
return _repeat;
}
set
{
SetProperty(ref _repeat, value);
}
}
private bool _start;
public bool Start
{
get
{
return _start;
}
set
{
SetProperty(ref _start, value);
}
}
public int Completed
{
get; set;
}
2023-04-29 18:36:50 +08:00
private void AnimationViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
2023-04-29 15:29:22 +08:00
{
2023-04-29 18:36:50 +08:00
if (sender == AnimationPath)
2023-04-29 15:29:22 +08:00
{
2023-04-29 18:36:50 +08:00
RaisePropertyChanged(nameof(AnimationPath));
2023-04-29 15:29:22 +08:00
}
}
}
}