protected TransactedTool(DocumentWorkspace documentWorkspace, ImageResource toolBarImage, string name, string helpText, char hotKey, bool skipIfActiveOnHotKey, ToolBarConfigItems toolBarConfigItems, bool isCommitSupported) : base(documentWorkspace, toolBarImage, name, helpText, hotKey, skipIfActiveOnHotKey, toolBarConfigItems) { this.commitChangesRegion = new ProtectedRegion("CommitChanges", ProtectedRegionOptions.ErrorOnPerThreadReentrancy); this.updateStatusCallback = new Action(this.UpdateStatus); this.state = TransactedToolState.Inactive; base.IsCommitSupported = isCommitSupported; }
public void VerifyStateTransition(TransactedToolState oldState, TransactedToolState newState) { if ((((((oldState != TransactedToolState.Inactive) || (newState != TransactedToolState.Idle)) && ((oldState != TransactedToolState.Idle) || (newState != TransactedToolState.Inactive))) && (((oldState != TransactedToolState.Idle) || (newState != TransactedToolState.Drawing)) && ((oldState != TransactedToolState.Idle) || (newState != TransactedToolState.Dirty)))) && ((((oldState != TransactedToolState.Drawing) || (newState != TransactedToolState.Idle)) && ((oldState != TransactedToolState.Drawing) || (newState != TransactedToolState.Dirty))) && (((oldState != TransactedToolState.Dirty) || (newState != TransactedToolState.Idle)) && ((oldState != TransactedToolState.Dirty) || (newState != TransactedToolState.Editing))))) && ((oldState != TransactedToolState.Editing) || (newState != TransactedToolState.Dirty))) { throw new InvalidOperationException($"Illegal state transition, from {oldState} to {newState} (Tool={base.GetType().Name})"); } }
public void VerifyState(TransactedToolState requiredState) { ((TransactedTool <TDerived, TChanges>) this).VerifyAccess <TransactedTool <TDerived, TChanges> >(); if (this.State != requiredState) { throw new InvalidOperationException($"The tool must be in the {requiredState} state, but is actually in the {this.State} state (Tool={base.GetType().Name})"); } }
private static Visibility GetTransformControlVisibility(TransactedToolState state, RectDouble baseBounds) { if (((state != TransactedToolState.Idle) || baseBounds.IsEmpty) && (((state != TransactedToolState.Drawing) && (state != TransactedToolState.Dirty)) && (state != TransactedToolState.Editing))) { return(Visibility.Hidden); } return(Visibility.Visible); }
private static double GetBrushPreviewElementOpacity(TransactedToolState toolState) { switch (toolState) { case TransactedToolState.Drawing: return(0.5); } return(1.0); }
private void SetState(TransactedToolState newState) { ((TransactedTool <TDerived, TChanges>) this).VerifyAccess <TransactedTool <TDerived, TChanges> >(); if (newState == this.state) { throw new InvalidOperationException($"Cannot transition to the same state (State={newState}, Tool={base.GetType().Name})"); } TransactedToolState oldState = this.state; this.VerifyStateTransition(oldState, newState); this.state = newState; this.OnStateChanged(oldState, newState); this.InvalidateStatus(); }
protected override void OnStateChanged(TransactedToolState oldValue, TransactedToolState newValue) { if (newValue != TransactedToolState.Idle) { if (newValue == TransactedToolState.Drawing) { this.PushTimerScope(); } } else if (this.IsTimerScopeActive) { this.PopTimerScope(); } base.OnStateChanged(oldValue, newValue); }
private static Visibility GetHandleVisibility(TransactedToolState state) { switch (state) { case TransactedToolState.Inactive: case TransactedToolState.Idle: return(Visibility.Hidden); case TransactedToolState.Drawing: case TransactedToolState.Dirty: case TransactedToolState.Editing: return(Visibility.Visible); } ExceptionUtil.ThrowInvalidEnumArgumentException <TransactedToolState>(state, "state"); return(Visibility.Hidden); }
private Cursor GetHandleCursor(TransactedToolState state) { switch (state) { case TransactedToolState.Inactive: return(null); case TransactedToolState.Idle: case TransactedToolState.Dirty: return(this.handCursor); case TransactedToolState.Drawing: case TransactedToolState.Editing: return(this.handMouseDownCursor); } ExceptionUtil.ThrowInvalidEnumArgumentException <TransactedToolState>(state, "state"); return(null); }
protected virtual void OnStateChanged(TransactedToolState oldValue, TransactedToolState newValue) { if ((oldValue == TransactedToolState.Drawing) && (this.drawingAgent != null)) { throw new InternalErrorException($"this.drawingTransactionAgent must be set to null before leaving the Drawing state (Tool={base.GetType().Name})"); } if ((oldValue == TransactedToolState.Editing) && (this.editingAgent != null)) { throw new InternalErrorException($"this.editingTransactionAgent must be set to null before leaving the Editing state (Tool={base.GetType().Name})"); } if ((newValue == TransactedToolState.Drawing) && (this.drawingAgent == null)) { throw new InternalErrorException($"this.drawingTransactionAgent must be set before entering the Drawing state (Tool={base.GetType().Name})"); } if ((newValue == TransactedToolState.Editing) && (this.editingAgent == null)) { throw new InternalErrorException($"this.editingTransactionAgent must be set before entering the Editing state (Tool={base.GetType().Name})"); } this.UpdateCanCommit(); }