Ejemplo n.º 1
0
 private void tsmiSecondColor_Click(object sender, EventArgs e)
 {
     ColorPickerForm.PickColor(Options.Color2, out Color newColor, this);
     Options.Color2 = newColor;
     if (tsmiSecondColor.Image != null)
     {
         tsmiSecondColor.Image.Dispose();
     }
     tsmiSecondColor.Image = ImageHelpers.CreateColorPickerIcon(Options.Color2, new Rectangle(0, 0, 16, 16));
 }
Ejemplo n.º 2
0
        private void UpdateMenu()
        {
            if (menuForm == null)
            {
                return;
            }

            ShapeType shapeType = CurrentShapeType;

            foreach (ToolStripButton tsb in tsMain.Items.OfType <ToolStripButton>().Where(x => x.Tag is ShapeType))
            {
                if ((ShapeType)tsb.Tag == shapeType)
                {
                    tsb.RadioCheck();
                    break;
                }
            }

            Color borderColor;

            if (shapeType == ShapeType.DrawingTextBackground || shapeType == ShapeType.DrawingSpeechBalloon)
            {
                borderColor = AnnotationOptions.TextBorderColor;
            }
            else if (shapeType == ShapeType.DrawingTextOutline)
            {
                borderColor = AnnotationOptions.TextOutlineBorderColor;
            }
            else if (shapeType == ShapeType.DrawingStep)
            {
                borderColor = AnnotationOptions.StepBorderColor;
            }
            else
            {
                borderColor = AnnotationOptions.BorderColor;
            }

            if (tsbBorderColor.Image != null)
            {
                tsbBorderColor.Image.Dispose();
            }
            tsbBorderColor.Image = ImageHelpers.CreateColorPickerIcon(borderColor, new Rectangle(0, 0, 16, 16), 8);

            int borderSize;

            if (shapeType == ShapeType.DrawingTextBackground || shapeType == ShapeType.DrawingSpeechBalloon)
            {
                borderSize = AnnotationOptions.TextBorderSize;
            }
            else if (shapeType == ShapeType.DrawingTextOutline)
            {
                borderSize = AnnotationOptions.TextOutlineBorderSize;
            }
            else if (shapeType == ShapeType.DrawingStep)
            {
                borderSize = AnnotationOptions.StepBorderSize;
            }
            else
            {
                borderSize = AnnotationOptions.BorderSize;
            }

            tslnudBorderSize.Content.Value = borderSize;

            Color fillColor;

            if (shapeType == ShapeType.DrawingTextBackground || shapeType == ShapeType.DrawingSpeechBalloon)
            {
                fillColor = AnnotationOptions.TextFillColor;
            }
            else if (shapeType == ShapeType.DrawingStep)
            {
                fillColor = AnnotationOptions.StepFillColor;
            }
            else
            {
                fillColor = AnnotationOptions.FillColor;
            }

            if (tsbFillColor.Image != null)
            {
                tsbFillColor.Image.Dispose();
            }
            tsbFillColor.Image = ImageHelpers.CreateColorPickerIcon(fillColor, new Rectangle(0, 0, 16, 16));

            int cornerRadius = 0;

            if (shapeType == ShapeType.RegionRectangle)
            {
                cornerRadius = AnnotationOptions.RegionCornerRadius;
            }
            else if (shapeType == ShapeType.DrawingRectangle || shapeType == ShapeType.DrawingTextBackground)
            {
                cornerRadius = AnnotationOptions.DrawingCornerRadius;
            }

            tslnudCornerRadius.Content.Value = cornerRadius;

            tslnudBlurRadius.Content.Value = AnnotationOptions.BlurRadius;

            tslnudPixelateSize.Content.Value = AnnotationOptions.PixelateSize;

            if (tsbHighlightColor.Image != null)
            {
                tsbHighlightColor.Image.Dispose();
            }
            tsbHighlightColor.Image = ImageHelpers.CreateColorPickerIcon(AnnotationOptions.HighlightColor, new Rectangle(0, 0, 16, 16));

            tsmiShadow.Checked = AnnotationOptions.Shadow;

            tslnudCenterPoints.Content.Value = AnnotationOptions.LineCenterPointCount;

            tsmiArrowHeadsBothSide.Checked = AnnotationOptions.ArrowHeadsBothSide;

            switch (shapeType)
            {
            default:
                tsddbShapeOptions.Visible = false;
                break;

            case ShapeType.RegionRectangle:
            case ShapeType.DrawingRectangle:
            case ShapeType.DrawingEllipse:
            case ShapeType.DrawingFreehand:
            case ShapeType.DrawingLine:
            case ShapeType.DrawingArrow:
            case ShapeType.DrawingTextOutline:
            case ShapeType.DrawingTextBackground:
            case ShapeType.DrawingSpeechBalloon:
            case ShapeType.DrawingStep:
            case ShapeType.EffectBlur:
            case ShapeType.EffectPixelate:
                tsddbShapeOptions.Visible = true;
                break;
            }

            tsmiUndo.Enabled   = tsmiDeleteAll.Enabled = Shapes.Count > 0;
            tsmiDelete.Enabled = tsmiMoveTop.Enabled = tsmiMoveUp.Enabled = tsmiMoveDown.Enabled = tsmiMoveBottom.Enabled = CurrentShape != null;

            switch (shapeType)
            {
            default:
                tsbBorderColor.Visible   = false;
                tslnudBorderSize.Visible = false;
                tsmiShadow.Visible       = false;
                break;

            case ShapeType.DrawingRectangle:
            case ShapeType.DrawingEllipse:
            case ShapeType.DrawingFreehand:
            case ShapeType.DrawingLine:
            case ShapeType.DrawingArrow:
            case ShapeType.DrawingTextOutline:
            case ShapeType.DrawingTextBackground:
            case ShapeType.DrawingSpeechBalloon:
            case ShapeType.DrawingStep:
                tsbBorderColor.Visible   = true;
                tslnudBorderSize.Visible = true;
                tsmiShadow.Visible       = true;
                break;
            }

            switch (shapeType)
            {
            default:
                tsbFillColor.Visible = false;
                break;

            case ShapeType.DrawingRectangle:
            case ShapeType.DrawingEllipse:
            case ShapeType.DrawingTextBackground:
            case ShapeType.DrawingSpeechBalloon:
            case ShapeType.DrawingStep:
                tsbFillColor.Visible = true;
                break;
            }

            switch (shapeType)
            {
            default:
                tslnudCornerRadius.Visible = false;
                break;

            case ShapeType.RegionRectangle:
            case ShapeType.DrawingRectangle:
            case ShapeType.DrawingTextBackground:
                tslnudCornerRadius.Visible = true;
                break;
            }

            tslnudCenterPoints.Visible     = shapeType == ShapeType.DrawingLine || shapeType == ShapeType.DrawingArrow;
            tsmiArrowHeadsBothSide.Visible = shapeType == ShapeType.DrawingArrow;
            tslnudBlurRadius.Visible       = shapeType == ShapeType.EffectBlur;
            tslnudPixelateSize.Visible     = shapeType == ShapeType.EffectPixelate;
            tsbHighlightColor.Visible      = shapeType == ShapeType.EffectHighlight;

            if (tsmiRegionCapture != null)
            {
                tsmiRegionCapture.Visible = !Config.QuickCrop && ValidRegions.Length > 0;
            }
        }
