public App() { current = this; WinBlogXConfig config = WinBlogXConfig.Load(); if (config.StartDialog.Mru.Count > 0) { string path = config.StartDialog.Mru[0]; if (File.Exists(path)) { WinBlogXProject proj = null; XmlSerializer ser = new XmlSerializer(typeof(WinBlogXProject)); using (StreamReader reader = new StreamReader(path)) { proj = ser.Deserialize(reader) as WinBlogXProject; } if (proj != null) { proj.Upgrade(); SimpleBrowser browser = new SimpleBrowser(proj); browser.Show(); return; } } } new Start().Show(); }
private void ok_Click(object sender, System.EventArgs e) { if (openExisting.Checked) { if (existingProjects.SelectedItem != null && existingProjects.SelectedItem.ToString() != "More...") { Open(existingProjects.SelectedItem.ToString()); } else { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "WinBlogX Project Files (*.winblogx)|*.winblogx"; dlg.Title = "Open Project"; this.Visible = true; if (dlg.ShowDialog(this) == DialogResult.OK) { Open(dlg.FileName); } } } else { WinBlogXProject proj = new WinBlogXProject(); proj.Upgrade(); ProjectEditor editor = new ProjectEditor(); editor.Project = proj; if (editor.ShowDialog(this) == DialogResult.OK) { SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "WinBlogX Project Files (*.winblogx)|*.winblogx"; if (dlg.ShowDialog(this) == DialogResult.OK) { XmlSerializer ser = new XmlSerializer(typeof(WinBlogXProject)); using (StreamWriter writer = new StreamWriter(dlg.OpenFile())) { ser.Serialize(writer, proj); } Open(dlg.FileName); } } } }
void Open(string path) { WinBlogXProject proj = null; XmlSerializer ser = new XmlSerializer(typeof(WinBlogXProject)); using (StreamReader reader = new StreamReader(path)) { proj = ser.Deserialize(reader) as WinBlogXProject; } if (proj != null) { proj.Upgrade(); WinBlogXConfig config = WinBlogXConfig.Load(); config.StartDialog.AddMru(path); WinBlogXConfig.Save(config); SimpleBrowser browser = new SimpleBrowser(proj); browser.Show(); BeginInvoke(new MethodInvoker(Close)); } }