public ExecutingHistoryMementoEventArgs(HistoryMemento historyMemento, bool mayAlterSuspendToolProperty, bool suspendTool) { this.historyMemento = historyMemento; this.mayAlterSuspendToolProperty = mayAlterSuspendToolProperty; this.suspendTool = suspendTool; }
public ExecutedHistoryMementoEventArgs(HistoryMemento newHistoryMemento) { this.newHistoryMemento = newHistoryMemento; }
/// <summary> /// When the user does something new, it will clear out the redo stack. /// </summary> public void PushNewMemento(HistoryMemento value) { Utility.GCFullCollect(); OnChanging(); ClearRedoStack(); undoStack.Add(value); OnNewHistoryMemento(); OnChanged(); value.Flush(); Utility.GCFullCollect(); }
private void OnItemClicked(ItemType itemType, HistoryMemento hm) { int hmID = hm.ID; if (itemType == ItemType.Undo) { if (hmID == this.historyStack.UndoStack[historyStack.UndoStack.Count - 1].ID) { if (historyStack.UndoStack.Count > 1) { this.historyStack.StepBackward(); } } else { SuspendScrollOffsetSet(); this.historyStack.BeginStepGroup(); using (new WaitCursorChanger(this)) { while (this.historyStack.UndoStack[this.historyStack.UndoStack.Count - 1].ID != hmID) { this.historyStack.StepBackward(); } } this.historyStack.EndStepGroup(); ResumeScrollOffsetSet(); } } else // if (itemType == ItemType.Redo) { SuspendScrollOffsetSet(); // Step forward to redo this.historyStack.BeginStepGroup(); using (new WaitCursorChanger(this)) { while (this.historyStack.UndoStack[this.historyStack.UndoStack.Count - 1].ID != hmID) { this.historyStack.StepForward(); } } this.historyStack.EndStepGroup(); ResumeScrollOffsetSet(); } Focus(); }
private void OnFinished(HistoryMemento memento, Exception exception) { if (this.eventSink.InvokeRequired) { this.eventSink.BeginInvoke( new Procedure<HistoryMemento, Exception>(OnFinished), new object[2] { memento, exception }); } else { if (exception != null) { throw new WorkerThreadException(exception); } if (Finished != null) { Finished(this, new EventArgs<HistoryMemento>(memento)); } } }
public ExecutedHistoryMementoEventArgs(HistoryMemento newHistoryMemento) { this.newHistoryMemento = newHistoryMemento; }
private void StepBackwardImpl(IWin32Window owner) { HistoryMemento historyMemento = this.undoStack[this.undoStack.Count - 1]; ToolHistoryMemento memento2 = historyMemento as ToolHistoryMemento; if ((memento2 != null) && (memento2.ToolType != this.documentWorkspace.GetToolType())) { this.documentWorkspace.SetToolFromType(memento2.ToolType); this.StepBackwardImpl(owner); } else { this.OnChanging(); ExecutingHistoryMementoEventArgs e = new ExecutingHistoryMementoEventArgs(historyMemento, true, false); if ((memento2 == null) && (historyMemento.SeriesGuid == Guid.Empty)) { e.SuspendTool = true; } this.OnExecutingHistoryMemento(e); ReferenceValue changes = null; System.Type type = null; if (e.SuspendTool) { TransactedTool tool = this.documentWorkspace.Tool as TransactedTool; if (tool != null) { type = tool.GetType(); tool.ForceCancelDrawingOrEditing(); if (tool.State == TransactedToolState.Dirty) { changes = tool.Changes; tool.CancelChanges(); } } this.documentWorkspace.PushNullTool(); } HistoryMemento memento3 = this.undoStack[this.undoStack.Count - 1]; ExecutingHistoryMementoEventArgs args2 = new ExecutingHistoryMementoEventArgs(memento3, false, e.SuspendTool); this.OnExecutingHistoryMemento(args2); using (this.disallowPushNewMementoRegion.UseEnterScope()) { HistoryMemento item = this.undoStack[this.undoStack.Count - 1].PerformUndo(null); this.undoStack.RemoveAt(this.undoStack.Count - 1); this.redoStack.Insert(0, item); ExecutedHistoryMementoEventArgs args3 = new ExecutedHistoryMementoEventArgs(item); this.OnExecutedHistoryMemento(args3); this.OnChanged(); this.OnSteppedBackward(); item.Flush(); } if (e.SuspendTool) { this.documentWorkspace.PopNullTool(); if (changes != null) { ((TransactedTool)this.documentWorkspace.Tool).RestoreChanges(changes); } } } if (this.stepGroupDepth == 0) { this.OnFinishedStepGroup(); } }
/// <summary> /// Executes the HistoryFunction. /// </summary> /// <returns> /// A HistoryMemento instance if an operation was performed successfully, /// or null for success but no operation was performed.</returns> /// <exception cref="HistoryFunctionNonFatalException"> /// There was error while performing the operation. No changes have been made to the HistoryWorkspace (no-op). /// </exception> /// <remarks> /// If this HistoryFunction's ActionFlags contain the HistoryFlags.Cancellable bit, then it will be executed in /// a background thread. /// </remarks> public HistoryMemento Execute(IHistoryWorkspace historyWorkspace) { HistoryMemento returnVal = null; Exception exception = null; try { try { if (this.executed) { throw new InvalidOperationException("Already executed this HistoryFunction"); } this.executed = true; returnVal = OnExecute(historyWorkspace); return(returnVal); } catch (ArgumentOutOfRangeException aoorex) { if (this.criticalRegionCount > 0) { throw; } else { throw new HistoryFunctionNonFatalException(null, aoorex); } } catch (OutOfMemoryException oomex) { if (this.criticalRegionCount > 0) { throw; } else { throw new HistoryFunctionNonFatalException(null, oomex); } } } catch (Exception ex) { if (IsAsync) { exception = ex; return(returnVal); } else { throw; } } finally { if (IsAsync) { OnFinished(returnVal, exception); } } }
public ExecutingHistoryMementoEventArgs(HistoryMemento historyMemento, bool mayAlterSuspendToolProperty, bool suspendTool) { this.historyMemento = historyMemento; this.mayAlterSuspendToolProperty = mayAlterSuspendToolProperty; this.suspendTool = suspendTool; }
protected override void OnDragDrop(DragEventArgs drgevent) { Activate(); if (!IsCurrentModalForm || !Enabled) { // do nothing } else if (drgevent.Data.GetDataPresent(DataFormats.FileDrop)) { string[] allFiles = (string[])drgevent.Data.GetData(DataFormats.FileDrop); if (allFiles == null) { return; } string[] files = PruneDirectories(allFiles); bool importAsLayers = true; if (files.Length == 0) { return; } else { Icon formIcon = Utility.ImageToIcon(PdnResources.GetImageResource("Icons.DragDrop.OpenOrImport.FormIcon.png").Reference); string title = PdnResources.GetString("DragDrop.OpenOrImport.Title"); string infoText = PdnResources.GetString("DragDrop.OpenOrImport.InfoText"); TaskButton openTB = new TaskButton( PdnResources.GetImageResource("Icons.MenuFileOpenIcon.png").Reference, PdnResources.GetString("DragDrop.OpenOrImport.OpenButton.ActionText"), PdnResources.GetString("DragDrop.OpenOrImport.OpenButton.ExplanationText")); string importLayersExplanation; if (this.appWorkspace.DocumentWorkspaces.Length == 0) { importLayersExplanation = PdnResources.GetString("DragDrop.OpenOrImport.ImportLayers.ExplanationText.NoImagesYet"); } else { importLayersExplanation = PdnResources.GetString("DragDrop.OpenOrImport.ImportLayers.ExplanationText"); } TaskButton importLayersTB = new TaskButton( PdnResources.GetImageResource("Icons.MenuLayersImportFromFileIcon.png").Reference, PdnResources.GetString("DragDrop.OpenOrImport.ImportLayers.ActionText"), importLayersExplanation); TaskButton clickedTB = TaskDialog.Show( this, formIcon, title, null, false, infoText, new TaskButton[] { openTB, importLayersTB, TaskButton.Cancel }, null, TaskButton.Cancel); if (clickedTB == openTB) { importAsLayers = false; } else if (clickedTB == importLayersTB) { importAsLayers = true; } else { return; } } if (!importAsLayers) { // open files into new tabs this.appWorkspace.OpenFilesInNewWorkspace(files); } else { // no image open? we will have to create one if (this.appWorkspace.ActiveDocumentWorkspace == null) { Size newSize = this.appWorkspace.GetNewDocumentSize(); this.appWorkspace.CreateBlankDocumentInNewWorkspace( newSize, Document.DefaultDpuUnit, Document.GetDefaultDpu(Document.DefaultDpuUnit), false); } ImportFromFileAction action = new ImportFromFileAction(); HistoryMemento ha = action.ImportMultipleFiles(this.appWorkspace.ActiveDocumentWorkspace, files); if (ha != null) { this.appWorkspace.ActiveDocumentWorkspace.History.PushNewMemento(ha); } } } base.OnDragDrop(drgevent); }