private void dgvResults_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (WithFreewayFacilityFiles == true)
            {
                if (e.ColumnIndex > 0 && e.RowIndex >= 0)
                {
                    int link = Convert.ToInt32(dgvResults.Rows[e.RowIndex].Cells[colID.Name].Value);
                    int tp   = Convert.ToInt32(dgvResults.Rows[e.RowIndex].Cells[colTimePeriod.Name].Value);

                    if (e.ColumnIndex == 7) // Load in FreewawFacilities program
                    {
                        int freewayID = (int)dgvResults.Rows[e.RowIndex].Cells[colID.Name].Value;
                        GetLinkIndex(freewayID);
                        int numTPs = myResults.Count;
                        //numTPs-1: the last time period results contains them all
                        FreewayData fwy = myFreewayFacilities[GetFacilityID(freewayID)];
                        List <List <SegmentData> > tpsegs = fwy.TPsegs;
                        int NumOfLanes = tpsegs[0][0].NumThruLanes;
                        HCMCalc_Definitions.ProjectData FFproject = new HCMCalc_Definitions.ProjectData("Freeway Facility", AnalysisMode.HCM2016);
                        HCMCalc_Calculations.CalculationsMain.CalcResults(FFproject, NumOfLanes, ref fwy, ref tpsegs);
                        HCMCalc_FreewayFacility.mdiMain MDIform = new HCMCalc_FreewayFacility.mdiMain(FFproject, fwy, tpsegs);
                        MDIform.Show();
                    }
                }
            }
        }
Example #2
0
        private void tsbSaveLinkData_Click(object sender, EventArgs e)
        {
            bool DataSaved = SaveLinkData();

            if (DataSaved == true)
            {
                MessageBox.Show("Data successfully saved.", "XXE", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            if (Project.Type == ProjectType.FreewayFacilities)
            {
                FileListingTitle  = "XXE OD Data File";
                RegistryDirectory = "Software\\XXE\\ProjectFiles";
                RegistryPathForStoredFilenames = "Software\\XXE\\ProjectFiles\\MostRecentlyUsedFiles";
                Filter           = "Network Files (*.xml)|*.xml|All Files (*.*)|*.*";
                InitialDirectory = Application.StartupPath;
                FileName         = SwashWare_FileManagement.Main.GetFileNameForSave(Filter, RegistryDirectory, RegistryPathForStoredFilenames);
                if (FileName != "")
                {
                    HCMCalc_Definitions.ProjectData ProjectFF = new HCMCalc_Definitions.ProjectData("Freeway Facility", AnalysisMode.HCM2016);
                    FreewayFacilityIO FileIOFF = new FreewayFacilityIO();
                    FileIOFF.WriteFreewaysFile(FileName, false, true, ProjectFF, FreewayFacilities);
                    Project.NetworkFileName = FileName;
                }
            }
        }
Example #3
0
        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();
                    }
                }
            }
        }
Example #4
0
        private void SaveFreewayFacilitiesList()
        {
            HCMCalc_Definitions.ProjectData ProjectFF = new HCMCalc_Definitions.ProjectData("Freeway Facility", AnalysisMode.HCM2016);
            FreewayFacilityIO FileIOFF = new FreewayFacilityIO();

            FileIOFF.WriteFreewaysFile(Project.NetworkFileName, false, true, ProjectFF, FreewayFacilities);
        }
Example #5
0
        private void FileSave()  //do a direct save to currently named file
        {
            try
            {
                if (Project.Type == ProjectType.BPRlinks)
                {
                    XXE_Calculations.FileInputOutput.WriteXmlFile(Project.FileName, Project, Network, Links, OrigDestPairs);
                    FileSaveError = false;
                    frmFileSaveSummary FileSaveSummary = new frmFileSaveSummary();
                    FileSaveSummary.ShowDialog();
                }
                else
                {
                    //save freeway facilities file
                    HCMCalc_Definitions.ProjectData ProjectFF = new HCMCalc_Definitions.ProjectData("Freeway Facility", AnalysisMode.HCM2016);
                    FreewayFacilityIO FileIOFF = new FreewayFacilityIO();
                    FileIOFF.WriteFreewaysFile(Project.NetworkFileName, false, true, ProjectFF, FreewayFacilities);

                    //save OD data file
                    XXE_Calculations.FileInputOutput.WriteODdataFile(Project.ODfileName, OrigDestPairs);

                    //save project file
                    XXE_Calculations.FileInputOutput.WriteFreewayFacilitiesProjectFile(Project.FileName, Project, Network);
                }
            }
            catch
            {
                MessageBox.Show("One or more data input cells do not contain a valid entry.  File cannot be saved at this time.", "Data Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                FileSaveError = true;
            }
        }
Example #6
0
        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);
        }
