• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# UndoManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: SetUp

        public void SetUp()
        {
            _comboBox = new ComboBox();
            _comboBox.SetValue(UndoManager.UndoScopeNameProperty, "ScopeName");
            _fakeVm = new FakeVm();
            var selected = new Binding("SelectedEnum")
            {
                Source = _fakeVm,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit,
                NotifyOnSourceUpdated = true,
                NotifyOnTargetUpdated = true,
                Mode = BindingMode.TwoWay
            };
            BindingOperations.SetBinding(_comboBox, Selector.SelectedItemProperty, selected);

            var itemsSource = new Binding("EnumValues")
            {
                Source = _fakeVm,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit,
                NotifyOnSourceUpdated = true,
                NotifyOnTargetUpdated = true,
                Mode = BindingMode.OneWay
            };
            BindingOperations.SetBinding(_comboBox, ItemsControl.ItemsSourceProperty, itemsSource);
            _comboBox.DataContext = _fakeVm;
            _undoManager = UndoManager.GetUndoManager(_comboBox);
        }
开发者ID:JohanLarsson,项目名称:UndoRedo,代码行数:27,代码来源:ComboBoxTests.cs


示例2: UndoPopup

		/// <summary>
		/// Initializes a new instance of <see cref="UndoPopup"/>.
		/// </summary>
		/// <param name="undoManager">The undo manager used to populate the action list.</param>
		/// <param name="mode">The mode the popup shows actions for.</param>
		public UndoPopup(UndoManager undoManager, UndoPopupMode mode)
			: base(new Control())
		{
			// Set some defaults on the host control.
			Control.Margin = Padding.Empty;
			Control.Size = new Size(400, 300);
			Control.TabStop = false;

			// Add the listbox.
			_listBox = new ListBox
			{
				Dock = DockStyle.Fill,
				BorderStyle = BorderStyle.None,
				IntegralHeight = false,
				SelectionMode = SelectionMode.MultiSimple,
				HorizontalScrollbar = true
			};
			_listBox.MouseDown += ListBox_MouseDown;
			_listBox.MouseMove += ListBox_MouseMove;

			Control.Controls.Add(_listBox);

			// Create tooltip.
			_tooltip = new ToolTip();

			_mode = mode;
			UndoManager = undoManager;
		}
开发者ID:skwasjer,项目名称:skwas.Forms,代码行数:33,代码来源:UndoPopup.cs


示例3: Start

 void Start()
 {
     playerSelectManager = GetComponent<PlayerSelectManager>();
     gameManager = GetComponent<GameManager>();
     undoManager = GetComponent<UndoManager>();
     mapGenerator = GetComponent<MapGenerator>();
     currentActionSelected = -1;
     tileColorManager = GetComponent<TileColorManager>();
 }
开发者ID:OutOfHandGames,项目名称:PROMNight,代码行数:9,代码来源:ActionManager.cs


示例4: UndoRedoAction

 public UndoRedoAction(UndoManager undoManager, int position, string oldText, string newText,
     int insertMarkPosition, int selectionBoundPosition)
 {
     this.undoManager = undoManager;
     Position = position;
     OldText = oldText;
     NewText = newText;
     this.insertMarkPosition = insertMarkPosition;
     this.selectionBoundPosition = selectionBoundPosition;
 }
开发者ID:izadi,项目名称:GtkEdit,代码行数:10,代码来源:UndoRedoAction.cs


示例5: UndoRedoButtons

 public UndoRedoButtons(UndoManager undoManager,
     ToolStripMenuItem undoMenuItem, ToolStripSplitButton undoButton,
     ToolStripMenuItem redoMenuItem, ToolStripSplitButton redoButton,
     Action<Action> runUIAction)
 {
     _undoManager = undoManager;
     _undoMenuItem = undoMenuItem;
     _undoButton = undoButton;
     _redoMenuItem = redoMenuItem;
     _redoButton = redoButton;
     _runUIAction = runUIAction;
 }
开发者ID:lgatto,项目名称:proteowizard,代码行数:12,代码来源:UndoRedoButtons.cs


