Guest User

Untitled

a guest
Aug 7th, 2018
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1.     public partial class MainWindow : Window
  2.     {
  3.  
  4.         public MainWindow()
  5.         {
  6.             InitializeComponent();
  7.  
  8.             Opacity = 0;
  9.             Loaded += (o,e) => FadeIn();
  10.  
  11.         }
  12.  
  13.         private void Window_Closing(object sender, CancelEventArgs e)
  14.         {
  15.             Closing -= Window_Closing;
  16.             e.Cancel = true;
  17.  
  18.             DoubleAnimation fadeOut = new DoubleAnimation(0, TimeSpan.FromMilliseconds(350));
  19.             fadeOut.Completed += (s, _) => Close();
  20.             BeginAnimation(OpacityProperty, fadeOut);
  21.         }
  22.  
  23.         private void FadeIn()
  24.         {
  25.             DoubleAnimation fadeIn = new DoubleAnimation(1, TimeSpan.FromSeconds(2));
  26.             DoubleAnimation scaleWidth = new DoubleAnimation(Width, Width * 1.1, TimeSpan.FromSeconds(2));
  27.             DoubleAnimation scaleHeight = new DoubleAnimation(Height, Height * 1.1, TimeSpan.FromSeconds(2));
  28.  
  29.             BeginAnimation(OpacityProperty, fadeIn);
  30.             BeginAnimation(WidthProperty, scaleWidth);
  31.             BeginAnimation(HeightProperty, scaleHeight);
  32.         }
  33.     }
Advertisement
Add Comment
Please, Sign In to add comment