private void tsbLoadLinkData_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); openFileDialog.Filter = "DAT Files (*.dat)|*.dat|XML Files (*.xml)|*.xml|All Files (*.*)|*.*"; if (openFileDialog.ShowDialog(this) == DialogResult.OK) { FileName = openFileDialog.FileName; if (Project.Type == ProjectType.BPRlinks) { XXE_Calculations.FileInputOutput.ReadNWDatFile(FileName, Network, Links); Project.NetworkFileName = FileName; for (int i = 1; i <= Network.TotalLinks; i++) { object[] NewRow = new object[] { Links[i].FromNode, Links[i].ToNode, Links[i].Capacity[0], Links[i].Length, Links[i].FreeFlowSpeed, (Links[i].Length / Links[i].FreeFlowSpeed).ToString("0.0000"), Links[i].Description }; dgvLinkData.Rows.Add(NewRow); } } else { if (FileName != "") { HCMCalc_Definitions.ProjectData ProjectFF = new HCMCalc_Definitions.ProjectData("Freeway Facility", AnalysisMode.HCM2016); FreewayFacilityIO FileIOFF = new FreewayFacilityIO(); FreewayFacilities.Clear(); FileIOFF.ReadFreewaysFile(FileName, ref ProjectFF, FreewayFacilities); Project.NetworkFileName = FileName; LoadLinkData(); } } } }
private void ReadFreewayFacilitiesList(List <FreewayData> FreewayFacilities) { HCMCalc_Definitions.ProjectData ProjectFF = new HCMCalc_Definitions.ProjectData("Freeway Facility", AnalysisMode.HCM2016); FreewayFacilityIO FileIOFF = new FreewayFacilityIO(); FreewayFacilities.Clear(); FileIOFF.ReadFreewaysFile(Project.NetworkFileName, ref ProjectFF, FreewayFacilities); }
public void FileOpen(object sender, EventArgs e) { string FileName = Main.GetFilename(FileListingTitle, RegistryDirectory, RegistryPathForStoredFilenames, Filter, InitialDirectory); if (Project.Type == ProjectType.BPRlinks) { if (FileName != "") { this.CloseAllToolStripMenuItem_Click(this, e); //close currently active child forms Project.FileName = FileName; tstxtFilename.Text = Project.FileName; //XXE_Calculations.FileInputOutput FileIO = new XXE_Calculations.FileInputOutput(); XXE_Calculations.FileInputOutput.ReadXmlFile(Project.FileName, Project, Network, Links, OrigDestPairs); //string ShortFileName = System.IO.Path.GetFileName(ProjectData.FileName); this.Text = "XXE"; OpenAllDataForms(); } } else { if (FileName != "") { this.CloseAllToolStripMenuItem_Click(this, e); //close currently active child forms Project.FileName = FileName; tstxtFilename.Text = Project.FileName; //read proejct file XXE_Calculations.FileInputOutput.ReadFreewayFacilitiesProjectFile(FileName, Project, Network); //read freeway facilities network file HCMCalc_Definitions.ProjectData ProjectFF = new HCMCalc_Definitions.ProjectData("Freeway Facility", AnalysisMode.HCM2016); FreewayFacilityIO FileIOFF = new FreewayFacilityIO(); FreewayFacilities.Clear(); FileIOFF.ReadFreewaysFile(Project.NetworkFileName, ref ProjectFF, FreewayFacilities); //test for (int fwy = 0; fwy < FreewayFacilities.Count; fwy++) { List <List <SegmentData> > tpsegs = FreewayFacilities[fwy].TPsegs; FreewayData Freeway = FreewayFacilities[fwy]; HCMCalc_Definitions.ProjectData FFproject = new HCMCalc_Definitions.ProjectData("Freeway Facility", AnalysisMode.HCM2016); HCMCalc_Calculations.CalculationsMain.CalcResults(FFproject, FreewayFacilities[fwy].TPsegs[0][0].NumThruLanes, ref Freeway, ref tpsegs); } //read od data file XXE_Calculations.FileInputOutput.ReadODxmlFile(Project.ODfileName, Network, OrigDestPairs); tsConvCrit.Text = Network.ConvCrit.ToString(); tsMaxIter.Text = Network.MaxIterations.ToString(); this.Text = "XXE"; OpenAllDataForms(); } } }
private void dgvLinkData_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 6 && dgvLinkData.Columns["PrintTimePerData"].Visible == true) //Print Time Period Results check box column //check for visible column corrects bug where program crashes if user selects the 'Description' column on the right edge { // Force the update of the value for the checkbox column. // Without this, the value doens't get updated until you move off from the cell. dgvLinkData.Rows[e.RowIndex].Cells[6].Value = (bool)dgvLinkData.Rows[e.RowIndex].Cells[6].EditedFormattedValue; bool CheckValue = (bool)dgvLinkData.Rows[e.RowIndex].Cells[6].Value; if (CheckValue == true) { Links[e.RowIndex + 1].PrintTimePerResults = true; } else { Links[e.RowIndex + 1].PrintTimePerResults = false; } } if (e.ColumnIndex == 7) //Add Time Period Data check box column { dgvLinkData.Rows[e.RowIndex].Cells[7].Value = (bool)dgvLinkData.Rows[e.RowIndex].Cells[7].EditedFormattedValue; bool CheckValue = (bool)dgvLinkData.Rows[e.RowIndex].Cells[7].Value; if (CheckValue == true) { Links[e.RowIndex + 1].TimePerData = true; //set time period data flag to true Network.NumRestrictedLinks++; } else { Links[e.RowIndex + 1].TimePerData = false; Network.NumRestrictedLinks--; } //** have check box interact with enabling of edit link in next column } if (e.ColumnIndex == 8) //Edit Time Period Data Link { // Create a new instance of the modal form. frmLinkTimePerData frmTPdata = new frmLinkTimePerData(Network, Links); int RowIndex = e.RowIndex + 1; int FromNode = Convert.ToInt32(dgvLinkData.Rows[e.RowIndex].Cells[0].Value); int ToNode = Convert.ToInt32(dgvLinkData.Rows[e.RowIndex].Cells[1].Value); GetTimePeriodData(frmTPdata.ShowDialog(RowIndex, FromNode, ToNode, this), RowIndex); } if (Project.Type == ProjectType.FreewayFacilities) { if (e.ColumnIndex == 11) //Open FreewayFacilities module { if (dgvLinkData.Rows[e.RowIndex].Cells[colPhysicalLink.Name].EditedFormattedValue.ToString() == "Yes") { if (FreewayFacilities[e.RowIndex].TPsegs == null) { FreewayFacilities[e.RowIndex] = InitializeFreewayData(); } HCMCalc_Definitions.ProjectData project = new HCMCalc_Definitions.ProjectData("Freeway Facility", AnalysisMode.HCM2016); mdiMain MDIform = new mdiMain(project, FreewayFacilities[e.RowIndex], FreewayFacilities[e.RowIndex].TPsegs); MDIform.ShowDialog(); } } else if (e.ColumnIndex == 12) //Check freeway facility boundary { if (FreewayFacilities[e.RowIndex].PhysicalLinkXXE == true) { //!!!! //save freeway facilities first FileListingTitle = "XXE OD Data File"; RegistryDirectory = "Software\\XXE\\ProjectFiles"; RegistryPathForStoredFilenames = "Software\\XXE\\ProjectFiles\\MostRecentlyUsedFiles"; Filter = "Network Files (*.xml)|*.xml|All Files (*.*)|*.*"; InitialDirectory = Application.StartupPath; HCMCalc_Definitions.ProjectData ProjectFF = new HCMCalc_Definitions.ProjectData("Freeway Facility", AnalysisMode.HCM2016); FreewayFacilityIO FileIOFF = new FreewayFacilityIO(); FileIOFF.WriteFreewaysFile(Project.NetworkFileName, false, true, ProjectFF, FreewayFacilities); //load into boundary form FreewayFacility myFreewayFacilityForm = new FreewayFacility(FreewayFacilities[e.RowIndex]); myFreewayFacilityForm.ShowDialog(); //!!! //reload freeway facilities, cause TPsegs change in the volume assignment process FreewayFacilities.Clear(); FileIOFF.ReadFreewaysFile(Project.NetworkFileName, ref ProjectFF, FreewayFacilities); LoadLinkData(); //!!! } } } }