Exemplo n.º 1
0
 void IDeserializationCallback.OnDeserialization(object sender)
 {
     if (this.selectionDrawModeInfo == null)
     {
         this.selectionDrawModeInfo = SelectionDrawModeInfo.CreateDefault();
     }
 }
Exemplo n.º 2
0
        public void SetToDefaults()
        {
            this.antiAliasing   = true;
            this.fontSmoothing  = FontSmoothing.Smooth;
            this.primaryColor   = ColorBgra.FromBgra(0, 0, 0, 255);
            this.secondaryColor = ColorBgra.FromBgra(255, 255, 255, 255);
            this.gradientInfo   = new GradientInfo(GradientType.LinearClamped, false);
            this.penInfo        = new PenInfo(PenInfo.DefaultDashStyle, 2.0f, PenInfo.DefaultLineCap, PenInfo.DefaultLineCap, PenInfo.DefaultCapScale);
            this.brushInfo      = new BrushInfo(BrushType.Solid, HatchStyle.BackwardDiagonal);

            try
            {
                this.fontInfo = new FontInfo(new FontFamily("Arial"), 12, FontStyle.Regular);
            }

            catch (Exception)
            {
                this.fontInfo = new FontInfo(new FontFamily(GenericFontFamilies.SansSerif), 12, FontStyle.Regular);
            }

            this.textAlignment = TextAlignment.Left;
            this.shapeDrawType = ShapeDrawType.Outline;
            this.alphaBlending = true;
            this.tolerance     = 0.5f;

            this.colorPickerClickBehavior = ColorPickerClickBehavior.NoToolSwitch;
            this.resamplingAlgorithm      = ResamplingAlgorithm.Bilinear;
            this.selectionCombineMode     = CombineMode.Replace;
            this.floodMode             = FloodMode.Local;
            this.selectionDrawModeInfo = SelectionDrawModeInfo.CreateDefault();
        }
Exemplo n.º 3
0
 public void LoadFrom(ToolEnvironment toolEnvironment)
 {
     this.textAlignment            = toolEnvironment.textAlignment;
     this.gradientInfo             = toolEnvironment.gradientInfo.Clone();
     this.fontSmoothing            = toolEnvironment.fontSmoothing;
     this.fontInfo                 = toolEnvironment.fontInfo.Clone();
     this.penInfo                  = toolEnvironment.penInfo.Clone();
     this.brushInfo                = toolEnvironment.brushInfo.Clone();
     this.primaryColor             = toolEnvironment.primaryColor;
     this.secondaryColor           = toolEnvironment.secondaryColor;
     this.alphaBlending            = toolEnvironment.alphaBlending;
     this.shapeDrawType            = toolEnvironment.shapeDrawType;
     this.antiAliasing             = toolEnvironment.antiAliasing;
     this.colorPickerClickBehavior = toolEnvironment.colorPickerClickBehavior;
     this.resamplingAlgorithm      = toolEnvironment.resamplingAlgorithm;
     this.tolerance                = toolEnvironment.tolerance;
     this.selectionCombineMode     = toolEnvironment.selectionCombineMode;
     this.floodMode                = toolEnvironment.floodMode;
     this.selectionDrawModeInfo    = toolEnvironment.selectionDrawModeInfo.Clone();
     PerformAllChanged();
 }
