Ejemplo n.º 1
0
        private void ResetButton_Click(object sender, EventArgs e)
        {
            AppEnvironment defaults = new AppEnvironment();

            defaults.SetToDefaults();
            ToolType = Tool.DefaultToolType;
            LoadUIFromAppEnvironment(defaults);
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 3
0
        public void LoadUIFromAppEnvironment(AppEnvironment newAppEnvironment)
        {
            SuspendLayout();

            foreach (ToolConfigRow row in this.toolConfigRows)
            {
                row.ToolConfigStrip.LoadFromAppEnvironment(newAppEnvironment);
            }

            ResumeLayout();
        }
Ejemplo n.º 4
0
 public void LoadFrom(AppEnvironment appEnvironment)
 {
     this.textAlignment            = appEnvironment.textAlignment;
     this.gradientInfo             = appEnvironment.gradientInfo.Clone();
     this.fontSmoothing            = appEnvironment.fontSmoothing;
     this.fontInfo                 = appEnvironment.fontInfo.Clone();
     this.penInfo                  = appEnvironment.penInfo.Clone();
     this.brushInfo                = appEnvironment.brushInfo.Clone();
     this.primaryColor             = appEnvironment.primaryColor;
     this.secondaryColor           = appEnvironment.secondaryColor;
     this.alphaBlending            = appEnvironment.alphaBlending;
     this.shapeDrawType            = appEnvironment.shapeDrawType;
     this.colorPickerClickBehavior = appEnvironment.colorPickerClickBehavior;
     this.resamplingAlgorithm      = appEnvironment.resamplingAlgorithm;
     this.tolerance                = appEnvironment.tolerance;
     this.selectionCombineMode     = appEnvironment.selectionCombineMode;
     this.floodMode                = appEnvironment.floodMode;
     this.selectionDrawModeInfo    = appEnvironment.selectionDrawModeInfo.Clone();
     PerformAllChanged();
 }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
 public void SetToolBarSettings(Type newToolType, AppEnvironment newToolBarAppEnvironment)
 {
     this.toolBarToolType       = newToolType;
     this.toolBarAppEnvironment = newToolBarAppEnvironment.Clone();
 }
Ejemplo n.º 7
0
        public AppEnvironment CreateAppEnvironmentFromUI()
        {
            AppEnvironment newAppEnvironment = new AppEnvironment();

            foreach (ToolConfigRow row in this.toolConfigRows)
            {
                if ((row.ToolBarConfigItems & ToolBarConfigItems.AlphaBlending) != 0)
                {
                    newAppEnvironment.AlphaBlending = row.ToolConfigStrip.AlphaBlending;
                }

                if ((row.ToolBarConfigItems & ToolBarConfigItems.Brush) != 0)
                {
                    newAppEnvironment.BrushInfo = row.ToolConfigStrip.BrushInfo;
                }

                if ((row.ToolBarConfigItems & ToolBarConfigItems.ColorPickerBehavior) != 0)
                {
                    newAppEnvironment.ColorPickerClickBehavior = row.ToolConfigStrip.ColorPickerClickBehavior;
                }

                if ((row.ToolBarConfigItems & ToolBarConfigItems.FloodMode) != 0)
                {
                    newAppEnvironment.FloodMode = row.ToolConfigStrip.FloodMode;
                }

                if ((row.ToolBarConfigItems & ToolBarConfigItems.Gradient) != 0)
                {
                    newAppEnvironment.GradientInfo = row.ToolConfigStrip.GradientInfo;
                }

                if ((row.ToolBarConfigItems & ToolBarConfigItems.Pen) != 0 ||
                    (row.ToolBarConfigItems & ToolBarConfigItems.PenCaps) != 0)
                {
                    newAppEnvironment.PenInfo = row.ToolConfigStrip.PenInfo;
                }

                if ((row.ToolBarConfigItems & ToolBarConfigItems.Resampling) != 0)
                {
                    newAppEnvironment.ResamplingAlgorithm = row.ToolConfigStrip.ResamplingAlgorithm;
                }

                if ((row.ToolBarConfigItems & ToolBarConfigItems.SelectionCombineMode) != 0)
                {
                    newAppEnvironment.SelectionCombineMode = row.ToolConfigStrip.SelectionCombineMode;
                }

                if ((row.ToolBarConfigItems & ToolBarConfigItems.SelectionDrawMode) != 0)
                {
                    newAppEnvironment.SelectionDrawModeInfo = row.ToolConfigStrip.SelectionDrawModeInfo;
                }

                if ((row.ToolBarConfigItems & ToolBarConfigItems.ShapeType) != 0)
                {
                    newAppEnvironment.ShapeDrawType = row.ToolConfigStrip.ShapeDrawType;
                }

                if ((row.ToolBarConfigItems & ToolBarConfigItems.Text) != 0)
                {
                    newAppEnvironment.FontInfo      = row.ToolConfigStrip.FontInfo;
                    newAppEnvironment.FontSmoothing = row.ToolConfigStrip.FontSmoothing;
                    newAppEnvironment.TextAlignment = row.ToolConfigStrip.FontAlignment;
                }

                if ((row.ToolBarConfigItems & ToolBarConfigItems.Tolerance) != 0)
                {
                    newAppEnvironment.Tolerance = row.ToolConfigStrip.Tolerance;
                }
            }

            return(newAppEnvironment);
        }