private void CreateRecentFilesMenu(string workspace) { if (this.RecentFilesMenu != null) { this.RecentFilesMenu.SaveToRegistry(); this.RecentFilesMenu.RemoveAll(); } if (!string.IsNullOrEmpty(workspace)) { int hashCode = workspace.GetHashCode(); string key = "SOFTWARE\\Tencent\\Tag\\Behaviac\\MRF\\" + hashCode; this.RecentFilesMenu = new RecentMenu(recentFilesMenuItem, new RecentMenu.ClickedHandler(OnMenuRecentFiles), key); } }
private void loadLayout(EditModes editMode, string layoutFile, bool bLoadWks) { preLoadLayout(editMode); __layoutFile = layoutFile; // Remove all controls and create a new dockPanel. this.Controls.Clear(); InitializeComponent(); this.RecentWorkspacesMenu = new RecentMenu(this.recentWorkspacesMenuItem, new RecentMenu.ClickedHandler(OnMenuRecentWorkspaces), "SOFTWARE\\Tencent\\Tag\\Behaviac\\MRU"); this.FormClosed -= this.MainWindow_FormClosed; this.FormClosed += this.MainWindow_FormClosed; this.KeyDown -= this.MainWindow_KeyDown; this.KeyDown += this.MainWindow_KeyDown; // Display the file version this.Text = "BehaviacDesigner " + this.ProductVersion; // Set the stored settings for the window this.WindowState = Settings.Default.MainWindowState; if (this.WindowState == FormWindowState.Normal) { this.Size = Settings.Default.MainWindowSize; this.Location = Settings.Default.MainWindowLocation; this.PerformLayout(); } // If we have no stored layout, generate a default one if (behaviorTreeListDock != null) { nodeTreeList.Dispose(); nodeTreeList = null; behaviorTreeList.Dispose(); behaviorTreeList = null; behaviorTreeListDock.Close(); behaviorTreeListDock = null; } bool layoutFileExisting = System.IO.File.Exists(layoutFile); if (layoutFileExisting) { // Add child controls for the dockPanel from the layout file. dockPanel.LoadFromXml(layoutFile, new WeifenLuo.WinFormsUI.Docking.DeserializeDockContent(GetContentFromPersistString)); if (this.behaviorTreeList == null) { //the corrupt layout file was deleted layoutFileExisting = false; } } if (!layoutFileExisting) { BehaviorTreeListDock btlDock = new BehaviorTreeListDock(); RegisterBehaviorTreeList(btlDock); btlDock.Show(dockPanel, WeifenLuo.WinFormsUI.Docking.DockState.DockLeft); PropertiesDock dock = new PropertiesDock(); dock.Show(dockPanel, WeifenLuo.WinFormsUI.Docking.DockState.DockRight); } if (this.WindowState == FormWindowState.Maximized) { this.Hide(); this.WindowState = FormWindowState.Minimized; this.WindowState = FormWindowState.Maximized; this.Show(); if (!layoutFileExisting) { this.dockPanel.Size = new Size(this.Size.Width - 20, this.Size.Height - 68); } } postLoadLayout(editMode, bLoadWks); // Make sure the window is focused Focus(); }