private void RadialController_RotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args) { if (CurrentSelection == ColoringBookRadialController.Color) { if (args.RotationDeltaInDegrees > 0) { ColorPaletteViewModel.SelectNextItem(); } else { ColorPaletteViewModel.SelectPreviousItem(); } } else if (CurrentSelection == ColoringBookRadialController.UndoRedo) { if (args.RotationDeltaInDegrees > 0) { RedoOperation?.Invoke(this, EventArgs.Empty); } else { UndoOperation?.Invoke(this, EventArgs.Empty); } } }
private void OnGUI() { var current = Event.current; switch (current.type) { case EventType.MouseDown: if (lastOperation != null) { operations.Push(lastOperation); lastOperation = null; } break; case EventType.KeyDown: if (current.keyCode == KeyCode.Z && current.shift) { if (lastOperation != null) { lastOperation.action(lastOperation.value); lastOperation = null; } else if (operations.Count > 0) { var op = operations.Pop(); op.action(op.value); } } break; } }
public UndoData(UndoOperation Operation, object Data) { this.operation = Operation; this.data = Data; this.reason = UpdateReason.Other; this.updateCount = 0; this.undoFlag = false; this.position = Point.Empty; }
public UndoControlState Push(Component ctl, UndoOperation operation, Rectangle bounds, string caption, bool visibility) { var state = new UndoControlState() { Element = ctl, Operation = operation, Bounds = bounds, Caption = caption, Visible = visibility }; m_UndoStack.Push(state); return(state); }
public void BeginAtomicUndo() { if (currentAtomicOperation == null) { currentAtomicOperation = new UndoOperation(); currentAtomicOperation.undoNode = pieceTable.tree.Root.Clone(); currentAtomicOperation.undoCaret = new CaretPosition(Caret); } atomicUndoLevel++; }
public void BeginAtomicUndo() { if (currentAtomicOperation == null) { currentAtomicOperation = new UndoOperation(); currentAtomicOperation.undoNode = pieceTable.tree.Root.Clone(); currentAtomicOperation.undoCaret = lastChangeOffset; } atomicUndoLevel++; }
public void EndAtomicUndo() { atomicUndoLevel--; if (atomicUndoLevel == 0 && currentAtomicOperation != null) { currentAtomicOperation.redoNode = pieceTable.tree.Root.Clone(); currentAtomicOperation.redoCaret = new CaretPosition(Caret); undoStack.Push(currentAtomicOperation); redoStack.Clear(); currentAtomicOperation = null; } }
public void Undo() { if (undoStack.Count <= 0) { return; } isInUndo = true; UndoOperation operation = undoStack.Pop(); operation.Undo(this); redoStack.Push(operation); isInUndo = false; OnUndone(new UndoOperationEventArgs(operation.undoCaret)); }
public void Redo() { if (redoStack.Count <= 0) { return; } isInUndo = true; UndoOperation operation = redoStack.Pop(); operation.Redo(this); undoStack.Push(operation); isInUndo = false; OnRedone(new UndoOperationEventArgs(operation)); }
void InsertWithCursorOnLayer(EditorScript currentScript, InsertionCursorLayer layer, TaskCompletionSource <Script> tcs, IList <AstNode> nodes, IDocument target) { var doc = target as TextDocument; var op = new UndoOperation(layer, tcs); if (doc != null) { doc.UndoStack.Push(op); } layer.ScrollToInsertionPoint(); layer.Exited += delegate(object s, InsertionCursorEventArgs args) { doc.UndoStack.StartContinuedUndoGroup(); try { if (args.Success) { if (args.InsertionPoint.LineAfter == NewLineInsertion.None && args.InsertionPoint.LineBefore == NewLineInsertion.None && nodes.Count > 1) { args.InsertionPoint.LineAfter = NewLineInsertion.BlankLine; } int offset = currentScript.GetCurrentOffset(args.InsertionPoint.Location); int indentLevel = currentScript.GetIndentLevelAt(offset); foreach (var node in nodes.Reverse()) { var output = currentScript.OutputNode(indentLevel, node); int delta = args.InsertionPoint.Insert(target, output.Text); output.RegisterTrackedSegments(currentScript, delta + offset); } currentScript.FormatText(nodes); tcs.SetResult(currentScript); } layer.Dispose(); DisposeOnClose(); } finally { doc.UndoStack.EndUndoGroup(); } op.Reset(); }; }
public static void PushUndo(string name, Action <object> action, object value) { if (lastOperation != null) { if (lastOperation.name == name) { //lastOperation.action = action; //lastOperation.value = value; return; } else { operations.Push(lastOperation); lastOperation = null; } } else { lastOperation = new UndoOperation() { action = action, name = name, value = value }; } }
public void Insert (int index, UndoOperation operation) { operations.Insert (index, operation); }
void InsertWithCursorOnLayer(EditorScript currentScript, InsertionCursorLayer layer, TaskCompletionSource<Script> tcs, IList<AstNode> nodes, IDocument target) { var doc = target as TextDocument; var op = new UndoOperation(layer, tcs); if (doc != null) { doc.UndoStack.Push(op); } layer.Exited += delegate(object s, InsertionCursorEventArgs args) { doc.UndoStack.StartContinuedUndoGroup(); try { if (args.Success) { if (args.InsertionPoint.LineAfter == NewLineInsertion.None && args.InsertionPoint.LineBefore == NewLineInsertion.None && nodes.Count > 1) { args.InsertionPoint.LineAfter = NewLineInsertion.BlankLine; } foreach (var node in nodes.Reverse ()) { int indentLevel = currentScript.GetIndentLevelAt(target.GetOffset(args.InsertionPoint.Location)); var output = currentScript.OutputNode(indentLevel, node); var offset = target.GetOffset(args.InsertionPoint.Location); var delta = args.InsertionPoint.Insert(target, output.Text); output.RegisterTrackedSegments(currentScript, delta + offset); } tcs.SetResult(currentScript); } layer.Dispose(); DisposeOnClose(); } finally { doc.UndoStack.EndUndoGroup(); } op.Reset(); }; }
public void Replace (int offset, int count, string value, ICSharpCode.NRefactory.Editor.AnchorMovementType anchorMovementType = AnchorMovementType.Default) { if (offset < 0) throw new ArgumentOutOfRangeException ("offset", "must be > 0, was: " + offset); if (offset > TextLength) throw new ArgumentOutOfRangeException ("offset", "must be <= Length, was: " + offset); if (count < 0) throw new ArgumentOutOfRangeException ("count", "must be > 0, was: " + count); InterruptFoldWorker (); //int oldLineCount = LineCount; var args = new DocumentChangeEventArgs (offset, count > 0 ? GetTextAt (offset, count) : "", value, anchorMovementType); OnTextReplacing (args); value = args.InsertedText.Text; UndoOperation operation = null; if (!isInUndo) { operation = new UndoOperation (args); if (currentAtomicOperation != null) { currentAtomicOperation.Add (operation); } else { OnBeginUndo (); undoStack.Push (operation); OnEndUndo (new UndoOperationEventArgs (operation)); } redoStack.Clear (); } buffer.Replace (offset, count, value); foldSegmentTree.UpdateOnTextReplace (this, args); splitter.TextReplaced (this, args); versionProvider.AppendChange (args); OnTextReplaced (args); }
public UndoOperationEventArgs(UndoOperation operation) { this.Operation = operation; }
/// <summary> /// 新建工程的具体函数操作。新建工程时,如果发现工程的资源管理器中有其他工程处在打开状态,则提示是否保存, /// 如“保存”,则调用 saveProjectOperation()函数进行工程的保存操作; /// 对新建的工程的名称进行合法性检查,并在工程的资源管理器中新建一个根级文件夹节点作为当前工程项目文件夹。 /// /// 注: /// 在新建工程时,提供的是要保存的工程的名称, /// 在这个路径下会产生该以该工程名称命名的文件夹,该文件夹下会生成一个同名称的,以.caproj为后缀的工程资源管理文件, /// 并生成一个空的设计页面,名称为:DesignView_1 /// </summary> private void NewProject() { try { if (solutionTreeView.Nodes.Count > 0) { DialogResult Sresult = CassMessageBox.Question("是否保存原有项目?"); if (Sresult == DialogResult.Yes) { saveProjectOperation(); //调用保存工程程序 CassViewGenerator.currentTabPage = null; } } //清空原有资源管理器 ClearResource(); string tempNum = GetNewPnum();//临时工程序号 NewPorject newForm = new NewPorject(tempNum); DialogResult Oresult = newForm.ShowDialog(); if (Oresult == DialogResult.OK) { //保存文件路径、工程名、工程周期 ProjectName = newForm.Pname; ProjectInfo = newForm.Pinfo; ProjectNum = tempNum; PnumList.Add(ProjectNum); saveName = newForm.Pname + ".caproj"; savePath = programPath + "\\" + newForm.Pname; ProjectInfo = newForm.Pinfo; //添加到工程资源管理器节点中。 HostControl hostControl = hostDesignManage.GetNewHost(MainPageName); if (hostControl != null && hostControl.LoadBool == true) { ListObject listObject = new ListObject(); //新增加的链表结点 listObject.tabPage = AddTabForNewHost(MainPageName, hostControl); TreeNode designNode = CreateNode(MainPageName, this.treeMenuPage); this.solutionTreeView.Nodes.Add(designNode); listObject.pathName = designNode.FullPath.Trim(); listObject.UndoAndRedo = new UndoOperation(listObject.tabPage); currentUndo = listObject.UndoAndRedo; //将对象添加到链表中 this.tabList.Add(listObject); nodeList.Add(listObject); //按键设置,用于对当前控件的选择 if (tabControlView.SelectedTab != null) { CassViewGenerator.currentTabPage = this.tabControlView.SelectedTab; } this.solutionTreeView.Nodes.Add(CodePageName); this.solutionTreeView.ExpandAll(); this.dockManager.ShowContent(this.tabSolution_Property);//显示属性表 if (nodeList.Count > 0) //如果有设计页面,则显示可以形成项目文件 { this.saveProject.Enabled = true; } //设置编辑栏中的具体状态 this.aliginToolStripMenuItem.Enabled = false; this.cutToolStripMenuItem.Enabled = false; this.copyToolStripMenuItem.Enabled = false; this.deleteControlToolStripMenuItem.Enabled = false; this.selectAllMenuItem.Enabled = false; } else { CassMessageBox.Error("新建工程发生异常!"); } Directory.CreateDirectory(savePath); FileStream fStream = new FileStream(this.savePath + "//" + this.saveName, FileMode.Create); DirectoryInfo[] infos = new DirectoryInfo(programPath).GetDirectories(); //if (infos.Length != this.ProListBox.Items.Count) //{//如果工程文件夹数和现有工程数不同则判定为新加了控件 // ListViewItem newProject = new ListViewItem(new string[] { ProjectName, ProjectInfo }); // this.ProListBox.Items.Add(newProject); //} bool exist = false; for (int i = 0; i < this.ProListBox.Items.Count; i++) { if (ProListBox.Items[i].Text == ProjectName) { exist = true; } } if (!exist) { ListViewItem newProject = new ListViewItem(new string[] { ProjectName, ProjectInfo }); this.ProListBox.Items.Add(newProject); } this.Text = this.Text.Split('_')[0] + "_" + ProjectName;//显示当前工程名 this.saveProject.Enabled = true; //允许保存工程 this.saveProjecttoolStripButton.Enabled = true; this.closeProjecttoolStripMenuItem.Enabled = true; this.addItemtoolStripSplitButton.Enabled = true; this.designViewStripMenu.Enabled = true; fStream.Close(); //新建时状态栏显示图形编辑模式 ModeSelect(0); } } catch (FileNotFoundException ex) { CassMessageBox.Error("安装文件被损坏!"); } catch (DirectoryNotFoundException ex) { CassMessageBox.Error("安装文件被损坏!"); } catch (SecurityException ex) { CassMessageBox.Error("文件权限被修改!"); } catch (PathTooLongException e) { CassMessageBox.Error("磁盘文件物理路径过长!"); } catch (NotSupportedException e) { CassMessageBox.Error("创建的目录的路径无效!"); } catch (UnauthorizedAccessException e) { CassMessageBox.Error("磁盘保护,不可创建目录!"); } catch (IOException e) { CassMessageBox.Error("文件操作无效!"); } catch (Exception ex) { } }
void InsertWithCursorOnLayer(EditorScript currentScript, InsertionCursorLayer layer, TaskCompletionSource <Script> tcs, IList <AstNode> nodes, IDocument target) { var doc = target as TextDocument; var op = new UndoOperation(layer, tcs); if (doc != null) { doc.UndoStack.Push(op); } layer.ScrollToInsertionPoint(); layer.Exited += delegate(object s, InsertionCursorEventArgs args) { doc.UndoStack.StartContinuedUndoGroup(); try { if (args.Success) { if (args.InsertionPoint.LineAfter == NewLineInsertion.None && args.InsertionPoint.LineBefore == NewLineInsertion.None && nodes.Count > 1) { args.InsertionPoint.LineAfter = NewLineInsertion.BlankLine; } var insertionPoint = args.InsertionPoint; if (nodes.All(n => n is EnumMemberDeclaration)) { insertionPoint.LineAfter = NewLineInsertion.Eol; insertionPoint.LineBefore = NewLineInsertion.None; } int offset = currentScript.GetCurrentOffset(insertionPoint.Location); int indentLevel = currentScript.GetIndentLevelAt(Math.Max(0, offset - 1)); foreach (var node in nodes.Reverse()) { var output = currentScript.OutputNode(indentLevel, node); var text = output.Text; if (node is EnumMemberDeclaration) { if (insertionPoint != layer.InsertionPoints.Last()) { text += ","; } else { var parentEnum = currentScript.context.RootNode.GetNodeAt(insertionPoint.Location, n => (n is TypeDeclaration) && ((TypeDeclaration)n).ClassType == ClassType.Enum) as TypeDeclaration; if (parentEnum != null) { var lastMember = parentEnum.Members.LastOrDefault(); if (lastMember != null) { var segment = currentScript.GetSegment(lastMember); currentScript.InsertText(segment.EndOffset, ","); } } } } int delta = insertionPoint.Insert(target, text); output.RegisterTrackedSegments(currentScript, delta + offset); } currentScript.FormatText(nodes); tcs.SetResult(currentScript); } layer.Dispose(); DisposeOnClose(); } finally { doc.UndoStack.EndUndoGroup(); } op.Reset(); }; }
public void BeginAtomicUndo () { if (currentAtomicOperation == null) { currentAtomicOperation = new UndoOperation (); currentAtomicOperation.undoNode = pieceTable.tree.Root.Clone (); currentAtomicOperation.undoCaret = new CaretPosition (Caret); } atomicUndoLevel++; }
public UndoOperationTest() { _operator = new UndoOperation(Name); }
void IBuffer.Replace (int offset, int count, string value) { if (atomicUndoLevel == 0) { if (this.syntaxMode != null && !SuppressHighlightUpdate) Mono.TextEditor.Highlighting.SyntaxModeService.WaitUpdate (this); } InterruptFoldWorker (); // Mono.TextEditor.Highlighting.SyntaxModeService.WaitForUpdate (true); // Debug.Assert (count >= 0); // Debug.Assert (0 <= offset && offset + count <= Length); int oldLineCount = this.LineCount; var args = new ReplaceEventArgs (offset, count, value); if (Partitioner != null) Partitioner.TextReplacing (args); OnTextReplacing (args); value = args.Value; /* insert/repla lock (syncObject) { int endOffset = offset + count; foldSegments = new List<FoldSegment> (foldSegments.Where (s => (s.Offset < offset || s.Offset >= endOffset) && (s.EndOffset <= offset || s.EndOffset >= endOffset))); }*/ UndoOperation operation = null; if (!isInUndo) { operation = new UndoOperation (args, count > 0 ? GetTextAt (offset, count) : ""); if (currentAtomicOperation != null) { currentAtomicOperation.Add (operation); } else { OnBeginUndo (); undoStack.Push (operation); OnEndUndo (new UndoOperationEventArgs (operation)); } redoStack.Clear (); } buffer.Replace (offset, count, value); foldSegmentTree.UpdateOnTextReplace (this, args); splitter.TextReplaced (this, args); if (Partitioner != null) Partitioner.TextReplaced (args); OnTextReplaced (args); UpdateUndoStackOnReplace (args); if (operation != null) operation.Setup (this, args); if (this.syntaxMode != null && !SuppressHighlightUpdate) { Mono.TextEditor.Highlighting.SyntaxModeService.StartUpdate (this, this.syntaxMode, offset, value != null ? offset + value.Length : offset + count); } if (oldLineCount != LineCount) this.CommitLineToEndUpdate (this.OffsetToLocation (offset).Line); }
public IGraph _graph; // for ToString only public LGSPUndoAttributeChanged(IGraphElement elem, AttributeType attrType, AttributeChangeType changeType, Object newValue, Object keyValue, LGSPGraphProcessingEnvironment procEnv) { _elem = elem; _attrType = attrType; if(procEnv.graph is LGSPNamedGraph) _name = ((LGSPNamedGraph)procEnv.graph).GetElementName(_elem); else _name = "?"; _graph = procEnv.graph; if (_attrType.Kind == AttributeKind.SetAttr) { if (changeType == AttributeChangeType.PutElement) { IDictionary dict = (IDictionary)_elem.GetAttribute(_attrType.Name); if (dict.Contains(newValue)) { _undoOperation = UndoOperation.None; } else { _undoOperation = UndoOperation.RemoveElement; _value = newValue; } } else if (changeType == AttributeChangeType.RemoveElement) { IDictionary dict = (IDictionary)_elem.GetAttribute(_attrType.Name); if (dict.Contains(newValue)) { _undoOperation = UndoOperation.PutElement; _value = newValue; } else { _undoOperation = UndoOperation.None; } } else // Assign { Type keyType, valueType; IDictionary dict = ContainerHelper.GetDictionaryTypes( _elem.GetAttribute(_attrType.Name), out keyType, out valueType); IDictionary clonedDict = ContainerHelper.NewDictionary(keyType, valueType, dict); _undoOperation = UndoOperation.Assign; _value = clonedDict; } } else if (_attrType.Kind == AttributeKind.ArrayAttr) { if (changeType == AttributeChangeType.PutElement) { IList array = (IList)_elem.GetAttribute(_attrType.Name); _undoOperation = UndoOperation.RemoveElement; _keyOfValue = keyValue; } else if (changeType == AttributeChangeType.RemoveElement) { IList array = (IList)_elem.GetAttribute(_attrType.Name); _undoOperation = UndoOperation.PutElement; if(keyValue == null) { _value = array[array.Count-1]; } else { _value = array[(int)keyValue]; _keyOfValue = keyValue; } } else if(changeType == AttributeChangeType.AssignElement) { IList array = (IList)_elem.GetAttribute(_attrType.Name); _undoOperation = UndoOperation.AssignElement; _value = array[(int)keyValue]; _keyOfValue = keyValue; } else // Assign { Type valueType; IList array = ContainerHelper.GetListType( _elem.GetAttribute(_attrType.Name), out valueType); IList clonedArray = ContainerHelper.NewList(valueType, array); _undoOperation = UndoOperation.Assign; _value = clonedArray; } } else if(_attrType.Kind == AttributeKind.DequeAttr) { if(changeType == AttributeChangeType.PutElement) { IDeque deque = (IDeque)_elem.GetAttribute(_attrType.Name); _undoOperation = UndoOperation.RemoveElement; _keyOfValue = keyValue; } else if(changeType == AttributeChangeType.RemoveElement) { IDeque deque = (IDeque)_elem.GetAttribute(_attrType.Name); _undoOperation = UndoOperation.PutElement; if(keyValue == null) { _value = deque.Front; } else { _value = deque[(int)keyValue]; _keyOfValue = keyValue; } } else if(changeType == AttributeChangeType.AssignElement) { IDeque deque = (IDeque)_elem.GetAttribute(_attrType.Name); _undoOperation = UndoOperation.AssignElement; _value = deque[(int)keyValue]; _keyOfValue = keyValue; } else // Assign { Type valueType; IDeque deque = ContainerHelper.GetDequeType( _elem.GetAttribute(_attrType.Name), out valueType); IDeque clonedDeque = ContainerHelper.NewDeque(valueType, deque); _undoOperation = UndoOperation.Assign; _value = clonedDeque; } } else if(_attrType.Kind == AttributeKind.MapAttr) { if (changeType == AttributeChangeType.PutElement) { IDictionary dict = (IDictionary)_elem.GetAttribute(_attrType.Name); if (dict.Contains(keyValue)) { if (dict[keyValue] == newValue) { _undoOperation = UndoOperation.None; } else { _undoOperation = UndoOperation.PutElement; _value = dict[keyValue]; _keyOfValue = keyValue; } } else { _undoOperation = UndoOperation.RemoveElement; _value = newValue; _keyOfValue = keyValue; } } else if (changeType == AttributeChangeType.RemoveElement) { IDictionary dict = (IDictionary)_elem.GetAttribute(_attrType.Name); if (dict.Contains(keyValue)) { _undoOperation = UndoOperation.PutElement; _value = dict[keyValue]; _keyOfValue = keyValue; } else { _undoOperation = UndoOperation.None; } } else if(changeType == AttributeChangeType.AssignElement) { IDictionary dict = (IDictionary)_elem.GetAttribute(_attrType.Name); if(dict[keyValue] == newValue) { _undoOperation = UndoOperation.None; } else { _undoOperation = UndoOperation.AssignElement; _value = dict[keyValue]; _keyOfValue = keyValue; } } else // Assign { Type keyType, valueType; IDictionary dict = ContainerHelper.GetDictionaryTypes( _elem.GetAttribute(_attrType.Name), out keyType, out valueType); IDictionary clonedDict = ContainerHelper.NewDictionary(keyType, valueType, dict); _undoOperation = UndoOperation.Assign; _value = clonedDict; } } else // Primitve Type Assign { _undoOperation = UndoOperation.Assign; _value = _elem.GetAttribute(_attrType.Name); } }
public readonly IGraph _graph; // for ToString only public LGSPUndoAttributeChanged(IGraphElement elem, AttributeType attrType, AttributeChangeType changeType, Object newValue, Object keyValue, LGSPGraphProcessingEnvironment procEnv) { _elem = elem; _attrType = attrType; if (procEnv.graph is LGSPNamedGraph) { _name = ((LGSPNamedGraph)procEnv.graph).GetElementName(_elem); } else { _name = "?"; } _graph = procEnv.graph; if (_attrType.Kind == AttributeKind.SetAttr) { if (changeType == AttributeChangeType.PutElement) { IDictionary dict = (IDictionary)_elem.GetAttribute(_attrType.Name); if (dict.Contains(newValue)) { _undoOperation = UndoOperation.None; } else { _undoOperation = UndoOperation.RemoveElement; _value = newValue; } } else if (changeType == AttributeChangeType.RemoveElement) { IDictionary dict = (IDictionary)_elem.GetAttribute(_attrType.Name); if (dict.Contains(newValue)) { _undoOperation = UndoOperation.PutElement; _value = newValue; } else { _undoOperation = UndoOperation.None; } } else // Assign { Type keyType; Type valueType; IDictionary dict = ContainerHelper.GetDictionaryTypes( _elem.GetAttribute(_attrType.Name), out keyType, out valueType); IDictionary clonedDict = ContainerHelper.NewDictionary(keyType, valueType, dict); _undoOperation = UndoOperation.Assign; _value = clonedDict; } } else if (_attrType.Kind == AttributeKind.ArrayAttr) { if (changeType == AttributeChangeType.PutElement) { IList array = (IList)_elem.GetAttribute(_attrType.Name); _undoOperation = UndoOperation.RemoveElement; _keyOfValue = keyValue; } else if (changeType == AttributeChangeType.RemoveElement) { IList array = (IList)_elem.GetAttribute(_attrType.Name); _undoOperation = UndoOperation.PutElement; if (keyValue == null) { _value = array[array.Count - 1]; } else { _value = array[(int)keyValue]; _keyOfValue = keyValue; } } else if (changeType == AttributeChangeType.AssignElement) { IList array = (IList)_elem.GetAttribute(_attrType.Name); _undoOperation = UndoOperation.AssignElement; _value = array[(int)keyValue]; _keyOfValue = keyValue; } else // Assign { Type valueType; IList array = ContainerHelper.GetListType( _elem.GetAttribute(_attrType.Name), out valueType); IList clonedArray = ContainerHelper.NewList(valueType, array); _undoOperation = UndoOperation.Assign; _value = clonedArray; } } else if (_attrType.Kind == AttributeKind.DequeAttr) { if (changeType == AttributeChangeType.PutElement) { IDeque deque = (IDeque)_elem.GetAttribute(_attrType.Name); _undoOperation = UndoOperation.RemoveElement; _keyOfValue = keyValue; } else if (changeType == AttributeChangeType.RemoveElement) { IDeque deque = (IDeque)_elem.GetAttribute(_attrType.Name); _undoOperation = UndoOperation.PutElement; if (keyValue == null) { _value = deque.Front; } else { _value = deque[(int)keyValue]; _keyOfValue = keyValue; } } else if (changeType == AttributeChangeType.AssignElement) { IDeque deque = (IDeque)_elem.GetAttribute(_attrType.Name); _undoOperation = UndoOperation.AssignElement; _value = deque[(int)keyValue]; _keyOfValue = keyValue; } else // Assign { Type valueType; IDeque deque = ContainerHelper.GetDequeType( _elem.GetAttribute(_attrType.Name), out valueType); IDeque clonedDeque = ContainerHelper.NewDeque(valueType, deque); _undoOperation = UndoOperation.Assign; _value = clonedDeque; } } else if (_attrType.Kind == AttributeKind.MapAttr) { if (changeType == AttributeChangeType.PutElement) { IDictionary dict = (IDictionary)_elem.GetAttribute(_attrType.Name); if (dict.Contains(keyValue)) { if (dict[keyValue] == newValue) { _undoOperation = UndoOperation.None; } else { _undoOperation = UndoOperation.PutElement; _value = dict[keyValue]; _keyOfValue = keyValue; } } else { _undoOperation = UndoOperation.RemoveElement; _value = newValue; _keyOfValue = keyValue; } } else if (changeType == AttributeChangeType.RemoveElement) { IDictionary dict = (IDictionary)_elem.GetAttribute(_attrType.Name); if (dict.Contains(keyValue)) { _undoOperation = UndoOperation.PutElement; _value = dict[keyValue]; _keyOfValue = keyValue; } else { _undoOperation = UndoOperation.None; } } else if (changeType == AttributeChangeType.AssignElement) { IDictionary dict = (IDictionary)_elem.GetAttribute(_attrType.Name); if (dict[keyValue] == newValue) { _undoOperation = UndoOperation.None; } else { _undoOperation = UndoOperation.AssignElement; _value = dict[keyValue]; _keyOfValue = keyValue; } } else // Assign { Type keyType, valueType; IDictionary dict = ContainerHelper.GetDictionaryTypes( _elem.GetAttribute(_attrType.Name), out keyType, out valueType); IDictionary clonedDict = ContainerHelper.NewDictionary(keyType, valueType, dict); _undoOperation = UndoOperation.Assign; _value = clonedDict; } } else // Primitve Type Assign { _undoOperation = UndoOperation.Assign; _value = _elem.GetAttribute(_attrType.Name); } }
/// <summary> /// 由当前页面获取当前页面对应的 /// 撤销重做对象 /// </summary> private void GetCurrentUndo() { foreach (ListObject element in this.tabList) { if (CassViewGenerator.currentTabPage.Text == element.tabPage.Text) { CassViewGenerator.currentUndo = element.UndoAndRedo; } break; } }
public bool Add(UndoOperation operationType, int layerHandle, int shapeIndex) { return(_undoList.Add((tkUndoOperation)operationType, layerHandle, shapeIndex)); }
public void EndAtomicUndo () { atomicUndoLevel--; if (atomicUndoLevel == 0 && currentAtomicOperation != null) { currentAtomicOperation.redoNode = pieceTable.tree.Root.Clone (); currentAtomicOperation.redoCaret = new CaretPosition (Caret); undoStack.Push (currentAtomicOperation); redoStack.Clear (); currentAtomicOperation = null; } }
public void Add (UndoOperation operation) { operations.Add (operation); }
public AfterShapeEditEventArgs(UndoOperation operation, int layerHandle, int shapeIndex) : this(new _DMapEvents_AfterShapeEditEvent((tkUndoOperation)operation, layerHandle, shapeIndex)) { }
public UndoOperationEventArgs (UndoOperation operation) { this.Operation = operation; }
void InsertWithCursorOnLayer(EditorScript currentScript, InsertionCursorLayer layer, TaskCompletionSource<Script> tcs, IList<AstNode> nodes, IDocument target) { var doc = target as TextDocument; var op = new UndoOperation(layer, tcs); if (doc != null) { doc.UndoStack.Push(op); } layer.ScrollToInsertionPoint(); layer.Exited += delegate(object s, InsertionCursorEventArgs args) { doc.UndoStack.StartContinuedUndoGroup(); try { if (args.Success) { if (args.InsertionPoint.LineAfter == NewLineInsertion.None && args.InsertionPoint.LineBefore == NewLineInsertion.None && nodes.Count > 1) { args.InsertionPoint.LineAfter = NewLineInsertion.BlankLine; } var insertionPoint = args.InsertionPoint; if (nodes.All(n => n is EnumMemberDeclaration)) { insertionPoint.LineAfter = NewLineInsertion.Eol; insertionPoint.LineBefore = NewLineInsertion.None; } int offset = currentScript.GetCurrentOffset(insertionPoint.Location); int indentLevel = currentScript.GetIndentLevelAt(Math.Max(0, offset - 1)); foreach (var node in nodes.Reverse()) { var output = currentScript.OutputNode(indentLevel, node); var text = output.Text; if (node is EnumMemberDeclaration) { if (insertionPoint != layer.InsertionPoints.Last()) { text += ","; } else { var parentEnum = currentScript.context.RootNode.GetNodeAt(insertionPoint.Location, n => (n is TypeDeclaration) && ((TypeDeclaration)n).ClassType == ClassType.Enum) as TypeDeclaration; if (parentEnum != null) { var lastMember = parentEnum.Members.LastOrDefault(); if (lastMember != null) { var segment = currentScript.GetSegment(lastMember); currentScript.InsertText(segment.EndOffset, ","); } } } } int delta = insertionPoint.Insert(target, text); output.RegisterTrackedSegments(currentScript, delta + offset); } currentScript.FormatText(nodes); tcs.SetResult(currentScript); } layer.Dispose(); DisposeOnClose(); } finally { doc.UndoStack.EndUndoGroup(); } op.Reset(); }; }
/// <summary> /// 清空现有程序所占资源,并更新控件XML文件 /// </summary> private void ClearResource() { this.solutionTreeView.Nodes.Clear(); this.solutionTreeView.SelectedNode = null; this.addMenuService = false;//还原添加撤销重做功能 this.solutionTreeView.ImageList = solutionImageList; this.Text = this.Text.Split('_')[0];//清空窗口名种的工程名 ToolBoxServiceImpl.typeNameString = null; //更新ToolXML文件 ToolBoxServiceImpl.toolXML.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, PublicVariable.ToolConfigFileName)); this.tabControlView.TabPages.Clear(); this.tabList.Clear(); nodeList.Clear(); this.addressInfo.Clear();//初始化地址信息 this.IOlist.Clear();//初始化IO指令信息 StartComply(false);//初始化编译相关数组 CodeText = null;//初始化指令列表信息 this.controlfilteredPropertyGrid.SelectedObjects = null;//清空属性窗口 CassViewGenerator.PortInfoList = new List<ArrayList>();//切换工程后清空模块点名信息 CassViewGenerator.currentUndo = null; setEditEnable(false); }
public void Replace (int offset, int count, string value, ICSharpCode.NRefactory.Editor.AnchorMovementType anchorMovementType = AnchorMovementType.Default) { if (offset < 0) throw new ArgumentOutOfRangeException (nameof (offset), "must be > 0, was: " + offset); if (offset > TextLength) throw new ArgumentOutOfRangeException (nameof (offset), "must be <= TextLength(" + TextLength +"), was: " + offset); if (count < 0) throw new ArgumentOutOfRangeException (nameof (count), "must be > 0, was: " + count); if (ReadOnly) return; InterruptFoldWorker (); //int oldLineCount = LineCount; var args = new DocumentChangeEventArgs (offset, count > 0 ? GetTextAt (offset, count) : "", value, anchorMovementType); UndoOperation operation = null; bool endUndo = false; if (!isInUndo) { operation = new UndoOperation (args); if (currentAtomicOperation != null) { currentAtomicOperation.Add (operation); } else { OnBeginUndo (); undoStack.Push (operation); endUndo = true; } redoStack.Clear (); } if (value != null) EnsureSegmentIsUnfolded (offset, value.Length); OnTextReplacing (args); value = args.InsertedText.Text; cachedText = null; buffer = buffer.RemoveText(offset, count); if (!string.IsNullOrEmpty (value)) buffer = buffer.InsertText (offset, value); foldSegmentTree.UpdateOnTextReplace (this, args); splitter.TextReplaced (this, args); versionProvider.AppendChange (args); OnTextReplaced (args); if (endUndo) OnEndUndo (new UndoOperationEventArgs (operation)); }