Ejemplo n.º 1
0
 public void AddStep(string stepDescription, Action reversionAction)
 {
     BeginInvoke((Action)(() => {
         EditReversionStep newStep = new EditReversionStep(stepDescription, reversionAction);
         historyList.Items.Add(newStep);
         if (historyList.Items.Count > MAX_STEPS_TO_RETAIN)
         {
             historyList.Items.RemoveAt(0);
         }
         historyList.SelectedItem = newStep;
     }));
 }
Ejemplo n.º 2
0
        private void UndoUpToSelected()
        {
            List <EditReversionStep> stepsAsList  = historyList.Items.Cast <EditReversionStep>().ToList();
            EditReversionStep        selectedStep = historyList.SelectedItem as EditReversionStep;

            if (selectedStep == null)
            {
                MessageBox.Show(this, "Please select a step to revert to first.", "Undo");
                return;
            }
            EditReversionStep curStep;

            do
            {
                (curStep = stepsAsList.PopLast()).ReversionAction();
            } while (curStep != selectedStep);

            historyList.Items.Clear();
            foreach (EditReversionStep ers in stepsAsList)
            {
                historyList.Items.Add(ers);
            }
            historyList.SelectedIndex = historyList.Items.Count - 1;
        }