Exemplo n.º 4
0
        protected override List <PointF> CreateShape(List <Point> tracePoints)
        {
            Point a = tracePoints[0];
            Point b = tracePoints[tracePoints.Count - 1];

            Rectangle rect;

            SelectionDrawModeInfo sdmInfo = AppEnvironment.SelectionDrawModeInfo;

            switch (sdmInfo.DrawMode)
            {
            case SelectionDrawMode.Normal:
                if ((ModifierKeys & Keys.Shift) != 0)
                {
                    rect = Utility.PointsToConstrainedRectangle(a, b);
                }
                else
                {
                    rect = Utility.PointsToRectangle(a, b);
                }
                break;

            case SelectionDrawMode.FixedRatio:
                try
                {
                    int drawnWidth  = b.X - a.X;
                    int drawnHeight = b.Y - a.Y;

                    double drawnWidthScale  = (double)drawnWidth / (double)sdmInfo.Width;
                    double drawnWidthSign   = Math.Sign(drawnWidthScale);
                    double drawnHeightScale = (double)drawnHeight / (double)sdmInfo.Height;
                    double drawnHeightSign  = Math.Sign(drawnHeightScale);

                    double aspect = (double)sdmInfo.Width / (double)sdmInfo.Height;

                    if (drawnWidthScale < drawnHeightScale)
                    {
                        rect = Utility.PointsToRectangle(
                            new Point(a.X, a.Y),
                            new Point(a.X + drawnWidth, a.Y + (int)(drawnHeightSign * Math.Abs((double)drawnWidth / aspect))));
                    }
                    else
                    {
                        rect = Utility.PointsToRectangle(
                            new Point(a.X, a.Y),
                            new Point(a.X + (int)(drawnWidthSign * Math.Abs((double)drawnHeight * aspect)), a.Y + drawnHeight));
                    }
                }

                catch (ArithmeticException)
                {
                    rect = new Rectangle(a.X, a.Y, 0, 0);
                }

                break;

            case SelectionDrawMode.FixedSize:
                rect = new Rectangle(b.X, b.Y, (int)sdmInfo.Width, (int)sdmInfo.Height);

                break;

            default:
                throw new InvalidEnumArgumentException();
            }

            rect.Intersect(DocumentWorkspace.Document.Bounds);

            List <PointF> shape;

            if (rect.Width > 0 && rect.Height > 0)
            {
                shape = new List <PointF>(5);

                shape.Add(new PointF(rect.Left, rect.Top));
                shape.Add(new PointF(rect.Right, rect.Top));
                shape.Add(new PointF(rect.Right, rect.Bottom));
                shape.Add(new PointF(rect.Left, rect.Bottom));
                shape.Add(shape[0]);
            }
            else
            {
                shape = new List <PointF>(0);
            }

            return(shape);
        }
Exemplo n.º 5
0
        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 = "alignLeftButton";
            //
            // fontAlignCenterButton
            //
            this.fontAlignCenterButton.Name = "alignCenterButton";
            //
            // fontAlignRightButton
            //
            this.fontAlignRightButton.Name = "alignRightButton";
            //
            // resamplingSeparator
            //
            this.resamplingSeparator.Name = "resamplingSeparator";
            //
            // resamplingLabel
            //
            this.resamplingLabel.Name = "resamplingLabel";
            //
            // resamplingComboBox
            //
            this.resamplingComboBox.Name = "resamplingComboBox";
            this.resamplingComboBox.AutoSize = true;
            this.resamplingComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            this.resamplingComboBox.Sorted = false;
            this.resamplingComboBox.Width = 100;
            this.resamplingComboBox.DropDownWidth = 100;
            this.resamplingComboBox.SelectedIndexChanged += new EventHandler(ResamplingComboBox_SelectedIndexChanged);
            //
            // colorPickerSeparator
            //
            this.colorPickerSeparator.Name = "colorPickerSeparator";
            //
            // colorPickerLabel
            //
            this.colorPickerLabel.Name = "colorPickerLabel";
            //
            // colorPickerComboBox
            //
            this.colorPickerComboBox.Name = "colorPickerComboBox";
            this.colorPickerComboBox.AutoSize = true;
            this.colorPickerComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            this.colorPickerComboBox.Width = 200;
            this.colorPickerComboBox.DropDownWidth = 200;
            this.colorPickerComboBox.Sorted = false;
            this.colorPickerComboBox.SelectedIndexChanged += new EventHandler(ColorPickerComboBox_SelectedIndexChanged);
            //
            // selectionCombineModeSeparator
            //
            this.selectionCombineModeSeparator.Name = "selectionCombineModeSeparator";
            //
            // selectionCombineModeLabel
            //
            this.selectionCombineModeLabel.Name = "selectionCombineModeLabel";
            //
            // selectionCombineModeSplitButton
            //
            this.selectionCombineModeSplitButton.Name = "selectionCombineModeSplitButton";
            this.selectionCombineModeSplitButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
            this.selectionCombineModeSplitButton.DropDownOpening += new EventHandler(SelectionCombineModeSplitButton_DropDownOpening);
            this.selectionCombineModeSplitButton.DropDownClosed +=
                delegate(object sender, EventArgs e)
                {
                    this.selectionCombineModeSplitButton.DropDownItems.Clear();
                };
            this.selectionCombineModeSplitButton.ButtonClick +=
                delegate(object sender, EventArgs e)
                {
                    Tracing.LogFeature("ToolConfigStrip(selectionCombineModeSplitButton)");
                    this.SelectionCombineMode = CycleSelectionCombineMode(this.SelectionCombineMode);
                };
            //
            // floodModeSeparator
            //
            this.floodModeSeparator.Name = "floodModeSeparator";
            //
            // floodModeLabel
            //
            this.floodModeLabel.Name = "floodModeLabel";
            //
            // floodModeSplitButton
            //
            this.floodModeSplitButton.Name = "floodModeSplitButton";
            this.floodModeSplitButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
            this.floodModeSplitButton.DropDownOpening += new EventHandler(FloodModeSplitButton_DropDownOpening);
            this.floodModeSplitButton.DropDownClosed +=
                delegate(object sender, EventArgs e)
                {
                    this.floodModeSplitButton.DropDownItems.Clear();
                };
            this.floodModeSplitButton.ButtonClick +=
                delegate(object sender, EventArgs e)
                {
                    Tracing.LogFeature("ToolConfigStrip(floodModeSplitButton)");
                    this.FloodMode = CycleFloodMode(this.FloodMode);
                };
            //
            // selectionDrawModeSeparator
            //
            this.selectionDrawModeSeparator.Name = "selectionDrawModeSeparator";
            //
            // selectionDrawModeModeLabel
            //
            this.selectionDrawModeModeLabel.Name = "selectionDrawModeModeLabel";
            //
            // selectionDrawModeSplitButton
            //
            this.selectionDrawModeSplitButton.Name = "selectionDrawModeSplitButton";
            this.selectionDrawModeSplitButton.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
            this.selectionDrawModeSplitButton.DropDownOpening += new EventHandler(SelectionDrawModeSplitButton_DropDownOpening);
            this.selectionDrawModeSplitButton.DropDownClosed +=
                delegate(object sender, EventArgs e)
                {
                    this.selectionDrawModeSplitButton.DropDownItems.Clear();
                };
            this.selectionDrawModeSplitButton.ButtonClick +=
                delegate(object sender, EventArgs e)
                {
                    Tracing.LogFeature("ToolConfigStrip(selectionDrawModeSplitButton)");
                    SelectionDrawMode newSDM = CycleSelectionDrawMode(this.SelectionDrawModeInfo.DrawMode);
                    this.SelectionDrawModeInfo = this.SelectionDrawModeInfo.CloneWithNewDrawMode(newSDM);
                };
            //
            // selectionDrawModeWidthLabel
            //
            this.selectionDrawModeWidthLabel.Name = "selectionDrawModeWidthLabel";
            //
            // selectionDrawModeWidthTextBox
            //
            this.selectionDrawModeWidthTextBox.Name = "selectionDrawModeWidthTextBox";
            this.selectionDrawModeWidthTextBox.TextBox.Width = 50;
            this.selectionDrawModeWidthTextBox.TextBoxTextAlign = HorizontalAlignment.Right;
            this.selectionDrawModeWidthTextBox.Enter +=
                delegate(object sender, EventArgs e)
                {
                    this.selectionDrawModeWidthTextBox.TextBox.Select(0, this.selectionDrawModeWidthTextBox.TextBox.Text.Length);
                };
            this.selectionDrawModeWidthTextBox.Leave +=
                delegate(object sender, EventArgs e)
                {
                    Tracing.LogFeature("ToolConfigStrip(selectionDrawModeWidthTextBox.Leave)");

                    double newWidth;
                    if (double.TryParse(this.selectionDrawModeWidthTextBox.Text, out newWidth))
                    {
                        this.SelectionDrawModeInfo = this.selectionDrawModeInfo.CloneWithNewWidth(newWidth);
                    }
                    else
                    {
                        this.selectionDrawModeWidthTextBox.Text = this.selectionDrawModeInfo.Width.ToString();
                    }
                };
            //
            // selectionDrawModeSwapButton
            //
            this.selectionDrawModeSwapButton.Name = "selectionDrawModeSwapButton";
            this.selectionDrawModeSwapButton.Click +=
                delegate(object sender, EventArgs e)
                {
                    Tracing.LogFeature("ToolConfigStrip(selectionDrawModeSwapButton)");

                    SelectionDrawModeInfo oldSDMI = this.SelectionDrawModeInfo;
                    SelectionDrawModeInfo newSDMI = new SelectionDrawModeInfo(oldSDMI.DrawMode, oldSDMI.Height, oldSDMI.Width, oldSDMI.Units);
                    this.SelectionDrawModeInfo = newSDMI;
                };
            //
            // selectionDrawModeHeightLabel
            //
            this.selectionDrawModeHeightLabel.Name = "selectionDrawModeHeightLabel";
            //
            // selectionDrawModeHeightTextBox
            //
            this.selectionDrawModeHeightTextBox.Name = "selectionDrawModeHeightTextBox";
            this.selectionDrawModeHeightTextBox.TextBox.Width = 50;
            this.selectionDrawModeHeightTextBox.TextBoxTextAlign = HorizontalAlignment.Right;
            this.selectionDrawModeHeightTextBox.Enter +=
                delegate(object sender, EventArgs e)
                {
                    this.selectionDrawModeHeightTextBox.TextBox.Select(0, this.selectionDrawModeHeightTextBox.TextBox.Text.Length);
                };
            this.selectionDrawModeHeightTextBox.Leave +=
                delegate(object sender, EventArgs e)
                {
                    Tracing.LogFeature("ToolConfigStrip(selectionDrawModeHeightTextBox.Leave)");

                    double newHeight;
                    if (double.TryParse(this.selectionDrawModeHeightTextBox.Text, out newHeight))
                    {
                        this.SelectionDrawModeInfo = this.selectionDrawModeInfo.CloneWithNewHeight(newHeight);
                    }
                    else
                    {
                        this.selectionDrawModeHeightTextBox.Text = this.selectionDrawModeInfo.Height.ToString();
                    }
                };
            //
            // selectionDrawModeUnits
            //
            this.selectionDrawModeUnits.Name = "selectionDrawModeUnits";
            this.selectionDrawModeUnits.UnitsDisplayType = UnitsDisplayType.Plural;
            this.selectionDrawModeUnits.LowercaseStrings = true;
            this.selectionDrawModeUnits.Size = new Size(90, this.selectionDrawModeUnits.Height);
            //
            // DrawConfigStrip
            //
            this.AutoSize = true;

            this.Items.AddRange(
                new ToolStripItem[]
                {
                    this.selectionCombineModeSeparator,
                    this.selectionCombineModeLabel,
                    this.selectionCombineModeSplitButton,

                    this.selectionDrawModeSeparator,
                    this.selectionDrawModeModeLabel,
                    this.selectionDrawModeSplitButton,
                    this.selectionDrawModeWidthLabel,
                    this.selectionDrawModeWidthTextBox,
                    this.selectionDrawModeSwapButton,
                    this.selectionDrawModeHeightLabel,
                    this.selectionDrawModeHeightTextBox,
                    this.selectionDrawModeUnits,

                    this.floodModeSeparator,
                    this.floodModeLabel,
                    this.floodModeSplitButton,

                    this.resamplingSeparator,
                    this.resamplingLabel,
                    this.resamplingComboBox,

                    this.colorPickerSeparator,
                    this.colorPickerLabel,
                    this.colorPickerComboBox,

                    this.fontSeparator,
                    this.fontLabel,
                    this.fontFamilyComboBox,
                    this.fontSizeComboBox,
                    this.fontSmoothingComboBox,
                    this.fontStyleSeparator,
                    this.fontBoldButton,
                    this.fontItalicsButton,
                    this.fontUnderlineButton,
                    this.fontAlignSeparator,
                    this.fontAlignLeftButton,
                    this.fontAlignCenterButton,
                    this.fontAlignRightButton,

                    this.shapeSeparator,
                    this.shapeButton,

                    this.gradientSeparator1,
                    this.gradientLinearClampedButton,
                    this.gradientLinearReflectedButton,
                    this.gradientLinearDiamondButton,
                    this.gradientRadialButton,
                    this.gradientConicalButton,
                    this.gradientSeparator2,
                    this.gradientChannelsSplitButton,

                    this.penSeparator,
                    this.penSizeLabel,
                    this.penSizeDecButton,
                    this.penSizeComboBox,
                    this.penSizeIncButton,
                    this.penStyleLabel,
                    this.penStartCapSplitButton,
                    this.penDashStyleSplitButton,
                    this.penEndCapSplitButton,

                    this.brushSeparator,
                    this.brushStyleLabel,
                    this.brushStyleComboBox,

                    this.toleranceSeparator,
                    this.toleranceLabel,
                    this.toleranceSliderStrip,

                    this.blendingSeparator,
                    this.antiAliasingSplitButton,
                    this.alphaBlendingSplitButton
                });

            this.ResumeLayout(false);            
        }
Exemplo n.º 6
0
 private void SelectionDrawModeUnits_UnitsChanged(object sender, EventArgs e)
 {
     OnSelectionDrawModeUnitsChanging();
     this.SelectionDrawModeInfo = this.selectionDrawModeInfo.CloneWithNewUnits(this.selectionDrawModeUnits.Units);
     OnSelectionDrawModeUnitsChanged();
 }
Exemplo n.º 7
0
        private void SelectionDrawModeSplitButton_DropDownOpening(object sender, EventArgs e)
        {
            this.selectionDrawModeSplitButton.DropDownItems.Clear();

            foreach (SelectionDrawMode sdm in
                new SelectionDrawMode[]
                {
                    SelectionDrawMode.Normal,
                    SelectionDrawMode.FixedRatio,
                    SelectionDrawMode.FixedSize
                })
            {
                ToolStripMenuItem sdmTSMI = new ToolStripMenuItem(
                    GetSelectionDrawModeString(sdm),
                    GetSelectionDrawModeImage(sdm),
                    delegate(object sender2, EventArgs e2)
                    {
                        ToolStripMenuItem asTSMI = (ToolStripMenuItem)sender2;
                        SelectionDrawMode newSDM = (SelectionDrawMode)asTSMI.Tag;
                        this.SelectionDrawModeInfo = this.SelectionDrawModeInfo.CloneWithNewDrawMode(newSDM);
                    });

                sdmTSMI.Tag = sdm;
                sdmTSMI.Checked = (sdm == this.SelectionDrawModeInfo.DrawMode);

                this.selectionDrawModeSplitButton.DropDownItems.Add(sdmTSMI);
            }
        }
