Esempio n. 1
0
        void DrawTriangle(float x, float y, bool flipped)
        {
            Brush brush = BrushRegistry.GetBrush(Color.FromArgb(192, 192, 192));

            base.Graphics.FillRectangle(brush, new RectangleF(x, y, triHeight, triHeight));
            float triHeight2 = triHeight / 2;
            float triHeight4 = triHeight / 4;

            brush = Brushes.Black;
            if (flipped)
            {
                base.Graphics.FillPolygon(brush, new PointF[] {
                    new PointF(x, y + triHeight2 - triHeight4),
                    new PointF(x + triWidth / 2, y + triHeight2 + triHeight4),
                    new PointF(x + triWidth, y + triHeight2 - triHeight4),
                });
            }
            else
            {
                base.Graphics.FillPolygon(brush, new PointF[] {
                    new PointF(x, y + triHeight2 + triHeight4),
                    new PointF(x + triWidth / 2, y + triHeight2 - triHeight4),
                    new PointF(x + triWidth, y + triHeight2 + triHeight4),
                });
            }
        }
Esempio n. 2
0
        private void DrawTriangle(float x, float y, bool flipped)
        {
            Brush brush = BrushRegistry.GetBrush(Color.FromArgb(192, 192, 192));

            base.Graphics.FillRectangle(brush, new RectangleF(x, y, this.triHeight, this.triHeight));
            float num  = this.triHeight / 2f;
            float num2 = this.triHeight / 4f;

            brush = Brushes.Black;
            if (flipped)
            {
                base.Graphics.FillPolygon(brush, new PointF[]
                {
                    new PointF(x, y + num - num2),
                    new PointF(x + this.triWidth / 2f, y + num + num2),
                    new PointF(x + this.triWidth, y + num - num2)
                });
                return;
            }
            base.Graphics.FillPolygon(brush, new PointF[]
            {
                new PointF(x, y + num + num2),
                new PointF(x + this.triWidth / 2f, y + num - num2),
                new PointF(x + this.triWidth, y + num + num2)
            });
        }
Esempio n. 3
0
 public override void Draw(PointF location)
 {
     if (this.IsTextVisible())
     {
         RectangleF layoutRectangle = new RectangleF(location, base.AllocatedSize);
         base.Graphics.DrawString(this.tipText, this.tipFont, BrushRegistry.GetBrush(this.Color), layoutRectangle, this.GetInternalStringFormat());
     }
 }
Esempio n. 4
0
 public override void Draw(PointF location)
 {
     if (IsTextVisible())
     {
         RectangleF drawRectangle = new RectangleF(location, AllocatedSize);
         Graphics.DrawString(tipText, tipFont, BrushRegistry.GetBrush(Color), drawRectangle, GetInternalStringFormat());
     }
 }
