Пример #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics          g                 = e.Graphics;
            SmoothingMode     smoothingMode     = g.SmoothingMode;
            TextRenderingHint textRenderingHint = g.TextRenderingHint;

            g.SmoothingMode     = SmoothingMode.HighQuality;
            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            #region Draw
            if (buttonStyle == 0)
            {
                DrawStyle1(g);
            }
            else
            {
                DrawStyle2(g);
            }

            if (image != null)
            {
                g.DrawImage(image, new RectangleF(18, 18, 32, 32));
            }

            // Header
            using (Font font = new Font("Segoe UI", 16))
            {
                g.DrawString(this.header, font, (IsMouseOver ? selectedTextBrush : textBrush), 67, -8);
            }

            // Desription
            using (StringFormat sf = new StringFormat())
            {
                sf.FormatFlags = 0;
                sf.Trimming    = StringTrimming.EllipsisWord;
                sf.Alignment   = StringAlignment.Center;

                StiTextDrawing.DrawStringWidth(g, this.Text, this.Font, (IsMouseOver ? selectedTextBrush : textBrush), new RectangleD(70, 18, 365, 50), sf);
            }
            #endregion

            g.SmoothingMode     = smoothingMode;
            g.TextRenderingHint = textRenderingHint;
        }
Пример #2
0
        public override void Paint(StiComponent component, StiPaintEventArgs e)
        {
            Graphics   g    = e.Graphics;
            RectangleD rect = component.GetPaintRectangle();

            RectangleF rectF = rect.ToRectangleF();

            g.DrawRectangle(Pens.Gray, rectF.Left, rectF.Top, rectF.Width, rectF.Height);

            MyCustomComponentWithExpression customComponent = component as MyCustomComponentWithExpression;

            using (StringFormat stringFormat = new StringFormat())
                using (Font font = new Font("Arial", (float)(15 * component.Page.Zoom)))
                    using (Brush brush = new SolidBrush(Color.Gray))
                    {
                        stringFormat.LineAlignment = StringAlignment.Center;
                        stringFormat.Alignment     = StringAlignment.Center;

                        string value = component.IsDesigning ? customComponent.CustomCode.Value : customComponent.CustomCodeValue;

                        StiTextDrawing.DrawString(g, value, font, brush,
                                                  new RectangleD(rect.Left, rect.Top, rect.Width, rect.Height), stringFormat);
                    }
        }