예제 #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            personListBindingSource.DataSource = _personList;
            lbPeople.DataSource    = personListBindingSource;
            lbPeople.DisplayMember = "Name";

            //기본 대상자 2명 입력.
            AddDefaultPeople();

            ///clear any undo operations added implicitly during startup
            UndoRedoManager.Instance().Clear();
        }
예제 #2
0
        private void RemovePerson(Person person)
        {
            //Nothing to do if the person is not in the list
            bool found = _personList.Exists(p => p.ID == person.ID);

            if (!found)
            {
                return;
            }

            UndoRedoManager.Instance().Push(p => AddPerson(p), person, "Remove Person");

            personListBindingSource.Remove(person);
        }
예제 #3
0
        private Person AddPerson(Person person)
        {
            //Do not add if the person is already in the list
            Person personInList = _personList.Find(p => p.ID == person.ID);

            if (personInList != null)
            {
                return(personInList);
            }

            //UndoRedoManager.Instance().Push(p => RemovePerson(p), person,"Add Person");
            UndoRedoManager.Instance().Push(delegate(Person p) { RemovePerson(p); }, person, "Add Person");

            personListBindingSource.Position = personListBindingSource.Add(person);

            return(person);
        }
예제 #4
0
 public MainForm()
 {
     InitializeComponent();
     UndoRedoManager.Instance().RedoStackStatusChanged += new UndoRedoManager.OnStackStatusChanged(MainForm_RedoStackStatusChanged);
     UndoRedoManager.Instance().UndoStackStatusChanged += new UndoRedoManager.OnStackStatusChanged(MainForm_UndoStackStatusChanged);
 }
예제 #5
0
 private void redoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     UndoRedoManager.Instance().Redo();
 }
예제 #6
0
 public void Dispose()
 {
     UndoRedoManager.Instance().EndTransaction(this);
 }
예제 #7
0
 public UndoTransaction(string name = "")
 {
     _Name = name;
     UndoRedoManager.Instance().StartTransaction(this);
 }