private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (DialogResult.OK.Equals(ofdProjectFile.ShowDialog(this))) { projectFilePath = ofdProjectFile.FileName; projectFolderPath = Path.GetDirectoryName(projectFilePath); ProjectFileReader pfr = new ProjectFileReader(projectFilePath); opcMockProject = pfr.OpcMockProject; opcMockProject.OnProtocolAdded += new OpcMockProject.ProtocolHandler(opcMockProject_OnProtocolAdded); projectFileWriter = new ProjectFileWriter(opcMockProject, projectFolderPath); if (!File.Exists(DataFilePath())) { File.Create(DataFilePath()).Close(); } opcReader = new OpcReaderCsv(DataFilePath()); opcWriter = new OpcWriterCsv(DataFilePath()); FillOpcDataGrid(opcReader.ReadAllTags()); Text = "OPC Mock - " + opcMockProject.Name; EnableButtonsAfterDataFileLoad(); } }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { CreateProjectDialog cpd = new CreateProjectDialog(); cpd.StartPosition = FormStartPosition.CenterParent; if (DialogResult.OK.Equals(cpd.ShowDialog(this))) { opcMockProject = cpd.Project; opcMockProject.OnProtocolAdded += new OpcMockProject.ProtocolHandler(opcMockProject_OnProtocolAdded); projectFolderPath = cpd.ProjectFolderPath; projectFileWriter = new ProjectFileWriter(opcMockProject, projectFolderPath); projectFileWriter.Save(); if (!File.Exists(DataFilePath())) { File.Create(DataFilePath()).Close(); } opcReader = new OpcReaderCsv(DataFilePath()); opcWriter = new OpcWriterCsv(DataFilePath()); Text = "OPC Mock - " + opcMockProject.Name; EnableButtonsAfterDataFileLoad(); } cpd.Dispose(); }