コード例 #1
0
        /// <summary>
        /// Switches the Workspace.
        /// </summary>
        /// <param name="newWorkspace">to switch to.</param>
        /// <param name="treeDesigner">The tree designer to remove remaining stuff.</param>
        public static void SwitchWorkspace(string newWorkspace, UcTreeDesigner treeDesigner)
        {
            //Be sure the new Workspace exists:
            if (!string.IsNullOrWhiteSpace(newWorkspace))
            {
                Directory.CreateDirectory(newWorkspace);
            }


            //Save the new Workspace to the Registry:
            try{
                var key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(RegSubKey);
                if (key != null)
                {
                    key.SetValue(RegWorkspaceKey, newWorkspace);
                    key.Close();
                }
            }catch (Exception exp) { Debug.Print(exp.ToString()); }


            //Clear the current Tree and the GUI:
            treeDesigner?.Clear();


            //Set the new Workspace:
            WorkSpace.DIR = newWorkspace;
            CopyDefault(WorkSpace.DIR);


            //Reload the managers:
            DataType.ReloadFromBaseFolder();
            Singleton <SmaSTraConfiguration> .Instance.Reload();

            Singleton <NodeBlacklist> .Instance.Reload();

            Singleton <ClassManager> .Instance.Reload();

            Singleton <Library> .Instance.loadLibrary();

            //Restore last state:
            if (treeDesigner != null)
            {
                RegularSaver.TryLoad(treeDesigner);
            }
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: SmaSTra/SmaSTra
        private void This_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            //Before closing, we try to save the current state:
            RegularSaver.Save(this.tdTreeDesigner);

            DialogClosingApplication closingDialog = new DialogClosingApplication();

            if (closingDialog.ShowDialog() == true)
            {
                if (closingDialog.YesClicked)
                {
                    e.Cancel = false;
                }
                else
                {
                    e.Cancel = true;
                }
            }
        }