Ejemplo n.º 3
0
        public TextDrawingInputBox(string text, TextDrawingOptions options, bool supportGradient)
        {
            InitializeComponent();
            ShareXResources.ApplyTheme(this);

            InputText = text;
            Options   = options;

            if (InputText != null)
            {
                txtInput.Text = InputText;
            }

            UpdateInputBox();

            cbFonts.Items.AddRange(FontFamily.Families.Select(x => x.Name).ToArray());

            if (cbFonts.Items.Contains(Options.Font))
            {
                cbFonts.SelectedItem = Options.Font;
            }
            else
            {
                cbFonts.SelectedItem = AnnotationOptions.DefaultFont;
            }

            nudTextSize.SetValue(Options.Size);
            btnTextColor.Color = Options.Color;

            btnGradient.Visible = supportGradient;

            if (supportGradient)
            {
                tsmiEnableGradient.Checked = Options.Gradient;

                tsmiSecondColor.Image = ImageHelpers.CreateColorPickerIcon(Options.Color2, new Rectangle(0, 0, 16, 16));

                switch (Options.GradientMode)
                {
                case LinearGradientMode.Horizontal:
                    tsrbmiGradientHorizontal.Checked = true;
                    break;

                case LinearGradientMode.Vertical:
                    tsrbmiGradientVertical.Checked = true;
                    break;

                case LinearGradientMode.ForwardDiagonal:
                    tsrbmiGradientForwardDiagonal.Checked = true;
                    break;

                case LinearGradientMode.BackwardDiagonal:
                    tsrbmiGradientBackwardDiagonal.Checked = true;
                    break;
                }
            }

            cbBold.Checked      = Options.Bold;
            cbItalic.Checked    = Options.Italic;
            cbUnderline.Checked = Options.Underline;

            UpdateButtonImages();
            UpdateEnterTip();

            txtInput.SupportSelectAll();
        }
