Exemple #1
0
        public override void PaintValue(PaintValueEventArgs e)
        {
            MindFusion.FlowChartX.ShapeTemplate shape =
                e.Value as MindFusion.FlowChartX.ShapeTemplate;

            if (shape == null)
            {
                return;
            }

            // Draw the shape
            RectangleF rect = new RectangleF(
                (float)e.Bounds.Left, (float)e.Bounds.Top,
                (float)e.Bounds.Width - 1, (float)e.Bounds.Height - 1);

            rect.Inflate(-2, -2);
            MindFusion.FlowChartX.ShapeTemplate.PathData data =
                shape.initData(rect, 0);
            System.Drawing.Brush brush =
                new System.Drawing.SolidBrush(Color.LightSteelBlue);
            System.Drawing.Pen pen =
                new System.Drawing.Pen(Color.Black);

            System.Drawing.Drawing2D.SmoothingMode mode =
                e.Graphics.SmoothingMode;
            e.Graphics.SmoothingMode =
                System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            System.Drawing.Drawing2D.GraphicsPath path =
                shape.getPath(data, 0);
            e.Graphics.FillPath(brush, path);
            e.Graphics.DrawPath(pen, path);
            path.Dispose();

            path = shape.getDecorationPath(data, 0);
            if (path != null)
            {
                e.Graphics.DrawPath(pen, path);
                path.Dispose();
            }

            e.Graphics.SmoothingMode = mode;

            pen.Dispose();
            brush.Dispose();
        }
Exemple #2
0
        private void OnDrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            e.DrawBackground();
            e.DrawFocusRectangle();

            Rectangle rect = e.Bounds;

            rect.X      += 1;
            rect.Y      += 1;
            rect.Height -= 2;
            rect.Width   = rect.Height;

            System.Drawing.Brush brush =
                new System.Drawing.SolidBrush(Color.White);
            System.Drawing.Brush fill =
                new System.Drawing.SolidBrush(Color.LightSteelBlue);
            System.Drawing.Pen pen =
                new System.Drawing.Pen(Color.Black, 0);

            e.Graphics.FillRectangle(brush, rect);
            e.Graphics.DrawRectangle(pen, rect);

            System.Drawing.Drawing2D.SmoothingMode mode =
                e.Graphics.SmoothingMode;
            e.Graphics.SmoothingMode =
                System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            rect.Inflate(-2, -2);
            string        shapeId = _list.Items[e.Index].ToString();
            ShapeTemplate shape   = ShapeTemplate.FromId(shapeId);
            RectangleF    rectf   = new RectangleF(
                (float)rect.X, (float)rect.Y,
                (float)rect.Width, (float)rect.Height);

            MindFusion.FlowChartX.ShapeTemplate.PathData data =
                shape.initData(rectf, 0);

            System.Drawing.Drawing2D.GraphicsPath path =
                shape.getPath(data, 0);
            e.Graphics.FillPath(fill, path);
            e.Graphics.DrawPath(pen, path);
            path.Dispose();

            path = shape.getDecorationPath(data, 0);
            if (path != null)
            {
                e.Graphics.DrawPath(pen, path);
                path.Dispose();
            }

            e.Graphics.SmoothingMode = mode;

            pen.Dispose();
            fill.Dispose();
            brush.Dispose();

            // Draw the text;
            rectf.X     = rectf.Right + 6;
            rectf.Width = (float)e.Bounds.Width - rectf.X;

            StringFormat format = new StringFormat();

            format.Alignment     = StringAlignment.Near;
            format.LineAlignment = StringAlignment.Center;
            System.Drawing.Brush textBrush =
                new System.Drawing.SolidBrush(Color.Black);
            e.Graphics.DrawString(shapeId, Font, textBrush, rectf, format);
            textBrush.Dispose();
            format.Dispose();
        }