当前位置: 首页>>代码示例>>C#>>正文


C# UndoOperation类代码示例

本文整理汇总了C#中UndoOperation的典型用法代码示例。如果您正苦于以下问题:C# UndoOperation类的具体用法?C# UndoOperation怎么用?C# UndoOperation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UndoOperation类属于命名空间,在下文中一共展示了UndoOperation类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UndoOperationEventArgs

			public UndoOperationEventArgs (UndoOperation operation)
			{
				this.Operation = operation;
			}
开发者ID:telebovich,项目名称:monodevelop,代码行数:4,代码来源:TextDocument.cs

示例2: Insert

			public void Insert (int index, UndoOperation operation)
			{
				operations.Insert (index, operation);
			}
开发者ID:telebovich,项目名称:monodevelop,代码行数:4,代码来源:TextDocument.cs

示例3: Add

			public void Add (UndoOperation operation)
			{
				operations.Add (operation);
			}
开发者ID:telebovich,项目名称:monodevelop,代码行数:4,代码来源:TextDocument.cs

示例4: InsertWithCursorOnLayer

		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();
			};
		}
开发者ID:kristjan84,项目名称:SharpDevelop,代码行数:32,代码来源:EditorScript.cs

示例5: Replace

		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);
		}
开发者ID:telebovich,项目名称:monodevelop,代码行数:33,代码来源:TextDocument.cs

示例6: LGSPUndoAttributeChanged

        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);
//.........这里部分代码省略.........
开发者ID:jblomer,项目名称:GrGen.NET,代码行数:101,代码来源:lgspTransactionManagerUndoItems.cs

示例7: InterruptFoldWorker

		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);
		}
开发者ID:kangaroo,项目名称:monodevelop,代码行数:52,代码来源:Document.cs

示例8: BeginAtomicUndo

		public void BeginAtomicUndo ()
		{
			if (currentAtomicOperation == null) {
				currentAtomicOperation = new UndoOperation ();
				currentAtomicOperation.undoNode = pieceTable.tree.Root.Clone ();
				currentAtomicOperation.undoCaret = new CaretPosition (Caret);
			}
			atomicUndoLevel++;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:9,代码来源:HexEditorData.cs

示例9: Replace

		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));
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:46,代码来源:TextDocument.cs

示例10: InsertWithCursorOnLayer

		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();
			};
		}
开发者ID:linquize,项目名称:SharpDevelop,代码行数:57,代码来源:EditorScript.cs

示例11: NewProject

        /// <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;
                        }
//.........这里部分代码省略.........
开发者ID:alloevil,项目名称:A-embedded-image-processing-platform--,代码行数:101,代码来源:CassViewGenerator.cs

示例12: EndAtomicUndo

		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;
			}
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:12,代码来源:HexEditorData.cs

示例13: GetCurrentUndo

 /// <summary>
 /// 由当前页面获取当前页面对应的
 /// 撤销重做对象
 /// </summary>
 private void GetCurrentUndo()
 {
     foreach (ListObject element in this.tabList)
     {
         if (CassViewGenerator.currentTabPage.Text == element.tabPage.Text)
         {
             CassViewGenerator.currentUndo = element.UndoAndRedo;
         }
         break;
     }
 }
开发者ID:alloevil,项目名称:A-embedded-image-processing-platform--,代码行数:15,代码来源:CassViewGenerator.cs

示例14: ClearResource

        /// <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);
        }
开发者ID:alloevil,项目名称:A-embedded-image-processing-platform--,代码行数:26,代码来源:CassViewGenerator.cs


注:本文中的UndoOperation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。