示例#1
0
 private void FromState(SpaceSavedState state)
 {
     if (!string.IsNullOrWhiteSpace(state.StatementXml))
     {
         FromXml(state.StatementXml);
     }
     FromXml(state.Xml);
     FromXml(state.BgXml);
     ChangesPending = state.ChangesPending;
     NamedIdList    = state.NamedIdList.ToList();
     NamelessIdList = state.NamelessIdList.ToList();
     foreach (int i in state.NamedImported)
     {
         NamedObjects[i].Imported = true;
     }
     foreach (int i in state.NamelessImported)
     {
         NamelessObjects[i].Imported = true;
     }
     foreach (int i in state.NamedSelected)
     {
         NamedObjects[i].Selected = true;
     }
     if (state.NamelessSelected != null)
     {
         SelectionNameless = NamelessObjects[state.NamelessSelected.Value];
     }
 }
示例#2
0
        public bool Redo(SpaceSavedState state = null)
        {
            if (RedoStack.Count == 0)
            {
                return(false);
            }

            state = state ?? RedoStack.Peek();
            while (UndoStack.Count == 0 || UndoStack.Peek() != state)
            {
                UndoStack.Push(RedoStack.Pop());
            }
            FromState(UndoStack.Peek());

            return(true);
        }
示例#3
0
        private SpaceSavedState ToState(string shortDescription)
        {
            SpaceSavedState state = new SpaceSavedState();

            state.StatementXml     = SelectionSpecial == null ? null : "<statementInput>" + SelectionSpecial.ToXml(new XmlDocument()).OuterXml + "</statementInput>";
            state.Xml              = ToXml();
            state.BgXml            = ToXml(true);
            state.ChangesPending   = ChangesPending;
            state.Description      = shortDescription;
            state.NamedIdList      = NamedIdList.ToList();
            state.NamelessIdList   = NamelessIdList.ToList();
            state.NamedImported    = new List <int>();
            state.NamelessImported = new List <int>();
            for (int i = 0; i < NamedObjects.Count; i++)
            {
                if (NamedObjects[i].Imported)
                {
                    state.NamedImported.Add(i);
                }
            }
            for (int i = 0; i < NamelessObjects.Count; i++)
            {
                if (NamelessObjects[i].Imported)
                {
                    state.NamelessImported.Add(i);
                }
            }
            state.NamedSelected = new List <int>();
            for (int i = 0; i < NamedObjects.Count; i++)
            {
                if (NamedObjects[i].Selected)
                {
                    state.NamedSelected.Add(i);
                }
            }
            if (SelectionNameless == null)
            {
                state.NamelessSelected = null;
            }
            else
            {
                state.NamelessSelected = NamelessObjects.IndexOf(SelectionNameless);
            }

            return(state);
        }
 public void Undo(SpaceSavedState state = null)
 {
     if (SpaceMap.Undo(state))
     {
         UpdateFormText();
         Selection_Update();
         UpdateObjectLists();
         Redraw();
     }
 }
示例#5
0
        public bool Redo(SpaceSavedState state = null)
        {
            if (RedoStack.Count == 0)
                return false;

            state = state ?? RedoStack.Peek();
            while (UndoStack.Count == 0 || UndoStack.Peek() != state)
                UndoStack.Push(RedoStack.Pop());
            FromState(UndoStack.Peek());

            return true;
        }
示例#6
0
        private SpaceSavedState ToState(string shortDescription)
        {
            SpaceSavedState state = new SpaceSavedState();

            state.StatementXml = SelectionSpecial == null ? null : "<statementInput>" + SelectionSpecial.ToXml(new XmlDocument()).OuterXml + "</statementInput>";
            state.Xml = ToXml();
            state.BgXml = ToXml(true);
            state.ChangesPending = ChangesPending;
            state.Description = shortDescription;
            state.NamedIdList = NamedIdList.ToList();
            state.NamelessIdList = NamelessIdList.ToList();
            state.NamedImported = new List<int>();
            state.NamelessImported = new List<int>();
            for (int i = 0; i < NamedObjects.Count; i++)
                if (NamedObjects[i].Imported)
                    state.NamedImported.Add(i);
            for (int i = 0; i < NamelessObjects.Count; i++)
                if (NamelessObjects[i].Imported)
                    state.NamelessImported.Add(i);
            state.NamedSelected = new List<int>();
            for (int i = 0; i < NamedObjects.Count; i++)
                if (NamedObjects[i].Selected)
                    state.NamedSelected.Add(i);
            if (SelectionNameless == null)
                state.NamelessSelected = null;
            else
                state.NamelessSelected = NamelessObjects.IndexOf(SelectionNameless);

            return state;
        }
示例#7
0
 private void FromState(SpaceSavedState state)
 {
     if (!string.IsNullOrWhiteSpace(state.StatementXml)) FromXml(state.StatementXml);
     FromXml(state.Xml);
     FromXml(state.BgXml);
     ChangesPending = state.ChangesPending;
     NamedIdList = state.NamedIdList.ToList();
     NamelessIdList = state.NamelessIdList.ToList();
     foreach (int i in state.NamedImported)
         NamedObjects[i].Imported = true;
     foreach (int i in state.NamelessImported)
         NamelessObjects[i].Imported = true;
     foreach (int i in state.NamedSelected)
         NamedObjects[i].Selected = true;
     if (state.NamelessSelected != null)
         SelectionNameless = NamelessObjects[state.NamelessSelected.Value];
 }