示例#1
0
		private UndoRedo<int> m_Prj_Sheet_ID;// = new UndoRedo<int>();
		
		
		
		#endregion 私有成员
		
		#region 构造函数
					
		/// <summary>
		/// 默认构造函数
		/// <summary>
		public Cld_FCBlock():base(){
			this.m_ID = new UndoRedo<int>(-1);
			this.m_ID.Owner = this;
			this.m_Cld_FCInput_List = new UndoRedo<UndoRedoList<EntityBase>>(null);
			this.m_Cld_FCInput_List.Owner = this;
			this.m_Cld_FCOutput_List = new UndoRedo<UndoRedoList<EntityBase>>(null);
			this.m_Cld_FCOutput_List.Owner = this;
			this.m_Cld_FCParameter_List = new UndoRedo<UndoRedoList<EntityBase>>(null);
			this.m_Cld_FCParameter_List.Owner = this;
			this.m_AlgName = new UndoRedo<string>(String.Empty);
			this.m_AlgName.Owner = this;
			this.m_Sequence = new UndoRedo<int>(-1);
			this.m_Sequence.Owner = this;
			this.m_FunctionName = new UndoRedo<string>(String.Empty);
			this.m_FunctionName.Owner = this;
			this.m_X_Y = new UndoRedo<string>(String.Empty);
			this.m_X_Y.Owner = this;
			this.m_SymbolName = new UndoRedo<string>(String.Empty);
			this.m_SymbolName.Owner = this;
			this.m_Description = new UndoRedo<string>(String.Empty);
			this.m_Description.Owner = this;
			this.m_Prj_Controller_ID = new UndoRedo<int>(-1);
			this.m_Prj_Controller_ID.Owner = this;
			this.m_Prj_Controller = new UndoRedo<Prj_Controller>(null);
			this.m_Prj_Controller.Owner = this;
			this.m_Prj_Document_ID = new UndoRedo<int>(-1);
			this.m_Prj_Document_ID.Owner = this;
			this.m_Prj_Document = new UndoRedo<Prj_Document>(null);
			this.m_Prj_Document.Owner = this;
			this.m_Prj_Sheet_ID = new UndoRedo<int>(-1);
			this.m_Prj_Sheet_ID.Owner = this;
			this.m_Prj_Sheet = new UndoRedo<Prj_Sheet>(null);
			this.m_Prj_Sheet.Owner = this;
		}
		private UndoRedo<string> m_Type;// = new UndoRedo<string>();
		
		
		
		#endregion 私有成员
		
		#region 构造函数
					
		/// <summary>
		/// 默认构造函数
		/// <summary>
		public Meta_FCMaster():base(){
			this.m_ID = new UndoRedo<int>(-1);
			this.m_ID.Owner = this;
			this.m_Meta_FCDetail_List = new UndoRedo<UndoRedoList<EntityBase>>(null);
			this.m_Meta_FCDetail_List.Owner = this;
			this.m_FunctionName = new UndoRedo<string>(String.Empty);
			this.m_FunctionName.Owner = this;
			this.m_FunctionCode = new UndoRedo<int>(-1);
			this.m_FunctionCode.Owner = this;
			this.m_Description = new UndoRedo<string>(String.Empty);
			this.m_Description.Owner = this;
			this.m_Function = new UndoRedo<string>(String.Empty);
			this.m_Function.Owner = this;
			this.m_DIAG = new UndoRedo<int>(-1);
			this.m_DIAG.Owner = this;
			this.m_InputCount = new UndoRedo<int>(-1);
			this.m_InputCount.Owner = this;
			this.m_SpecCount = new UndoRedo<int>(-1);
			this.m_SpecCount.Owner = this;
			this.m_OutPutCount = new UndoRedo<int>(-1);
			this.m_OutPutCount.Owner = this;
			this.m_InternalCount = new UndoRedo<int>(-1);
			this.m_InternalCount.Owner = this;
			this.m_FCLength = new UndoRedo<short>(-1);
			this.m_FCLength.Owner = this;
			this.m_Type = new UndoRedo<string>(String.Empty);
			this.m_Type.Owner = this;
		}
        public void BasicScenario()
        {
            var i1 = new UndoRedo<int>(0);
            var i2 = new UndoRedo<int>(0);
            var i3 = new UndoRedo<int>(0);

            using (UndoRedoManager.Start("1"))
            {
                i1.Value = 1;
                i2.Value = 1;
                i3.Value = 1;
                using (UndoRedoManager.Start("2"))
                {
                    i2.Value = 2;
                    i3.Value = 2;
                    UndoRedoManager.Commit();
                }
                Assert.AreEqual(i1.Value, 1);
                Assert.AreEqual(i2.Value, 2);
                Assert.AreEqual(i3.Value, 2);

                i3.Value = 3;

                UndoRedoManager.Commit();
            }
            Assert.AreEqual(i1.Value, 1);
            Assert.AreEqual(i2.Value, 2);
            Assert.AreEqual(i3.Value, 3);
        }
示例#4
0
        public void SequenceOf2Areas()
        {
            var area1 = new UndoRedoArea("area1");
            var area2 = new UndoRedoArea("area2");

            var i1 = new UndoRedo<int>(0);
            var i2 = new UndoRedo<int>(0);

            using (area1.Start("command1"))
            {
                i1.Value = 1;
                area1.Commit();
            }

            using (area2.Start("command2"))
            {
                i2.Value = 2;
                area2.Commit();
            }

            Assert.AreEqual(1, i1.Value, "value from area1 is wrong");
            Assert.AreEqual(2, i2.Value, "value from area2 is wrong");

            area1.Undo();
            area2.Undo();

            Assert.AreEqual(0, i1.Value, "value from area1 is wrong");
            Assert.AreEqual(0, i2.Value, "value from area2 is wrong");

            area1.Redo();
            area2.Redo();

            Assert.AreEqual(1, i1.Value, "value from area1 is wrong");
            Assert.AreEqual(2, i2.Value, "value from area2 is wrong");
        }
        public void CommitCancel_Commit()
        {
            var i1 = new UndoRedo<int>(0);
            var i2 = new UndoRedo<int>(0);

            using (UndoRedoManager.Start("1"))
            {
                i1.Value = 1;
                i2.Value = 1;
                using (UndoRedoManager.Start("2"))
                {
                    i1.Value = 2;
                    UndoRedoManager.Commit();
                }
                Assert.AreEqual(i1.Value, 2);
                Assert.AreEqual(i2.Value, 1);
                using (UndoRedoManager.Start("3"))
                {
                    i1.Value = 3;
                    i2.Value = 3;
                    Assert.AreEqual(i1.Value, 3);
                    Assert.AreEqual(i2.Value, 3);
                }
                Assert.AreEqual(i1.Value, 2);
                Assert.AreEqual(i2.Value, 1);

                UndoRedoManager.Commit();
            }
            Assert.AreEqual(i1.Value, 2);
            Assert.AreEqual(i2.Value, 1);
        }
示例#6
0
 public void ExtendedFlow()
 {
     var i = new UndoRedo<int>();
     var o = new object();
     // clear history
     UndoRedoManager.ClearHistory();
     // first affined command
     UndoRedoManager.Start("Command 1", o);
     i.Value = 1;
     UndoRedoManager.Commit();
     // second affined command
     UndoRedoManager.Start("Command 1", o);
     i.Value = 2;
     UndoRedoManager.Commit();
     // invisible command
     UndoRedoManager.StartInvisible("Command 2");
     i.Value = 3;
     UndoRedoManager.Commit();
     string s = UndoRedoManager.GetLog();
     var sample =
     @"[Clear History]
     'Command 1'
     [Commit]
     'Command 1' (affined)
     [Commit]
     'Command 2' (invisible)
     [Commit]
     ";
     Assert.AreEqual(sample, s);
 }