Esempio n. 5
0
        float DrawDocumentWord(Graphics g, string word, PointF position, Font font, Color foreColor)
        {
            if (word == null || word.Length == 0)
            {
                return(0f);
            }
            SizeF wordSize = g.MeasureString(word, font, 32768, sf);

            g.DrawString(word,
                         font,
                         BrushRegistry.GetBrush(foreColor),
                         position,
                         sf);
            return(wordSize.Width);
        }
        private void DrawTriangle(float x, float y, bool flipped)
        {
            Brush brush = BrushRegistry.GetBrush(System.Drawing.Color.FromArgb(192, 192, 192));

            base.Graphics.FillRectangle(brush, new RectangleF(x, y, this.triHeight, this.triHeight));
            float single  = this.triHeight / 2f;
            float single1 = this.triHeight / 4f;

            brush = Brushes.Black;
            if (flipped)
            {
                System.Drawing.Graphics graphics = base.Graphics;
                PointF[] pointF = new PointF[] { new PointF(x, y + single - single1), new PointF(x + this.triWidth / 2f, y + single + single1), new PointF(x + this.triWidth, y + single - single1) };
                graphics.FillPolygon(brush, pointF);
                return;
            }
            System.Drawing.Graphics graphic = base.Graphics;
            PointF[] pointFArray            = new PointF[] { new PointF(x, y + single + single1), new PointF(x + this.triWidth / 2f, y + single - single1), new PointF(x + this.triWidth, y + single + single1) };
            graphic.FillPolygon(brush, pointFArray);
        }
        public override void Paint(Graphics g, Rectangle rect)
        {
            var totalWidth = Width;
            var leftWidth  = (int)(totalWidth / 2.0);
            var rightWidth = rect.Width - leftWidth;

            var fontHeight             = textArea.TextView.FontHeight;
            var lineNumberPainterColor = textArea.Document.HighlightingStrategy.GetColorFor("LineNumbers");
            var fillBrush = textArea.Enabled ? BrushRegistry.GetBrush(lineNumberPainterColor.BackgroundColor) : SystemBrushes.InactiveBorder;
            var drawBrush = BrushRegistry.GetBrush(lineNumberPainterColor.Color);

            for (var y = 0; y < ((DrawingPosition.Height + textArea.TextView.VisibleLineDrawingRemainder) / fontHeight) + 1; ++y)
            {
                var ypos = drawingPosition.Y + (fontHeight * y) - textArea.TextView.VisibleLineDrawingRemainder;
                var backgroundRectangle = new Rectangle(drawingPosition.X, ypos, drawingPosition.Width, fontHeight);
                if (!rect.IntersectsWith(backgroundRectangle))
                {
                    continue;
                }

                g.FillRectangle(fillBrush, backgroundRectangle);
                var curLine = textArea.Document.GetFirstLogicalLine(textArea.Document.GetVisibleLine(textArea.TextView.FirstVisibleLine) + y);

                if (curLine >= textArea.Document.TotalNumberOfLines)
                {
                    continue;
                }

                if (!_diffLines.ContainsKey(curLine + 1))
                {
                    continue;
                }

                var diffLine = _diffLines[curLine + 1];
                if (diffLine.LineType != DiffLineType.Context)
                {
                    var brush = default(Brush);
                    switch (diffLine.LineType)
                    {
                    case DiffLineType.Context:
                        break;

                    case DiffLineType.Plus:
                        brush = new SolidBrush(AppSettings.DiffAddedColor);
                        break;

                    case DiffLineType.Minus:
                        brush = new SolidBrush(AppSettings.DiffRemovedColor);
                        break;

                    case DiffLineType.Header:
                        brush = new SolidBrush(AppSettings.DiffSectionColor);
                        break;
                    }

                    Debug.Assert(brush != null, string.Format("brush != null, unknow diff line style {0}", diffLine.LineType));
                    g.FillRectangle(brush, new Rectangle(0, backgroundRectangle.Top, leftWidth, backgroundRectangle.Height));

                    g.FillRectangle(brush, new Rectangle(leftWidth, backgroundRectangle.Top, rightWidth, backgroundRectangle.Height));
                }

                if (diffLine.LeftLineNumber != DiffLineInfo.NotApplicableLineNum)
                {
                    g.DrawString(diffLine.LeftLineNumber.ToString(),
                                 lineNumberPainterColor.GetFont(TextEditorProperties.FontContainer),
                                 drawBrush,
                                 new Point(TextHorizontalMargin, backgroundRectangle.Top));
                }

                if (diffLine.RightLineNumber != DiffLineInfo.NotApplicableLineNum)
                {
                    g.DrawString(diffLine.RightLineNumber.ToString(),
                                 lineNumberPainterColor.GetFont(TextEditorProperties.FontContainer),
                                 drawBrush,
                                 new Point(TextHorizontalMargin + (totalWidth / 2), backgroundRectangle.Top));
                }
            }
        }
        protected override void OnPaint(PaintEventArgs pe)
        {
            float yPos       = 1;
            float itemHeight = ItemHeight;
            // Maintain aspect ratio
            //int imageWidth = (int)(itemHeight * imageList.ImageSize.Width / imageList.ImageSize.Height);
            int imageWidth = 16;

            int      curItem = firstItem;
            Graphics g       = pe.Graphics;

            while (curItem < completionData.Length && yPos < Height)
            {
                RectangleF drawingBackground = new RectangleF(1, yPos, Width - 2, itemHeight);
                //drawingBackground.X += 3;
                if (drawingBackground.IntersectsWith(pe.ClipRectangle))
                {
                    // draw Background

                    if (curItem == selectedItem)
                    {
                        Rectangle r = Rectangle.Round(drawingBackground);
                        r.Width  -= 4;
                        r.Height -= 1;

                        r.Width -= imageWidth;
                        r.X     += imageWidth;
                        r.X     += 3;

                        g.DrawRectangle(BrushRegistry.GetPen(Color.FromArgb(229, 195, 101)), r);

                        using (LinearGradientBrush brush = new LinearGradientBrush(r, startColorTop, endColorTop, LinearGradientMode.Vertical))
                        {
                            g.FillRectangle(brush, r.X + 1, r.Y + 1, r.Width - 1, (r.Height / 2));
                        }
                        //Console.WriteLine();
                        g.FillRectangle(BrushRegistry.GetBrush(colorBottom), r.X + 1, r.Y + (r.Height / 2) + 1, r.Width - 1, (r.Height / 2));
                        //LinearGradientBrush gradientBrush = new LinearGradientBrush(r,
                        //g.FillRectangle(SystemBrushes.Highlight, drawingBackground);
                    }
                    else
                    {
                        g.FillRectangle(SystemBrushes.Window, drawingBackground);
                    }

                    // draw Icon
                    int xPos = 0;
                    if (imageList != null && completionData[curItem].ImageIndex < imageList.Images.Count)
                    {
                        g.FillRectangle(SystemBrushes.Window, drawingBackground.X, drawingBackground.Y, imageWidth + 3, itemHeight);
                        g.DrawImage(imageList.Images[completionData[curItem].ImageIndex], new RectangleF(3, yPos + 1, imageWidth, 16));
                        xPos = imageWidth + 3;
                    }

                    // draw text
                    if (curItem == selectedItem)
                    {
                        g.DrawString(completionData[curItem].Text, Font, BrushRegistry.GetBrush(Color.Black), xPos, yPos);
                    }
                    else
                    {
                        g.DrawString(completionData[curItem].Text, Font, SystemBrushes.WindowText, xPos, yPos);
                    }
                }

                yPos += itemHeight;
                ++curItem;
            }
            g.DrawRectangle(SystemPens.ControlDark, new Rectangle(0, 0, Width - 1, Height - 1));
        }
