コード例 #1
0
        private void LoadState(ProjectState targetState)
        {
            if (targetState == null)
                return;

            LoadSerializedContent(targetState.SerializedProject, targetState.ProjectPath, Project.Name);

            // Open graph views
            foreach (MyNodeGroup nodeGroup in
                    targetState.GraphPanes.Select(nodeId => Project.GetNodeById(nodeId)).OfType<MyNodeGroup>())
                OpenGraphLayout(nodeGroup);

            // Select active graph view
            if (targetState.SelectedGraphView < dockPanel.DocumentsCount)
                (dockPanel.DocumentsToArray()[targetState.SelectedGraphView] as GraphLayoutForm).Activate();

            foreach (GraphLayoutForm graph in GraphViews.Values)
                graph.SelectNodeView(targetState.SelectedNode);

            foreach (ObserverForm observerView in ObserverViews
                .Where(observerView => observerView.Observer.Id == targetState.SelectedObserver))
                observerView.FocusWindow();

            //DebugUndoManager();
        }
コード例 #2
0
        private void SaveState(string content, string filePath, string action)
        {
            int selectedNodeId = -1;
            string selectedObserverId = null;

            var selectedNode = NodePropertyView.Target as MyNode;
            if (selectedNode != null)
                selectedNodeId = selectedNode.Id;

            var selectedObserver = NodePropertyView.Target as MyAbstractObserver;
            if (selectedObserver != null)
                selectedObserverId = selectedObserver.Id;

            var projectState = new ProjectState(content)
            {
                ProjectPath = filePath,
                Action = action,
                SelectedNode = selectedNodeId,
                SelectedObserver = selectedObserverId
            };

            projectState.GraphPanes.AddRange(GraphViews.Select(view => view.Value.Target.Id));
            var activeGraphView = GraphViews.WithIndex().FirstOrDefault(view => view.Item.Value == dockPanel.ActiveDocument);
            if (activeGraphView != null)
                projectState.SelectedGraphView = activeGraphView.Index;

            UndoManager.SaveState(projectState);
        }
コード例 #3
0
        public void SaveState(ProjectState state)
        {
            if (HistorySize == 0)
                return;

            // Clear the redo stack, an action means we're throwing away the future.
            m_redoStates.Clear();

            // HistorySize + 1 (1 for the current step).
            while (m_undoStates.Count >= HistorySize + 1)
                m_undoStates.RemoveFirst();

            m_undoStates.AddLast(state);
        }