public bool OpenFile(string filePath) { bool success = false; if (File.Exists(filePath)) { SeriesFileReader file = new SeriesFileReader(filePath); try { this.data = file.ReadData(); seriesDataList.SetData(this.data.SeriesVariables, this.data.SeriesGroups); this.variableViewPane.SetData(this.data); this.Text = this.data.SeriesName + " : \"" + filePath + "\""; string[] tabPageList = file.ReadViewPane(); foreach (string item in tabPageList) { this.variableViewPane.AddTabPage(item); } List<FATabStripItem> tmpTabPages = file.ReadResultPane(this.data); foreach (FATabStripItem tp in tmpTabPages) { tp.IsDrawn = true; this.tabControlResult.AddTab(tp); } success = true; this.filePath = filePath; this.initializeData(); this.printer = new SeriesDataPrinter(this.data); data.Changed += new ChangedEventHandler(OnChanged); this.variableViewPane.Changed += new ChangedEventHandler(OnChanged); this.tabControlResult.ControlAdded += new System.Windows.Forms.ControlEventHandler(this.tabControlResult_ControlAdded); this.tabControlResult.ControlRemoved += new System.Windows.Forms.ControlEventHandler(this.tabControlResult_ControlRemoved); } catch { MessageBox.Show("File contains incorrect format", "Can't open file", MessageBoxButtons.OK); success = false; } finally { file.CloseFile(); } } else { MessageBox.Show("File doesn't exist"); success = false; } return success; }
public bool OpenFile() { OpenFileDialog dlg = new OpenFileDialog(); bool success = false; dlg.Title = "Open Series Data...."; dlg.DefaultExt = ".zft"; dlg.Filter = "zaitun Files (*.zft)|*.zft"; //saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); //dlg.InitialDirectory = @"D:\"; dlg.RestoreDirectory = false; if (dlg.ShowDialog() == DialogResult.OK) { SeriesFileReader file = new SeriesFileReader(dlg.FileName); try { this.data = file.ReadData(); seriesDataList.SetData(this.data.SeriesVariables, this.data.SeriesGroups); this.variableViewPane.SetData(this.data); this.Text = this.data.SeriesName + " : \"" + dlg.FileName + "\""; string[] tabPageList = file.ReadViewPane(); foreach (string item in tabPageList) { this.variableViewPane.AddTabPage(item); } List<FATabStripItem> tmpTabPages = file.ReadResultPane(this.data); foreach (FATabStripItem tp in tmpTabPages) { tp.IsDrawn = true; this.tabControlResult.AddTab(tp); } success = true; this.filePath = dlg.FileName; this.initializeData(); this.printer = new SeriesDataPrinter(this.data); data.Changed += new ChangedEventHandler(OnChanged); this.variableViewPane.Changed += new ChangedEventHandler(OnChanged); this.tabControlResult.ControlAdded += new System.Windows.Forms.ControlEventHandler(this.tabControlResult_ControlAdded); this.tabControlResult.ControlRemoved += new System.Windows.Forms.ControlEventHandler(this.tabControlResult_ControlRemoved); } catch { MessageBox.Show("File contains incorrect format", "Can't open file", MessageBoxButtons.OK); success = false; } finally { file.CloseFile(); } } return success; }