Esempio n. 1
0
 /// <summary>
 /// Requests cancellation of the command.
 /// </summary>
 public void Cancel()
 {
     if (CancelCommand.CanExecute())
     {
         CancelCommand.Execute();
     }
 }
        public DownloadingViewModel(IUnityContainer container) : base(container)
        {
            PauseAllCommand = new RelayCommand(() =>
            {
                foreach (var task in TransferTasks)
                {
                    if (PauseCommand.CanExecute(task))
                    {
                        PauseCommand.Execute(task);
                    }
                }
            },
                                               () => TransferTasks?.Any() ?? false);

            CancelAllCommand = new RelayCommand(() =>
            {
                foreach (var task in TransferTasks)
                {
                    if (CancelCommand.CanExecute(task))
                    {
                        CancelCommand.Execute(task);
                    }
                }
            },
                                                () => TransferTasks?.Any() ?? false);
        }
        private void Cancel_Internal()
        {
            if (CancelCommand?.CanExecute(null) ?? false)
            {
                CancelCommand.Execute(null);
            }

            Cancel();
        }
Esempio n. 4
0
 private void ExecuteCancelWizard()
 {
     RaiseRoutedEvent(Wizard.CancelEvent);
     if (CancelCommand?.CanExecute(CanCancel) == true)
     {
         CancelCommand?.Execute(CanCancel);
     }
     if (CancelButtonClosesWindow)
     {
         CloseParentWindow(false);
     }
 }
Esempio n. 5
0
        private void CancelClick(object sender, RoutedEventArgs e)
        {
            VisualStateManager.GoToState(this, "ReadyState", true);

            foreach (var editableItemsControl in _containedEditableItemsControls)
            {
                editableItemsControl.AddingItem = Activator.CreateInstance(editableItemsControl.AddingItem.GetType());
            }

            if (CancelCommand != null && CancelCommand.CanExecute(Content))
            {
                CancelCommand.Execute(Content);
            }
        }
 private void CancelButton_Clicked(object sender, EventArgs e)
 {
     if (CancelCommand == null)
     {
         this.Hide();
     }
     else
     {
         if (CancelCommand.CanExecute(null))
         {
             CancelCommand.Execute(null);
         }
     }
 }
Esempio n. 7
0
        /// <summary>
        /// Cancels the current changes in the TextBox.
        /// </summary>
        public void Cancel()
        {
            BindingExpression expression = GetBindingExpression(TextProperty);
            if (expression != null)
                expression.UpdateTarget();

            ClearUndoStack();

            var cancelledArgs = new RoutedEventArgs(CancelledEvent);
            OnCancelled();
            RaiseEvent(cancelledArgs);

            if (CancelCommand != null && CancelCommand.CanExecute(CancelCommandParameter))
                CancelCommand.Execute(CancelCommandParameter);
        }
Esempio n. 8
0
        private void Cancel()
        {
            BindingExpression expression = AssociatedObject.GetBindingExpression(TextBox.TextProperty);

            if (expression != null)
            {
                expression.UpdateTarget();
            }

            ClearUndoStack();

            AssociatedObject.RaiseEvent(new RoutedEventArgs(CancelledEvent));

            if (CancelCommand != null && CancelCommand.CanExecute(CancelCommandParameter))
            {
                CancelCommand.Execute(CancelCommandParameter);
            }
        }
Esempio n. 9
0
        public DownloadingViewModel(IUnityContainer container) : base(container)
        {
            PauseAllCommand = new RelayCommand(() => TransferTasks.ForEach(item =>
            {
                if (PauseCommand.CanExecute(item))
                {
                    PauseCommand.Execute(item);
                }
            }),
                                               () => TransferTasks?.Any() ?? false);

            CancelAllCommand = new RelayCommand(() => TransferTasks.ForEach(item =>
            {
                if (CancelCommand.CanExecute(item))
                {
                    CancelCommand.Execute(item);
                }
            }),
                                                () => TransferTasks?.Any() ?? false);
        }
Esempio n. 10
0
 protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs e)
 {
     base.OnPropertyChanged(e);
     if (
         e.Property.Name == nameof(CanSelectNextPage) ||
         (e.Property.Name == nameof(CanHelp)) ||
         (e.Property.Name == nameof(CanFinish)) ||
         (e.Property.Name == nameof(CanCancel)) ||
         (e.Property.Name == nameof(CanSelectPreviousPage)) ||
         (e.Property.Name == nameof(CurrentPage))
         )
     {
         CancelCommand?.CanExecute(CanCancel);
         FinishCommand?.CanExecute(CanFinish);
         PreviousPageCommand?.CanExecute(CanSelectPreviousPage);
         NextPageCommand?.CanExecute(CanSelectNextPage);
         HelpCommand?.CanExecute(CanHelp);
         UpdateButtonState();
     }
 }