private void btnOK_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.txtProjectFile.Text)) { if (!string.IsNullOrEmpty(DBGlobalService.ProjectFile)) { DBGlobalService.Save(); } DBGlobalService.ProjectFile = this.txtProjectFile.Text.Trim(); //ProjectDoc doc = new ProjectDoc(); var doc = new Document(); doc.Load(DBGlobalService.ProjectFile); DBGlobalService.CurrentProject = new ProjectType(doc); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } }
/// <summary> /// Open an existing file /// </summary> /// <param name="path">Path for note</param> private void Open(string path) { try { using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read)) { Document document = new Document(); document.Load(fs); fNoteBox.Document = document; fFilePath = path; fFileName = System.IO.Path.GetFileNameWithoutExtension(path); Text = fFileName + " - " + TITLE; fNoteBox.Modified = false; } } catch (Exception e) { MessageBox.Show(this, "Unable to open file: " + path + "\n" + e.Message, "Error opening file", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Open(string filename) { try { using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) { Document document = new Document(); document.Load(fs); fScribble.Document = document; //fScribble.Scribble.Highlight(new object[] { "the" }); fFilePath = filename; fFileName = System.IO.Path.GetFileNameWithoutExtension(filename); Text = fFileName + " - " + TITLE; fScribble.Modified = false; } } catch (Exception e) { MessageBox.Show(this, "Unable to open file: " + filename + "\n" + e.Message, "Error opening file", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void LoadDB() { string selectDir = GlobalService.CurrentPrj_Dir; string projectName = GlobalService.CurrentPrj_Name; string path = System.IO.Path.Combine(selectDir, ""); DBGlobalService.ProjectFile = System.IO.Path.Combine(path, projectName + ".xml"); var doc = new Document(); ProjectType prj = null; if (!System.IO.File.Exists(DBGlobalService.ProjectFile)) { var stream = System.IO.File.Create(DBGlobalService.ProjectFile); stream.Close(); prj = doc.CreateNode<ProjectType>(); } else { doc.Load(DBGlobalService.ProjectFile); prj = new ProjectType(doc); } DBGlobalService.CurrentProjectDoc = doc; DBGlobalService.CurrentProject = prj; DBGlobalService.CurrentProject.Name = projectName; doc.Save(DBGlobalService.ProjectFile); this.CreateDBTree(); }