Esempio n. 1
0
        public void DeleteExecute()
        {
            var dm = new TestItemDM()
            {
                Id = this.SelectedTestItem.Id, SomeDouble = this.SelectedTestItem.SomeDouble, Message = this.SelectedTestItem.Message
            };
            var vm       = new TestItemVM(dm);
            var hashCode = vm.GetHashCode();

            #region undo/redo
            var oldValue = dataModel.Message;

            var undo = new Action(() =>
            {
                obsTestList.Add(vm);
            });

            var redo = new Action(() =>
            {
                var deleteMe = obsTestList.FirstOrDefault(x => x.GetHashCode() == hashCode);
                obsTestList.Remove(deleteMe);
            });

            undoActions.Add(new List <Action>()
            {
                undo, redo
            });
            #endregion undo/redo

            obsTestList.Remove(SelectedTestItem);
        }
Esempio n. 2
0
        public void AddExecute()
        {
            var dm = new TestItemDM()
            {
                Id = Id, Message = Message, SomeDouble = SomeDouble
            };
            var vm = new TestItemVM(dm);

            vm.TestItemPropChanged += OnTestItemPropChanged;
            var hashCode = vm.GetHashCode();

            #region undo/redo
            var oldValue = dataModel.Message;

            var undo = new Action(() =>
            {
                var deleteMe = obsTestList.FirstOrDefault(x => x.GetHashCode() == hashCode);
                obsTestList.Remove(deleteMe);
            });

            var redo = new Action(() =>
            {
                obsTestList.Add(vm);
            });

            undoActions.Add(new List <Action>()
            {
                undo, redo
            });
            #endregion undo/redo

            obsTestList.Add(vm);
        }
Esempio n. 3
0
 public TestItemVM(TestItemVM vm)
 {
     this.dataModel = new TestItemDM()
     {
         Id = vm.Id, Message = vm.Message, SomeDouble = vm.SomeDouble
     };
 }
Esempio n. 4
0
 public TestItemVM(TestItemVM vm)
 {
     this.dataModel = new TestItemDM() { Id = vm.Id, Message = vm.Message, SomeDouble = vm.SomeDouble };
 }
Esempio n. 5
0
 public TestItemVM(TestItemDM dataModel, IList<Action> undoActions = null)
 {
     this.dataModel = dataModel;
 }
Esempio n. 6
0
        public void DeleteExecute()
        {
            var dm = new TestItemDM() { Id = this.SelectedTestItem.Id, SomeDouble = this.SelectedTestItem.SomeDouble, Message = this.SelectedTestItem.Message };
            var vm = new TestItemVM(dm);
            var hashCode = vm.GetHashCode();

            #region undo/redo
            var oldValue = dataModel.Message;

            var undo = new Action(() =>
            {
                obsTestList.Add(vm);
            });

            var redo = new Action(() =>
            {
                var deleteMe = obsTestList.FirstOrDefault(x => x.GetHashCode() == hashCode);
                obsTestList.Remove(deleteMe);
            });

            undoActions.Add(new List<Action>() { undo, redo });
            #endregion undo/redo

            obsTestList.Remove(SelectedTestItem);
        }
Esempio n. 7
0
        public void AddExecute()
        {
            var dm = new TestItemDM() { Id = Id, Message = Message, SomeDouble = SomeDouble };
            var vm = new TestItemVM(dm);
            vm.TestItemPropChanged += OnTestItemPropChanged;
            var hashCode = vm.GetHashCode();

            #region undo/redo
            var oldValue = dataModel.Message;

            var undo = new Action(() =>
            {
                var deleteMe = obsTestList.FirstOrDefault(x => x.GetHashCode() == hashCode);
                obsTestList.Remove(deleteMe);
            });

            var redo = new Action(() =>
            {
                obsTestList.Add(vm);
            });

            undoActions.Add(new List<Action>() { undo, redo });
            #endregion undo/redo

            obsTestList.Add(vm);
        }
Esempio n. 8
0
 public TestItemVM(TestItemDM dataModel, IList <Action> undoActions = null)
 {
     this.dataModel = dataModel;
 }