Esempio n. 1
0
        private void buttonReadSerVols(object sender, EventArgs e)
        {
            SwashWare_FileManagement.frmSelectFile SelectFile = new SwashWare_FileManagement.frmSelectFile("HCM-CALC Urban Streets Service Volume Input File", "Software\\SwashWare\\HCMCalc\\UrbanStreets", "Software\\SwashWare\\HCMCalc\\UrbanStreets\\MostRecentlyUsedFiles");
            SelectFile.ShowDialog();

            if (SelectFile.CancelWasPressed)
            {
                return;
            }

            if (SelectFile.SelectedMru.Length > 0)
            {
                if (!File.Exists(SelectFile.SelectedMru))
                {
                    DialogResult result = MessageBox.Show(SelectFile.SelectedMru + "\r\nCannot be found\r\n\r\nDo you want to remove this filename from the Most recently Used File list?", "File does not exist", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                    if (result == DialogResult.Yes)
                    {
                        SelectFile.Mrus.DeleteFilePath(SelectFile.SelectedMru);
                    }

                    return;
                }
                else
                {
                    SelectFile.Mrus.ReportFileBeingOpenedOrSavedOrClosed(SelectFile.SelectedMru);
                    LoadSerVolsProject(SelectFile.SelectedMru);
                }
            }
            else
            {
                string Mrd = SwashWare_FileManagement.MostRecentlyUsedDirectory.GetMostRecentlyUsedDirectory("Software\\SwashWare\\HCMCalc\\UrbanStreets");
                string InitialDirectory;
                if (string.IsNullOrEmpty(Mrd))
                {
                    InitialDirectory = System.Windows.Forms.Application.StartupPath;   // + "\\Example";
                }
                else
                {
                    InitialDirectory = Mrd;
                }

                string Filename = GetFilenameFromOpenDialog(InitialDirectory);

                if (Filename != "No Filename")
                {
                    SwashWare_FileManagement.MostRecentlyUsedDirectory.SetMostRecentlyUsedDirectory(Path.GetDirectoryName(Filename));
                    SelectFile.Mrus.ReportFileBeingOpenedOrSavedOrClosed(Filename);
                    LoadSerVolsProject(Filename);
                    Project.FileName = Filename;
                }
                else
                {
                    //give warning message
                    return;
                }
            }
        }
Esempio n. 2
0
        private void btnReadFile_Click(object sender, EventArgs e)
        {
            //from HCM-CALC

            /*
             *  string FileListingTitle = ProjectData.SelectFacilityNameString(Module) + " Files";
             *  string RegistryDirectory = SwashWare_FileManagement.RegistryPathsHCMcalc.SelectMostRecentlyUsedDirectoryRegistryPath((SwashWare_FileManagement.FacilityType)Module);
             *  string RegistryPathForStoredFilenames = SwashWare_FileManagement.RegistryPathsHCMcalc.SelectMostRecentlyUsedFilesRegistryPath((SwashWare_FileManagement.FacilityType)Module);
             *  string Filter = SwashWare_FileManagement.RegistryPathsHCMcalc.SelectFileExtensionFilter((SwashWare_FileManagement.FacilityType)Module);
             *  string InitialDirectory = System.Windows.Forms.Application.StartupPath;
             *
             *  string Filename = SwashWare_FileManagement.Main.GetFilename(FileListingTitle, RegistryDirectory, RegistryPathForStoredFilenames, Filter, InitialDirectory);
             *
             *  if (Filename != "")
             *      ReadFileData(Filename);
             */

            //-------------------------------

            SwashWare_FileManagement.frmSelectFile SelectFile = new SwashWare_FileManagement.frmSelectFile("HCM-CALC Urban Streets Project Files", "Software\\SwashWare\\HCMCalc\\UrbanStreets", "Software\\SwashWare\\HCMCalc\\UrbanStreets\\MostRecentlyUsedFiles");
            SelectFile.ShowDialog();

            if (SelectFile.CancelWasPressed)
            {
                //FileOpenError = true;
                return;
            }

            if (SelectFile.SelectedMru.Length > 0)
            {
                if (!File.Exists(SelectFile.SelectedMru))
                {
                    DialogResult result = MessageBox.Show(SelectFile.SelectedMru + "\r\nCannot be found\r\n\r\nDo you want to remove this filename from the Most recently Used File list?", "File does not exist", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                    if (result == DialogResult.Yes)
                    {
                        SelectFile.Mrus.DeleteFilePath(SelectFile.SelectedMru);
                    }
                    //FileOpenError = true;
                    return;
                }
                else
                {
                    SelectFile.Mrus.ReportFileBeingOpenedOrSavedOrClosed(SelectFile.SelectedMru);
                    LoadProject(SelectFile.SelectedMru);
                }
            }
            else
            {
                string Mrd = SwashWare_FileManagement.MostRecentlyUsedDirectory.GetMostRecentlyUsedDirectory("Software\\SwashWare\\HCMCalc\\UrbanStreets");
                string InitialDirectory;
                if (string.IsNullOrEmpty(Mrd))
                {
                    InitialDirectory = System.Windows.Forms.Application.StartupPath;   // + "\\Example";
                }
                else
                {
                    InitialDirectory = Mrd;
                }

                string Filename = GetFilenameFromOpenDialog(InitialDirectory);

                if (Filename != "No Filename")
                {
                    SwashWare_FileManagement.MostRecentlyUsedDirectory.SetMostRecentlyUsedDirectory(Path.GetDirectoryName(Filename));
                    SelectFile.Mrus.ReportFileBeingOpenedOrSavedOrClosed(Filename);
                    LoadProject(Filename);
                    Project.FileName = Filename;
                }
                else
                {
                    //give warning message
                    return;
                }
            }

            //tstFilename.Text = Inputs.Project.FileName;

            //Filename = @"X:\OneDrive\Software Projects\HCM-CALC\_DataFiles\HCM\Urban Streets\UrbanStreetsTest1.xus";
            //Filename = @"X:\OneDrive\Software Projects\HCM-CALC\_DataFiles\HCM\Urban Streets\Scenario1.xus";
            //FileIO.ReadXmlFile(Filename, Project, Art, Ints, Segs);

            //Filename = @"X:\OneDrive\Software Projects\HCM-CALC\_DataFiles\HCM\Urban Streets\ArterialTest.xml";
            //Art = FileInputOutput2.DeserializeArterialData(Filename);
        }