private void LoadFSCToolStripMenuItem_Click_1( object sender, EventArgs e) { DialogResult result = DialogResult.No; if (this.dataGridView.Rows.Count > 0) { result = MessageBox.Show( "Clear Grid?", "Question", MessageBoxButtons.YesNo); } else { result = DialogResult.Yes; } this.openFileDialog.Filter = C45Constants.FILTER_C45DATA; if (result == DialogResult.Yes) { this.openFileDialog.FileName = ""; this.openFileDialog.ShowDialog(); if (this.openFileDialog.FileName != String.Empty) { this.featureSetCollection = C45FeatureSetCollection.LoadFSCFromFile(this.openFileDialog.FileName); this.SetEventHandler(); this.RestoreDataGridView(); } } }
internal C45FeatureSetCollection GetFSCFromFile(String filename) { C45FeatureSetCollection featureSetCollection = new C45FeatureSetCollection(); C45Schema schema = C45Schema.CreateFromFile(filename.Replace(".data".ToString(), ".names".ToString())); int character = 0; String line = String.Empty; FileStream file = new FileStream( filename, FileMode.Open); while (character >= 0) { line = String.Empty; character = file.ReadByte(); while (character != 0x0A && character > 0) { line += Convert.ToChar(character); character = file.ReadByte(); } featureSetCollection.Add(C45FeatureSet.GetFSFromLine(line, schema)); } return(featureSetCollection); }
public static C45FeatureSetCollection LoadFSCFromFile(String filename) { C45Controller controller = new C45Controller(); if (instance == null) { instance = controller.GetFSCFromFile(filename); } return(instance); }