示例6: UndoManagerVm

        public UndoManagerVm(string name, UndoManager manager)
        {
            Name = name;
            Manager = manager;

            UndoStack = new CollectionView(Manager.History.UndoStack);
            RedoStack = new CollectionView(Manager.History.RedoStack);
            manager.History.PropertyChanged += (sender, args) =>
            {
                UndoStack.Refresh();
                RedoStack.Refresh();
            };
        }
开发者ID:kevlut,项目名称:UndoRedo,代码行数:13,代码来源:UndoManagerVm.cs


示例7: MainWindow

 public MainWindow()
     : base(Gtk.WindowType.Toplevel)
 {
     Build ();
     _undoManager = new UndoManager ();
     View = new StandardDrawingView (this);
     _scrolledwindow.Add ((Widget) View);
     Tool = new SelectionTool (this);
     UndoManager.StackChanged += delegate {
         UpdateUndoRedoSensitiveness ();
     };
     ShowAll ();
 }
开发者ID:mono,项目名称:monohotdraw,代码行数:13,代码来源:MainWindow.cs


示例8: Start

    void Start()
    {
        initializeEntityLists();
		turnsCompleted = 0;
        gameManager = this;
        currentPlayers = new LinkedList<Entity>();
        currentTurn = JANITOR;
        cameraManager = GetComponent<CameraManager>();
        undoManager = GetComponent<UndoManager>();
        uiManager = GameObject.FindObjectOfType<UIManager>();
        aiStateMachine = GameObject.FindObjectOfType<AIStateMachine>();
        turnsLeft = turnsPerPlayer;
        updateEntitiesPresent();
    }
开发者ID:OutOfHandGames,项目名称:PROMNight,代码行数:14,代码来源:GameManager.cs


示例9: ExecuteXDocumentVariation

 public void ExecuteXDocumentVariation(XNode toReplace, XNode newValue)
 {
     XDocument xDoc = new XDocument(toReplace);
     XDocument xDocOriginal = new XDocument(xDoc);
     using (UndoManager undo = new UndoManager(xDoc))
     {
         undo.Group();
         using (EventsHelper docHelper = new EventsHelper(xDoc))
         {
             toReplace.ReplaceWith(newValue);
             docHelper.Verify(new XObjectChange[] { XObjectChange.Remove, XObjectChange.Add }, new XObject[] { toReplace, newValue });
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(xDoc, xDocOriginal), "Undo did not work!");
     }
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:16,代码来源:EventsReplace.cs


示例10: Execute

        /// <summary>
        /// Execution of the Action.  
        /// </summary>
        /// <returns>True:  Execution of the Action was successful</returns>
        public bool Execute(ActionCallingContext ctx)
        {
            using (UndoStep undo = new UndoManager().CreateUndoStep())
            {
                SelectionSet sel = new SelectionSet();

                //Make sure that terminals are ordered by designation
                var terminals = sel.Selection.OfType<Terminal>().OrderBy(t => t.Properties.FUNC_PINORTERMINALNUMBER.ToInt());
                if (terminals.Count() < 2)
                    throw new Exception("Must select at least 2 Terminals");

                //Create a list of terminals for each level. Those lists get added to a dictionnary
                //with the level as the key.
                Dictionary<int, List<Terminal>> levels = new Dictionary<int, List<Terminal>>();

                //Fill the dictionnary
                foreach (Terminal t in terminals)
                {
                    int level = t.Properties.FUNC_TERMINALLEVEL;

                    if (!levels.ContainsKey(level))
                        levels.Add(level, new List<Terminal>());

                    levels[level].Add(t);
                }

                var keys = levels.Keys.OrderBy(k => k);

                //Make sure that all levels have the same number of terminals
                int qty = levels.First().Value.Count;
                if (!levels.All(l => l.Value.Count == qty))
                    throw new Exception("There must be the same number of Terminals on each level");

                //Assign sort code by taking a terminal from each level in sequence
                int sortCode = 1;
                for (int i = 0; i < qty; i++)
                {
                    foreach (int j in keys)
                    {
                        levels[j][i].Properties.FUNC_TERMINALSORTCODE = sortCode++;
                    }
                }

            }

            return true;
        }
开发者ID:mrlucmorin,项目名称:Multi-Level-Terminals-API,代码行数:51,代码来源:MLTReorderAction.cs


示例11: SetUp

 public void SetUp()
 {
     _textBox = new TextBox();
     _textBox.SetValue(UndoManager.UndoScopeNameProperty, "ScopeName");
     _fakeVm = new FakeVm();
     var binding = new Binding("Value")
     {
         Source = _fakeVm,
         UpdateSourceTrigger = UpdateSourceTrigger.Explicit,
         NotifyOnSourceUpdated = true,
         NotifyOnTargetUpdated = true,
         Mode = BindingMode.TwoWay
     };
     BindingOperations.SetBinding(_textBox, TextBox.TextProperty, binding);
     _textBox.DataContext = _fakeVm;
     _undoManager = UndoManager.GetUndoManager(_textBox);
 }
开发者ID:JohanLarsson,项目名称:UndoRedo,代码行数:17,代码来源:SingleTextBoxTests.cs


示例12: ExecuteXElementVariation

 public void ExecuteXElementVariation(XElement toChange, XName newName)
 {
     XElement original = new XElement(toChange);
     using (UndoManager undo = new UndoManager(toChange))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(toChange))
         {
             toChange.Name = newName;
             Assert.True(newName.Namespace == toChange.Name.Namespace, "Namespace did not change");
             Assert.True(newName.LocalName == toChange.Name.LocalName, "LocalName did not change");
             eHelper.Verify(XObjectChange.Name, toChange);
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(toChange, original), "Undo did not work");
     }
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:17,代码来源:EventsName.cs