Exemplo n.º 8
0
 void IDeserializationCallback.OnDeserialization(object sender)
 {
     if (this.selectionDrawModeInfo == null)
     {
         this.selectionDrawModeInfo = SelectionDrawModeInfo.CreateDefault();
     }
 }
Exemplo n.º 9
0
        public void SetToDefaults()
        {
            this.antiAliasing = true;
            this.fontSmoothing = FontSmoothing.Smooth;
            this.primaryColor = ColorBgra.FromBgra(0, 0, 0, 255);
            this.secondaryColor = ColorBgra.FromBgra(255, 255, 255, 255);
            this.gradientInfo = new GradientInfo(GradientType.LinearClamped, false);
            this.penInfo = new PenInfo(PenInfo.DefaultDashStyle, 2.0f, PenInfo.DefaultLineCap, PenInfo.DefaultLineCap, PenInfo.DefaultCapScale);
            this.brushInfo = new BrushInfo(BrushType.Solid, HatchStyle.BackwardDiagonal);

            try
            {
                this.fontInfo = new FontInfo(new FontFamily("Arial"), 12, FontStyle.Regular);
            }

            catch (Exception)
            {
                this.fontInfo = new FontInfo(new FontFamily(GenericFontFamilies.SansSerif), 12, FontStyle.Regular);
            }

            this.textAlignment = TextAlignment.Left;
            this.shapeDrawType = ShapeDrawType.Outline;
            this.alphaBlending = true;
            this.tolerance = 0.5f;

            this.colorPickerClickBehavior = ColorPickerClickBehavior.NoToolSwitch;
            this.resamplingAlgorithm = ResamplingAlgorithm.Bilinear;
            this.selectionCombineMode = CombineMode.Replace;
            this.floodMode = FloodMode.Local;
            this.selectionDrawModeInfo = SelectionDrawModeInfo.CreateDefault();
        }
Exemplo n.º 10
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();
 }