/// <summary> /// Implement cancelation request. Save Item if need /// </summary> /// <param name="arg"></param> private void RaiseCancelInteractionRequest(object arg) { if (!IsModified) { OnCloseViewRequestedEvent(EventArgs.Empty); } else if (!HasPermission()) { CloseWithoutSave(); } else { CancelConfirmRequest.Raise(CancelConfirm(), (x) => { if (x.Confirmed) { SaveUI(true); //check thread } else if (((RefusedConfirmation)x).Refused) { CloseWithoutSave(); } else { // cancel closing var cancelArgs = arg as System.ComponentModel.CancelEventArgs; if (cancelArgs != null) { cancelArgs.Cancel = true; OpenItemCommand.Execute(); } } }); } }
public ItemViewModel() { items = new ObservableCollection <ItemModel>(); recommand_four = new ObservableCollection <ItemModel>(); recommandsList = new ObservableCollection <ItemModel>(); OpenItemCommandProperty = new OpenItemCommand(); OpenSearchItemCommandProperty = new OpenSearchItemCommand(); AddItemCommandProperty = new AddItemCommand(); IsItemPopup = false; }
protected override void OnSelectedItem(BarEntryModel item) { base.OnSelectedItem(item); ExportCommand.CanExecute(SelectedItem); ImportCommand.CanExecute(SelectedItem); OpenItemCommand.CanExecute(SelectedItem); OnPropertyChanged(nameof(ExportFileName)); }
protected void OnCancelCommand(object arg) { if (IsModified) { CancelConfirmRequest.Raise(new RefusedConfirmation { Content = "Save changes to Import job '" + DisplayName + "'?", Title = "Action confirmation" }, (x) => { if (x.Confirmed) { //if (InnerItem.Validate()) //{ IsInitializing = true; PerformTasksInBackgroundWorker((Action) delegate() { DoSaveChanges(); OnUIThread((Action) delegate() { OnCloseViewRequestedEvent(EventArgs.Empty); }); }, (Action) delegate() { IsInitializing = false; }); //} } else if (((RefusedConfirmation)x).Refused) { InnerItem = _originalItem; IsModified = false; OnCloseViewRequestedEvent(EventArgs.Empty); } else { // cancel closing var cancelArgs = arg as System.ComponentModel.CancelEventArgs; if (cancelArgs != null) { cancelArgs.Cancel = true; OpenItemCommand.Execute(); } } }); } else { OnCloseViewRequestedEvent(EventArgs.Empty); } }
public void Handle(OpenItemCommand message) { if (message.Item is PartProjectItem) { _eventAggregator.Publish(new AddTabViewCommand { Model = _partitemViewModelBuilder((PartProjectItem)message.Item) }); } else { _eventAggregator.Publish(new AddTabViewCommand { Model = _itemViewModelBuilder(message.Item) }); } // _eventAggregator.Publish(new AddTabViewCommand { Model = _itemViewModelBuilder(message.Item) }); }