示例13: ExecuteXDocumentVariation

 public void ExecuteXDocumentVariation(XNode[] content, int index)
 {
     XDocument xDoc = new XDocument(content);
     XDocument xDocOriginal = new XDocument(xDoc);
     XNode toRemove = xDoc.Nodes().ElementAt(index);
     using (UndoManager undo = new UndoManager(xDoc))
     {
         undo.Group();
         using (EventsHelper docHelper = new EventsHelper(xDoc))
         {
             toRemove.Remove();
             docHelper.Verify(XObjectChange.Remove, toRemove);
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(xDoc, xDocOriginal), "Undo did not work!");
     }
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:17,代码来源:EventsRemove.cs


示例14: XProcessingInstructionPIVariation

 public void XProcessingInstructionPIVariation()
 {
     XProcessingInstruction toChange = new XProcessingInstruction("target", "data");
     XProcessingInstruction original = new XProcessingInstruction(toChange);
     using (UndoManager undo = new UndoManager(toChange))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(toChange))
         {
             toChange.Target = "newTarget";
             Assert.True(toChange.Target.Equals("newTarget"), "Name did not change");
             eHelper.Verify(XObjectChange.Name, toChange);
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(toChange, original), "Undo did not work");
     }
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:17,代码来源:EventsName.cs


