/src/ToolConfigStrip.cs
C# | 3124 lines | 2471 code | 428 blank | 225 comment | 225 complexity | 3fcd10914ff97202e869d92fec081adf MD5 | raw file
Possible License(s): Unlicense
Large files files are truncated, but you can click here to view the full file
- /////////////////////////////////////////////////////////////////////////////////
- // Paint.NET //
- // Copyright (C) dotPDN LLC, Rick Brewster, Tom Jackson, and contributors. //
- // Portions Copyright (C) Microsoft Corporation. All Rights Reserved. //
- // See src/Resources/Files/License.txt for full licensing and attribution //
- // details. //
- // . //
- /////////////////////////////////////////////////////////////////////////////////
-
- using PaintDotNet.SystemLayer;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Globalization;
- using System.Text;
- using System.Threading;
- using System.Windows.Forms;
-
- namespace PaintDotNet
- {
- // TODO: for 4.0, refactor into smaller ToolConfigStrip "Sections"
- // better yet, use IndirectUI
- internal class ToolConfigStrip
- : ToolStripEx,
- IBrushConfig,
- IShapeTypeConfig,
- IPenConfig,
- IAntiAliasingConfig,
- IAlphaBlendingConfig,
- ITextConfig,
- IToleranceConfig,
- IColorPickerConfig,
- IGradientConfig,
- IResamplingConfig,
- ISelectionCombineModeConfig,
- IFloodModeConfig,
- ISelectionDrawModeConfig
- {
- private ToolBarConfigItems toolBarConfigItems = ToolBarConfigItems.None;
-
- private EnumLocalizer hatchStyleNames = EnumLocalizer.Create(typeof(HatchStyle));
- private string solidBrushText;
- private ImageResource shapeOutlineImage = PdnResources.GetImageResource("Icons.ShapeOutlineIcon.png");
- private ImageResource shapeInteriorImage = PdnResources.GetImageResource("Icons.ShapeInteriorIcon.png");
- private ImageResource shapeBothImage = PdnResources.GetImageResource("Icons.ShapeBothIcon.png");
-
- private ToolStripSeparator brushSeparator;
- private ToolStripLabel brushStyleLabel;
- private ToolStripComboBox brushStyleComboBox;
-
- private ToolStripSeparator shapeSeparator;
- private ToolStripSplitButton shapeButton;
-
- private ToolStripSeparator penSeparator;
- private ToolStripLabel penSizeLabel;
- private ToolStripButton penSizeDecButton;
- private ToolStripComboBox penSizeComboBox;
- private ToolStripButton penSizeIncButton;
- private ToolStripLabel penStyleLabel;
- private ToolStripSplitButton penStartCapSplitButton; // Tag property is used to store chosen LineCap value
- private ToolStripSplitButton penDashStyleSplitButton; // Tag property is used to store chosen DashStyle value
- private ToolStripSplitButton penEndCapSplitButton; // Tag property is used to store chosen LineCap value
-
- private EnumLocalizer lineCapLocalizer = EnumLocalizer.Create(typeof(LineCap2));
- private EnumLocalizer dashStyleLocalizer = EnumLocalizer.Create(typeof(DashStyle));
-
- private ToolStripSeparator blendingSeparator;
- private ToolStripSplitButton alphaBlendingSplitButton;
- private bool alphaBlendingEnabled = true;
- private ImageResource alphaBlendingEnabledImage;
- private ImageResource alphaBlendingOverwriteImage;
-
- private ToolStripSplitButton antiAliasingSplitButton;
- private bool antiAliasingEnabled = true;
- private ImageResource antiAliasingEnabledImage;
- private ImageResource antiAliasingDisabledImage;
-
- private EnumLocalizer resamplingAlgorithmNames = EnumLocalizer.Create(typeof(ResamplingAlgorithm));
- private ToolStripSeparator resamplingSeparator;
- private ToolStripLabel resamplingLabel;
- private ToolStripComboBox resamplingComboBox;
-
- private EnumLocalizer colorPickerBehaviorNames = EnumLocalizer.Create(typeof(ColorPickerClickBehavior));
- private ToolStripSeparator colorPickerSeparator;
- private ToolStripLabel colorPickerLabel;
- private ToolStripComboBox colorPickerComboBox;
-
- private ToolStripSeparator toleranceSeparator;
- private ToolStripLabel toleranceLabel;
- private ToolStripControlHost toleranceSliderStrip;
- private ToleranceSliderControl toleranceSlider;
-
- private LineCap2[] lineCaps =
- new LineCap2[]
- {
- LineCap2.Flat,
- LineCap2.Arrow,
- LineCap2.ArrowFilled,
- LineCap2.Rounded
- };
-
- private DashStyle[] dashStyles =
- new DashStyle[]
- {
- DashStyle.Solid,
- DashStyle.Dash,
- DashStyle.DashDot,
- DashStyle.DashDotDot,
- DashStyle.Dot
- };
-
- private const float minPenSize = 1.0f;
- private const float maxPenSize = 500.0f;
- private int[] brushSizes =
- new int[]
- {
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
- 11, 12, 13, 14, 15, 20, 25, 30,
- 35, 40, 45, 50, 55, 60, 65, 70,
- 75, 80, 85, 90, 95, 100, 125,
- 150, 175, 200, 225, 250, 275, 300,
- 325, 350, 375, 400, 425, 450, 475,
- 500
- };
- private ShapeDrawType shapeDrawType;
-
- private EnumLocalizer gradientTypeNames = EnumLocalizer.Create(typeof(GradientType));
- private GradientInfo gradientInfo = new GradientInfo(GradientType.LinearClamped, false);
- private ToolStripSeparator gradientSeparator1;
- private ToolStripButton gradientLinearClampedButton;
- private ToolStripButton gradientLinearReflectedButton;
- private ToolStripButton gradientLinearDiamondButton;
- private ToolStripButton gradientRadialButton;
- private ToolStripButton gradientConicalButton;
- private ToolStripSeparator gradientSeparator2;
- private ToolStripSplitButton gradientChannelsSplitButton;
- private ImageResource gradientAllColorChannelsImage;
- private ImageResource gradientAlphaChannelOnlyImage;
-
- private EnumLocalizer fontSmoothingLocalizer = EnumLocalizer.Create(typeof(FontSmoothing));
- private const int maxFontSize = 2000;
- private const int minFontSize = 1;
- private const int initialFontSize = 12;
-
- private FontFamily arialFontFamily;
- private FontStyle fontStyle;
- private TextAlignment alignment;
- private float oldSizeValue;
- private Brush highlightBrush;
- private Brush highlightTextBrush;
- private Brush windowBrush;
- private Brush windowTextBrush;
- private Font arialFontBase;
- private const string arialName = "Arial";
-
- private static ManualResetEvent staticFontNamesPopulatedEvent = new ManualResetEvent(false);
- private static List<string> staticFontNames = null;
- private bool fontsComboBoxPopulated = false;
-
- private ToolStripSeparator fontSeparator;
- private ToolStripLabel fontLabel;
- private ToolStripComboBox fontFamilyComboBox;
- private ToolStripComboBox fontSizeComboBox;
- private ToolStripComboBox fontSmoothingComboBox;
- private ToolStripSeparator fontStyleSeparator;
- private ToolStripButton fontBoldButton;
- private ToolStripButton fontItalicsButton;
- private ToolStripButton fontUnderlineButton;
- private ToolStripSeparator fontAlignSeparator;
- private ToolStripButton fontAlignLeftButton;
- private ToolStripButton fontAlignCenterButton;
- private ToolStripButton fontAlignRightButton;
-
- private int[] defaultFontSizes =
- new int[]
- {
- 8, 9, 10, 11, 12, 14, 16, 18, 20,
- 22, 24, 26, 28, 36, 48, 72, 84, 96,
- 108, 144, 192, 216, 288
- };
-
- private ToolStripSeparator selectionCombineModeSeparator;
- private ToolStripLabel selectionCombineModeLabel;
- private ToolStripSplitButton selectionCombineModeSplitButton;
-
- private ToolStripSeparator floodModeSeparator;
- private ToolStripLabel floodModeLabel;
- private ToolStripSplitButton floodModeSplitButton;
-
- private SelectionDrawModeInfo selectionDrawModeInfo;
- private ToolStripSeparator selectionDrawModeSeparator;
- private ToolStripLabel selectionDrawModeModeLabel;
- private ToolStripSplitButton selectionDrawModeSplitButton;
- private ToolStripLabel selectionDrawModeWidthLabel;
- private ToolStripTextBox selectionDrawModeWidthTextBox;
- private ToolStripButton selectionDrawModeSwapButton;
- private ToolStripLabel selectionDrawModeHeightLabel;
- private ToolStripTextBox selectionDrawModeHeightTextBox;
- private UnitsComboBoxStrip selectionDrawModeUnits;
-
- public event EventHandler SelectionDrawModeUnitsChanging;
- protected void OnSelectionDrawModeUnitsChanging()
- {
- if (SelectionDrawModeUnitsChanging != null)
- {
- SelectionDrawModeUnitsChanging(this, EventArgs.Empty);
- }
- }
-
- public event EventHandler SelectionDrawModeUnitsChanged;
- protected void OnSelectionDrawModeUnitsChanged()
- {
- if (SelectionDrawModeUnitsChanged != null)
- {
- SelectionDrawModeUnitsChanged(this, EventArgs.Empty);
- }
- }
-
- 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;
- SelectionCombineMode = appEnvironment.SelectionCombineMode;
- FloodMode = appEnvironment.FloodMode;
- SelectionDrawModeInfo = appEnvironment.SelectionDrawModeInfo;
- }
-
- public event EventHandler BrushInfoChanged;
- protected virtual void OnBrushChanged()
- {
- if (BrushInfoChanged != null)
- {
- BrushInfoChanged(this, EventArgs.Empty);
- }
- }
-
- public BrushInfo BrushInfo
- {
- get
- {
- if (this.brushStyleComboBox.SelectedItem.ToString() == this.solidBrushText)
- {
- return new BrushInfo(BrushType.Solid, HatchStyle.BackwardDiagonal);
- }
-
- if (this.brushStyleComboBox.SelectedIndex == -1)
- {
- return new BrushInfo(BrushType.Solid, HatchStyle.BackwardDiagonal);
- }
- else
- {
- return new BrushInfo(
- BrushType.Hatch,
- (HatchStyle)this.hatchStyleNames.LocalizedNameToEnumValue(this.brushStyleComboBox.SelectedItem.ToString()));
- }
- }
-
- set
- {
- if (value.BrushType == BrushType.Solid)
- {
- this.brushStyleComboBox.SelectedItem = this.solidBrushText;
- }
- else
- {
- this.brushStyleComboBox.SelectedItem = this.hatchStyleNames.EnumValueToLocalizedName(value.HatchStyle);
- }
- }
- }
-
- public event EventHandler GradientInfoChanged;
-
- protected virtual void OnGradientInfoChanged()
- {
- if (GradientInfoChanged != null)
- {
- GradientInfoChanged(this, EventArgs.Empty);
- }
- }
-
- public void PerformGradientInfoChanged()
- {
- OnGradientInfoChanged();
- }
-
- public GradientInfo GradientInfo
- {
- get
- {
- return this.gradientInfo;
- }
-
- set
- {
- if (value == null)
- {
- throw new ArgumentNullException();
- }
-
- this.gradientInfo = value;
- OnGradientInfoChanged();
- SyncGradientInfo();
- }
- }
-
- private void SyncGradientInfo()
- {
- this.gradientConicalButton.Checked = false;
- this.gradientRadialButton.Checked = false;
- this.gradientLinearClampedButton.Checked = false;
- this.gradientLinearReflectedButton.Checked = false;
- this.gradientLinearDiamondButton.Checked = false;
-
- switch (this.gradientInfo.GradientType)
- {
- case GradientType.Conical:
- this.gradientConicalButton.Checked = true;
- break;
-
- case GradientType.LinearClamped:
- this.gradientLinearClampedButton.Checked = true;
- break;
-
- case GradientType.LinearReflected:
- this.gradientLinearReflectedButton.Checked = true;
- break;
-
- case GradientType.LinearDiamond:
- this.gradientLinearDiamondButton.Checked = true;
- break;
-
- case GradientType.Radial:
- this.gradientRadialButton.Checked = true;
- break;
-
- default:
- throw new InvalidEnumArgumentException();
- }
-
- if (this.gradientInfo.AlphaOnly)
- {
- this.gradientChannelsSplitButton.Image = this.gradientAlphaChannelOnlyImage.Reference;
- }
- else
- {
- this.gradientChannelsSplitButton.Image = this.gradientAllColorChannelsImage.Reference;
- }
- }
-
- private void ShapeButton_DropDownOpening(object sender, EventArgs e)
- {
- ToolStripMenuItem outlineMI = new ToolStripMenuItem();
- outlineMI.Text = PdnResources.GetString("ShapeDrawTypeConfigWidget.OutlineButton.ToolTipText");
- outlineMI.Image = this.shapeOutlineImage.Reference;
- outlineMI.Tag = (object)ShapeDrawType.Outline;
- outlineMI.Click += new EventHandler(ShapeMI_Click);
-
- ToolStripMenuItem interiorMI = new ToolStripMenuItem();
- interiorMI.Text = PdnResources.GetString("ShapeDrawTypeConfigWidget.InteriorButton.ToolTipText");
- interiorMI.Image = this.shapeInteriorImage.Reference;
- interiorMI.Tag = (object)ShapeDrawType.Interior;
- interiorMI.Click += new EventHandler(ShapeMI_Click);
-
- ToolStripMenuItem bothMI = new ToolStripMenuItem();
- bothMI.Text = PdnResources.GetString("ShapeDrawTypeConfigWidget.BothButton.ToolTipText");
- bothMI.Image = this.shapeBothImage.Reference;
- bothMI.Tag = (object)ShapeDrawType.Both;
- bothMI.Click += new EventHandler(ShapeMI_Click);
-
- switch (this.shapeDrawType)
- {
- case ShapeDrawType.Outline:
- outlineMI.Checked = true;
- break;
-
- case ShapeDrawType.Interior:
- interiorMI.Checked = true;
- break;
-
- case ShapeDrawType.Both:
- bothMI.Checked = true;
- break;
-
- default:
- throw new InvalidEnumArgumentException();
- }
-
- this.shapeButton.DropDownItems.AddRange(
- new ToolStripItem[]
- {
- outlineMI,
- interiorMI,
- bothMI
- });
- }
-
- private void ShapeMI_Click(object sender, EventArgs e)
- {
- ShapeDrawType sdt = (ShapeDrawType)((ToolStripMenuItem)sender).Tag;
- Tracing.LogFeature("ToolConfigStrip(" + sdt.ToString() + ")");
- this.ShapeDrawType = sdt;
- }
-
- public ToolConfigStrip()
- {
- SuspendLayout();
- InitializeComponent();
-
- this.solidBrushText = PdnResources.GetString("BrushConfigWidget.SolidBrush.Text"); // "Solid Brush"
- this.brushStyleComboBox.Items.Add(this.solidBrushText);
- string[] styleNames = this.hatchStyleNames.GetLocalizedNames();
- Array.Sort(styleNames);
-
- foreach (string styleName in styleNames)
- {
- brushStyleComboBox.Items.Add(styleName);
- }
-
- brushStyleComboBox.SelectedIndex = 0;
-
- this.brushStyleLabel.Text = PdnResources.GetString("BrushConfigWidget.FillStyleLabel.Text");
-
- this.shapeDrawType = ShapeDrawType.Outline;
- this.shapeButton.Image = this.shapeOutlineImage.Reference;
-
- this.penSizeLabel.Text = PdnResources.GetString("PenConfigWidget.BrushWidthLabel");
-
- this.penSizeComboBox.ComboBox.SuspendLayout();
-
- for (int i = 0; i < this.brushSizes.Length; ++i)
- {
- this.penSizeComboBox.Items.Add(this.brushSizes[i].ToString());
- }
-
- this.penSizeComboBox.ComboBox.ResumeLayout(false);
- this.penSizeComboBox.SelectedIndex = 1; // default to brush size of 2
-
- this.penSizeDecButton.ToolTipText = PdnResources.GetString("ToolConfigStrip.PenSizeDecButton.ToolTipText");
- this.penSizeDecButton.Image = PdnResources.GetImageResource("Icons.MinusButtonIcon.png").Reference;
- this.penSizeIncButton.ToolTipText = PdnResources.GetString("ToolConfigStrip.PenSizeIncButton.ToolTipText");
- this.penSizeIncButton.Image = PdnResources.GetImageResource("Icons.PlusButtonIcon.png").Reference;
- this.penStyleLabel.Text = PdnResources.GetString("ToolConfigStrip.PenStyleLabel.Text");
- this.penStartCapSplitButton.Tag = PenInfo.DefaultLineCap;
- this.penStartCapSplitButton.Image = GetLineCapImage(PenInfo.DefaultLineCap, true).Reference;
- this.penStartCapSplitButton.ToolTipText = PdnResources.GetString("ToolConfigStrip.PenStartCapSplitButton.ToolTipText");
- this.penDashStyleSplitButton.Tag = PenInfo.DefaultDashStyle;
- this.penDashStyleSplitButton.Image = GetDashStyleImage(PenInfo.DefaultDashStyle);
- this.penDashStyleSplitButton.ToolTipText = PdnResources.GetString("ToolConfigStrip.PenDashStyleSplitButton.ToolTipText");
- this.penEndCapSplitButton.Tag = PenInfo.DefaultLineCap;
- this.penEndCapSplitButton.Image = GetLineCapImage(PenInfo.DefaultLineCap, false).Reference;
- this.penEndCapSplitButton.ToolTipText = PdnResources.GetString("ToolConfigStrip.PenEndCapSplitButton.ToolTipText");
-
- this.gradientLinearClampedButton.ToolTipText = this.gradientTypeNames.EnumValueToLocalizedName(GradientType.LinearClamped);
- this.gradientLinearClampedButton.Image = PdnResources.GetImageResource("Icons.LinearClampedGradientIcon.png").Reference;
- this.gradientLinearReflectedButton.ToolTipText = this.gradientTypeNames.EnumValueToLocalizedName(GradientType.LinearReflected);
- this.gradientLinearReflectedButton.Image = PdnResources.GetImageResource("Icons.LinearReflectedGradientIcon.png").Reference;
- this.gradientLinearDiamondButton.ToolTipText = this.gradientTypeNames.EnumValueToLocalizedName(GradientType.LinearDiamond);
- this.gradientLinearDiamondButton.Image = PdnResources.GetImageResource("Icons.LinearDiamondGradientIcon.png").Reference;
- this.gradientRadialButton.ToolTipText = this.gradientTypeNames.EnumValueToLocalizedName(GradientType.Radial);
- this.gradientRadialButton.Image = PdnResources.GetImageResource("Icons.RadialGradientIcon.png").Reference;
- this.gradientConicalButton.ToolTipText = this.gradientTypeNames.EnumValueToLocalizedName(GradientType.Conical);
- this.gradientConicalButton.Image = PdnResources.GetImageResource("Icons.ConicalGradientIcon.png").Reference;
-
- this.gradientAllColorChannelsImage = PdnResources.GetImageResource("Icons.AllColorChannelsIcon.png");
- this.gradientAlphaChannelOnlyImage = PdnResources.GetImageResource("Icons.AlphaChannelOnlyIcon.png");
- this.gradientChannelsSplitButton.Image = this.gradientAllColorChannelsImage.Reference;
-
- this.antiAliasingEnabledImage = PdnResources.GetImageResource("Icons.AntiAliasingEnabledIcon.png");
- this.antiAliasingDisabledImage = PdnResources.GetImageResource("Icons.AntiAliasingDisabledIcon.png");
- this.antiAliasingSplitButton.Image = this.antiAliasingEnabledImage.Reference;
-
- this.alphaBlendingEnabledImage = PdnResources.GetImageResource("Icons.BlendingEnabledIcon.png");
- this.alphaBlendingOverwriteImage = PdnResources.GetImageResource("Icons.BlendingOverwriteIcon.png");
- this.alphaBlendingSplitButton.Image = this.alphaBlendingEnabledImage.Reference;
-
- this.penSizeComboBox.Size = new Size(UI.ScaleWidth(this.penSizeComboBox.Width), penSizeComboBox.Height);
- this.brushStyleComboBox.Size = new Size(UI.ScaleWidth(this.brushStyleComboBox.Width), brushStyleComboBox.Height);
- this.brushStyleComboBox.DropDownWidth = UI.ScaleWidth(this.brushStyleComboBox.DropDownWidth);
- this.brushStyleComboBox.DropDownHeight = UI.ScaleHeight(this.brushStyleComboBox.DropDownHeight);
-
- this.toleranceLabel.Text = PdnResources.GetString("ToleranceConfig.ToleranceLabel.Text");
- this.toleranceSlider.Tolerance = 0.5f;
-
- this.fontSizeComboBox.ComboBox.SuspendLayout();
- for (int i = 0; i < this.defaultFontSizes.Length; ++i)
- {
- this.fontSizeComboBox.Items.Add(this.defaultFontSizes[i].ToString());
- }
- this.fontSizeComboBox.ComboBox.ResumeLayout(false);
-
- this.fontSmoothingComboBox.Items.AddRange(
- new object[]
- {
- this.fontSmoothingLocalizer.EnumValueToLocalizedName(FontSmoothing.Smooth),
- this.fontSmoothingLocalizer.EnumValueToLocalizedName(FontSmoothing.Sharp)
- });
-
- this.fontSmoothingComboBox.SelectedIndex = 0;
-
- this.fontLabel.Text = PdnResources.GetString("TextConfigWidget.FontLabel.Text");
-
- try
- {
- this.arialFontFamily = new FontFamily(arialName);
- }
-
- catch (Exception)
- {
- this.arialFontFamily = new FontFamily(System.Drawing.Text.GenericFontFamilies.SansSerif);
- }
-
- try
- {
- this.arialFontBase = new Font(arialFontFamily, initialFontSize, FontStyle.Regular);
- }
-
- catch (Exception)
- {
- this.arialFontBase = new Font(FontFamily.GenericSansSerif, initialFontSize, FontStyle.Regular);
- }
-
- this.fontFamilyComboBox.ComboBox.DropDownHeight = 600;
-
- this.alignment = TextAlignment.Left;
- this.fontAlignLeftButton.Checked = true;
- this.oldSizeValue = initialFontSize;
-
- this.highlightBrush = new SolidBrush(SystemColors.Highlight);
- this.highlightTextBrush = new SolidBrush(SystemColors.HighlightText);
- this.windowBrush = new SolidBrush(SystemColors.Window);
- this.windowTextBrush = new SolidBrush(SystemColors.WindowText);
-
- // These buttons need a color key to maintain consistency with v2.5 language packs
- this.fontBoldButton.ImageTransparentColor = Utility.TransparentKey;
- this.fontItalicsButton.ImageTransparentColor = Utility.TransparentKey;
- this.fontUnderlineButton.ImageTransparentColor = Utility.TransparentKey;
-
- this.fontBoldButton.Image = PdnResources.GetImageBmpOrPng("Icons.FontBoldIcon");
- this.fontItalicsButton.Image = PdnResources.GetImageBmpOrPng("Icons.FontItalicIcon");
- this.fontUnderlineButton.Image = PdnResources.GetImageBmpOrPng("Icons.FontUnderlineIcon");
-
- this.fontAlignLeftButton.Image = PdnResources.GetImageResource("Icons.TextAlignLeftIcon.png").Reference;
- this.fontAlignCenterButton.Image = PdnResources.GetImageResource("Icons.TextAlignCenterIcon.png").Reference;
- this.fontAlignRightButton.Image = PdnResources.GetImageResource("Icons.TextAlignRightIcon.png").Reference;
-
- this.fontBoldButton.ToolTipText = PdnResources.GetString("TextConfigWidget.BoldButton.ToolTipText");
- this.fontItalicsButton.ToolTipText = PdnResources.GetString("TextConfigWidget.ItalicButton.ToolTipText");
- this.fontUnderlineButton.ToolTipText = PdnResources.GetString("TextConfigWidget.UnderlineButton.ToolTipText");
- this.fontAlignLeftButton.ToolTipText = PdnResources.GetString("TextConfigWidget.AlignLeftButton.ToolTipText");
- this.fontAlignCenterButton.ToolTipText = PdnResources.GetString("TextConfigWidget.AlignCenterButton.ToolTipText");
- this.fontAlignRightButton.ToolTipText = PdnResources.GetString("TextConfigWidget.AlignRightButton.ToolTipText");
-
- this.fontFamilyComboBox.Size = new Size(UI.ScaleWidth(this.fontFamilyComboBox.Width), fontFamilyComboBox.Height);
- this.fontFamilyComboBox.DropDownWidth = UI.ScaleWidth(this.fontFamilyComboBox.DropDownWidth);
- this.fontSizeComboBox.Size = new Size(UI.ScaleWidth(this.fontSizeComboBox.Width), fontSizeComboBox.Height);
-
- this.fontSmoothingComboBox.Size = new Size(UI.ScaleWidth(this.fontSmoothingComboBox.Width), fontSmoothingComboBox.Height);
- this.fontSmoothingComboBox.DropDownWidth = UI.ScaleWidth(this.fontSmoothingComboBox.DropDownWidth);
-
- this.resamplingLabel.Text = PdnResources.GetString("ToolConfigStrip.ResamplingLabel.Text");
- this.resamplingComboBox.BeginUpdate();
- this.resamplingComboBox.Items.Add(this.resamplingAlgorithmNames.EnumValueToLocalizedName(ResamplingAlgorithm.Bilinear));
- this.resamplingComboBox.Items.Add(this.resamplingAlgorithmNames.EnumValueToLocalizedName(ResamplingAlgorithm.NearestNeighbor));
- this.resamplingComboBox.EndUpdate();
- this.resamplingComboBox.SelectedIndex = 0; // bilinear
-
- this.resamplingComboBox.Size = new Size(UI.ScaleWidth(this.resamplingComboBox.Width), resamplingComboBox.Height);
- this.resamplingComboBox.DropDownWidth = UI.ScaleWidth(this.resamplingComboBox.DropDownWidth);
-
- this.colorPickerLabel.Text = PdnResources.GetString("ToolConfigStrip.ColorPickerLabel.Text");
- string[] colorPickerBehaviorNames = this.colorPickerBehaviorNames.GetLocalizedNames();
-
- // Make sure these items are sorted to be in the order specified by the enumeration
- Array.Sort<string>(
- colorPickerBehaviorNames,
- delegate(string lhs, string rhs)
- {
- ColorPickerClickBehavior lhsE = (ColorPickerClickBehavior)this.colorPickerBehaviorNames.LocalizedNameToEnumValue(lhs);
- ColorPickerClickBehavior rhsE = (ColorPickerClickBehavior)this.colorPickerBehaviorNames.LocalizedNameToEnumValue(rhs);
-
- if ((int)lhsE < (int)rhsE)
- {
- return -1;
- }
- else if ((int)lhsE > (int)rhsE)
- {
- return +1;
- }
- else
- {
- return 0;
- }
- });
-
- this.colorPickerComboBox.Items.AddRange(colorPickerBehaviorNames);
- this.colorPickerComboBox.SelectedIndex = 0;
-
- this.colorPickerComboBox.Size = new Size(UI.ScaleWidth(this.colorPickerComboBox.Width), colorPickerComboBox.Height);
- this.colorPickerComboBox.DropDownWidth = UI.ScaleWidth(this.colorPickerComboBox.DropDownWidth);
-
- this.toleranceSlider.Size = UI.ScaleSize(this.toleranceSlider.Size);
-
- this.selectionCombineModeLabel.Text = PdnResources.GetString("ToolConfigStrip.SelectionCombineModeLabel.Text");
-
- this.floodModeLabel.Text = PdnResources.GetString("ToolConfigStrip.FloodModeLabel.Text");
-
- this.selectionDrawModeModeLabel.Text = PdnResources.GetString("ToolConfigStrip.SelectionDrawModeLabel.Text");
- this.selectionDrawModeWidthLabel.Text = PdnResources.GetString("ToolConfigStrip.SelectionDrawModeWidthLabel.Text");
- this.selectionDrawModeHeightLabel.Text = PdnResources.GetString("ToolConfigStrip.SelectionDrawModeHeightLabel.Text");
- this.selectionDrawModeSwapButton.Image = PdnResources.GetImageResource("Icons.ToolConfigStrip.SelectionDrawModeSwapButton.png").Reference;
-
- this.selectionDrawModeWidthTextBox.Size = new Size(UI.ScaleWidth(this.selectionDrawModeWidthTextBox.Width), this.selectionDrawModeWidthTextBox.Height);
- this.selectionDrawModeHeightTextBox.Size = new Size(UI.ScaleWidth(this.selectionDrawModeHeightTextBox.Width), this.selectionDrawModeHeightTextBox.Height);
- this.selectionDrawModeUnits.Size = new Size(UI.ScaleWidth(this.selectionDrawModeUnits.Width), this.selectionDrawModeUnits.Height);
-
- ToolBarConfigItems = ToolBarConfigItems.None;
- ResumeLayout(false);
- }
-
- private void AsyncInitFontNames()
- {
- if (!IsHandleCreated)
- {
- CreateControl();
- }
-
- if (!this.fontFamilyComboBox.ComboBox.IsHandleCreated)
- {
- this.fontFamilyComboBox.ComboBox.CreateControl();
- }
-
- if (staticFontNames == null)
- {
- ThreadPool.QueueUserWorkItem(new WaitCallback(this.PopulateFontsBackgroundThread), null);
- }
- }
-
- protected override void OnHandleCreated(EventArgs e)
- {
- if ((this.toolBarConfigItems & ToolBarConfigItems.Text) == ToolBarConfigItems.Text)
- {
- AsyncInitFontNames();
- }
-
- base.OnHandleCreated(e);
- }
-
- private void InitializeComponent()
- {
- this.brushSeparator = new ToolStripSeparator();
- this.brushStyleLabel = new ToolStripLabel();
- this.brushStyleComboBox = new ToolStripComboBox();
-
- this.shapeSeparator = new ToolStripSeparator();
- this.shapeButton = new ToolStripSplitButton();
-
- this.gradientSeparator1 = new ToolStripSeparator();
- this.gradientLinearClampedButton = new ToolStripButton();
- this.gradientLinearReflectedButton = new ToolStripButton();
- this.gradientLinearDiamondButton = new ToolStripButton();
- this.gradientRadialButton = new ToolStripButton();
- this.gradientConicalButton = new ToolStripButton();
- this.gradientSeparator2 = new ToolStripSeparator();
- this.gradientChannelsSplitButton = new ToolStripSplitButton();
-
- this.penSeparator = new ToolStripSeparator();
- this.penSizeLabel = new ToolStripLabel();
- this.penSizeDecButton = new ToolStripButton();
- this.penSizeComboBox = new ToolStripComboBox();
- this.penSizeIncButton = new ToolStripButton();
- this.penStyleLabel = new ToolStripLabel();
- this.penStartCapSplitButton = new ToolStripSplitButton();
- this.penDashStyleSplitButton = new ToolStripSplitButton();
- this.penEndCapSplitButton = new ToolStripSplitButton();
-
- this.blendingSeparator = new ToolStripSeparator();
- this.antiAliasingSplitButton = new ToolStripSplitButton();
- this.alphaBlendingSplitButton = new ToolStripSplitButton();
-
- this.toleranceSeparator = new ToolStripSeparator();
- this.toleranceLabel = new ToolStripLabel();
- this.toleranceSlider = new ToleranceSliderControl();
- this.toleranceSliderStrip = new ToolStripControlHost(this.toleranceSlider);
-
- this.fontSeparator = new ToolStripSeparator();
- this.fontLabel = new ToolStripLabel();
- this.fontFamilyComboBox = new ToolStripComboBox();
- this.fontSizeComboBox = new ToolStripComboBox();
- this.fontSmoothingComboBox = new ToolStripComboBox();
- this.fontStyleSeparator = new ToolStripSeparator();
- this.fontBoldButton = new ToolStripButton();
- this.fontItalicsButton = new ToolStripButton();
- this.fontUnderlineButton = new ToolStripButton();
- this.fontAlignSeparator = new ToolStripSeparator();
- this.fontAlignLeftButton = new ToolStripButton();
- this.fontAlignCenterButton = new ToolStripButton();
- this.fontAlignRightButton = new ToolStripButton();
-
- this.resamplingSeparator = new ToolStripSeparator();
- this.resamplingLabel = new ToolStripLabel();
- this.resamplingComboBox = new ToolStripComboBox();
-
- this.colorPickerSeparator = new ToolStripSeparator();
- this.colorPickerLabel = new ToolStripLabel();
- this.colorPickerComboBox = new ToolStripComboBox();
-
- this.selectionCombineModeSeparator = new ToolStripSeparator();
- this.selectionCombineModeLabel = new ToolStripLabel();
- this.selectionCombineModeSplitButton = new ToolStripSplitButton();
-
- this.floodModeSeparator = new ToolStripSeparator();
- this.floodModeLabel = new ToolStripLabel();
- this.floodModeSplitButton = new ToolStripSplitButton();
-
- this.selectionDrawModeSeparator = new ToolStripSeparator();
- this.selectionDrawModeModeLabel = new ToolStripLabel();
- this.selectionDrawModeSplitButton = new ToolStripSplitButton();
- this.selectionDrawModeWidthLabel = new ToolStripLabel();
- this.selectionDrawModeWidthTextBox = new ToolStripTextBox();
- this.selectionDrawModeSwapButton = new ToolStripButton();
- this.selectionDrawModeHeightLabel = new ToolStripLabel();
- this.selectionDrawModeHeightTextBox = new ToolStripTextBox();
- this.selectionDrawModeUnits = new UnitsComboBoxStrip();
-
- this.SuspendLayout();
- //
- // brushStyleLabel
- //
- this.brushStyleLabel.Name = "fillStyleLabel";
- //
- // brushStyleComboBox
- //
- this.brushStyleComboBox.Name = "styleComboBox";
- this.brushStyleComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.brushStyleComboBox.DropDownWidth = 234;
- this.brushStyleComboBox.AutoSize = true;
- //
- // brushStyleComboBox.ComboBox
- //
- this.brushStyleComboBox.ComboBox.DrawMode = DrawMode.OwnerDrawVariable;
- this.brushStyleComboBox.ComboBox.MeasureItem += ComboBoxStyle_MeasureItem;
- this.brushStyleComboBox.ComboBox.SelectedValueChanged += ComboBoxStyle_SelectedValueChanged;
- this.brushStyleComboBox.ComboBox.DrawItem += ComboBoxStyle_DrawItem;
- //
- // shapeButton
- //
- this.shapeButton.Name = "shapeButton";
- this.shapeButton.DropDownOpening += new EventHandler(ShapeButton_DropDownOpening);
-
- this.shapeButton.DropDownClosed +=
- delegate(object sender, EventArgs e)
- {
- this.shapeButton.DropDownItems.Clear();
- };
-
- this.shapeButton.ButtonClick +=
- delegate(object sender, EventArgs e)
- {
- Tracing.LogFeature("ToolConfigStrip(shapeButton)");
-
- switch (ShapeDrawType)
- {
- case ShapeDrawType.Outline:
- ShapeDrawType = ShapeDrawType.Interior;
- break;
-
- case ShapeDrawType.Interior:
- ShapeDrawType = ShapeDrawType.Both;
- break;
-
- case ShapeDrawType.Both:
- ShapeDrawType = ShapeDrawType.Outline;
- break;
-
- default:
- throw new InvalidEnumArgumentException();
- }
- };
- //
- // gradientSeparator
- //
- this.gradientSeparator1.Name = "gradientSeparator";
- //
- // gradientLinearClampedButton
- //
- this.gradientLinearClampedButton.Name = "gradientLinearClampedButton";
- this.gradientLinearClampedButton.Click += GradientTypeButtonClicked;
- this.gradientLinearClampedButton.Tag = GradientType.LinearClamped;
- //
- // gradientLinearReflectedButton
- //
- this.gradientLinearReflectedButton.Name = "gradientLinearReflectedButton";
- this.gradientLinearReflectedButton.Click += GradientTypeButtonClicked;
- this.gradientLinearReflectedButton.Tag = GradientType.LinearReflected;
- //
- // gradientLinearDiamondButton
- //
- this.gradientLinearDiamondButton.Name = "gradientLinearDiamondButton";
- this.gradientLinearDiamondButton.Click += GradientTypeButtonClicked;
- this.gradientLinearDiamondButton.Tag = GradientType.LinearDiamond;
- //
- // gradientRadialButton
- //
- this.gradientRadialButton.Name = "gradientRadialButton";
- this.gradientRadialButton.Click += GradientTypeButtonClicked;
- this.gradientRadialButton.Tag = GradientType.Radial;
- //
- // gradientConicalButton
- //
- this.gradientConicalButton.Name = "gradientConicalButton";
- this.gradientConicalButton.Click += GradientTypeButtonClicked;
- this.gradientConicalButton.Tag = GradientType.Conical;
- //
- // gradientSeparator2
- //
- this.gradientSeparator2.Name = "gradientSeparator2";
- //
- // gradientChannelsSplitButton
- //
- this.gradientChannelsSplitButton.Name = "gradientChannelsSplitButton";
- this.gradientChannelsSplitButton.DropDownOpening += new EventHandler(GradientChannelsSplitButton_DropDownOpening);
- this.gradientChannelsSplitButton.DropDownClosed +=
- delegate(object sender, EventArgs e)
- {
- this.gradientChannelsSplitButton.DropDownItems.Clear();
- };
- this.gradientChannelsSplitButton.ButtonClick +=
- delegate(object sender, EventArgs e)
- {
- Tracing.LogFeature("ToolConfigStrip(gradientChannelsSplitButton)");
- GradientInfo = new GradientInfo(GradientInfo.GradientType, !GradientInfo.AlphaOnly);
- };
- //
- // penSeparator
- //
- this.penSeparator.Name = "penSeparator";
- //
- // penSizeLabel
- //
- this.penSizeLabel.Name = "brushSizeLabel";
- //
- // penSizeDecButton
- //
- this.penSizeDecButton.Name = "penSizeDecButton";
- this.penSizeDecButton.Click +=
- delegate(object sender, EventArgs e)
- {
- Tracing.LogFeature("ToolConfigStrip(penSizeDecButton)");
-
- float amount = -1.0f;
-
- if ((Control.ModifierKeys & Keys.Control) != 0)
- {
- amount *= 5.0f;
- }
-
- AddToPenSize(amount);
- };
- //
- // penSizeComboBox
- //
- this.penSizeComboBox.Name = "penSizeComboBox";
- this.penSizeComboBox.Validating += new CancelEventHandler(this.BrushSizeComboBox_Validating);
- this.penSizeComboBox.TextChanged += new EventHandler(this.SizeComboBox_TextChanged);
- this.penSizeComboBox.AutoSize = false;
- this.penSizeComboBox.Width = 44;
- //
- // penSizeIncButton
- //
- this.penSizeIncButton.Name = "penSizeIncButton";
- this.penSizeIncButton.Click +=
- delegate(object sender, EventArgs e)
- {
- Tracing.LogFeature("ToolConfigStrip(penSizeIncButton)");
-
- float amount = 1.0f;
-
- if ((Control.ModifierKeys & Keys.Control) != 0)
- {
- amount *= 5.0f;
- }
-
- AddToPenSize(amount);
- };
- //
- // penStartCapLabel
- //
- this.penStyleLabel.Name = "penStartCapLabel";
- //
- // penStartCapSplitButton
- //
- this.penStartCapSplitButton.Name = "penStartCapSplitButton";
- this.penStartCapSplitButton.DropDownOpening += PenCapSplitButton_DropDownOpening;
- this.penStartCapSplitButton.DropDownClosed +=
- delegate(object sender, EventArgs e)
- {
- this.penStartCapSplitButton.DropDownItems.Clear();
- };
- this.penStartCapSplitButton.ButtonClick +=
- delegate(object sender, EventArgs e)
- {
- Tracing.LogFeature("ToolConfigStrip(penStartCapSplitButton)");
- CyclePenStartCap();
- };
- //
- // penDashStyleSplitButton
- //
- this.penDashStyleSplitButton.Name = "penDashStyleSplitButton";
- this.penDashStyleSplitButton.ImageScaling = ToolStripItemImageScaling.None;
- this.penDashStyleSplitButton.DropDownOpening += PenDashStyleButton_DropDownOpening;
- this.penDashStyleSplitButton.DropDownClosed +=
- delegate(object sender, EventArgs e)
- {
- this.penDashStyleSplitButton.DropDownItems.Clear();
- };
- this.penDashStyleSplitButton.ButtonClick +=
- delegate(object sender, EventArgs e)
- {
- Tracing.LogFeature("ToolConfigStrip(penDashStyleSplitButton)");
- CyclePenDashStyle();
- };
- //
- // penEndCapSplitButton
- //
- this.penEndCapSplitButton.Name = "penEndCapSplitButton";
- this.penEndCapSplitButton.DropDownOpening += PenCapSplitButton_DropDownOpening;
- this.penEndCapSplitButton.DropDownClosed +=
- delegate(object sender, EventArgs e)
- {
- this.penEndCapSplitButton.DropDownItems.Clear();
- };
- this.penEndCapSplitButton.ButtonClick +=
- delegate(object sender, EventArgs e)
- {
- Tracing.LogFeature("ToolConfigStrip(penEndCapSplitButton)");
- CyclePenEndCap();
- };
- //
- // antiAliasingSplitButton
- //
- this.antiAliasingSplitButton.Name = "antiAliasingSplitButton";
- this.antiAliasingSplitButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
- this.antiAliasingSplitButton.DropDownOpening += AntiAliasingSplitButton_DropDownOpening;
- this.antiAliasingSplitButton.DropDownClosed +=
- delegate(object sender, EventArgs e)
- {
- this.antiAliasingSplitButton.DropDownItems.Clear();
- };
- this.antiAliasingSplitButton.ButtonClick +=
- delegate(object sender, EventArgs e)
- {
- Tracing.LogFeature("ToolConfigStrip(antiAliasingSplitButton)");
- AntiAliasing = !AntiAliasing;
- };
- //
- // alphaBlendingSplitButton
- //
- this.alphaBlendingSplitButton.Name = "alphaBlendingSplitButton";
- this.alphaBlendingSplitButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
- this.alphaBlendingSplitButton.DropDownOpening += new EventHandler(AlphaBlendingSplitButton_DropDownOpening);
- this.alphaBlendingSplitButton.DropDownClosed +=
- delegate(object sender, EventArgs e)
- {
- this.alphaBlendingSplitButton.DropDownItems.Clear();
- };
- this.alphaBlendingSplitButton.ButtonClick +=
- delegate(object sender, EventArgs e)
- {
- Tracing.LogFeature("ToolConfigStrip(alphaBlendingSplitButton)");
- AlphaBlending = !AlphaBlending;
- };
- //
- // toleranceLabel
- //
- this.toleranceLabel.Name = "toleranceLabel";
- //
- // toleranceSlider
- //
- this.toleranceSlider.Name = "toleranceSlider";
- this.toleranceSlider.ToleranceChanged += new EventHandler(ToleranceSlider_ToleranceChanged);
- this.toleranceSlider.Size = new Size(150, 16);
- //
- // toleranceSliderStrip
- //
- this.toleranceSliderStrip.Name = "toleranceSliderStrip";
- this.toleranceSliderStrip.AutoSize = false;
- //
- // fontLabel
- //
- this.fontLabel.Name = "fontLabel";
- //
- // fontFamilyComboBox
- //
- this.fontFamilyComboBox.Name = "fontComboBox";
- this.fontFamilyComboBox.DropDownWidth = 240;
- this.fontFamilyComboBox.MaxDropDownItems = 12;
- this.fontFamilyComboBox.Sorted = true;
- this.fontFamilyComboBox.GotFocus += new EventHandler(FontFamilyComboBox_GotFocus);
- this.fontFamilyComboBox.Items.Add(arialName);
- this.fontFamilyComboBox.SelectedItem = arialName;
- this.fontFamilyComboBox.SelectedIndexChanged += FontFamilyComboBox_SelectedIndexChanged;
- this.fontFamilyComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
- //
- // fontFamilyComboBox.ComboBox
- //
- this.fontFamilyComboBox.ComboBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
- this.fontFamilyComboBox.ComboBox.MeasureItem += new System.Windows.Forms.MeasureItemEventHandler(this.FontFamilyComboBox_MeasureItem);
- this.fontFamilyComboBox.ComboBox.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.FontFamilyComboBox_DrawItem);
- //
- // fontSizeComboBox
- //
- this.fontSizeComboBox.Name = "fontSizeComboBox";
- this.fontSizeComboBox.AutoSize = false;
- this.fontSizeComboBox.TextChanged += new EventHandler(FontSizeComboBox_TextChanged);
- this.fontSizeComboBox.Validating += new CancelEventHandler(FontSizeComboBox_Validating);
- this.fontSizeComboBox.Text = initialFontSize.ToString();
- this.fontSizeComboBox.Width = 44;
- //
- // fontSmoothingComboBox
- //
- this.fontSmoothingComboBox.Name = "smoothingComboBOx";
- this.fontSmoothingComboBox.AutoSize = false;
- this.fontSmoothingComboBox.Sorted = false;
- this.fontSmoothingComboBox.Width = 70;
- this.fontSmoothingComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
- this.fontSmoothingComboBox.SelectedIndexChanged += new EventHandler(SmoothingComboBox_SelectedIndexChanged);
- //
- // fontBoldButton
- //
- this.fontBoldButton.Name = "boldButton";
- //
- // fontItalicsButton
- //
- this.fontItalicsButton.Name = "italicsButton";
- //
- // fontUnderlineButton
- //
- this.fontUnderlineButton.Name = "underlineButton";
- //
- // fontAlignLeftButton
- //
- this.fontAlignLeftButton.Name =…
Large files files are truncated, but you can click here to view the full file