public static bool OpenProjectFile(IWin32Window w, string projectPath) { OpenFileDialog dlg = new OpenFileDialog(); dlg.RestoreDirectory = true; dlg.InitialDirectory = Program.GetProjectFullPath(); dlg.Title = "開啟檔案"; // Set filter for file extension and default file extension dlg.Filter = "resed file|" + Program.projectFileFilter; string projectFile; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK && dlg.FileName != null) { // Open document projectFile = dlg.FileName; if (Path.GetDirectoryName(projectFile) != Program.GetProjectFullPath()) { MessageBox.Show("請選取專案目錄內的檔案!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } Program.projectFileName = Path.GetFileNameWithoutExtension(projectFile); } else { return(false); } try { RiverSimulationProfile.profile = RiverSimulationProfile.DeSerialize(projectFile); RiverSimulationProfile.profile.ResetGoogleStaticMap(); } catch { return(false); } return(true); }