This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
/
Form1.cs
66 lines (57 loc) · 2.45 KB
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using System.Windows.Forms;
using DevExpress.XtraGauges.Core.Model;
using System.Collections.Generic;
namespace XtraGauge_Animation {
public partial class Form1 : Form {
Dictionary<string, IEasingFunction> functions = new Dictionary<string, IEasingFunction>();
Dictionary<string, EasingMode> modes = new Dictionary<string, EasingMode>();
Timer timer;
Random random = new Random(DateTime.Now.Millisecond);
public Form1() {
InitializeComponent();
InitData();
this.Load += new EventHandler(Form1_Load);
}
private void InitData() {
functions.Add("BackEase", new BackEase());
functions.Add("ElasticEase", new ElasticEase());
functions.Add("PowerEase", new PowerEase(1));
functions.Add("QuadraticEase", new QuadraticEase());
functions.Add("QuinticEase", new QuinticEase());
functions.Add("SineEase", new SineEase());
functions.Add("ExponentialEase", new ExponentialEase());
functions.Add("CircleEase", new CircleEase());
functions.Add("BounceEase", new BounceEase());
functions.Add("CubicEase", new CubicEase());
modes.Add("EaseIn", EasingMode.EaseIn);
modes.Add("EaseOut", EasingMode.EaseOut);
modes.Add("EaseInOut", EasingMode.EaseInOut);
foreach (var item in modes) {
EaseMode.Items.Add(item.Key);
}
arcScaleComponent1.EnableAnimation = true;
}
private void ChangeEaseFunction(object sender, EventArgs e) {
RadioButton radioButton = sender as RadioButton;
if (radioButton.Checked) {
arcScaleComponent1.EasingFunction = functions[((RadioButton)sender).Name];
}
}
void Form1_Load(object sender, EventArgs e) {
timer = new Timer();
timer.Interval = 2000;
timer.Tick += new EventHandler(OnTimerTick);
timer.Start();
}
void OnTimerTick(object sender, EventArgs e) {
arcScaleComponent1.Value = AnimateScaleValue(arcScaleComponent1);
}
float AnimateScaleValue(IScale scale) {
return random.Next(0, 100);
}
private void EaseMode_SelectedIndexChanged(object sender, EventArgs e) {
arcScaleComponent1.EasingMode = modes[EaseMode.SelectedItem.ToString()];
}
}
}