Esempio n. 1
0
 private void EmbiggenBarcode_Up(object sender, EventArgs e)
 {
     if (EmbiggenBarcode.IsEnabled == false)
     {
         return;
     }
     EmbiggenBarcode.IsEnabled = false;
     if (BarcodeEmbiggened)
     {
         EmbiggenBarcode.Source = new BitmapImage(new Uri("Expand-76.png", UriKind.Relative));
         PowerEase pe = new PowerEase();
         pe.Power = 2.5;
         Size            bigSize           = new Size(Barcode.Width / 2.25, Barcode.Height / 3);
         Duration        animationDuration = new Duration(TimeSpan.FromSeconds(0.5));
         DoubleAnimation dw = new DoubleAnimation();
         dw.EasingFunction = pe;
         dw.From           = Barcode.Width;
         dw.To             = bigSize.Width;
         dw.Duration       = animationDuration;
         DoubleAnimation dh = new DoubleAnimation();
         dh.EasingFunction = pe;
         dh.From           = Barcode.Height;
         dh.To             = bigSize.Height;
         dh.Duration       = animationDuration;
         ThicknessAnimation dm = new ThicknessAnimation();
         dm.EasingFunction = pe;
         dm.From           = Barcode.Margin;
         dm.To             = BarcodeMargin;
         dm.Duration       = animationDuration;
         ColorAnimation pc = new ColorAnimation();
         pc.EasingFunction = pe;
         Color blackFrom = Colors.Black;
         blackFrom.A = 153;
         pc.From     = blackFrom;
         blackFrom.A = 0;
         pc.To       = blackFrom;
         pc.Duration = animationDuration;
         DelayCall(500, new Action(() => { BarcodeSplash.Visibility = Visibility.Hidden; }));
         BarcodeSplash.Background.BeginAnimation(SolidColorBrush.ColorProperty, pc);
         Barcode.BeginAnimation(Grid.HeightProperty, dh);
         Barcode.BeginAnimation(Grid.WidthProperty, dw);
         Barcode.BeginAnimation(Grid.MarginProperty, dm);
     }
     else
     {
         EmbiggenBarcode.Source = new BitmapImage(new Uri("Retract-76.png", UriKind.Relative));
         BarcodeMargin          = Barcode.Margin;
         PowerEase pe = new PowerEase();
         pe.Power = 2.5;
         Size            bigSize = new Size(Barcode.Width * 2.25, Barcode.Height * 3);
         DoubleAnimation dw      = new DoubleAnimation();
         dw.EasingFunction = pe;
         dw.From           = Barcode.Width;
         dw.To             = bigSize.Width;
         dw.Duration       = AnimationDuration;
         DoubleAnimation dh = new DoubleAnimation();
         dh.EasingFunction = pe;
         dh.From           = Barcode.Height;
         dh.To             = bigSize.Height;
         dh.Duration       = AnimationDuration;
         ThicknessAnimation dm = new ThicknessAnimation();
         dm.EasingFunction = pe;
         dm.From           = Barcode.Margin;
         dm.To             = new Thickness((this.Width - bigSize.Width) / 2, Barcode.Margin.Top, Barcode.Margin.Right, (this.Height - bigSize.Height) / 2);
         dm.Duration       = AnimationDuration;
         ColorAnimation pc = new ColorAnimation();
         pc.EasingFunction = pe;
         Color blackFrom = Colors.Black;
         blackFrom.A = 0;
         pc.From     = blackFrom;
         blackFrom.A = 153;
         pc.To       = blackFrom;
         pc.Duration = AnimationDuration;
         BarcodeSplash.Visibility = Visibility.Visible;
         BarcodeSplash.Background.BeginAnimation(SolidColorBrush.ColorProperty, pc);
         Barcode.BeginAnimation(Grid.HeightProperty, dh);
         Barcode.BeginAnimation(Grid.WidthProperty, dw);
         Barcode.BeginAnimation(Grid.MarginProperty, dm);
     }
     DelayCall(510, new Action(() => { EmbiggenBarcode.IsEnabled = true; }));
     BarcodeEmbiggened = !BarcodeEmbiggened;
 }