Example #1
0
        private void buttonConfigCancel_Click(object sender, RoutedEventArgs e)
        {
            ThreadPool.QueueUserWorkItem(o =>
            {
                try
                {
                    configuration.OnCancel();
                    configuration.OnClosing();
                }
                catch
                {
                    ErrorLog.AddError(ErrorType.Failure, "Error cancelling " + SelectedModule.Name + "'s configuration");
                }
            });

            // Animate the render transform of the grid
            DoubleAnimation animSlideOut = new DoubleAnimation();

            animSlideOut.To         = 0;
            animSlideOut.Duration   = new Duration(TimeSpan.FromSeconds(AnimationTime));
            animSlideOut.Completed += delegate
            {
                stackPanelConfig.Visibility = Visibility.Hidden;
            };
            gridControls.RenderTransform.BeginAnimation(TranslateTransform.XProperty, animSlideOut);

            // Animate the render transform of the list (this covers up the white space between them)
            ((TranslateTransform)stackPanelList.RenderTransform).X = 20;
            stackPanelList.Visibility = Visibility.Visible;
            animSlideOut          = new DoubleAnimation();
            animSlideOut.To       = 0;
            animSlideOut.Duration = new Duration(TimeSpan.FromSeconds(AnimationTime));
            stackPanelList.RenderTransform.BeginAnimation(TranslateTransform.XProperty, animSlideOut);

            // Animate the window size to match the list control
            Rect target = new Rect(
                Left - ((listWidth - ActualWidth) / 2),
                Top - ((listHeight - ActualHeight) / 2),
                listWidth,
                listHeight);

            StartStoryBoard(WindowRect, target, AnimationTime);

            buttonChoose.IsEnabled       = true;
            buttonCancel.IsEnabled       = true;
            buttonSave.IsEnabled         = false;
            buttonConfigCancel.IsEnabled = false;
        }
Example #2
0
 private void Button_Cancel_Click(object sender, RoutedEventArgs e)
 {
     ThreadPool.QueueUserWorkItem(o =>
     {
         try
         {
             configuration.OnCancel();
             configuration.OnClosing();
         }
         catch
         {
             Dispatcher.Invoke(DispatcherPriority.Normal, (System.Action)(() =>
             {
                 ErrorLog.AddError(ErrorType.Failure, "Error cancelling " + configuration.Name + "'s configuration");
             }));
         }
     });
     DialogResult = false;
 }