public MemberViewModel(IProvider provider) { this.provider = provider; Members = new ObservableCollection<MemberModel>(); AddCommandModel = new AddCommand(this); EditCommandModel = new EditCommand(this); DeleteCommandModel = new DeleteCommand(this); }
/// <summary> /// Constructor /// </summary> /// <param name="provider">The provider.</param> public CustomerViewModel(IProvider provider) { _provider = provider; Customers = new ObservableCollection<CustomerModel>(); AddCommandModel = new AddCommand(this); EditCommandModel = new EditCommand(this); DeleteCommandModel = new DeleteCommand(this); Index = -1; }
protected virtual void OnCommand(EditCommand command) { switch (command) { case EditCommand.None: break; case EditCommand.Home: this.OnHome(); break; case EditCommand.LeftArrow: this.OnLeft(); break; case EditCommand.Copy: break; case EditCommand.Exit: this.OnExit(); break; case EditCommand.End: this.OnEnd(); break; case EditCommand.RightArrow: this.OnRight(); break; case EditCommand.Backspace: this.OnBackspace(); break; case EditCommand.Tab: this.OnTab(); break; case EditCommand.Quit: case EditCommand.Enter: this.OnEnter(); break; case EditCommand.DownArrow: this.OnDown(); break; case EditCommand.UpArrow: this.OnUp(); break; case EditCommand.Paste: break; case EditCommand.Cut: break; case EditCommand.Redo: break; case EditCommand.Undo: break; case EditCommand.Delete: this.OnDelete(); break; } }
private CommandStatus QueryStatus(EditCommand editCommand) { if (editCommand.HasKeyInput && _vimBuffer.CanProcess(editCommand.KeyInput)) { var commandStatus = QueryStatusCore(editCommand.KeyInput); if (commandStatus.HasValue) { return commandStatus.Value; } } return CommandStatus.PassOn; }
void OnEnable() { if (!editObject) { editObject = ((PrimitivesPro.MeshEditor.MeshEditorObject) target); } if (!editObject) { Instance = null; return; } editObject.Init(); if (Toolbar.Instance) { selectionType = Toolbar.Instance.MeshSelection; } vertexSelection = new HashSet<int>(); faceSelection = new HashSet<PPMesh.Face>(); edgeSelection = new HashSet<PPMesh.HalfEdge>(); settings = new MeshEditorSettings(); settings.Deserialize(); if (grid == null) { grid = new Grid(settings); } editCommand = new EditCommand { Command = EditCommand.CommandType.None, Face = null }; defaultTool = Tools.current; if (defaultTool == Tool.None) { defaultTool = Tool.Move; } handlesRotation = Quaternion.identity; Instance = this; }
protected virtual void OnCommand(EditCommand action) { this.Command.Call(action); }
public CollectionViewModel(TProperty property, ViewModelFactory factory) : base(property) { Collection = property.Collection.ToReadOnlyReactiveCollection(x => { IPropertyViewModel vm = null; try { vm = factory.Create(x); } catch (Exception e) { OnErrorSubject.OnNext(e); return(null); } vm.OnChanged.Subscribe(y => OnChangedSubject.OnNext(Unit.Default)); vm.OnError.Subscribe(e => OnErrorSubject.OnNext(e)); return(vm); }); FormatedString = Property.Count.Select(x => $"Count = {x}") .ToReactiveProperty(mode: ReactivePropertyMode.RaiseLatestValueOnSubscribe); AddCommand.Subscribe(x => { try { Property.AddNewElement(); } catch (Exception e) { OnErrorSubject.OnNext(e); } OnChangedSubject.OnNext(Unit.Default); }); RemoveCommand.Subscribe(x => { try { Property.RemoveElementAt(x); } catch (Exception e) { OnErrorSubject.OnNext(e); } OnChangedSubject.OnNext(Unit.Default); }); EditCommand.Subscribe(x => ShowDetailSubject.OnNext(this)); UpCommand.Subscribe(x => { Property.Move(x - 1, x); SelectedIndex.Value = x - 1; }); DownCommand.Subscribe(x => { Property.Move(x + 1, x); SelectedIndex.Value = x; }); DuplicateCommand.Subscribe(x => { Property.Duplicate(x, x + 1); }); }
protected LearnCommand(IStudyProvider studyProvider, EditCommand editCommand) : base(editCommand) { _studyProvider = studyProvider; }
internal bool Exec(EditCommand editCommand, out Action action) { action = null; // If the KeyInput was already handled then pretend we handled it here if (editCommand.HasKeyInput && _vimBufferCoordinator.IsDiscarded(editCommand.KeyInput)) { return true; } switch (editCommand.EditCommandKind) { case EditCommandKind.Undo: // The user hit the undo button. Don't attempt to map anything here and instead just // run a single Vim undo operation _vimBuffer.UndoRedoOperations.Undo(1); return true; case EditCommandKind.Redo: // The user hit the redo button. Don't attempt to map anything here and instead just // run a single Vim redo operation _vimBuffer.UndoRedoOperations.Redo(1); return true; case EditCommandKind.Paste: return Paste(); case EditCommandKind.GoToDefinition: // The GoToDefinition command will often cause a selection to occur in the // buffer. We don't want that to cause us to enter Visual Mode so clear it // out. This command can cause the active document to switch if the target // of the goto def is in another file. This file won't be registered as the // active file yet so just clear out the active selections action = () => { _textManager.GetDocumentTextViews(DocumentLoad.RespectLazy) .Where(x => !x.Selection.IsEmpty) .ForEach(x => x.Selection.Clear()); }; return false; case EditCommandKind.Comment: case EditCommandKind.Uncomment: // The comment / uncomment command will often induce a selection on the // editor even if there was no selection before the command was run (single line // case). if (_textView.Selection.IsEmpty) { action = () => { _textView.Selection.Clear(); }; } return false; case EditCommandKind.UserInput: case EditCommandKind.VisualStudioCommand: if (editCommand.HasKeyInput) { var keyInput = editCommand.KeyInput; // Discard the input if it's been flagged by a previous QueryStatus if (_vimBufferCoordinator.IsDiscarded(keyInput)) { return true; } // Try and process the command with the IVimBuffer if (TryProcessWithBuffer(keyInput)) { return true; } } return false; default: Debug.Assert(false); return false; } }
CommandStatus ICommandTarget.QueryStatus(EditCommand editCommand) { return QueryStatus(editCommand); }
private bool Exec(EditCommand editCommand, out Action action) { action = null; return(false); }
int IOleCommandTarget.Exec(ref Guid commandGroup, uint cmdId, uint cmdExecOpt, IntPtr variantIn, IntPtr variantOut) { EditCommand editCommand; if (!OleCommandUtil.TryConvert(commandGroup, cmdId, variantIn, KeyModifiers.None, out editCommand)) { _lastExecEditCommand = null; return VSConstants.E_FAIL; } _lastExecEditCommand = editCommand; return TryExec(editCommand.KeyInput) ? VSConstants.S_OK : VSConstants.E_FAIL; }
CommandStatus ICommandTarget.QueryStatus(EditCommand editCommand) { return(QueryStatus(editCommand)); }
bool ICommandTarget.Exec(EditCommand editCommand, out Action action) { return(Exec(editCommand, out action)); }
public virtual async Task Edit(EditCommand <Cart> command, CancellationToken cancellationToken = default) { var(cartId, cart) = command; if (string.IsNullOrEmpty(cartId)) { throw new ArgumentOutOfRangeException(nameof(command)); } if (Computed.IsInvalidating()) { TryGet(cartId, default).Ignore(); return; } await using var dbContext = await CreateCommandDbContext(cancellationToken); var dbCart = await dbContext.Carts.FindAsync(ComposeKey(cartId), cancellationToken); if (cart == null) { if (dbCart != null) { dbContext.Remove(dbCart); } } else { if (dbCart != null) { await dbContext.Entry(dbCart).Collection(c => c.Items).LoadAsync(cancellationToken); // Removing what doesn't exist in cart.Items dbCart.Items.RemoveAll(i => !cart.Items.ContainsKey(i.DbProductId)); // Updating the ones that exist in both collections foreach (var dbCartItem in dbCart.Items) { dbCartItem.Quantity = cart.Items[dbCartItem.DbProductId]; } // Adding the new ones var existingProductIds = dbCart.Items.Select(i => i.DbProductId).ToHashSet(); foreach (var item in cart.Items.Where(i => !existingProductIds.Contains(i.Key))) { var dbCartItem = new DbCartItem() { DbCartId = cartId, DbProductId = item.Key, Quantity = item.Value, }; dbCart.Items.Add(dbCartItem); } } else { dbContext.Add(new DbCart() { Id = cartId, Items = cart.Items.Select(i => new DbCartItem() { DbCartId = cartId, DbProductId = i.Key, Quantity = i.Value, }).ToList(), }); } } await dbContext.SaveChangesAsync(cancellationToken); }
public async Task <ActionResult <Unit> > Edit(Guid id, EditCommand command) { command.Id = id; return(await Mediator.Send(command)); }
public Resource() { this.tags = new List <Tag>(); Edit = new EditCommand(this); Delete = new DeleteCommand(this); }
internal void RunExec(EditCommand editCommand) { var oleCommandData = OleCommandData.Empty; try { Assert.True(OleCommandUtil.TryConvert(editCommand, out oleCommandData)); _target.Exec(oleCommandData); } finally { oleCommandData.Dispose(); } }
public void GoToDefinition() { var editCommand = new EditCommand(KeyInputUtil.CharToKeyInput('i'), EditCommandKind.GoToDefinition, Guid.Empty, 42); Assert.False(_targetRaw.ExecCore(editCommand)); }
protected override void OnCommand(EditCommand command) { if (command != EditCommand.Tab) this.help = false; base.OnCommand(command); }
private bool Exec(EditCommand editCommand, out Action action) { action = null; return false; }
int IOleCommandTarget.QueryStatus(ref Guid commandGroup, uint commandCount, OLECMD[] commands, IntPtr commandText) { EditCommand editCommand; if (1 != commandCount || !OleCommandUtil.TryConvert(commandGroup, commands[0].cmdID, commandText, KeyModifiers.None, out editCommand)) { _lastQueryStatusEditCommand = null; commands[0].cmdf = 0; return NativeMethods.S_OK; } _lastQueryStatusEditCommand = editCommand; commands[0].cmdf = (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED); return NativeMethods.S_OK; }
bool ICommandTarget.Exec(EditCommand editCommand, out Action preAction, out Action postAction) { return(Exec(editCommand, out preAction, out postAction)); }
private CommandStatus QueryStatus(EditCommand editCommand) { var action = CommandStatus.PassOn; switch (editCommand.EditCommandKind) { case EditCommandKind.Undo: case EditCommandKind.Redo: action = CommandStatus.Enable; break; case EditCommandKind.Paste: action = _vimBuffer.ModeKind == ModeKind.Command ? CommandStatus.Enable : CommandStatus.PassOn; break; default: if (editCommand.HasKeyInput && _vimBuffer.CanProcess(editCommand.KeyInput)) { action = CommandStatus.Enable; } break; } return action; }
private bool CanEdit() { return(EditCommand != null && EditCommand.CanExecute(Text)); }
bool ICommandTarget.Exec(EditCommand editCommand, out Action action) { return Exec(editCommand, out action); }
internal bool Exec(EditCommand editCommand, out Action action) { action = null; // If the KeyInput was already handled then pretend we handled it here if (editCommand.HasKeyInput && _vimBufferCoordinator.IsDiscarded(editCommand.KeyInput)) { return(true); } switch (editCommand.EditCommandKind) { case EditCommandKind.Undo: // The user hit the undo button. Don't attempt to map anything here and instead just // run a single Vim undo operation _vimBuffer.UndoRedoOperations.Undo(1); return(true); case EditCommandKind.Redo: // The user hit the redo button. Don't attempt to map anything here and instead just // run a single Vim redo operation _vimBuffer.UndoRedoOperations.Redo(1); return(true); case EditCommandKind.Paste: return(Paste()); case EditCommandKind.GoToDefinition: // The GoToDefinition command will often cause a selection to occur in the // buffer. We don't want that to cause us to enter Visual Mode so clear it // out. This command can cause the active document to switch if the target // of the goto def is in another file. This file won't be registered as the // active file yet so just clear out the active selections action = () => { _textManager.GetDocumentTextViews(DocumentLoad.RespectLazy) .Where(x => !x.Selection.IsEmpty) .ForEach(x => x.Selection.Clear()); }; return(false); case EditCommandKind.Comment: case EditCommandKind.Uncomment: // The comment / uncomment command will often induce a selection on the // editor even if there was no selection before the command was run (single line // case). if (_textView.Selection.IsEmpty) { action = () => { _textView.Selection.Clear(); }; } return(false); case EditCommandKind.UserInput: case EditCommandKind.VisualStudioCommand: if (editCommand.HasKeyInput) { var keyInput = editCommand.KeyInput; // Discard the input if it's been flagged by a previous QueryStatus if (_vimBufferCoordinator.IsDiscarded(keyInput)) { return(true); } // Try and process the command with the IVimBuffer if (TryProcessWithBuffer(keyInput)) { return(true); } } return(false); default: Debug.Assert(false); return(false); } }
public void EditUserProfileTest() { var profilePutModel = new ProfilePutModel(); var command = new EditCommand(GetFakeApiController(), GetFakeUserRepository(), profilePutModel); Task<HttpResponseMessage> result = command.Execute(); result.Wait(); Assert.IsFalse(result.IsFaulted); Assert.IsNotNull(result.Result); Assert.IsTrue(result.Result.StatusCode == HttpStatusCode.OK); }
private bool Exec(EditCommand editCommand, out Action preAction, out Action postAction) { preAction = null; postAction = null; return(false); }