9
9
using System . Windows . Documents ;
10
10
using System . Windows . Input ;
11
11
using System . Windows . Media ;
12
+ using System . Windows . Media . Animation ;
12
13
using System . Windows . Media . Imaging ;
13
14
using System . Windows . Shapes ;
14
15
@@ -19,9 +20,35 @@ namespace Lively.Views
19
20
/// </summary>
20
21
public partial class SplashWindow : Window
21
22
{
23
+ private readonly double fadeInDuration = 200 ;
24
+ private readonly double fadeOutDuration = 200 ;
25
+
22
26
public SplashWindow ( )
23
27
{
24
28
InitializeComponent ( ) ;
25
29
}
30
+
31
+ public SplashWindow ( double fadeInDuration , double fadeOutDuration ) : this ( )
32
+ {
33
+ this . fadeInDuration = fadeInDuration ;
34
+ this . fadeOutDuration = fadeOutDuration ;
35
+ this . Closing += Window_Closing ;
36
+ this . Loaded += Window_Loaded ;
37
+ }
38
+
39
+ private void Window_Closing ( object sender , System . ComponentModel . CancelEventArgs e )
40
+ {
41
+ this . Closing -= Window_Closing ;
42
+ e . Cancel = true ;
43
+ var anim = new DoubleAnimation ( 0 , ( Duration ) TimeSpan . FromMilliseconds ( fadeOutDuration ) ) ;
44
+ anim . Completed += ( s , _ ) => this . Close ( ) ;
45
+ this . BeginAnimation ( UIElement . OpacityProperty , anim ) ;
46
+ }
47
+
48
+ private void Window_Loaded ( object sender , RoutedEventArgs e )
49
+ {
50
+ var anim = new DoubleAnimation ( 0 , 1 , ( Duration ) TimeSpan . FromMilliseconds ( fadeInDuration ) ) ;
51
+ this . BeginAnimation ( UIElement . OpacityProperty , anim ) ;
52
+ }
26
53
}
27
54
}
0 commit comments