本文整理汇总了C#中UndoManager类的典型用法代码示例。如果您正苦于以下问题:C# UndoManager类的具体用法?C# UndoManager怎么用?C# UndoManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UndoManager类属于命名空间,在下文中一共展示了UndoManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例3: Start
void Start()
{
playerSelectManager = GetComponent<PlayerSelectManager>();
gameManager = GetComponent<GameManager>();
undoManager = GetComponent<UndoManager>();
mapGenerator = GetComponent<MapGenerator>();
currentActionSelected = -1;
tileColorManager = GetComponent<TileColorManager>();
}
示例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;
}
示例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;
}
示例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();
};
}
示例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 ();
}
示例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();
}
示例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!");
}
}
示例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;
}
示例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);
}
示例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");
}
}
示例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!");
}
}
示例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");
}
}
示例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!");
}
}