コード例 #1
0
        private void ResetButton_Click(object sender, EventArgs e)
        {
            AppEnvironment defaults = new AppEnvironment();

            defaults.SetToDefaults();
            ToolType = Tool.DefaultToolType;
            LoadUIFromAppEnvironment(defaults);
        }
コード例 #2
0
        private void ToolChooserStrip_ChooseDefaultsClicked(object sender, EventArgs e)
        {
            PdnBaseForm.UpdateAllForms();

            WaitCursorChanger wcc = new WaitCursorChanger(this);

            using (ChooseToolDefaultsDialog dialog = new ChooseToolDefaultsDialog())
            {
                EventHandler shownDelegate = null;

                shownDelegate =
                    delegate(object sender2, EventArgs e2)
                {
                    wcc.Dispose();
                    wcc           = null;
                    dialog.Shown -= shownDelegate;
                };

                dialog.Shown += shownDelegate;
                dialog.SetToolBarSettings(this.appWorkspace.GlobalToolTypeChoice, this.appWorkspace.AppEnvironment);

                AppEnvironment defaultAppEnv = AppEnvironment.GetDefaultAppEnvironment();

                try
                {
                    dialog.LoadUIFromAppEnvironment(defaultAppEnv);
                }

                catch (Exception)
                {
                    defaultAppEnv = new AppEnvironment();
                    defaultAppEnv.SetToDefaults();
                    dialog.LoadUIFromAppEnvironment(defaultAppEnv);
                }

                dialog.ToolType = this.appWorkspace.DefaultToolType;

                DialogResult dr = dialog.ShowDialog(this);

                if (dr != DialogResult.Cancel)
                {
                    AppEnvironment newDefaultAppEnv = dialog.CreateAppEnvironmentFromUI();
                    newDefaultAppEnv.SaveAsDefaultAppEnvironment();
                    this.appWorkspace.AppEnvironment.LoadFrom(newDefaultAppEnv);
                    this.appWorkspace.DefaultToolType      = dialog.ToolType;
                    this.appWorkspace.GlobalToolTypeChoice = dialog.ToolType;
                }
            }

            if (wcc != null)
            {
                wcc.Dispose();
                wcc = null;
            }
        }
コード例 #3
0
        public static AppEnvironment GetDefaultAppEnvironment()
        {
            AppEnvironment appEnvironment;

            try
            {
                string defaultAppEnvBase64 = Settings.CurrentUser.GetString(SettingNames.DefaultAppEnvironment, null);

                if (defaultAppEnvBase64 == null)
                {
                    appEnvironment = null;
                }
                else
                {
                    byte[]          defaultAppEnvBytes = System.Convert.FromBase64String(defaultAppEnvBase64);
                    BinaryFormatter formatter          = new BinaryFormatter();

                    using (MemoryStream stream = new MemoryStream(defaultAppEnvBytes, false))
                    {
                        object defaultAppEnvObject = formatter.Deserialize(stream);
                        appEnvironment = (AppEnvironment)defaultAppEnvObject;
                    }
                }
            }

            catch (Exception)
            {
                appEnvironment = null;
            }

            if (appEnvironment == null)
            {
                appEnvironment = new AppEnvironment();
                appEnvironment.SetToDefaults();
            }

            return(appEnvironment);
        }