port from perforce
This commit is contained in:
86
aiwaz/AiwazAnimator/MainWindow.xaml.cs
Normal file
86
aiwaz/AiwazAnimator/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.ComponentModel;
|
||||
using System.Threading;
|
||||
|
||||
namespace AiwazAnimator
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window, INotifyPropertyChanged
|
||||
{
|
||||
public AnimationManager AnimationManager { set; get; }
|
||||
private DateTime StartTime;
|
||||
private Timer StateTimer;
|
||||
private AddAnimationWindow AddAnimationWindow;
|
||||
|
||||
private float _value1;
|
||||
[Animateable]
|
||||
public float Value1 { get { return _value1; } set { _value1 = value; OnPropertyChanged("Value1"); } }
|
||||
private float _value2;
|
||||
[Animateable]
|
||||
public float Value2 { get { return _value2; } set { _value2 = value; OnPropertyChanged("Value2"); } }
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
AnimationManager = new AnimationManager();
|
||||
ContentArea.DataContext = AnimationManager;
|
||||
StatusArea.DataContext = this;
|
||||
StartTime = DateTime.Now;
|
||||
StatusArea.Add(() => { return Value1; });
|
||||
StatusArea.Add(() => { return Value2; });
|
||||
bool invoked = false;
|
||||
StateTimer = new Timer((o) =>
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
if (AnimationManager.Animating)
|
||||
{
|
||||
AnimationManager.Animate((float)((DateTime.Now - StartTime).TotalSeconds));
|
||||
if (!invoked)
|
||||
{
|
||||
Dispatcher.BeginInvoke(new Action(() => { invoked = false; StatusArea.Tick(); }), null);
|
||||
invoked = true;
|
||||
}
|
||||
}
|
||||
StartTime = now;
|
||||
}, null, 0, 10);
|
||||
}
|
||||
|
||||
protected virtual void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private void btnStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AnimationManager.Start();
|
||||
}
|
||||
|
||||
private void btnStop_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AnimationManager.Stop();
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AddAnimationWindow = new AddAnimationWindow(this);
|
||||
AddAnimationWindow.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user