-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathLoadingPanel.cs
More file actions
55 lines (43 loc) · 1.63 KB
/
LoadingPanel.cs
File metadata and controls
55 lines (43 loc) · 1.63 KB
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
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Animation;
namespace ModAPI.Common.UI
{
[TemplatePart(Name = PartFlashGrid, Type = typeof(Grid))]
public class LoadingPanel : ContentControl
{
const String PartFlashGrid = "PART_FlashGrid";
public LoadingPanel()
{
}
Grid _flashGrid;
int _currentFlashCell = 0;
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_flashGrid = GetTemplateChild(PartFlashGrid) as Grid;
if (_flashGrid != null)
{
_currentFlashCell = 0;
DoubleAnimation opacityDoubleAnimation = new DoubleAnimation()
{
BeginTime = TimeSpan.FromMilliseconds(0),
Duration = TimeSpan.FromMilliseconds(250),
From = 1,
To = 0
};
opacityDoubleAnimation.Completed += delegate
{
_flashGrid.Children[_currentFlashCell].BeginAnimation(Canvas.OpacityProperty, null);
if (_currentFlashCell >= _flashGrid.Children.Count)
_currentFlashCell = 0;
else
_currentFlashCell++;
(_flashGrid.Children[_currentFlashCell] as Canvas).BeginAnimation(Canvas.OpacityProperty, opacityDoubleAnimation);
};
(_flashGrid.Children[_currentFlashCell] as Canvas).BeginAnimation(Canvas.OpacityProperty, opacityDoubleAnimation);
}
}
}
}