Exemplo n.º 1
0
 public static void SaveDefaultProjectFolder()
 {
     RiverSimulationApplication.Properties.Settings s = RiverSimulationApplication.Properties.Settings.Default;
     if (Directory.Exists(Program.projectBaseFolder))
     {
         s.DefaultOpenProjectFolder = Program.projectBaseFolder;
         s.Save();
     }
 }
Exemplo n.º 2
0
        public static bool OpenProject(IWin32Window w)
        {
            FolderBrowserDialog folderOpen = new FolderBrowserDialog();

            RiverSimulationApplication.Properties.Settings s = RiverSimulationApplication.Properties.Settings.Default;
            folderOpen.ShowNewFolderButton = false;
            if (s.DefaultOpenProjectFolder != null && s.DefaultOpenProjectFolder.Length > 0)
            {
                folderOpen.SelectedPath = s.DefaultOpenProjectFolder;
            }
            else
            {
                folderOpen.SelectedPath = Program.documentPath;
            }
            SendKeys.Send("{TAB}{TAB}{RIGHT}");

            string projectFolder;

            if (folderOpen.ShowDialog(w) == DialogResult.OK)
            {
                projectFolder             = folderOpen.SelectedPath;
                Program.projectBaseFolder = Path.GetDirectoryName(projectFolder);
                Program.projectName       = Path.GetFileName(projectFolder);

                //Program.projectBaseFolder = folderOpen.SelectedPath;
            }
            else
            {
                return(false);
            }

            /*
             * if (File.Exists(Program.GetProjectFullPath() + @"\resed.i"))
             * {
             *  File.Delete(Program.GetProjectFullPath() + @"\resed.i");
             * }
             * if (File.Exists(Program.GetProjectFullPath() + @"\3Dinput.dat"))
             * {
             *  File.Delete(Program.GetProjectFullPath() + @"\3Dinput.dat");
             * }
             * if (File.Exists(Program.GetProjectFullPath() + @"\sed.dat"))
             * {
             *  File.Delete(Program.GetProjectFullPath() + @"\sed.dat");
             * }
             * if (File.Exists(Program.GetProjectFullPath() + @"\resed.O"))
             * {
             *  File.Delete(Program.GetProjectFullPath() + @"\resed.O");
             * }
             * if (File.Exists(Program.GetProjectFullPath() + @"\out"))
             * {
             *  File.Delete(Program.GetProjectFullPath() + @"\out");
             * }
             * if (File.Exists(Program.GetProjectFullPath() + @"\123"))
             * {
             *  File.Delete(Program.GetProjectFullPath() + @"\123");
             * }
             * if (File.Exists(Program.GetProjectFullPath() + @"\resed.er"))
             * {
             *  File.Delete(Program.GetProjectFullPath() + @"\resed.er");
             * }
             * if (File.Exists(Program.GetProjectFullPath() + @"\run.bat"))
             * {
             *  File.Delete(Program.GetProjectFullPath() + @"\run.bat");
             * }
             * if (File.Exists(Program.GetProjectFullPath() + @"\resed.exe"))
             * {
             *  File.Delete(Program.GetProjectFullPath() + @"\resed.exe");
             * }
             * */
            Program.SaveDefaultProjectFolder();
            return(true);
        }
Exemplo n.º 3
0
        public static bool NewProject(IWin32Window w)
        {
            FolderBrowserDialog folderOpen = new FolderBrowserDialog();

            RiverSimulationApplication.Properties.Settings s = RiverSimulationApplication.Properties.Settings.Default;
            folderOpen.ShowNewFolderButton = false;
            if (s.DefaultOpenProjectFolder != null && s.DefaultOpenProjectFolder.Length > 0)
            {
                folderOpen.SelectedPath = s.DefaultOpenProjectFolder;
            }
            else
            {
                folderOpen.SelectedPath = Program.documentPath;
            }
            //folderOpen.RootFolder = Environment.SpecialFolder.MyComputer;
            SendKeys.Send("{TAB}{TAB}{RIGHT}");

            string projectFolder;

            if (folderOpen.ShowDialog(w) == DialogResult.OK)
            {
                projectFolder             = folderOpen.SelectedPath;
                Program.projectBaseFolder = folderOpen.SelectedPath;
            }
            else
            {
                return(false);
            }

            //FindNewProjectName(projectFolder);
            InputForm dlg = new InputForm();

            dlg.Text          = "建立專案";
            dlg.desc.Text     = "請輸入新專案名稱";
            dlg.inputTxt.Text = FindNewProjectName(projectFolder);
            if (DialogResult.OK != dlg.ShowDialog())
            {
                return(false);
            }

            if (System.IO.Directory.Exists(projectFolder + "\\" + dlg.inputTxt.Text))
            {
                MessageBox.Show("此專案已存在!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }

            try
            {
                Program.projectName = dlg.inputTxt.Text;
                System.IO.Directory.CreateDirectory(Program.GetProjectFullPath());
            }
            catch (Exception)
            {
                MessageBox.Show("無法建立專案!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }

            //RiverSimulationProfile.profile = new RiverSimulationProfile();
            //Program.projectFolder = Program.documentPath + "\\" + dlg.inputTxt.Text;
            Program.SaveDefaultProjectFolder();
            return(true);
        }