示例#7
0
		private UndoRedo<int> m_Prj_Controller_ID;// = new UndoRedo<int>();
		
		
		
		#endregion 私有成员
		
		#region 构造函数
					
		/// <summary>
		/// 默认构造函数
		/// <summary>
		public Cld_FCInput():base(){
			this.m_ID = new UndoRedo<int>(-1);
			this.m_ID.Owner = this;
			this.m_PinName = new UndoRedo<string>(String.Empty);
			this.m_PinName.Owner = this;
			this.m_PointName = new UndoRedo<string>(String.Empty);
			this.m_PointName.Owner = this;
			this.m_InitialValue = new UndoRedo<string>(String.Empty);
			this.m_InitialValue.Owner = this;
			this.m_Point = new UndoRedo<string>(String.Empty);
			this.m_Point.Owner = this;
			this.m_Visible = new UndoRedo<bool>(false);
			this.m_Visible.Owner = this;
			this.m_Description = new UndoRedo<string>(String.Empty);
			this.m_Description.Owner = this;
			this.m_Cld_FCBlock_ID = new UndoRedo<int>(-1);
			this.m_Cld_FCBlock_ID.Owner = this;
			this.m_Cld_FCBlock = new UndoRedo<Cld_FCBlock>(null);
			this.m_Cld_FCBlock.Owner = this;
			this.m_Prj_Sheet_ID = new UndoRedo<int>(-1);
			this.m_Prj_Sheet_ID.Owner = this;
			this.m_Prj_Sheet = new UndoRedo<Prj_Sheet>(null);
			this.m_Prj_Sheet.Owner = this;
			this.m_Prj_Document_ID = new UndoRedo<int>(-1);
			this.m_Prj_Document_ID.Owner = this;
			this.m_Prj_Document = new UndoRedo<Prj_Document>(null);
			this.m_Prj_Document.Owner = this;
			this.m_Prj_Controller_ID = new UndoRedo<int>(-1);
			this.m_Prj_Controller_ID.Owner = this;
			this.m_Prj_Controller = new UndoRedo<Prj_Controller>(null);
			this.m_Prj_Controller.Owner = this;
		}
示例#8
0
        public void StandardFlow()
        {
            var i = new UndoRedo<int>();
            // commits
            UndoRedoManager.Start("Command 1");
            i.Value = 1;
            UndoRedoManager.Commit();

            UndoRedoManager.Start("Command 2");
            i.Value = 2;
            UndoRedoManager.Commit();
            // cancel
            UndoRedoManager.Start("Command 3");
            i.Value = 3;
            UndoRedoManager.Cancel();
            // undo
            UndoRedoManager.Undo();
            // redo
            UndoRedoManager.Redo();

            string s = UndoRedoManager.GetLog();
            var sample =
            @"'Command 1'
            [Commit]
            'Command 2'
            [Commit]
            'Command 3'
            [Cancel]
            [Undo 'Command 2']
            [Redo 'Command 2']
            ";
            Assert.AreEqual(sample, s);
        }
示例#9
0
        public void AutoCancel()
        {
            var i = new UndoRedo<int>(0);

            // "successful" scenario
            using (UndoRedoManager.Start(""))
            {
                i.Value = 1;
                UndoRedoManager.Commit();
            }
            Assert.AreEqual(1, i.Value);

            // "failed" scenario
            try
            {
                using (UndoRedoManager.Start(""))
                {
                    i.Value = 2;
                    throw new Exception("Some exception");
                    // this code is never reached in this scenario (compiler warning is disabled)
                    #pragma warning disable
                    UndoRedoManager.Commit();
                    #pragma warning restore
                }
            }
            catch { }
            Assert.AreEqual(1, i.Value);
        }
示例#10
0
        public void Commit_Cancel()
        {
            var i1 = new UndoRedo<int>(0);
            var i2 = new UndoRedo<int>(0);

            // do test twice to exclude interference
            Commit_Cancel(i1, i2);
            Commit_Cancel(i1, i2);
        }
示例#11
0
 public void InitForText()
 {
     ConfigurationManager.Language = "text";
     Indentation.ShowGuides        = false;
     MatchBraces       = false;
     IsBraceMatching   = false;
     Lexing.Lexer      = Lexer.Automatic;
     Folding.IsEnabled = false;
     Lexing.SetProperty("fold", "0");
     Lexing.SetProperty("fold.html", "0");
     Margins[0].Width = 40;
     Margins[1].Width = 16;
     Margins[2].Width = 40;
     UndoRedo.EmptyUndoBuffer();
     Modified = false;
 }
示例#12
0
        public void CustomLogging()
        {
            var i = new UndoRedo<int>();
            UndoRedoManager.Start("Command 1");
            i.Value = 1;
            UndoRedoManager.Log("i = " + i.Value);
            UndoRedoManager.Commit();

            string s = UndoRedoManager.GetLog();
            var sample =
            @"'Command 1'
            i = 1
            [Commit]
            ";
            Assert.AreEqual(sample, s);
        }
示例#13
0
 public void TestIgnoreRepetitiveActions()
 {
     var list = new PersistentList<string>();
     var undoRedo = new UndoRedo<PersistentList<string>>(list);
     undoRedo.NewAction("add");
     list.Add("1");
     undoRedo.NewAction("add");
     list.Add("2");
     undoRedo.Undo();
     Assert.True(list.Count == 1);
     undoRedo.IgnoreRepetitiveActions = true;
     undoRedo.NewAction("add");
     list.Add("2");
     undoRedo.Undo();
     Assert.True(list.Count == 0);
 }
示例#14
0
		private UndoRedo<int> m_Prj_Project_ID;// = new UndoRedo<int>();
		
		
		
		#endregion 私有成员
		
		#region 构造函数
					
		/// <summary>
		/// 默认构造函数
		/// <summary>
		public Prj_Network():base(){
			this.m_ID = new UndoRedo<int>(-1);
			this.m_ID.Owner = this;
			this.m_Prj_Unit_List = new UndoRedo<UndoRedoList<EntityBase>>(null);
			this.m_Prj_Unit_List.Owner = this;
			this.m_NetworkAddress = new UndoRedo<string>(String.Empty);
			this.m_NetworkAddress.Owner = this;
			this.m_NetworkName = new UndoRedo<string>(String.Empty);
			this.m_NetworkName.Owner = this;
			this.m_Description = new UndoRedo<string>(String.Empty);
			this.m_Description.Owner = this;
			this.m_Prj_Project_ID = new UndoRedo<int>(-1);
			this.m_Prj_Project_ID.Owner = this;
			this.m_Prj_Project = new UndoRedo<Prj_Project>(null);
			this.m_Prj_Project.Owner = this;
		}
示例#15
0
        private UndoRedo <int> m_Prj_Project_ID;       // = new UndoRedo<int>();



        #endregion 私有成员

        #region 构造函数

        /// <summary>
        /// 默认构造函数
        /// <summary>
        public Prj_Network() : base()
        {
            this.m_ID                   = new UndoRedo <int>(-1);
            this.m_ID.Owner             = this;
            this.m_Prj_Unit_List        = new UndoRedo <UndoRedoList <EntityBase> >(null);
            this.m_Prj_Unit_List.Owner  = this;
            this.m_NetworkAddress       = new UndoRedo <string>(String.Empty);
            this.m_NetworkAddress.Owner = this;
            this.m_NetworkName          = new UndoRedo <string>(String.Empty);
            this.m_NetworkName.Owner    = this;
            this.m_Description          = new UndoRedo <string>(String.Empty);
            this.m_Description.Owner    = this;
            this.m_Prj_Project_ID       = new UndoRedo <int>(-1);
            this.m_Prj_Project_ID.Owner = this;
            this.m_Prj_Project          = new UndoRedo <Prj_Project>(null);
            this.m_Prj_Project.Owner    = this;
        }
        public FrameworkElement ResolveEditor(PropertyItem propertyItem)
        {
            Binding binding = new Binding("Value")
            {
                Source = propertyItem,
                ValidatesOnExceptions = true,
                ValidatesOnDataErrors = true,
                Mode = BindingMode.OneWay
            };

            BindingOperations.SetBinding(this, ValueProperty, binding);

            variables    = new UndoRedo <VariableCollection>(Value.Clone() as VariableCollection);
            textbox.Text = string.Format("[{0}]", Value.Count());

            return(this);
        }
示例#17
0
        public void AddActionTest()
        {
            // arrange
            byte   row      = 1;
            byte   column   = 1;
            byte   oldValue = 0;
            byte   value    = 3;
            string method   = "manual";
            var    undoRedo = new UndoRedo();

            // act
            undoRedo.AddAction(row, column, oldValue, value, method);
            undoRedo.AddAction(2, 2, 0, 4, "manual");

            // assert
            Assert.AreEqual(2, undoRedo.UndoLength());
        }
