Пример #1
0
        public ManualSolverForm(ProblemSpec problem)
        {
            Model = new ManualSolverModel(problem);
            var copy = new ToolStripMenuItem("Reflect copy", null, (sender, args) => ChangeModel(Model.StartOperation(PendingOperationType.ReflectCopy)));

            copy.ShortcutKeys = Keys.Q | Keys.Control;
            var move = new ToolStripMenuItem("Reflect move", null, (sender, args) => ChangeModel(Model.StartOperation(PendingOperationType.ReflectMove)));

            move.ShortcutKeys = Keys.W | Keys.Control;
            var cancel = new ToolStripMenuItem("Cancel", null, (sender, args) => ChangeModel(Model.CancelPendingOperation()));
            var undo   = new ToolStripMenuItem("Undo", null, (sender, args) => Undo());

            undo.ShortcutKeys = Keys.Z | Keys.Control;
            var redo = new ToolStripMenuItem("Redo", null, (sender, args) => Redo());

            redo.ShortcutKeys = Keys.Z | Keys.Control | Keys.Shift;
            var border    = new ToolStripMenuItem("MarkAsBorder", null, (sender, args) => ChangeModel(Model.MarkAsBorder()));
            var noborder  = new ToolStripMenuItem("MarkAsNOTBorder", null, (sender, args) => ChangeModel(Model.MarkAsNoBorder()));
            var solve     = new ToolStripMenuItem("Solve", null, SolveClick);
            var selectAll = new ToolStripMenuItem("Select All", null, (sender, args) => ChangeModel(Model.SelectAll()));

            selectAll.ShortcutKeys = Keys.A | Keys.Control;
            var menu = new ToolStrip(selectAll, copy, move, cancel, undo, redo, border, noborder, solve);

            WindowState = FormWindowState.Maximized;
            this.Controls.Add(menu);
        }
Пример #2
0
 private void Redo()
 {
     if (!undone.Any())
     {
         return;
     }
     done.Push(Model);
     Model = undone.Pop();
     Invalidate();
 }
Пример #3
0
 private void Undo()
 {
     if (!done.Any())
     {
         return;
     }
     undone.Push(Model);
     Model = done.Pop();
     Invalidate();
 }
Пример #4
0
 private void ChangeModel(ManualSolverModel newModel)
 {
     if (newModel == Model)
     {
         return;
     }
     if (Model != null)
     {
         done.Push(Model);
     }
     undone.Clear();
     Model = newModel;
     Invalidate();
 }