Exemple #1
0
        private void ResetButton_Click(object sender, EventArgs e)
        {
            AppEnvironment defaults = new AppEnvironment();

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

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

            ResumeLayout();
        }
 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.antiAliasing             = appEnvironment.antiAliasing;
     this.colorPickerClickBehavior = appEnvironment.colorPickerClickBehavior;
     this.resamplingAlgorithm      = appEnvironment.resamplingAlgorithm;
     this.tolerance                = appEnvironment.tolerance;
     PerformAllChanged();
 }
Exemple #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);
        }
Exemple #6
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;
            }
        }
Exemple #7
0
        public AppEnvironment CreateAppEnvironmentFromUI()
        {
            AppEnvironment newAppEnvironment = new AppEnvironment();

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

                if (row.ToolBarConfigItems.HasFlag(ToolBarConfigItems.Antialiasing))
                {
                    newAppEnvironment.AntiAliasing = row.ToolConfigStrip.AntiAliasing;
                }

                if (row.ToolBarConfigItems.HasFlag(ToolBarConfigItems.Brush))
                {
                    newAppEnvironment.BrushInfo = row.ToolConfigStrip.BrushInfo;
                }

                if (row.ToolBarConfigItems.HasFlag(ToolBarConfigItems.ColorPickerBehavior))
                {
                    newAppEnvironment.ColorPickerClickBehavior = row.ToolConfigStrip.ColorPickerClickBehavior;
                }

                if (row.ToolBarConfigItems.HasFlag(ToolBarConfigItems.FloodMode))
                {
                    newAppEnvironment.FloodMode = row.ToolConfigStrip.FloodMode;
                }

                if (row.ToolBarConfigItems.HasFlag(ToolBarConfigItems.Gradient))
                {
                    newAppEnvironment.GradientInfo = row.ToolConfigStrip.GradientInfo;
                }

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

                if (row.ToolBarConfigItems.HasFlag(ToolBarConfigItems.Resampling))
                {
                    newAppEnvironment.ResamplingAlgorithm = row.ToolConfigStrip.ResamplingAlgorithm;
                }

                if (row.ToolBarConfigItems.HasFlag(ToolBarConfigItems.SelectionCombineMode))
                {
                    newAppEnvironment.SelectionCombineMode = row.ToolConfigStrip.SelectionCombineMode;
                }

                if (row.ToolBarConfigItems.HasFlag(ToolBarConfigItems.SelectionDrawMode))
                {
                    newAppEnvironment.SelectionDrawModeInfo = row.ToolConfigStrip.SelectionDrawModeInfo;
                }

                if (row.ToolBarConfigItems.HasFlag(ToolBarConfigItems.ShapeType))
                {
                    newAppEnvironment.ShapeDrawType = row.ToolConfigStrip.ShapeDrawType;
                }

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

                if (row.ToolBarConfigItems.HasFlag(ToolBarConfigItems.Tolerance))
                {
                    newAppEnvironment.Tolerance = row.ToolConfigStrip.Tolerance;
                }
            }

            return(newAppEnvironment);
        }
Exemple #8
0
 public void SetToolBarSettings(Type newToolType, AppEnvironment newToolBarAppEnvironment)
 {
     this.toolBarToolType       = newToolType;
     this.toolBarAppEnvironment = newToolBarAppEnvironment.Clone();
 }
 public void LoadFromAppEnvironment(AppEnvironment appEnvironment)
 {
     AlphaBlending = appEnvironment.AlphaBlending;
     AntiAliasing = appEnvironment.AntiAliasing;
     BrushInfo = appEnvironment.BrushInfo;
     ColorPickerClickBehavior = appEnvironment.ColorPickerClickBehavior;
     GradientInfo = appEnvironment.GradientInfo;
     PenInfo = appEnvironment.PenInfo;
     ResamplingAlgorithm = appEnvironment.ResamplingAlgorithm;
     ShapeDrawType = appEnvironment.ShapeDrawType;
     FontInfo = appEnvironment.FontInfo;
     FontSmoothing = appEnvironment.FontSmoothing;
     FontAlignment = appEnvironment.TextAlignment;
     Tolerance = appEnvironment.Tolerance;
 }
        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.Antialiasing) != 0)
                {
                    newAppEnvironment.AntiAliasing = row.ToolConfigStrip.AntiAliasing;
                }

                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.Gradient) != 0)
                {
                    newAppEnvironment.GradientInfo = row.ToolConfigStrip.GradientInfo;
                }

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

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

                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;
        }
 private void ResetButton_Click(object sender, EventArgs e)
 {
     AppEnvironment defaults = new AppEnvironment();
     defaults.SetToDefaults();
     ToolType = Tool.DefaultToolType;
     LoadUIFromAppEnvironment(defaults);
 }
 public void SetToolBarSettings(Type newToolType, AppEnvironment newToolBarAppEnvironment)
 {
     this.toolBarToolType = newToolType;
     this.toolBarAppEnvironment = newToolBarAppEnvironment.Clone();
 }
        public void LoadUIFromAppEnvironment(AppEnvironment newAppEnvironment)
        {
            SuspendLayout();

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

            ResumeLayout();
        }
Exemple #14
0
        public void LoadSettings()
        {
            try
            {
                LoadDefaultToolType();

                this.globalToolTypeChoice = this.defaultToolTypeChoice;
                this.globalRulersChoice = Settings.CurrentUser.GetBoolean(SettingNames.Rulers, false);
                this.DrawGrid = Settings.CurrentUser.GetBoolean(SettingNames.DrawGrid, false);

                this.appEnvironment = AppEnvironment.GetDefaultAppEnvironment();

                this.widgets.ViewConfigStrip.Units = (MeasurementUnit)Enum.Parse(typeof(MeasurementUnit),
                    Settings.CurrentUser.GetString(SettingNames.Units, MeasurementUnit.Pixel.ToString()), true);
            }

            catch (Exception)
            {
                this.appEnvironment = new AppEnvironment();
                this.appEnvironment.SetToDefaults();

                try
                {
                    Settings.CurrentUser.Delete(
                        new string[] 
                        {    
                            SettingNames.Rulers, 
                            SettingNames.DrawGrid, 
                            SettingNames.Units,
                            SettingNames.DefaultAppEnvironment,
                            SettingNames.DefaultToolTypeName,
                        });
                }

                catch (Exception)
                {
                }
            }

            try
            {
                this.toolBar.ToolConfigStrip.LoadFromAppEnvironment(this.appEnvironment);
            }

            catch (Exception)
            {
                this.appEnvironment = new AppEnvironment();
                this.appEnvironment.SetToDefaults();
                this.toolBar.ToolConfigStrip.LoadFromAppEnvironment(this.appEnvironment);
            }
        }
Exemple #15
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;
        }
Exemple #16
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.antiAliasing = appEnvironment.antiAliasing;
     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();
 }