示例#18
0
 //-----------------------------------------------------------------------
 public void MoveItem(int src, int dst)
 {
     UndoRedo.ApplyDoUndo(
         delegate
     {
         Children.Move(src, dst);
         RaisePropertyChangedEvent("HasContent");
         RaisePropertyChangedEvent("Description");
     },
         delegate
     {
         Children.Move(dst, src);
         RaisePropertyChangedEvent("HasContent");
         RaisePropertyChangedEvent("Description");
     },
         "Moving item " + src + " to " + dst + " in collection " + Name);
 }
示例#19
0
		private UndoRedo<int> m_Prj_Network_ID;// = new UndoRedo<int>();
		
		
		
		#endregion 私有成员
		
		#region 构造函数
					
		/// <summary>
		/// 默认构造函数
		/// <summary>
		public Prj_Unit():base(){
			this.m_ID = new UndoRedo<int>(-1);
			this.m_ID.Owner = this;
			this.m_Prj_Controller_List = new UndoRedo<UndoRedoList<EntityBase>>(null);
			this.m_Prj_Controller_List.Owner = this;
			this.m_UnitAddress = new UndoRedo<string>(String.Empty);
			this.m_UnitAddress.Owner = this;
			this.m_UnitName = new UndoRedo<string>(String.Empty);
			this.m_UnitName.Owner = this;
			this.m_NetworkAddress = new UndoRedo<string>(String.Empty);
			this.m_NetworkAddress.Owner = this;
			this.m_Description = new UndoRedo<string>(String.Empty);
			this.m_Description.Owner = this;
			this.m_Prj_Network_ID = new UndoRedo<int>(-1);
			this.m_Prj_Network_ID.Owner = this;
			this.m_Prj_Network = new UndoRedo<Prj_Network>(null);
			this.m_Prj_Network.Owner = this;
		}
示例#20
0
 //todo V - Add
 public void AddObjectInstant(Helper.Shape shape)
 {
     ShapeToDraw = shape;
     if (shape != Helper.Shape.ConnectionLine)
     {
         if (ShapeToDraw == Helper.Shape.Start)
         {
             if (!CheckIsStartExist())
             {
                 CanvObj.MyAdd(new Point(Width * 10 / 100, Height * 10 / 100), ShapeToDraw);
                 UndoRedo.Push(new List <UndoRedoItem>()
                 {
                     new UndoRedoItem(MyAction.Add, CanvObj[0], null)
                 });
             }
         }
         else if (ShapeToDraw == Helper.Shape.End)
         {
             if (!CheckIsEndExist())
             {
                 CanvObj.MyAdd(new Point(Width * 10 / 100, Height * 10 / 100), ShapeToDraw);
                 UndoRedo.Push(new List <UndoRedoItem>()
                 {
                     new UndoRedoItem(MyAction.Add, CanvObj[0], null)
                 });
             }
         }
         else
         {
             CanvObj.MyAdd(new Point(Width * 10 / 100, Height * 10 / 100), ShapeToDraw);
             UndoRedo.Push(new List <UndoRedoItem>()
             {
                 new UndoRedoItem(MyAction.Add, CanvObj[0], null)
             });
         }
         ShapeToDraw = Helper.Shape.Nothing;
         Invalidate();
     }
     else
     {
         MessageBox.Show(
             "Niestety linia nie może zostać dodana poprzez 2xLPM. Należy wybrać linie a następnie wskazać blok początkowy a następnie blok końcowy by powstało połączenie między blokami");
     }
 }
示例#21
0
        private UndoRedo <int> m_Sequence;       // = new UndoRedo<int>();



        #endregion 私有成员

        #region 构造函数

        /// <summary>
        /// 默认构造函数
        /// <summary>
        public Prj_Controller() : base()
        {
            this.m_ID                         = new UndoRedo <int>(-1);
            this.m_ID.Owner                   = this;
            this.m_Cld_Constant_List          = new UndoRedo <UndoRedoList <EntityBase> >(null);
            this.m_Cld_Constant_List.Owner    = this;
            this.m_Cld_FCBlock_List           = new UndoRedo <UndoRedoList <EntityBase> >(null);
            this.m_Cld_FCBlock_List.Owner     = this;
            this.m_Cld_FCInput_List           = new UndoRedo <UndoRedoList <EntityBase> >(null);
            this.m_Cld_FCInput_List.Owner     = this;
            this.m_Cld_FCOutput_List          = new UndoRedo <UndoRedoList <EntityBase> >(null);
            this.m_Cld_FCOutput_List.Owner    = this;
            this.m_Cld_FCParameter_List       = new UndoRedo <UndoRedoList <EntityBase> >(null);
            this.m_Cld_FCParameter_List.Owner = this;
            this.m_Cld_Graphic_List           = new UndoRedo <UndoRedoList <EntityBase> >(null);
            this.m_Cld_Graphic_List.Owner     = this;
            this.m_Cld_Signal_List            = new UndoRedo <UndoRedoList <EntityBase> >(null);
            this.m_Cld_Signal_List.Owner      = this;
            this.m_Prj_Document_List          = new UndoRedo <UndoRedoList <EntityBase> >(null);
            this.m_Prj_Document_List.Owner    = this;
            this.m_Prj_Sheet_List             = new UndoRedo <UndoRedoList <EntityBase> >(null);
            this.m_Prj_Sheet_List.Owner       = this;
            this.m_ControllerAddress          = new UndoRedo <string>(String.Empty);
            this.m_ControllerAddress.Owner    = this;
            this.m_ControllerName             = new UndoRedo <string>(String.Empty);
            this.m_ControllerName.Owner       = this;
            this.m_CreateTime                 = new UndoRedo <DateTime>(DateTime.MinValue);
            this.m_CreateTime.Owner           = this;
            this.m_ModifyTime                 = new UndoRedo <DateTime>(DateTime.MinValue);
            this.m_ModifyTime.Owner           = this;
            this.m_Description                = new UndoRedo <string>(String.Empty);
            this.m_Description.Owner          = this;
            this.m_Version                    = new UndoRedo <string>(String.Empty);
            this.m_Version.Owner              = this;
            this.m_TranslatorResult           = new UndoRedo <string>(String.Empty);
            this.m_TranslatorResult.Owner     = this;
            this.m_Prj_Unit_ID                = new UndoRedo <int>(-1);
            this.m_Prj_Unit_ID.Owner          = this;
            this.m_Prj_Unit                   = new UndoRedo <Prj_Unit>(null);
            this.m_Prj_Unit.Owner             = this;
            this.m_Sequence                   = new UndoRedo <int>(-1);
            this.m_Sequence.Owner             = this;
        }
        //-----------------------------------------------------------------------
        public void SetWrappedItem(GraphNodeItem item)
        {
            var oldItem = WrappedItem;

            UndoRedo.ApplyDoUndo(delegate
            {
                WrappedItem = item;
            },
                                 delegate
            {
                WrappedItem = oldItem;
            },
                                 "Set Item " + item.Name);

            if (IsCircular())
            {
                LinkType = LinkType.Reference;
            }
        }
示例#23
0
        private UndoRedo <int> m_Prj_Network_ID;       // = new UndoRedo<int>();



        #endregion 私有成员

        #region 构造函数

        /// <summary>
        /// 默认构造函数
        /// <summary>
        public Prj_Unit() : base()
        {
            this.m_ID                        = new UndoRedo <int>(-1);
            this.m_ID.Owner                  = this;
            this.m_Prj_Controller_List       = new UndoRedo <UndoRedoList <EntityBase> >(null);
            this.m_Prj_Controller_List.Owner = this;
            this.m_UnitAddress               = new UndoRedo <string>(String.Empty);
            this.m_UnitAddress.Owner         = this;
            this.m_UnitName                  = new UndoRedo <string>(String.Empty);
            this.m_UnitName.Owner            = this;
            this.m_NetworkAddress            = new UndoRedo <string>(String.Empty);
            this.m_NetworkAddress.Owner      = this;
            this.m_Description               = new UndoRedo <string>(String.Empty);
            this.m_Description.Owner         = this;
            this.m_Prj_Network_ID            = new UndoRedo <int>(-1);
            this.m_Prj_Network_ID.Owner      = this;
            this.m_Prj_Network               = new UndoRedo <Prj_Network>(null);
            this.m_Prj_Network.Owner         = this;
        }
