Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
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;
            }
        }