public void OpenCanvas(object sender, CCanvas c) { _MainView.Hide(); _EditorView.PauseMouseCapture(); EditorViewModel context = _EditorView.DataContext as EditorViewModel; context.activeCanvas = c; // HACK WorkspaceViewModel mvm = _MainView.DataContext as WorkspaceViewModel; string wsName; if (_MainView.navHasFocus) { wsName = "All Canvases"; } else { wsName = mvm.activeWS.name; } _EditorView.RefreshWorkspaceComboBox(wsName); _EditorView.SelectActiveCanvas(); _EditorView.Show(); Console.WriteLine("Done opening canvas!"); }
public void LoadState(out CanvasModel cm, out WorkspaceModel wm) { string dataPath = ".\\data"; string path = dataPath + "\\canvasstate.xml"; if (File.Exists(path)) { XmlSerializer x = new XmlSerializer(typeof(CanvasModel)); CanvasModel tempModel; using (XmlReader xReader = XmlReader.Create(path)) { tempModel = (CanvasModel)x.Deserialize(xReader); } foreach (CCanvas c in tempModel.allCanvases) { c.LoadFromFile(dataPath); } cm = tempModel; } else { cm = new CanvasModel(); } path = dataPath + "\\workspacestate.xml"; if (File.Exists(path)) { XmlSerializer x = new XmlSerializer(typeof(WorkspaceModel)); WorkspaceModel tempModel; using (XmlReader xReader = XmlReader.Create(path)) { tempModel = (WorkspaceModel)x.Deserialize(xReader); } foreach (Workspace ws in tempModel.allWorkspaces) { foreach (SketchThumbnail s in ws.Sketches) { CCanvas ancestor = cm[s.canvasID]; s.thumbnail = ancestor.getThumbnail(); s.canvas = ancestor; } } wm = tempModel; foreach (Workspace ws in _wsModel.allWorkspaces) { ws.LoadNotesFromFile(dataPath); } } else { wm = new WorkspaceModel(); wm.Initialize(); } }