示例#24
0
        public void BasicScenario()
        {
            var i = new UndoRedo<int>(0);

            UndoRedoManager.Start("");
            i.Value = 1;
            UndoRedoManager.Commit();
            Assert.AreEqual(1, i.Value);
            Assert.IsTrue(UndoRedoManager.CanUndo);
            Assert.IsFalse(UndoRedoManager.CanRedo);

            UndoRedoManager.Undo();
            Assert.AreEqual(0, i.Value);
            Assert.IsFalse(UndoRedoManager.CanUndo);
            Assert.IsTrue(UndoRedoManager.CanRedo);

            UndoRedoManager.Redo();
            Assert.AreEqual(1, i.Value);
        }
示例#25
0
 //-----------------------------------------------------------------------
 public GraphStructItem(DataDefinition definition, UndoRedoManager undoRedo) : base(definition, undoRedo)
 {
     PropertyChanged += (e, a) =>
     {
         if (a.PropertyName == "HasContent")
         {
             RaisePropertyChangedEvent("ShowClearButton");
         }
         else if (a.PropertyName == "Parent")
         {
             if (!HasContent && (Parent is CollectionChildItem || Parent is ReferenceItem))
             {
                 using (UndoRedo.DisableUndoScope())
                 {
                     Create();
                 }
             }
         }
     };
 }
示例#26
0
 //-----------------------------------------------------------------------
 public StructItem(DataDefinition definition, UndoRedoManager undoRedo) : base(definition, undoRedo)
 {
     PropertyChanged += (e, a) =>
     {
         if (a.PropertyName == "HasContent")
         {
             RaisePropertyChangedEvent("ShowClearButton");
         }
         else if (a.PropertyName == "Parent")
         {
             if (!HasContent && IsWrappedItem)
             {
                 using (UndoRedo.DisableUndoScope())
                 {
                     Create();
                 }
             }
         }
     };
 }
示例#27
0
        //-----------------------------------------------------------------------
        public void Duplicate()
        {
            var el = new XElement("Root");

            WrappedItem.Definition.SaveData(el, WrappedItem);

            CollectionChildItem child = null;

            using (UndoRedo.DisableUndoScope())
            {
                var item = WrappedItem.Definition.LoadData(el.Elements().First(), UndoRedo);
                child             = Definition.CreateData(UndoRedo) as CollectionChildItem;
                child.WrappedItem = item;
            }

            var collection = ParentCollection;
            var index      = collection.Children.IndexOf(this) + 1;

            (ParentCollection as ICollectionItem).Insert(index, child);
        }
示例#28
0
        public UIEditor()
        {
            InitializeComponent();

            m_finalClose     = false;
            m_stringDictLoad = false;

            guiRenderControl      = new NGUIRenderControl(this);
            guiRenderControl.Dock = DockStyle.Fill;
            guiRenderControl.CreateViewport();
            guiRenderControl.WindowCreated += new UIECreateWindowEventHander(guiRenderControl_WindowCreated);

            this.Closing += new CancelEventHandler(UIEditor_Closing);
            this.GUIPreview.Controls.Add(guiRenderControl);

            CopyWindowResourceName = new NResourceLoc("content", "ui/_temp/_copy.nui");
            CurrentMode            = UIEditorMode.Editor;

            UndoRedoCommands = new UndoRedo();
        }
示例#29
0
		private UndoRedo<int> m_Prj_Controller_ID;// = new UndoRedo<int>();
		
		
		
		#endregion 私有成员
		
		#region 构造函数
					
		/// <summary>
		/// 默认构造函数
		/// <summary>
		public Cld_Constant():base(){
			this.m_ID = new UndoRedo<int>(-1);
			this.m_ID.Owner = this;
			this.m_Name = new UndoRedo<string>(String.Empty);
			this.m_Name.Owner = this;
			this.m_X_Y = new UndoRedo<string>(String.Empty);
			this.m_X_Y.Owner = this;
			this.m_Prj_Sheet_ID = new UndoRedo<int>(-1);
			this.m_Prj_Sheet_ID.Owner = this;
			this.m_Prj_Sheet = new UndoRedo<Prj_Sheet>(null);
			this.m_Prj_Sheet.Owner = this;
			this.m_Prj_Document_ID = new UndoRedo<int>(-1);
			this.m_Prj_Document_ID.Owner = this;
			this.m_Prj_Document = new UndoRedo<Prj_Document>(null);
			this.m_Prj_Document.Owner = this;
			this.m_Prj_Controller_ID = new UndoRedo<int>(-1);
			this.m_Prj_Controller_ID.Owner = this;
			this.m_Prj_Controller = new UndoRedo<Prj_Controller>(null);
			this.m_Prj_Controller.Owner = this;
		}
示例#30
0
        public Form1()
        {
            InitializeComponent();
            g = pictureBox1.CreateGraphics();
            Shape strt = new Circle(Size.Width / 2, Size.Height / 2);

            tochka.Add(strt);
            pictureBox1.Invalidate();
            circleToolStripMenuItem.Checked = true;
            t[0]      = typeof(List <Circle>);
            t[1]      = typeof(List <Square>);
            t[2]      = typeof(List <Triangle>);
            formatter = new XmlSerializer(typeof(List <Shape>), t);
            saveFileDialog1.AddExtension = true;
            saveFileDialog1.DefaultExt   = ".mng";
            openFileDialog1.DefaultExt   = ".mng";
            openFileDialog1.Filter       = "Многоугольники(*.mng)|*.mng";
            undoredo = new UndoRedo(5);
            undoredo.AddAction(tochka, Shape.Getc, Shape.Getcout, Shape.Getr);
        }
示例#31
0
        public void DifferentOwners()
        {
            var owner1 = new object();
            var owner2 = new object();
            var i = new UndoRedo<int>(0);

            using (UndoRedoManager.Start("MyCommand", owner1))
            {
                i.Value = 1;
                UndoRedoManager.Commit();
            }
            Assert.AreEqual(1, i.Value);

            using (UndoRedoManager.Start("MyCommand", owner2))
            {
                i.Value = 2;
                UndoRedoManager.Commit();
            }
            Assert.AreEqual(2, i.Value);

            using (UndoRedoManager.Start("MyCommand", owner1))
            {
                i.Value = 3;
                UndoRedoManager.Commit();
            }
            Assert.AreEqual(3, i.Value);

            UndoRedoManager.Undo();
            Assert.AreEqual(2, i.Value);
            UndoRedoManager.Undo();
            Assert.AreEqual(1, i.Value);
            UndoRedoManager.Undo();
            Assert.AreEqual(0, i.Value);

            UndoRedoManager.Redo();
            Assert.AreEqual(1, i.Value);
            UndoRedoManager.Redo();
            Assert.AreEqual(2, i.Value);
            UndoRedoManager.Redo();
            Assert.AreEqual(3, i.Value);
        }
示例#32
0
        //-----------------------------------------------------------------------
        public void Remove(TreeItem item)
        {
            var def = Definition as TreeDefinition;

            var index = Children.IndexOf(item);

            UndoRedo.ApplyDoUndo(
                delegate
            {
                Children.Remove(item);
                RaisePropertyChangedEvent("HasContent");
                RaisePropertyChangedEvent("Description");
            },
                delegate
            {
                Children.Insert(index, item);
                RaisePropertyChangedEvent("HasContent");
                RaisePropertyChangedEvent("Description");
            },
                "Removing item " + item.Name + " from collection " + Name);
        }
        private void DeleteSelection()
        {
            IPointSeries plp = PointSeries.Union(_controlPoints.EndPoints,
                                                 PointSeries.Difference(_controlPoints, _adorner.SelectedPoints));

            UndoRedo.PushUndo(new UndoObject(
                                  "delete " + Channel.ToString() + " point deletion.",
                                  new UndoContext(new PointSeries(_controlPoints), new PointSeries(plp)),
                                  (uc) => { Palette.UpdateControlPoints(Channel, uc[0] as PointSeries);
                                            InvalidateVisual();
                                            return(uc); },
                                  (rc) =>
            {
                Palette.UpdateControlPoints(Channel, rc[1] as PointSeries);
                InvalidateVisual();
            }));
            Palette.UpdateControlPoints(Channel, plp);
            _controlPoints = Palette.GetControlPoints(Channel);
            _adorner.ClearSelection();
            InvalidateVisual();
        }