Esempio n. 9
0
        public override void Draw(PointF location)
        {
            if (IsTextVisible())
            {
                RectangleF drawRectangle = new RectangleF(location, AllocatedSize);
                Font       fnt           = new Font(tipFont, FontStyle.Bold);

                /*Graphics.DrawString(tipText.Substring(0,beg_bold), tipFont,
                 *                  BrushRegistry.GetBrush(Color),
                 *                  drawRectangle,
                 *                  GetInternalStringFormat());
                 * Graphics.DrawString(tipText.Substring(beg_bold,len_bold), fnt,
                 *                  BrushRegistry.GetBrush(Color),
                 *                  drawRectangle,
                 *                  GetInternalStringFormat());
                 * Graphics.DrawString(tipText.Substring(beg_bold+len_bold), tipFont,
                 *                  BrushRegistry.GetBrush(Color),
                 *                  drawRectangle,
                 *                  GetInternalStringFormat());*/
                if (this is CountTipText || is_doc)
                {
                    Graphics.DrawString(tipText, tipFont,
                                        BrushRegistry.GetBrush(Color),
                                        drawRectangle,
                                        GetInternalStringFormat());
                }
                else if (is_head)
                {
                    Graphics.DrawString(tipText, fnt,
                                        BrushRegistry.GetBrush(Color),
                                        drawRectangle,
                                        GetInternalStringFormatForHeader());
                }
                else if (param_name)
                {
                    drawRectangle.X += 10;
                    Graphics.DrawString(tipText, fnt,
                                        BrushRegistry.GetBrush(System.Drawing.Color.Brown),
                                        drawRectangle,
                                        GetInternalStringFormatForHeader());
                }
                else if (need_tab)
                {
                    if (param_desc)
                    {
                        drawRectangle.X += 20;
                    }
                    else
                    {
                        drawRectangle.X += 10;
                    }
                    Graphics.DrawString(tipText, tipFont,
                                        BrushRegistry.GetBrush(Color),
                                        drawRectangle,
                                        GetInternalStringFormat());
                }
                else
                {
                    SizeF szfull = Graphics.MeasureString(tipText, tipFont, new SizeF(drawRectangle.Width, drawRectangle.Height), GetInternalStringFormat());

                    SizeF sz1 = Graphics.MeasureString(tipText.Substring(0, beg_bold), tipFont, new SizeF(drawRectangle.Width, drawRectangle.Height), GetInternalStringFormat());
                    if (szfull.Height > sz1.Height + 3)
                    {
                        Graphics.DrawString(tipText, tipFont,
                                            BrushRegistry.GetBrush(Color),
                                            drawRectangle,
                                            GetInternalStringFormat());
                        return;
                    }
                    Graphics.DrawString(tipText.Substring(0, beg_bold), tipFont,
                                        BrushRegistry.GetBrush(Color),
                                        drawRectangle,
                                        GetInternalStringFormat());
                    SizeF sz2      = Graphics.MeasureString(tipText.Substring(beg_bold, len_bold), fnt, new SizeF(drawRectangle.Width, drawRectangle.Height), GetInternalStringFormat());
                    SizeF sz2_simp = Graphics.MeasureString(tipText.Substring(beg_bold, len_bold), tipFont, new SizeF(drawRectangle.Width, drawRectangle.Height), GetInternalStringFormat());
                    float x_coord  = drawRectangle.X;
                    float y_coord  = drawRectangle.Y;
                    if (sz1.Width + sz2.Width > drawRectangle.Width)
                    {
                        if (drawRectangle.Height > sz1.Height)
                        {
                            y_coord += sz1.Height;
                        }
                    }
                    else
                    {
                        x_coord += sz1.Width;
                    }
                    Graphics.DrawString(tipText.Substring(beg_bold, len_bold), fnt,
                                        BrushRegistry.GetBrush(Color),
                                        x_coord,
                                        y_coord,
                                        GetInternalStringFormat());
                    SizeF sz3 = Graphics.MeasureString(tipText.Substring(beg_bold + len_bold), tipFont, new SizeF(drawRectangle.Width, drawRectangle.Height), GetInternalStringFormat());
                    if (sz1.Width + sz2.Width + sz3.Width > drawRectangle.Width)
                    {
                        if (drawRectangle.Height > sz1.Height)
                        {
                            x_coord  = drawRectangle.X;
                            y_coord += sz2.Height;
                        }
                    }
                    else
                    {
                        x_coord += sz2.Width;
                    }
                    Graphics.DrawString(tipText.Substring(beg_bold + len_bold), tipFont,
                                        BrushRegistry.GetBrush(Color),
                                        x_coord,
                                        y_coord,
                                        GetInternalStringFormat());
                }
            }
        }