private void LoadDocument(string file, Workspace workspace) { TabPage tab = new TabPage(Path.GetFileNameWithoutExtension(file)); tab.Name = file; // the key // loads and associates the tab page with the document Document doc = workspace.CreateDocument(file, tab); doc.Services.AddService(typeof(IMenuCommandService), new MenuCommandService(doc.Services)); doc.Load(); doc.Services.AddService(typeof(UndoEngine), new UndoRedoEngine(doc.Services)); if (doc.LoadSuccessful) { doc.Modified += OnDocumentModified; workspace.ActiveDocument = doc; ((Control)doc.DesignSurface.View).Dock = DockStyle.Fill; tab.Controls.Add((Control)doc.DesignSurface.View); surfaceTabs.SuspendLayout(); surfaceTabs.TabPages.Add(tab); surfaceTabs.ResumeLayout(); surfaceTabs.SelectedTab = surfaceTabs.TabPages[file]; } else { MessageBox.Show("Unable to load!"); tab.Dispose(); workspace.CloseDocument(doc); } }
private void CloseDocument(Document doc) { doc.Modified -= OnDocumentModified; surfaceTabs.TabPages.Remove(surfaceTabs.SelectedTab); _workspace.CloseDocument(doc); propertyGrid.Clear(); }
private void LoadDocument(string file, Workspace workspace) { TabPage tab = new TabPage (Path.GetFileNameWithoutExtension (file)); tab.Name = file; // the key // loads and associates the tab page with the document Document doc = workspace.CreateDocument (file, tab); doc.Services.AddService (typeof (IMenuCommandService), new MenuCommandService (doc.Services)); doc.Load (); doc.Services.AddService (typeof (UndoEngine), new UndoRedoEngine (doc.Services)); if (doc.LoadSuccessful) { doc.Modified += OnDocumentModified; workspace.ActiveDocument = doc; ((Control)doc.DesignSurface.View).Dock = DockStyle.Fill; tab.Controls.Add ((Control)doc.DesignSurface.View); surfaceTabs.SuspendLayout (); surfaceTabs.TabPages.Add (tab); surfaceTabs.ResumeLayout (); surfaceTabs.SelectedTab = surfaceTabs.TabPages[file]; } else { MessageBox.Show ("Unable to load!"); tab.Dispose (); workspace.CloseDocument (doc); } }