Exemplo n.º 1
0
        /// <summary>
        /// Рисует горизонтальную линию с надписью цены
        /// </summary>
        /// <param name="g"></param>
        /// <param name="rectPaint"></param>
        /// <param name="valPrice"></param>
        /// <param name="Text"></param>
        /// <param name="maxPrice"></param>
        /// <param name="minPrice"></param>
        public void Paint(Graphics g, Rectangle rectPaint, decimal valPrice, string ValText, decimal maxPrice, decimal minPrice)
        {
            int Y = GMath.GetCoordinate(rectPaint.Height, maxPrice, minPrice, valPrice);

            //Если выходит за пределы, удаляем
            if (Y < 0 || Y > rectPaint.Y + rectPaint.Height)
            {
                return;
            }

            var font = new Font(this.FontFamily, this.FontSize, FontStyle.Regular, GraphicsUnit.Point);

            var dataText   = g.MeasureString(ValText, font);
            int WidthText  = (int)dataText.Width;
            int HeightText = (int)dataText.Height;

            Point pLine1 = new Point(rectPaint.X, rectPaint.Y + Y);
            Point pLine2 = new Point(rectPaint.X + rectPaint.Width - WidthText - 2, rectPaint.Y + Y);

            float x = 0;
            float y = rectPaint.Y + Y - (this.FontSize);

            //ВЫравнивание лейбла
            switch (this.TextHAlign)
            {
            case DirectionLine.Left:
                x      = rectPaint.X;
                pLine1 = new Point(rectPaint.X + WidthText, rectPaint.Y + Y);
                pLine2 = new Point(rectPaint.X + rectPaint.Width, rectPaint.Y + Y);
                break;

            case DirectionLine.Center:
                //Canvas.SetLeft(this.TextLabel, PaintPanel.X + (PaintPanel.Width / 2 - this.TextLabel.ActualWidth));
                break;

            case DirectionLine.Right:
                x = rectPaint.X + rectPaint.Width - WidthText;
                break;
            }

            if (this.FillText)
            {
                var rect = new RectDraw();
                rect.ColorBorder = rect.ColorFill = Color.White;
                rect.Paint(g, x, y, WidthText, HeightText);
            }

            g.DrawString(ValText, font, new SolidBrush(this.ColorText), x, y);

            PaintLine(g, pLine1, pLine2);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Рисует текст на полотне
        /// </summary>
        /// <param name="g"></param>
        /// <param name="text"></param>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        /// <param name="color"></param>
        public void Paint(Graphics g, string text, float X, float Y, Color color)
        {
            this.Color = color;

            var dataText   = this.GetSizeText(g, text);
            int WidthText  = (int)dataText.Width;
            int HeightText = (int)dataText.Height;

            var rect = new RectDraw();

            rect.ColorBorder = rect.ColorFill = Color.FromArgb(200, Color.White);
            rect.Paint(g, X, Y, WidthText, HeightText);

            g.DrawString(text, this.Font,
                         new SolidBrush(this.Color), X, Y);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Рисует вертикальнцю линию с надписью
        /// </summary>
        /// <param name="g"></param>
        /// <param name="ValText"></param>
        /// <param name="pStart"></param>
        /// <param name="pEnd"></param>
        public void Paint(Graphics g, string ValText, PointF pStart, PointF pEnd)
        {
            int WidthText  = 0;
            int HeightText = 0;
            var textP      = new TextDraw();

            if (ValText.NotIsNull())
            {
                textP.SetFontSize(7);
                textP.Color = this.ColorText;
                var sizeText = textP.GetSizeText(g, ValText);
                WidthText  = (int)sizeText.Width;
                HeightText = (int)sizeText.Height;
            }

            float x = pEnd.X - WidthText / 2;
            float y = 0;

            //Выравнивание лейбла
            switch (this.TextVAlign)
            {
            case DirectionLine.Bottom:
                pEnd.Y -= HeightText;
                y       = pEnd.Y;
                break;

            case DirectionLine.Top:
                pStart.Y += HeightText;
                y         = pStart.Y + HeightText;
                break;
            }
            if (ValText.NotIsNull())
            {
                if (this.FillText)
                {
                    var rect = new RectDraw();
                    rect.ColorBorder = rect.ColorFill = Color.White;
                    rect.Paint(g, x, y, WidthText, HeightText);
                }
                textP.Paint(g, ValText, x, y);
            }

            var line = new Line();

            line.Width = this.WidthLine;
            line.Paint(g, pStart, pEnd, this.ColorLine);
        }