示例#34
0
        public void Interference_2AreasIn1Thread()
        {
            var area1 = new UndoRedoArea("area1");
            var area2 = new UndoRedoArea("area2");

            var i1 = new UndoRedo<int>(0);
            var i2 = new UndoRedo<int>(0);
            using (area1.Start("Command1"))
            {
                i1.Value = 1;
                using (area2.Start("Command1"))
                {
                    i2.Value = 1;
                    Assert.AreEqual(i1.Value, 1);
                    Assert.AreEqual(i2.Value, 1);
                }
                area1.Commit();
            }
            Assert.AreEqual(i1.Value, 1);
            Assert.AreEqual(i2.Value, 0);
        }
示例#35
0
        private void DiaoController_RotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args)
        {
            var selectedTool = _diaoController.Menu.GetSelectedMenuItem();

            if (selectedTool == DiaoToolOpacity)
            {
                OpacityChanging?.Invoke(sender, args);
            }
            if (selectedTool == DiaoToolUndoRedo)
            {
                UndoRedo?.Invoke(sender, args);
            }
            if (selectedTool == DiaoToolZoom)
            {
                Zooming?.Invoke(sender, args);
            }
            if (selectedTool == DiaoToolAlignmentGrid)
            {
                AlignmentGridChanging?.Invoke(sender, args);
            }
        }
        /// <summary>
        /// Looks at the last set of changes and applies the old values.
        /// </summary>
        public void Undo()
        {
            if (_undoStack.Count == 0)
            {
                return;
            }

            UndoRedo Changes = _undoStack.Pop();

            _redoStack.Push(Changes);

            ApplyChangeset(Changes, Activity.Undo);

            // Get a new Snapshot of the data
            _lastSnapshot = new Snapshot(_Document);

            // Fire the events
            OnRedoChanged();
            OnUndoChanged();
            OnCompleted();
        }
示例#37
0
        private UndoRedo <int> m_Prj_Controller_ID;         // = new UndoRedo<int>();



        #endregion 私有成员

        #region 构造函数

        /// <summary>
        /// 默认构造函数
        /// <summary>
        public Cld_Constant() : base()
        {
            this.m_ID                      = new UndoRedo <int>(-1);
            this.m_ID.Owner                = this;
            this.m_Name                    = new UndoRedo <string>(String.Empty);
            this.m_Name.Owner              = this;
            this.m_X_Y                     = new UndoRedo <string>(String.Empty);
            this.m_X_Y.Owner               = this;
            this.m_Prj_Sheet_ID            = new UndoRedo <int>(-1);
            this.m_Prj_Sheet_ID.Owner      = this;
            this.m_Prj_Sheet               = new UndoRedo <Prj_Sheet>(null);
            this.m_Prj_Sheet.Owner         = this;
            this.m_Prj_Document_ID         = new UndoRedo <int>(-1);
            this.m_Prj_Document_ID.Owner   = this;
            this.m_Prj_Document            = new UndoRedo <Prj_Document>(null);
            this.m_Prj_Document.Owner      = this;
            this.m_Prj_Controller_ID       = new UndoRedo <int>(-1);
            this.m_Prj_Controller_ID.Owner = this;
            this.m_Prj_Controller          = new UndoRedo <Prj_Controller>(null);
            this.m_Prj_Controller.Owner    = this;
        }
示例#38
0
        public void ClearHistory()
        {
            var i = new UndoRedo<int>(0);

            // start + commit + flush
            UndoRedoManager.Start("");
            i.Value = 1;
            UndoRedoManager.Commit();
            Assert.AreEqual(1, i.Value);

            UndoRedoManager.ClearHistory();
            Assert.IsFalse(UndoRedoManager.CanUndo); // history must be empty
            Assert.AreEqual(1, i.Value); // data must be intact

            // start + flush
            UndoRedoManager.Start("");
            i.Value = 2;
            UndoRedoManager.ClearHistory();
            Assert.IsFalse(UndoRedoManager.CanUndo); // history must be empty
            Assert.AreEqual(2, i.Value); // data must be intact
        }
示例#39
0
		private UndoRedo<int> m_Prj_Sheet_ID;// = new UndoRedo<int>();
		
		
		
		#endregion 私有成员
		
		#region 构造函数
					
		/// <summary>
		/// 默认构造函数
		/// <summary>
		public Cld_Graphic():base(){
			this.m_ID = new UndoRedo<int>(-1);
			this.m_ID.Owner = this;
			this.m_Type = new UndoRedo<string>(String.Empty);
			this.m_Type.Owner = this;
			this.m_Layer = new UndoRedo<string>(String.Empty);
			this.m_Layer.Owner = this;
			this.m_Data = new UndoRedo<string>(String.Empty);
			this.m_Data.Owner = this;
			this.m_Prj_Controller_ID = new UndoRedo<int>(-1);
			this.m_Prj_Controller_ID.Owner = this;
			this.m_Prj_Controller = new UndoRedo<Prj_Controller>(null);
			this.m_Prj_Controller.Owner = this;
			this.m_Prj_Document_ID = new UndoRedo<int>(-1);
			this.m_Prj_Document_ID.Owner = this;
			this.m_Prj_Document = new UndoRedo<Prj_Document>(null);
			this.m_Prj_Document.Owner = this;
			this.m_Prj_Sheet_ID = new UndoRedo<int>(-1);
			this.m_Prj_Sheet_ID.Owner = this;
			this.m_Prj_Sheet = new UndoRedo<Prj_Sheet>(null);
			this.m_Prj_Sheet.Owner = this;
		}
        //-----------------------------------------------------------------------
        public void Create()
        {
            if (IsMultiediting)
            {
                foreach (var item in MultieditItems)
                {
                    var ri = item as ReferenceItem;
                    ri.SelectedDefinition = SelectedDefinition;
                    ri.Create();
                }
            }
            else
            {
                DataItem item   = null;
                var      chosen = (Definition as ReferenceDefinition).Definitions[SelectedDefinition.Item1];
                using (UndoRedo.DisableUndoScope())
                {
                    item = chosen.CreateData(UndoRedo);
                    if (item is StructItem && item.Children.Count == 0)
                    {
                        (item.Definition as StructDefinition).CreateChildren(item as StructItem, UndoRedo);
                    }
                }

                UndoRedo.ApplyDoUndo(delegate
                {
                    ChosenDefinition = chosen;
                    WrappedItem      = item;
                },
                                     delegate
                {
                    ChosenDefinition = null;
                    WrappedItem      = null;
                },
                                     "Create Item " + item.Name);

                IsExpanded = true;
            }
        }
        /// <summary>
        /// Compares the current snapshot to the last one, records the differences in a ChangeSet
        /// </summary>
        /// <param name="action">Text to indicate the last operation the program performed to warrent undoing</param>
        /// <param name="current">The current Snapshot of the data</param>
        /// <returns>ChangeSet object that holds the differences between the current snapshot and the last one</returns>
        private UndoRedo FindSnapshotChanges(string action, Snapshot current)
        {
            var Changes         = new UndoRedo(action);
            var FoundSerialized = string.Empty;

            // Background
            //if (current.Data.Background != _lastSnapshot.Data.Background)
            //{
            //	Changes.Undo.Background = _lastSnapshot.Data.Background;
            //	Changes.Redo.Background = current.Data.Background;
            //}

            // Scaling
            if (current.Data.Scaling.LatticeSize != _lastSnapshot.Data.Scaling.LatticeSize)
            {
                Changes.Undo.Scaling.LatticeSize = _lastSnapshot.Data.Scaling.LatticeSize;
                Changes.Redo.Scaling.LatticeSize = current.Data.Scaling.LatticeSize;
            }

            if (current.Data.Scaling.CellSize != _lastSnapshot.Data.Scaling.CellSize)
            {
                Changes.Undo.Scaling.CellSize = _lastSnapshot.Data.Scaling.CellSize;
                Changes.Redo.Scaling.CellSize = current.Data.Scaling.CellSize;
            }

            if (current.Data.Scaling.ShowGridLines != _lastSnapshot.Data.Scaling.ShowGridLines)
            {
                Changes.Undo.Scaling.ShowGridLines = _lastSnapshot.Data.Scaling.ShowGridLines;
                Changes.Redo.Scaling.ShowGridLines = current.Data.Scaling.ShowGridLines;
            }

            if (current.Data.Scaling.Zoom != _lastSnapshot.Data.Scaling.Zoom)
            {
                Changes.Undo.Scaling.Zoom = _lastSnapshot.Data.Scaling.Zoom;
                Changes.Redo.Scaling.Zoom = current.Data.Scaling.Zoom;
            }

            return(Changes);
        }