示例15: ExecuteXElementVariation

 public void ExecuteXElementVariation(XNode toReplace, XNode newValue)
 {
     XElement xElem = new XElement("root", toReplace);
     XElement xElemOriginal = new XElement(xElem);
     using (UndoManager undo = new UndoManager(xElem))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(xElem))
         {
             toReplace.ReplaceWith(newValue);
             xElem.Verify();
             eHelper.Verify(new XObjectChange[] { XObjectChange.Remove, XObjectChange.Add }, new XObject[] { toReplace, newValue });
         }
         undo.Undo();
         Assert.True(xElem.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
         Assert.True(xElem.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
     }
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:18,代码来源:EventsReplace.cs


示例16: ExecuteXDocumentVariation

 public void ExecuteXDocumentVariation(XNode toReplace)
 {
     XNode newValue = new XText(" ");
     XDocument xDoc = new XDocument(toReplace);
     XDocument xDocOriginal = new XDocument(xDoc);
     using (UndoManager undo = new UndoManager(xDoc))
     {
         undo.Group();
         using (EventsHelper docHelper = new EventsHelper(xDoc))
         {
             xDoc.ReplaceNodes(newValue);
             Assert.True(xDoc.Nodes().Count() == 1, "Not all content were removed");
             Assert.True(Object.ReferenceEquals(xDoc.FirstNode, newValue), "Did not replace correctly");
             docHelper.Verify(new XObjectChange[] { XObjectChange.Remove, XObjectChange.Add }, new XObject[] { toReplace, newValue });
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(xDoc, xDocOriginal), "Undo did not work!");
     }
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:19,代码来源:EventsReplace.cs


示例17: ExecuteXElementVariation

 public void ExecuteXElementVariation(XNode[] content, int index)
 {
     XElement xElem = new XElement("root", content);
     XNode toRemove = xElem.Nodes().ElementAt(index);
     XElement xElemOriginal = new XElement(xElem);
     using (UndoManager undo = new UndoManager(xElem))
     {
         undo.Group();
         using (EventsHelper elemHelper = new EventsHelper(xElem))
         {
             toRemove.Remove();
             xElem.Verify();
             elemHelper.Verify(XObjectChange.Remove, toRemove);
         }
         undo.Undo();
         Assert.True(xElem.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
         Assert.True(xElem.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
     }
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:19,代码来源:EventsRemove.cs


示例18: ShowList

        /// <summary>
        /// Populates the list box with the list of undo/redo actions, and displays the form
        /// directly below the tool strip button.
        /// </summary>
        /// <param name="dropDownButton">Tool strip button under which this form should be displayed</param>
        /// <param name="undo">true if this is "undo", false for "redo"</param>
        /// <param name="undoManager">the UndoManager</param>
        public void ShowList(ToolStripDropDownItem dropDownButton, bool undo, UndoManager undoManager)
        {
            Point location =
                dropDownButton.Owner.PointToScreen(new Point(dropDownButton.Bounds.Left, dropDownButton.Bounds.Bottom));
            Left = location.X;
            Top = location.Y;
            _undo = undo;
            _undoManager = undoManager;
            listBox.Items.Clear();
            IEnumerable<String> descriptions = undo ? undoManager.UndoDescriptions : undoManager.RedoDescriptions;
            foreach (String description in descriptions)
            {
                listBox.Items.Add(description);
            }
            UpdateSelectedIndex(0);

            Height = listBox.ItemHeight * Math.Min(MAX_DISPLAY_ITEMS, listBox.Items.Count) + label.Height + TOTAL_BORDER_WIDTH;
            Show(dropDownButton.Owner);
            listBox.Focus();
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:27,代码来源:UndoRedoList.cs


示例19: ExecuteXDocumentVariation

 public void ExecuteXDocumentVariation(XNode[] toAdd, XNode contextNode)
 {
     IEnumerable<XNode> toAddList = toAdd.OfType<XNode>();
     XDocument xDoc = new XDocument(contextNode);
     XDocument xDocOriginal = new XDocument(xDoc);
     using (UndoManager undo = new UndoManager(xDoc))
     {
         undo.Group();
         using (EventsHelper docHelper = new EventsHelper(xDoc))
         {
             using (EventsHelper nodeHelper = new EventsHelper(contextNode))
             {
                 contextNode.AddBeforeSelf(toAdd);
                 Assert.True(toAddList.SequenceEqual(contextNode.NodesBeforeSelf(), XNode.EqualityComparer), "Nodes not added correctly!");
                 nodeHelper.Verify(0);
             }
             docHelper.Verify(XObjectChange.Add, toAdd);
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(xDoc, xDocOriginal), "Undo did not work!");
     }
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:22,代码来源:EventsAdd.cs


示例20: UIEditor

        public UIEditor()
        {
            Space = new WindowSpace();

            UndoManager = new UndoManager();

            ViewModel = new MainViewModel(this);
            ViewModel.Resolution = new Size(1024, 768);
            ViewModel.OnPropertyChanged(ViewModel_SelectedGadget, "SelectedGadget");
            ViewModel.OnPropertyChanged(ViewModel_ChangeFile, "UIFile");

            InitializeComponent();

            ViewsContainer.SizeChanged += ViewsContainer_SizeChanged;
            ViewsContainer.MouseDown += ViewsContainer_MouseDown;

            IsVisibleChanged += (o, e) => {
                if (dirty) Load();
            };

            KeyDown += MainWindow_KeyDown;
        }
开发者ID:Weesals,项目名称:ModHQ,代码行数:22,代码来源:UIEditor.xaml.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UndoOperation类代码示例发布时间:2022-05-24
下一篇:
C# UncheckedStatement类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap