Ejemplo n.º 1
0
        private void saveProjectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.DefaultExt = "lxj";
            dlg.Filter     = "LogExpert session (*.lxj)|*.lxj";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string        fileName  = dlg.FileName;
                List <string> fileNames = new List <string>();

                lock (logWindowList)
                {
                    foreach (DockContent content in dockPanel.Contents)
                    {
                        LogWindow logWindow = content as LogWindow;
                        if (logWindow != null)
                        {
                            string persistenceFileName = logWindow.SavePersistenceData(true);
                            if (persistenceFileName != null)
                            {
                                fileNames.Add(persistenceFileName);
                            }
                        }
                    }
                }
                ProjectData projectData = new ProjectData();
                projectData.memberList   = fileNames;
                projectData.tabLayoutXml = SaveLayout();
                ProjectPersister.SaveProjectData(fileName, projectData);
            }
        }
Ejemplo n.º 2
0
        private void LoadProject(string projectFileName, bool restoreLayout)
        {
            ProjectData projectData   = ProjectPersister.LoadProjectData(projectFileName);
            bool        hasLayoutData = projectData.tabLayoutXml != null;

            if (hasLayoutData && restoreLayout && logWindowList.Count > 0)
            {
                ProjectLoadDlg dlg = new ProjectLoadDlg();
                if (DialogResult.Cancel != dlg.ShowDialog())
                {
                    switch (dlg.ProjectLoadResult)
                    {
                    case ProjectLoadDlgResult.IgnoreLayout:
                        hasLayoutData = false;
                        break;

                    case ProjectLoadDlgResult.CloseTabs:
                        CloseAllTabs();
                        break;

                    case ProjectLoadDlgResult.NewWindow:
                        LogExpertProxy.NewWindow(new string[] { projectFileName });
                        return;
                    }
                }
            }

            if (projectData != null)
            {
                foreach (string fileName in projectData.memberList)
                {
                    if (hasLayoutData)
                    {
                        AddFileTabDeferred(fileName, false, null, true, null);
                    }
                    else
                    {
                        AddFileTab(fileName, false, null, true, null);
                    }
                }

                if (hasLayoutData && restoreLayout)
                {
                    // Re-creating tool (non-document) windows is needed because the DockPanel control would throw strange errors
                    DestroyToolWindows();
                    InitToolWindows();
                    RestoreLayout(projectData.tabLayoutXml);
                }
            }
        }