示例#42
0
        public void RedoTest()
        {
            // arrange
            var undoRedo = new UndoRedo();

            undoRedo.AddAction(1, 2, 3, 4, "manual");
            undoRedo.AddAction(5, 6, 7, 8, "manually");

            // act
            var(row, column, oldValue, value, method, undoLength, redoLength) = undoRedo.Undo();
            (row, column, oldValue, value, method, undoLength, redoLength)    = undoRedo.Undo();
            (row, column, oldValue, value, method, undoLength, redoLength)    = undoRedo.Redo();

            // assert
            Assert.AreEqual(1, row);
            Assert.AreEqual(2, column);
            Assert.AreEqual(3, oldValue);
            Assert.AreEqual(4, value);
            Assert.AreEqual("manual", method);
            Assert.AreEqual(1, undoLength);
            Assert.AreEqual(1, redoLength);
        }
示例#43
0
        public void LoadFileText(FileInformation fileInfo, string text)
        {
            ResetEditor();
            this.Text = text;
            m_fileInfo.Filename.Assign(fileInfo.Filename);
            this.FileLocation = fileInfo.Location;

            UpdateSyntaxHighlighting();


            string filename = Path.GetFileName(this.Filename);

            string indicator = (this.FileLocation == FileLocation.Local) ? "L" : "R";

            string tabText = string.Format("({0}) {1}", indicator, filename);

            m_parentTab.Title = tabText;

            // do stuff with EOL here?

            UndoRedo.EmptyUndoBuffer();
        }
        public void FinishMoveSelection()
        {
            if (GridPainter.InsertedBlock != null)
            {
                using (SuspendUpdateVisualImage())
                    using (SourceImage.Palette.SuppressRemoveColorsWithoutOccurrences())
                        using (UndoRedo.BeginMultiActionsUndoRedoStep(UndoRedoProvider.UndoRedoActionPaste))
                        {
                            ImageCopier.CopyWithPalette(GridPainter.InsertedBlock, SourceImage, new Point(SelectedRect.Left, SelectedRect.Top));

                            GridPainter.InsertedBlock = null;

                            if (MouseMode == MouseActionMode.MoveSelection)
                            {
                                MouseMode = MouseActionMode.Shift;
                            }

                            UpdateVisualImage();
                            SourceImage.TriggerImageChanged();
                        }
            }
        }
        //-----------------------------------------------------------------------
        public void Save(bool isBackup = false)
        {
            if (IsMultiediting)
            {
                foreach (var doc in MultieditDocs)
                {
                    doc.Save();
                }

                return;
            }

            var path = isBackup ? BackupPath : Path;

            Workspace.DisableFileEvents = true;

            Data.Save(path);
            if (!isBackup)
            {
                ProjectViewTool.Instance.Add(path);
            }

            Workspace.DisableFileEvents = false;

            if (isBackup)
            {
            }
            else
            {
                IsBackup = false;
                UndoRedo.MarkSavePoint();

                if (Path.EndsWith(".xmldef"))
                {
                    Workspace.LoadDefinitions();
                }
            }
        }
示例#46
0
        private UndoRedo <int> m_Prj_Sheet_ID;       // = new UndoRedo<int>();



        #endregion 私有成员

        #region 构造函数

        /// <summary>
        /// 默认构造函数
        /// <summary>
        public Cld_Graphic() : base()
        {
            this.m_ID                      = new UndoRedo <int>(-1);
            this.m_ID.Owner                = this;
            this.m_Type                    = new UndoRedo <string>(String.Empty);
            this.m_Type.Owner              = this;
            this.m_Layer                   = new UndoRedo <string>(String.Empty);
            this.m_Layer.Owner             = this;
            this.m_Data                    = new UndoRedo <string>(String.Empty);
            this.m_Data.Owner              = this;
            this.m_Prj_Controller_ID       = new UndoRedo <int>(-1);
            this.m_Prj_Controller_ID.Owner = this;
            this.m_Prj_Controller          = new UndoRedo <Prj_Controller>(null);
            this.m_Prj_Controller.Owner    = this;
            this.m_Prj_Document_ID         = new UndoRedo <int>(-1);
            this.m_Prj_Document_ID.Owner   = this;
            this.m_Prj_Document            = new UndoRedo <Prj_Document>(null);
            this.m_Prj_Document.Owner      = this;
            this.m_Prj_Sheet_ID            = new UndoRedo <int>(-1);
            this.m_Prj_Sheet_ID.Owner      = this;
            this.m_Prj_Sheet               = new UndoRedo <Prj_Sheet>(null);
            this.m_Prj_Sheet.Owner         = this;
        }
示例#47
0
        private bool LPM_MoveObject(Point e)
        {
            var _scrolledPoint = new Point(e.X - AutoScrollPosition.X, e.Y - AutoScrollPosition.Y);

            if (CanvObj.GetSelectedItems().Count > 0)
            {
                if (!isMoved)
                {
                    UndoRedo.Push(CanvObj.ToListHistory(MyAction.Move));
                    isMoved = true;
                }
                CanvObj.My_MoveSelectedObjects(ref _mouseDownLocation, _scrolledPoint);
                CanvLines.MyUpdate(ref CanvObj);
                if (CanvObj.Count > 0)
                {
                    _rubbers.ShowRubbers(CanvObj[0], AutoScrollPosition); //zawsze index 0 to to ostatni zaznaczony objekt
                }
                _mouseDownLocation = _scrolledPoint;
                Invalidate();
                return(false);
            }
            return(true);
        }
示例#48
0
 private void SaveDocument(object sender, EventArgs e)
 {
     if (!switchingDoc)
     {
         CurrentNode?.Doc.Save(Title_TXT.Text, Paragraph_TXT.Text);
         if (sender.Equals(Title_TXT))
         {
             if (CurrentNode != null)
             {
                 CurrentNode.Text = "*" + CurrentNode.Doc.Title + "*";
             }
         }
         if (KeyPressed)
         {
             KeyPressed = false;
             UndoRedo.Do(new TextEditor(sender as Control, prevText, (sender as Control).Text));
         }
     }
     else
     {
         switchingDoc = false;
     }
 }
示例#49
0
        private UndoRedo <int> m_Meta_FCMaster_ID;        // = new UndoRedo<int>();



        #endregion 私有成员

        #region 构造函数

        /// <summary>
        /// 默认构造函数
        /// <summary>
        public Meta_FCDetail() : base()
        {
            this.m_ID                     = new UndoRedo <int>(-1);
            this.m_ID.Owner               = this;
            this.m_FunctionName           = new UndoRedo <string>(String.Empty);
            this.m_FunctionName.Owner     = this;
            this.m_PinName                = new UndoRedo <string>(String.Empty);
            this.m_PinName.Owner          = this;
            this.m_PinIndex               = new UndoRedo <int>(-1);
            this.m_PinIndex.Owner         = this;
            this.m_DataType               = new UndoRedo <string>(String.Empty);
            this.m_DataType.Owner         = this;
            this.m_Tune                   = new UndoRedo <bool>(false);
            this.m_Tune.Owner             = this;
            this.m_PinType                = new UndoRedo <string>(String.Empty);
            this.m_PinType.Owner          = this;
            this.m_MaxValue               = new UndoRedo <string>(String.Empty);
            this.m_MaxValue.Owner         = this;
            this.m_MinValue               = new UndoRedo <string>(String.Empty);
            this.m_MinValue.Owner         = this;
            this.m_ValidValue             = new UndoRedo <string>(String.Empty);
            this.m_ValidValue.Owner       = this;
            this.m_DefaultValue           = new UndoRedo <string>(String.Empty);
            this.m_DefaultValue.Owner     = this;
            this.m_Required               = new UndoRedo <bool>(false);
            this.m_Required.Owner         = this;
            this.m_Description            = new UndoRedo <string>(String.Empty);
            this.m_Description.Owner      = this;
            this.m_Fixed                  = new UndoRedo <bool>(false);
            this.m_Fixed.Owner            = this;
            this.m_PinSignalType          = new UndoRedo <string>(String.Empty);
            this.m_PinSignalType.Owner    = this;
            this.m_Meta_FCMaster_ID       = new UndoRedo <int>(-1);
            this.m_Meta_FCMaster_ID.Owner = this;
            this.m_Meta_FCMaster          = new UndoRedo <Meta_FCMaster>(null);
            this.m_Meta_FCMaster.Owner    = this;
        }
