private void m_menuOpen_Click(object sender, EventArgs e) { OpenFileDialog diag = new OpenFileDialog(); diag.Filter = "ui layout files (*.ui_layout)|*.ui_layout|All files (*.*)|*.*"; diag.InitialDirectory = UDesignApp.Instance.RootPath; string lastDir = Properties.Settings.Default.RecentAccessedDir; if (!string.IsNullOrEmpty(lastDir) && Directory.Exists(lastDir)) { diag.InitialDirectory = lastDir; } else { string testDir = LuaRuntime.GetGlobalString("ResPath_Test"); if (!string.IsNullOrEmpty(testDir)) { var testDirFull = SysUtil.NormalizePath(Path.Combine(UDesignApp.Instance.RootPath, testDir)); if (Directory.Exists(testDirFull)) { diag.InitialDirectory = testDirFull; } } } if (diag.ShowDialog(this) == DialogResult.OK) { string file = diag.FileName; if (File.Exists(file)) { // 这里重置前,应先提示用户保存 if (!ResetScene(file)) { Logging.Instance.Message("打开文件失败。"); } SetRecentAccessedDirectory(Path.GetDirectoryName(file)); } } }