示例#1
0
        /// <summary>
        /// Handles the event when the system queries whether <see cref="StopExecutionCommand"/> can be executed.
        /// </summary>
        /// <param name="sender">Sender of the event.</param>
        /// <param name="e">The <see cref="CanExecuteRoutedEventArgs"/> associated with the event.</param>
        private static void CanStopExecution(object sender, CanExecuteRoutedEventArgs e)
        {
            ExecutionPanel panel = (ExecutionPanel)sender;

            if (panel.ViewModel == null)
            {
                e.CanExecute = false;
            }
            else
            {
                e.CanExecute = panel.ViewModel.CanStopExecution();
            }
        }
示例#2
0
        /// <summary>
        /// Handles the event when the <see cref="ExecutionContext"/> property changes.
        /// </summary>
        /// <param name="obj">The <see cref="DependencyObject"/> that owns the property.</param>
        /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> associated with the event.</param>
        private static void OnExecutionContextChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            ExecutionPanel panel = (ExecutionPanel)obj;

            if (e.OldValue != null)
            {
                ((ExecutionContext)e.OldValue).PropertyChanged -= panel.ExecutionContext_PropertyChanged;
                panel.ViewModel?.Dispose();
            }

            if (e.NewValue != null)
            {
                ExecutionContext executionContext = (ExecutionContext)e.NewValue;
                panel.ViewModel = new ExecutionPanelViewModel(executionContext);
                executionContext.PropertyChanged += panel.ExecutionContext_PropertyChanged;
                panel.UpdateCanExecuteProperties();
            }
        }