示例#50
0
        //-----------------------------------------------------------------------
        public void PasteNew()
        {
            foreach (var childDef in CDef.ChildDefinitions)
            {
                if (Clipboard.ContainsData(childDef.WrappedDefinition.CopyKey))
                {
                    var flat = Clipboard.GetData(childDef.WrappedDefinition.CopyKey) as string;
                    var root = XElement.Parse(flat);

                    CollectionChildItem child = null;

                    using (UndoRedo.DisableUndoScope())
                    {
                        var item = childDef.WrappedDefinition.LoadData(root, UndoRedo);
                        child             = childDef.CreateData(UndoRedo) as CollectionChildItem;
                        child.WrappedItem = item;
                    }

                    UndoRedo.ApplyDoUndo(
                        delegate
                    {
                        Children.Add(child);
                        RaisePropertyChangedEvent("HasContent");
                        RaisePropertyChangedEvent("Description");
                    },
                        delegate
                    {
                        Children.Remove(child);
                        RaisePropertyChangedEvent("HasContent");
                        RaisePropertyChangedEvent("Description");
                    },
                        Name + " pasted new");

                    IsExpanded = true;
                }
            }
        }
示例#51
0
		private UndoRedo<string> m_AlarmVersion;// = new UndoRedo<string>();
		
		
		
		#endregion 私有成员
		
		#region 构造函数
					
		/// <summary>
		/// 默认构造函数
		/// <summary>
		public Prj_Project():base(){
			this.m_ID = new UndoRedo<int>(-1);
			this.m_ID.Owner = this;
			this.m_Prj_Network_List = new UndoRedo<UndoRedoList<EntityBase>>(null);
			this.m_Prj_Network_List.Owner = this;
			this.m_ProjectName = new UndoRedo<string>(String.Empty);
			this.m_ProjectName.Owner = this;
			this.m_CreateTime = new UndoRedo<DateTime>(DateTime.MinValue);
			this.m_CreateTime.Owner = this;
			this.m_ModifyTime = new UndoRedo<DateTime>(DateTime.MinValue);
			this.m_ModifyTime.Owner = this;
			this.m_Type = new UndoRedo<string>(String.Empty);
			this.m_Type.Owner = this;
			this.m_BlockMaxNumber = new UndoRedo<string>(String.Empty);
			this.m_BlockMaxNumber.Owner = this;
			this.m_PinMaxNumber = new UndoRedo<string>(String.Empty);
			this.m_PinMaxNumber.Owner = this;
			this.m_ProjectPath = new UndoRedo<string>(String.Empty);
			this.m_ProjectPath.Owner = this;
			this.m_VarSystemVersion = new UndoRedo<string>(String.Empty);
			this.m_VarSystemVersion.Owner = this;
			this.m_AlarmVersion = new UndoRedo<string>(String.Empty);
			this.m_AlarmVersion.Owner = this;
		}
示例#52
0
		private UndoRedo<int> m_Prj_Sheet_ID;// = new UndoRedo<int>();
		
		
		
		#endregion 私有成员
		
		#region 构造函数
					
		/// <summary>
		/// 默认构造函数
		/// <summary>
		public Cld_Signal():base(){
			this.m_ID = new UndoRedo<int>(-1);
			this.m_ID.Owner = this;
			this.m_Name = new UndoRedo<string>(String.Empty);
			this.m_Name.Owner = this;
			this.m_SignalType = new UndoRedo<string>(String.Empty);
			this.m_SignalType.Owner = this;
			this.m_EntityBelongTo = new UndoRedo<string>(String.Empty);
			this.m_EntityBelongTo.Owner = this;
			this.m_Data = new UndoRedo<string>(String.Empty);
			this.m_Data.Owner = this;
			this.m_Prj_Controller_ID = new UndoRedo<int>(-1);
			this.m_Prj_Controller_ID.Owner = this;
			this.m_Prj_Controller = new UndoRedo<Prj_Controller>(null);
			this.m_Prj_Controller.Owner = this;
			this.m_Prj_Document_ID = new UndoRedo<int>(-1);
			this.m_Prj_Document_ID.Owner = this;
			this.m_Prj_Document = new UndoRedo<Prj_Document>(null);
			this.m_Prj_Document.Owner = this;
			this.m_Prj_Sheet_ID = new UndoRedo<int>(-1);
			this.m_Prj_Sheet_ID.Owner = this;
			this.m_Prj_Sheet = new UndoRedo<Prj_Sheet>(null);
			this.m_Prj_Sheet.Owner = this;
		}
		private UndoRedo<int> m_Prj_Controller_ID;// = new UndoRedo<int>();
		
		
		
		#endregion 私有成员
		
		#region 构造函数
					
		/// <summary>
		/// 默认构造函数
		/// <summary>
		public Cld_FCParameter():base(){
			this.m_ID = new UndoRedo<int>(-1);
			this.m_ID.Owner = this;
			this.m_Name = new UndoRedo<string>(String.Empty);
			this.m_Name.Owner = this;
			this.m_PValue = new UndoRedo<string>(String.Empty);
			this.m_PValue.Owner = this;
			this.m_Cld_FCBlock_ID = new UndoRedo<int>(-1);
			this.m_Cld_FCBlock_ID.Owner = this;
			this.m_Cld_FCBlock = new UndoRedo<Cld_FCBlock>(null);
			this.m_Cld_FCBlock.Owner = this;
			this.m_Prj_Sheet_ID = new UndoRedo<int>(-1);
			this.m_Prj_Sheet_ID.Owner = this;
			this.m_Prj_Sheet = new UndoRedo<Prj_Sheet>(null);
			this.m_Prj_Sheet.Owner = this;
			this.m_Prj_Document_ID = new UndoRedo<int>(-1);
			this.m_Prj_Document_ID.Owner = this;
			this.m_Prj_Document = new UndoRedo<Prj_Document>(null);
			this.m_Prj_Document.Owner = this;
			this.m_Prj_Controller_ID = new UndoRedo<int>(-1);
			this.m_Prj_Controller_ID.Owner = this;
			this.m_Prj_Controller = new UndoRedo<Prj_Controller>(null);
			this.m_Prj_Controller.Owner = this;
		}
示例#54
0
        public void HistorySize()
        {
            var i = new UndoRedo<int>(0);

            UndoRedoManager.Start("1");
            i.Value = 1;
            UndoRedoManager.Commit();

            UndoRedoManager.Start("2");
            i.Value = 2;
            UndoRedoManager.Commit();

            UndoRedoManager.Start("3");
            i.Value = 3;
            UndoRedoManager.Commit();

            UndoRedoManager.Start("4");
            i.Value = 4;
            UndoRedoManager.Commit();

            UndoRedoManager.StartInvisible("4+i1");
            i.Value = 4;
            UndoRedoManager.Commit();

            UndoRedoManager.StartInvisible("4+i2");
            i.Value = 4;
            UndoRedoManager.Commit();

            Assert.AreEqual(4, new List<string>(UndoRedoManager.UndoCommands).Count);

            UndoRedoManager.MaxHistorySize = 3;

            Assert.AreEqual(3, new List<string>(UndoRedoManager.UndoCommands).Count);

            UndoRedoManager.Start("5");
            i.Value = 5;
            UndoRedoManager.Commit();

            Assert.AreEqual(3, new List<string>(UndoRedoManager.UndoCommands).Count);
        }