Example #7
0
        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();
                }
            }
        }
Example #8
0
        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();
                        //!!!
                    }
                }
            }
        }
Example #9
0
        private void FileSaveAs()
        {
            try
            {
                if (Project.Type == ProjectType.BPRlinks)
                {
                    string FileName = Main.GetFileNameForSave(Filter, RegistryDirectory, RegistryPathForStoredFilenames);

                    if (FileName != "")
                    {
                        Project.FileName = FileName;
                        XXE_Calculations.FileInputOutput.WriteXmlFile(Project.FileName, Project, Network, Links, OrigDestPairs);
                        tstxtFilename.Text = Project.FileName;
                        FileSaveError      = false;
                        frmFileSaveSummary FileSaveSummary = new frmFileSaveSummary();
                        FileSaveSummary.ShowDialog();
                    }
                }
                else
                {
                    FileListingTitle  = "XXE Network File";
                    RegistryDirectory = "Software\\XXE\\ProjectFiles";
                    RegistryPathForStoredFilenames = "Software\\XXE\\ProjectFiles\\MostRecentlyUsedFiles";
                    Filter           = "Network Files (*.net)|*.xml|All Files (*.*)|*.*";
                    InitialDirectory = Application.StartupPath;
                    string FileName = "";
                    if (Project.NetworkFileName == "untitled.xml")
                    {
                        //save freeway facilities file
                        FileName = Main.GetFileNameForSave(Filter, RegistryDirectory, RegistryPathForStoredFilenames);
                        if (FileName != "")
                        {
                            HCMCalc_Definitions.ProjectData ProjectFF = new HCMCalc_Definitions.ProjectData("Freeway Facility", AnalysisMode.HCM2016);
                            FreewayFacilityIO FileIOFF = new FreewayFacilityIO();
                            Project.NetworkFileName = FileName;
                            FileIOFF.WriteFreewaysFile(FileName, false, true, ProjectFF, FreewayFacilities);
                        }
                    }
                    else
                    {
                        HCMCalc_Definitions.ProjectData ProjectFF = new HCMCalc_Definitions.ProjectData("Freeway Facility", AnalysisMode.HCM2016);
                        FreewayFacilityIO FileIOFF = new FreewayFacilityIO();
                        FileIOFF.WriteFreewaysFile(Project.NetworkFileName, false, true, ProjectFF, FreewayFacilities);
                    }

                    if (Project.ODfileName == "untitled.xml")
                    {
                        //save OD data file
                        FileListingTitle  = "XXE OD Data File";
                        RegistryDirectory = "Software\\XXE\\ProjectFiles";
                        RegistryPathForStoredFilenames = "Software\\XXE\\ProjectFiles\\MostRecentlyUsedFiles";
                        Filter           = "OD Files (*.od)|*.xml|All Files (*.*)|*.*";
                        InitialDirectory = Application.StartupPath;
                        FileName         = Main.GetFileNameForSave(Filter, RegistryDirectory, RegistryPathForStoredFilenames);
                        if (FileName != "")
                        {
                            Project.ODfileName = FileName;
                            XXE_Calculations.FileInputOutput.WriteODdataFile(FileName, OrigDestPairs);
                        }
                    }
                    else
                    {
                        XXE_Calculations.FileInputOutput.WriteODdataFile(Project.ODfileName, OrigDestPairs);
                    }

                    //save project file
                    FileListingTitle  = "XXE Network File";
                    RegistryDirectory = "Software\\XXE\\ProjectFiles";
                    RegistryPathForStoredFilenames = "Software\\XXE\\ProjectFiles\\MostRecentlyUsedFiles";
                    Filter           = "XML Files (*.xml)|*.xml|All Files (*.*)|*.*";
                    InitialDirectory = Application.StartupPath;
                    FileName         = Main.GetFileNameForSave(Filter, RegistryDirectory, RegistryPathForStoredFilenames);
                    if (FileName != "")
                    {
                        XXE_Calculations.FileInputOutput.WriteFreewayFacilitiesProjectFile(FileName, Project, Network);
                    }
                }
            }
            catch
            {
                MessageBox.Show("One or more data input cells do not contain a valid entry.  File cannot be saved at this time.", "Data Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                FileSaveError = true;
            }
        }