Example #1
0
        /// <summary>
        /// Handles when the main window becomes visible.
        /// </summary>
        private void MainWindow_Shown(object sender, EventArgs e)
        {
            // set the stored settings for the window
            if (Settings.Default.MainWindowLocation.X > 0 && Settings.Default.MainWindowLocation.Y > 0 && Settings.Default.MainWindowSize.Width > 0 && Settings.Default.MainWindowSize.Height > 0)
            {
                Location = Settings.Default.MainWindowLocation;
                Size     = Settings.Default.MainWindowSize;
            }

            WindowState = Settings.Default.MainWindowState;

            // restore layout
            if (System.IO.File.Exists(__layoutFile))
            {
                dockPanel.LoadFromXml(__layoutFile, new WeifenLuo.WinFormsUI.Docking.DeserializeDockContent(GetContentFromPersistString));
            }

            // make sure the window is focused
            Focus();

            try
            {
                // let the user select the workspace
                WorkspaceDialog dialog = new WorkspaceDialog();
                DialogResult    result = dialog.ShowDialog();
                if (result == DialogResult.Cancel)
                {
                    Close();
                    return;
                }

                Workspace workspace = dialog.Workspace;

                // set the default export folder
                ExportDialog.LastUsedExportFolder = workspace.DefaultExportFolder;

                // load the plugins
                behaviorTreeList.LoadPlugins("plugins", workspace.Plugins);

                // set the default behaviour folder
                behaviorTreeList.BehaviorFolder = workspace.Folder;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Plugin Error", MessageBoxButtons.OK);

                // close the editor
                Close();
            }


            // show controls
            if (Settings.Default.ShowControlsOnStartUp)
            {
                //ControlsDialog ctrldlg= new ControlsDialog();
                //ctrldlg.ShowDialog();
            }
        }
        /// <summary>
        /// Handles when the main window becomes visible.
        /// </summary>
        private void MainWindow_Shown(object sender, EventArgs e)
        {
            // set the stored settings for the window
            if(Settings.Default.MainWindowLocation.X >0 && Settings.Default.MainWindowLocation.Y >0 && Settings.Default.MainWindowSize.Width >0 && Settings.Default.MainWindowSize.Height >0)
            {
                Location= Settings.Default.MainWindowLocation;
                Size= Settings.Default.MainWindowSize;
            }

            WindowState= Settings.Default.MainWindowState;

            // restore layout
            if(System.IO.File.Exists(__layoutFile))
                dockPanel.LoadFromXml(__layoutFile, new WeifenLuo.WinFormsUI.Docking.DeserializeDockContent(GetContentFromPersistString));

            // make sure the window is focused
            Focus();

            try
            {
                // let the user select the workspace
                WorkspaceDialog dialog= new WorkspaceDialog();
                DialogResult result= dialog.ShowDialog();
                if(result ==DialogResult.Cancel)
                {
                    Close();
                    return;
                }

                Workspace workspace= dialog.Workspace;

                // set the default export folder
                ExportDialog.LastUsedExportFolder= workspace.DefaultExportFolder;

                // set the default behaviour folder
                behaviorTreeList.BehaviorFolder= workspace.Folder;

                // load the plugins
                behaviorTreeList.LoadPlugins("plugins", workspace.Plugins);

                // build list of behaviours
                behaviorTreeList.RebuildBehaviorList();
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message, "Plugin Error", MessageBoxButtons.OK);

                // close the editor
                Close();
            }
        }