Ejemplo n.º 4
0
        private void UpdateContextMenu()
        {
            ShapeType shapeType = CurrentShapeType;

            tssObjectOptions.Visible   = tsmiDeleteAll.Visible = Shapes.Count > 0;
            tsmiDeleteSelected.Visible = CurrentShape != null;

            foreach (ToolStripMenuItem tsmi in cmsContextMenu.Items.OfType <ToolStripMenuItem>().Where(x => x.Tag is ShapeType))
            {
                if ((ShapeType)tsmi.Tag == shapeType)
                {
                    tsmi.RadioCheck();
                    break;
                }
            }

            Color borderColor;

            if (shapeType == ShapeType.DrawingText)
            {
                borderColor = AnnotationOptions.TextBorderColor;
            }
            else if (shapeType == ShapeType.DrawingStep)
            {
                borderColor = AnnotationOptions.StepBorderColor;
            }
            else
            {
                borderColor = AnnotationOptions.BorderColor;
            }

            if (tsmiBorderColor.Image != null)
            {
                tsmiBorderColor.Image.Dispose();
            }
            tsmiBorderColor.Image = ImageHelpers.CreateColorPickerIcon(borderColor, new Rectangle(0, 0, 16, 16));

            int borderSize;

            if (shapeType == ShapeType.DrawingText)
            {
                borderSize = AnnotationOptions.TextBorderSize;
            }
            else if (shapeType == ShapeType.DrawingStep)
            {
                borderSize = AnnotationOptions.StepBorderSize;
            }
            else
            {
                borderSize = AnnotationOptions.BorderSize;
            }

            tslnudBorderSize.Content.Value = borderSize;

            Color fillColor;

            if (shapeType == ShapeType.DrawingText)
            {
                fillColor = AnnotationOptions.TextFillColor;
            }
            else if (shapeType == ShapeType.DrawingStep)
            {
                fillColor = AnnotationOptions.StepFillColor;
            }
            else
            {
                fillColor = AnnotationOptions.FillColor;
            }

            if (tsmiFillColor.Image != null)
            {
                tsmiFillColor.Image.Dispose();
            }
            tsmiFillColor.Image = ImageHelpers.CreateColorPickerIcon(fillColor, new Rectangle(0, 0, 16, 16));

            tslnudRoundedRectangleRadius.Content.Value = AnnotationOptions.RoundedRectangleRadius;

            tslnudBlurRadius.Content.Value = AnnotationOptions.BlurRadius;

            tslnudPixelateSize.Content.Value = AnnotationOptions.PixelateSize;

            if (tsmiHighlightColor.Image != null)
            {
                tsmiHighlightColor.Image.Dispose();
            }
            tsmiHighlightColor.Image = ImageHelpers.CreateColorPickerIcon(AnnotationOptions.HighlightColor, new Rectangle(0, 0, 16, 16));

            switch (shapeType)
            {
            default:
                tssShapeOptions.Visible = false;
                break;

            case ShapeType.RegionRoundedRectangle:
            case ShapeType.DrawingRectangle:
            case ShapeType.DrawingRoundedRectangle:
            case ShapeType.DrawingEllipse:
            case ShapeType.DrawingLine:
            case ShapeType.DrawingArrow:
            case ShapeType.DrawingText:
            case ShapeType.DrawingStep:
            case ShapeType.DrawingBlur:
            case ShapeType.DrawingPixelate:
            case ShapeType.DrawingHighlight:
                tssShapeOptions.Visible = true;
                break;
            }

            switch (shapeType)
            {
            default:
                tsmiBorderColor.Visible  = false;
                tslnudBorderSize.Visible = false;
                break;

            case ShapeType.DrawingRectangle:
            case ShapeType.DrawingRoundedRectangle:
            case ShapeType.DrawingEllipse:
            case ShapeType.DrawingLine:
            case ShapeType.DrawingArrow:
            case ShapeType.DrawingText:
            case ShapeType.DrawingStep:
                tsmiBorderColor.Visible  = true;
                tslnudBorderSize.Visible = true;
                break;
            }

            switch (shapeType)
            {
            default:
                tsmiFillColor.Visible = false;
                break;

            case ShapeType.DrawingRectangle:
            case ShapeType.DrawingRoundedRectangle:
            case ShapeType.DrawingEllipse:
            case ShapeType.DrawingText:
            case ShapeType.DrawingStep:
                tsmiFillColor.Visible = true;
                break;
            }

            tslnudRoundedRectangleRadius.Visible = shapeType == ShapeType.RegionRoundedRectangle || shapeType == ShapeType.DrawingRoundedRectangle;
            tslnudBlurRadius.Visible             = shapeType == ShapeType.DrawingBlur;
            tslnudPixelateSize.Visible           = shapeType == ShapeType.DrawingPixelate;
            tsmiHighlightColor.Visible           = shapeType == ShapeType.DrawingHighlight;
        }