Inheritance: System.ComponentModel.NotifyBase
Exemplo n.º 1
0
        public MoveAtomCommand(Atom atom, double newX, double newY)
        {
            this.atom = atom;
            this.newX = newX;
            this.newY = newY;

            oldX = atom.X;
            oldY = atom.Y;
        }
Exemplo n.º 2
0
 public AddAtomCommand(ObservableCollection<Atom> atoms, Atom atom)
 {
     this.atoms = atoms;
     this.atom = atom;
 }
Exemplo n.º 3
0
        public void TestRemoveSelectionCommand()
        {
            ViewModel vm = new ViewModel();

            //prepare data
            Atom atom1 = new Atom(1);
            Atom atom2 = new Atom(1);
            Atom atom3 = new Atom(1);

            Binding binding1 = new Binding(atom1, atom2);
            Binding binding2 = new Binding(atom2, atom3);

            vm.Atoms.Add(atom1);
            vm.Atoms.Add(atom2);
            vm.Atoms.Add(atom3);

            vm.Bindings.Add(binding1);
            vm.Bindings.Add(binding2);

            //execute
            vm.SelectAllCommand.Execute(null);
            vm.RemoveModelCommand.Execute(null);

            //verify
            //selection removed
            Assert.AreEqual(0, vm.Atoms.Count);
            Assert.AreEqual(0, vm.Bindings.Count);

            //undo
            vm.UndoCommand.Execute(null);

            //verify undo
            Assert.AreEqual(3, vm.Atoms.Count);
            Assert.AreEqual(2, vm.Bindings.Count);

            //redo
            vm.RedoCommand.Execute(null);

            //verify redo
            Assert.AreEqual(0, vm.Atoms.Count);
            Assert.AreEqual(0, vm.Bindings.Count);
        }