示例#55
0
        public void StartAffinedAfterUndo()
        {
            var owner = new object();
            var i = new UndoRedo<int>(0);
            using (UndoRedoManager.Start("MyCommand 1", owner))
            {
                i.Value = 1;
                UndoRedoManager.Commit();
            }
            Assert.AreEqual(1, i.Value);
            using (UndoRedoManager.Start("MyCommand 2", owner))
            {
                i.Value = 2;
                UndoRedoManager.Commit();
            }
            Assert.AreEqual(2, i.Value);

            UndoRedoManager.Undo();
            Assert.AreEqual(1, i.Value);

            using (UndoRedoManager.Start("MyCommand 1", owner))
            {
                i.Value = 3;
                UndoRedoManager.Commit();
            }
            Assert.AreEqual(3, i.Value);

            UndoRedoManager.Undo();
            Assert.AreEqual(1, i.Value);

            UndoRedoManager.Redo();
            Assert.AreEqual(3, i.Value);
        }
示例#56
0
        public void PureAffinedSequence()
        {
            var i = new UndoRedo<int>(0);
            var owner = new object();

            using (UndoRedoManager.Start("MyCommand", owner))
            {
                i.Value = 1;
                UndoRedoManager.Commit();
            }
            using (UndoRedoManager.Start("MyCommand", owner))
            {
                i.Value = 2;
                UndoRedoManager.Commit();
            }
            using (UndoRedoManager.Start("MyCommand", owner))
            {
                i.Value = 3;
                UndoRedoManager.Commit();
            }
            Assert.AreEqual(3, i.Value);

            UndoRedoManager.Undo();
            Assert.AreEqual(0, i.Value);
            Assert.IsFalse(UndoRedoManager.CanUndo);
            Assert.IsTrue(UndoRedoManager.CanRedo);

            UndoRedoManager.Redo();
            Assert.AreEqual(3, i.Value);
            Assert.IsTrue(UndoRedoManager.CanUndo);
            Assert.IsFalse(UndoRedoManager.CanRedo);

            using (UndoRedoManager.Start("MyCommand", owner))
            {
                i.Value = 4;
                UndoRedoManager.Commit();
            }
            Assert.AreEqual(4, i.Value);

            UndoRedoManager.Undo();
            Assert.AreEqual(3, i.Value);

            UndoRedoManager.Undo();
            Assert.AreEqual(0, i.Value);

            UndoRedoManager.Redo();
            Assert.AreEqual(3, i.Value);

            UndoRedoManager.Redo();
            Assert.AreEqual(4, i.Value);

            using (UndoRedoManager.Start("MyCommand", owner))
            {
                i.Value = 5;
            } // auto rollback is here

            Assert.AreEqual(4, i.Value);
        }
示例#57
0
		private UndoRedo<int> m_Prj_Document_ID;// = new UndoRedo<int>();
		
		
		
		#endregion 私有成员
		
		#region 构造函数
					
		/// <summary>
		/// 默认构造函数
		/// <summary>
		public Prj_Sheet():base(){
			this.m_ID = new UndoRedo<int>(-1);
			this.m_ID.Owner = this;
			this.m_Cld_Constant_List = new UndoRedo<UndoRedoList<EntityBase>>(null);
			this.m_Cld_Constant_List.Owner = this;
			this.m_Cld_FCBlock_List = new UndoRedo<UndoRedoList<EntityBase>>(null);
			this.m_Cld_FCBlock_List.Owner = this;
			this.m_Cld_FCInput_List = new UndoRedo<UndoRedoList<EntityBase>>(null);
			this.m_Cld_FCInput_List.Owner = this;
			this.m_Cld_FCOutput_List = new UndoRedo<UndoRedoList<EntityBase>>(null);
			this.m_Cld_FCOutput_List.Owner = this;
			this.m_Cld_FCParameter_List = new UndoRedo<UndoRedoList<EntityBase>>(null);
			this.m_Cld_FCParameter_List.Owner = this;
			this.m_Cld_Graphic_List = new UndoRedo<UndoRedoList<EntityBase>>(null);
			this.m_Cld_Graphic_List.Owner = this;
			this.m_Cld_Signal_List = new UndoRedo<UndoRedoList<EntityBase>>(null);
			this.m_Cld_Signal_List.Owner = this;
			this.m_SheetName = new UndoRedo<string>(String.Empty);
			this.m_SheetName.Owner = this;
			this.m_SheetNum = new UndoRedo<int>(-1);
			this.m_SheetNum.Owner = this;
			this.m_Sequence = new UndoRedo<string>(String.Empty);
			this.m_Sequence.Owner = this;
			this.m_Width = new UndoRedo<int>(-1);
			this.m_Width.Owner = this;
			this.m_Height = new UndoRedo<int>(-1);
			this.m_Height.Owner = this;
			this.m_Prj_Controller_ID = new UndoRedo<int>(-1);
			this.m_Prj_Controller_ID.Owner = this;
			this.m_Prj_Controller = new UndoRedo<Prj_Controller>(null);
			this.m_Prj_Controller.Owner = this;
			this.m_Prj_Document_ID = new UndoRedo<int>(-1);
			this.m_Prj_Document_ID.Owner = this;
			this.m_Prj_Document = new UndoRedo<Prj_Document>(null);
			this.m_Prj_Document.Owner = this;
		}
示例#58
0
        public void CommandDoneEvent()
        {
            bool? success = null;
            UndoRedoManager.CommandDone += delegate { success = UndoRedoManager.IsCommandStarted; };
            var i = new UndoRedo<int>();
            UndoRedoManager.Start("a command");
            i.Value++;
            UndoRedoManager.Commit();

            Assert.IsTrue(success.HasValue, "Error: CommandDone event was not fired");
            Assert.IsFalse(success.Value, "Error: CommandDone event was fired before changes had been commited");
        }
示例#59
0
        public void InvisibleCommands()
        {
            var i = new UndoRedo<string>("");

            UndoRedoManager.StartInvisible("0i");
            i.Value = "0i";
            UndoRedoManager.Commit();

            UndoRedoManager.Start("1");
            i.Value = "1";
            UndoRedoManager.Commit();

            UndoRedoManager.StartInvisible("1i");
            i.Value = "1i";
            UndoRedoManager.Commit();

            UndoRedoManager.Start("2");
            i.Value = "2";
            UndoRedoManager.Commit();

            UndoRedoManager.StartInvisible("2i");
            i.Value = "2i";
            UndoRedoManager.Commit();

            UndoRedoManager.StartInvisible("2ii");
            i.Value = "2ii";
            UndoRedoManager.Commit();

            UndoRedoManager.Start("3");
            i.Value = "3";
            UndoRedoManager.Commit();

            UndoRedoManager.Start("4");
            i.Value = "4";
            UndoRedoManager.Commit();

            UndoRedoManager.StartInvisible("4i");
            i.Value = "4i";
            UndoRedoManager.Commit();

            Assert.AreEqual("4i", i.Value);
            UndoRedoManager.Undo();
            Assert.AreEqual("3", i.Value);
            UndoRedoManager.Undo();
            Assert.AreEqual("2ii", i.Value);
            UndoRedoManager.Undo();
            Assert.AreEqual("1i", i.Value);
            UndoRedoManager.Undo();
            Assert.AreEqual("0i", i.Value);

            Assert.IsFalse(UndoRedoManager.CanUndo);

            UndoRedoManager.Redo();
            Assert.AreEqual("1i", i.Value);
            UndoRedoManager.Redo();
            Assert.AreEqual("2ii", i.Value);
            UndoRedoManager.Redo();
            Assert.AreEqual("3", i.Value);
            UndoRedoManager.Redo();
            Assert.AreEqual("4i", i.Value);

            Assert.IsFalse(UndoRedoManager.CanRedo);
        }
示例#60
0
        public void ManualCancel()
        {
            var i = new UndoRedo<int>(0);
            var list = new UndoRedoList<int>(new int[] {1, 2, 3});
            var dict = new UndoRedoDictionary<int, string>();

            UndoRedoManager.Start("");
            i.Value = 1;
            list.Add(4);
            dict[1] = "One";
            UndoRedoManager.Cancel();

            Assert.AreEqual(0, i.Value);
            Assert.AreEqual(3, list.Count);
            Assert.IsFalse(dict.ContainsKey(1));

            // run next command to make sure that framework works well after cancel
            UndoRedoManager.Start("");
            i.Value = 1;
            UndoRedoManager.Commit();

            Assert.AreEqual(1, i.Value);
        }