private void OpenToolStripMenuItem_Click( object sender, EventArgs e) { this.openFileDialog.FileName = String.Empty; this.openFileDialog.Filter = C45Constants.FILTER_C45PROJECTS; this.openFileDialog.ShowDialog(); try { this.project = C45Project.CreateInstance(this.openFileDialog.FileName); this.c45Settings = C45Settings.CreateFromFile(project.C45ConfigFile); if (project.ProjectType == C45ProjectType.HRT) { hRTMapperToolStripMenuItem.Visible = true; } else { hRTMapperToolStripMenuItem.Visible = false; } this.c45Settings.C45SchemaFilename = Path.GetFileNameWithoutExtension(project.SchemaFile); this.groupBoxStats.Text = project.ProjectName; this.CreateColumns(); this.AcquireColumnWidth(); this.EnableControls(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void OptionsToolStripMenuItem_Click( object sender, EventArgs e) { C45InteropConfiguration config = new C45InteropConfiguration(this.c45Settings, null); if (config.Changed) { this.c45Settings = config.Settings; this.c45Settings.Save(); } }
/// <summary> /// Constructor /// </summary> /// <param name="settings">C45Settings object</param> /// <param name="windowOwner">Owner window handle interface</param> public C45InteropConfiguration(C45Settings settings, IWin32Window windowOwner) { this.settings = settings; OptionsForm form = new OptionsForm(settings); form.ShowDialog(windowOwner); if (form.DialogResult == DialogResult.OK) { this.settings = form.Settings; this.Changed = true; } }
/// <summary> /// Object factory, create an static instance of c45 settings /// </summary> public static C45Settings CreateFromFile(String configFile) { C45Settings newInstance = new C45Settings(); FileStream fs = new FileStream( configFile, FileMode.OpenOrCreate); XmlSerializer serializer = new XmlSerializer(typeof(C45Settings)); try { newInstance = (C45Settings)serializer.Deserialize(fs); fs.Close(); } catch (Exception ex) { //Save settings with initial default values System.Diagnostics.Trace.Write(C45Exceptions.CONFIG_FILE_NOT_FOUND); fs.Close(); newInstance.Save(); } return(newInstance); }