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
| private static void AnimShowWindow(CustomWindowDialog customWindowDialog)
{
Storyboard board = new Storyboard();
DoubleAnimation wAnim = new DoubleAnimation(30, customWindowDialog.Width, new Duration(TimeSpan.FromMilliseconds(450)));
Storyboard.SetTargetProperty(wAnim, new PropertyPath("(0)", Window.WidthProperty));
Storyboard.SetTarget(wAnim, customWindowDialog);
DoubleAnimation hAnim = new DoubleAnimation(30, customWindowDialog.Height, new Duration(TimeSpan.FromMilliseconds(450)));
Storyboard.SetTargetProperty(hAnim, new PropertyPath("(0)", Window.HeightProperty));
Storyboard.SetTarget(hAnim, customWindowDialog);
DoubleAnimation oAnim = new DoubleAnimation(0.5, 1, new Duration(TimeSpan.FromMilliseconds(1000)));
Storyboard.SetTargetProperty(oAnim, new PropertyPath("(0)", Window.OpacityProperty));
Storyboard.SetTarget(oAnim, customWindowDialog);
Rectangle workingArea = Screen.PrimaryScreen.WorkingArea;
//Position de départ
customWindowDialog.Top = (workingArea.Height / 2) - (customWindowDialog.Height / 2);
customWindowDialog.Left = (workingArea.Width / 2) - (customWindowDialog.Width / 2);
double posTop = workingArea.Height / 2;
double posLeft = workingArea.Width / 2;
DoubleAnimation animTop = new DoubleAnimation(posTop, customWindowDialog.Top, new Duration(TimeSpan.FromMilliseconds(500)));
Storyboard.SetTargetProperty(animTop, new PropertyPath("(0)", Window.TopProperty));
Storyboard.SetTarget(animTop, customWindowDialog);
DoubleAnimation animLeft = new DoubleAnimation(posLeft, customWindowDialog.Left, new Duration(TimeSpan.FromMilliseconds(500)));
Storyboard.SetTargetProperty(animLeft, new PropertyPath("(0)", Window.LeftProperty));
Storyboard.SetTarget(animLeft, customWindowDialog);
board.Children.Add(wAnim);
board.Children.Add(hAnim);
board.Children.Add(animTop);
board.Children.Add(animLeft);
board.Children.Add(oAnim);
board.Begin();
customWindowDialog.ShowDialog();
} |
Partager