////////////////////////////////////////////////////////////////////////// private void OnLoad(object sender, EventArgs e) { this.MinimumSize = this.Size; if (AppMgr == null) { FormBase MainForm = ParentForm as FormBase; if (MainForm != null) { AppMgr = MainForm.AppMgr; } } if (AppMgr != null) { LoadLayout(AppMgr.Settings); } ListScripts.Items.Clear(); foreach (string Scr in Scripts) { ListScripts.Items.Add(Scr); } if (ListScripts.Items.Count > 0) { ListScripts.SelectedIndex = 0; } SetState(); }
////////////////////////////////////////////////////////////////////////// private void OnLoad(object sender, EventArgs e) { this.MinimumSize = this.Size; if (AppMgr == null) { FormBase MainForm = ParentForm as FormBase; if (MainForm != null) { AppMgr = MainForm.AppMgr; } } if (AppMgr != null) { LoadLayout(AppMgr.Settings); } }
////////////////////////////////////////////////////////////////////////// protected string GetProjectFile(FormBase ParentForm) { ProjectSelectionForm dlg = new ProjectSelectionForm(); if (ParentForm != null) { dlg.AppMgr = ParentForm.AppMgr; } dlg.RecentFiles = Document.RecentProjects; if (dlg.ShowDialog() == DialogResult.OK) { Document.AddRecentProject(dlg.FileName); return(dlg.FileName); } else { return(null); } }
////////////////////////////////////////////////////////////////////////// public WindowDoc(FormBase ParentForm) { _ParentForm = ParentForm; }
////////////////////////////////////////////////////////////////////////// protected string GetProjectFile(string DefinitionFile, FormBase ParentForm) { if (DefinitionFile == null) { return(GetProjectFile(ParentForm)); } try { string ProjectPath = ""; if (File.Exists(DefinitionFile)) { using (StreamReader sr = new StreamReader(DefinitionFile, Encoding.Default, true)) { string Line; string Magic = "; $EDITOR_PROJECT_ROOT_DIR$ "; while ((Line = sr.ReadLine()) != null) { if (Line.StartsWith(Magic)) { ProjectPath = Line.Substring(Magic.Length).Trim(); break; } } } } if (ProjectPath != "") { string FilePath = Path.GetDirectoryName(DefinitionFile); ProjectPath = Path.GetFullPath(Path.Combine(FilePath, ProjectPath)); if (Directory.Exists(ProjectPath)) { string[] ProjectFiles = Directory.GetFiles(ProjectPath, "*.wpr"); if (ProjectFiles.Length > 0) { Document.AddRecentProject(ProjectFiles[0]); return(ProjectFiles[0]); } } } // not found, we'll scan all the directories in file path string TestPath = Path.GetDirectoryName(DefinitionFile); while (true) { string[] ProjectFiles = Directory.GetFiles(TestPath, "*.wpr"); if (ProjectFiles.Length > 0) { Document.AddRecentProject(ProjectFiles[0]); return(ProjectFiles[0]); } int i = TestPath.LastIndexOfAny(new char[] { '\\', '/' }); if (i < 0) { break; } TestPath = TestPath.Substring(0, i); } // still not found, ask user return(GetProjectFile(ParentForm)); } catch (IOException) { return(GetProjectFile(ParentForm)); } catch (UnauthorizedAccessException) { return(GetProjectFile(ParentForm)); } }
////////////////////////////////////////////////////////////////////////// protected string GetProjectFile(FormBase ParentForm) { ProjectSelectionForm dlg = new ProjectSelectionForm(); if (ParentForm != null) dlg.AppMgr = ParentForm.AppMgr; dlg.RecentFiles = Document.RecentProjects; if (dlg.ShowDialog() == DialogResult.OK) { Document.AddRecentProject(dlg.FileName); return dlg.FileName; } else return null; }
////////////////////////////////////////////////////////////////////////// protected string GetProjectFile(string DefinitionFile, FormBase ParentForm) { if (DefinitionFile == null) return GetProjectFile(ParentForm); try { string ProjectPath = ""; if (File.Exists(DefinitionFile)) { using (StreamReader sr = new StreamReader(DefinitionFile, Encoding.Default, true)) { string Line; string Magic = "; $EDITOR_PROJECT_ROOT_DIR$ "; while ((Line = sr.ReadLine()) != null) { if (Line.StartsWith(Magic)) { ProjectPath = Line.Substring(Magic.Length).Trim(); break; } } } } if (ProjectPath != "") { string FilePath = Path.GetDirectoryName(DefinitionFile); ProjectPath = Path.GetFullPath(Path.Combine(FilePath, ProjectPath)); if (Directory.Exists(ProjectPath)) { string[] ProjectFiles = Directory.GetFiles(ProjectPath, "*.wpr"); if (ProjectFiles.Length > 0) { Document.AddRecentProject(ProjectFiles[0]); return ProjectFiles[0]; } } } // not found, we'll scan all the directories in file path string TestPath = Path.GetDirectoryName(DefinitionFile); while (true) { string[] ProjectFiles = Directory.GetFiles(TestPath, "*.wpr"); if (ProjectFiles.Length > 0) { Document.AddRecentProject(ProjectFiles[0]); return ProjectFiles[0]; } int i = TestPath.LastIndexOfAny(new char[] { '\\', '/' }); if (i < 0) break; TestPath = TestPath.Substring(0, i); } // still not found, ask user return GetProjectFile(ParentForm); } catch (IOException) { return GetProjectFile(ParentForm); } catch (UnauthorizedAccessException) { return GetProjectFile(ParentForm); } }