Ejemplo n.º 1
0
 public override void OnConfigLoad()
 {
     TextOptions = AnnotationOptions.TextOptions.Copy();
     BorderColor = AnnotationOptions.TextBorderColor;
     BorderSize  = AnnotationOptions.TextBorderSize;
     FillColor   = AnnotationOptions.TextFillColor;
 }
Ejemplo n.º 2
0
        public TextDrawingInputBox(string text, TextDrawingOptions options)
        {
            InitializeComponent();
            Icon = ShareXResources.Icon;

            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 = "Arial";
            }

            nudTextSize.SetValue(Options.Size);
            btnTextColor.Color = Options.Color;
            cbBold.Checked = Options.Bold;
            cbItalic.Checked = Options.Italic;
            cbUnderline.Checked = Options.Underline;

            UpdateHorizontalAlignmentImage();
            UpdateVerticalAlignmentImage();
        }
Ejemplo n.º 3
0
        public TextDrawingInputBox(string text, TextDrawingOptions options)
        {
            InitializeComponent();
            Icon = ShareXResources.Icon;

            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 = "Arial";
            }

            nudTextSize.SetValue(Options.Size);
            btnTextColor.Color  = Options.Color;
            cbBold.Checked      = Options.Bold;
            cbItalic.Checked    = Options.Italic;
            cbUnderline.Checked = Options.Underline;

            UpdateHorizontalAlignmentImage();
            UpdateVerticalAlignmentImage();
        }
Ejemplo n.º 4
0
 public override void UpdateShapeConfig()
 {
     Options = AnnotationOptions.TextOptions.Copy();
     BorderColor = AnnotationOptions.TextBorderColor;
     BorderSize = AnnotationOptions.TextBorderSize;
     FillColor = AnnotationOptions.TextFillColor;
 }
Ejemplo n.º 5
0
 public override void UpdateShapeConfig()
 {
     Options     = AnnotationOptions.TextOptions.Copy();
     BorderColor = AnnotationOptions.TextBorderColor;
     BorderSize  = AnnotationOptions.TextBorderSize;
     FillColor   = AnnotationOptions.TextFillColor;
 }
Ejemplo n.º 6
0
 public override void OnConfigLoad()
 {
     TextOptions = AnnotationOptions.TextOptions.Copy();
     BorderColor = AnnotationOptions.TextBorderColor;
     BorderSize = AnnotationOptions.TextBorderSize;
     FillColor = AnnotationOptions.TextFillColor;
     CornerRadius = AnnotationOptions.TextCornerRadius;
 }
Ejemplo n.º 7
0
 public override void OnConfigLoad()
 {
     TextOptions  = AnnotationOptions.TextOptions.Copy();
     BorderColor  = AnnotationOptions.TextBorderColor;
     BorderSize   = AnnotationOptions.TextBorderSize;
     FillColor    = AnnotationOptions.TextFillColor;
     CornerRadius = AnnotationOptions.DrawingCornerRadius;
     Shadow       = AnnotationOptions.Shadow;
 }
Ejemplo n.º 8
0
 protected void DrawText(Graphics g, string text, Color textColor, TextDrawingOptions options, Rectangle rect)
 {
     if (!string.IsNullOrEmpty(text) && rect.Width > 10 && rect.Height > 10)
     {
         using (Font font = new Font(options.Font, options.Size, options.Style))
         using (Brush textBrush = new SolidBrush(textColor))
         using (StringFormat sf = new StringFormat { Alignment = options.AlignmentHorizontal, LineAlignment = options.AlignmentVertical })
         {
             g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
             g.DrawString(text, font, textBrush, rect, sf);
             g.TextRenderingHint = TextRenderingHint.SystemDefault;
         }
     }
 }
Ejemplo n.º 9
0
 protected void DrawText(Graphics g, string text, Color textColor, TextDrawingOptions options, Rectangle rect)
 {
     if (!string.IsNullOrEmpty(text) && rect.Width > 10 && rect.Height > 10)
     {
         using (Font font = new Font(options.Font, options.Size, options.Style))
             using (Brush textBrush = new SolidBrush(textColor))
                 using (StringFormat sf = new StringFormat {
                     Alignment = options.AlignmentHorizontal, LineAlignment = options.AlignmentVertical
                 })
                 {
                     g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
                     g.DrawString(text, font, textBrush, rect, sf);
                     g.TextRenderingHint = TextRenderingHint.SystemDefault;
                 }
     }
 }
Ejemplo n.º 10
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.º 11
0
 protected void DrawText(Graphics g, string text, TextDrawingOptions options, Rectangle rect)
 {
     DrawText(g, text, options.Color, options, rect);
 }
Ejemplo n.º 12
0
        protected void DrawTextWithOutline(Graphics g, string text, TextDrawingOptions options, Color textColor, Color borderColor, int borderSize, Rectangle rect)
        {
            if (!string.IsNullOrEmpty(text) && rect.Width > 10 && rect.Height > 10)
            {
                using (GraphicsPath gp = new GraphicsPath())
                {
                    using (Font font = new Font(options.Font, options.Size, options.Style))
                        using (StringFormat sf = new StringFormat {
                            Alignment = options.AlignmentHorizontal, LineAlignment = options.AlignmentVertical
                        })
                        {
                            float emSize = g.DpiY * font.SizeInPoints / 72;
                            gp.AddString(text, font.FontFamily, (int)font.Style, emSize, rect, sf);
                        }

                    g.SmoothingMode = SmoothingMode.HighQuality;

                    if (Shadow)
                    {
                        using (Matrix matrix = new Matrix())
                        {
                            matrix.Translate(ShadowOffset.X, ShadowOffset.Y);
                            gp.Transform(matrix);

                            if (IsBorderVisible)
                            {
                                using (Pen shadowPen = new Pen(ShadowColor, borderSize)
                                {
                                    LineJoin = LineJoin.Round
                                })
                                {
                                    g.DrawPath(shadowPen, gp);
                                }
                            }
                            else
                            {
                                using (Brush shadowBrush = new SolidBrush(ShadowColor))
                                {
                                    g.FillPath(shadowBrush, gp);
                                }
                            }

                            matrix.Reset();
                            matrix.Translate(-ShadowOffset.X, -ShadowOffset.Y);
                            gp.Transform(matrix);
                        }
                    }

                    if (IsBorderVisible)
                    {
                        using (Pen borderPen = new Pen(borderColor, borderSize)
                        {
                            LineJoin = LineJoin.Round
                        })
                        {
                            g.DrawPath(borderPen, gp);
                        }
                    }

                    using (Brush textBrush = new SolidBrush(textColor))
                    {
                        g.FillPath(textBrush, gp);
                    }

                    g.SmoothingMode = SmoothingMode.None;
                }
            }
        }
Ejemplo n.º 13
0
 protected void DrawText(Graphics g, string text, TextDrawingOptions options, Rectangle rect)
 {
     DrawText(g, text, options.Color, options, rect);
 }