예제 #1
0
        /// <summary>
        /// Updates the toolbar buttons depending on the current document.
        /// </summary>
        private void CreateButtons()
        {
            base.Buttons.Clear();

            if (document == null)
            {
                return;
            }

            int index = 0;

            if (shapes == null || shapes.Length == 0)
            {
                // show all shapes
                foreach (ShapeTemplate template in ShapeTemplate.Shapes)
                {
                    createButton(template, index++);
                }
            }
            else
            {
                // show specified shapes
                foreach (string id in shapes)
                {
                    createButton(ShapeTemplate.FromId(id), index++);
                }
            }
        }
예제 #2
0
        private void OnSelected(object sender, System.EventArgs e)
        {
            if (_list.SelectedIndex != -1)
            {
                _selected = ShapeTemplate.FromId(
                    _list.SelectedItem.ToString());
            }

            _service.CloseDropDown();
        }
예제 #3
0
        /// <summary>
        /// Creates the image list with shape images using
        /// the current control settings.
        /// </summary>
        private void CreateImages()
        {
            this.ImageList = null;

            // Create the image list
            images                  = new ImageList();
            images.ImageSize        = imageSize;
            images.TransparentColor = SystemColors.Control;

            // Create a temporary hidden flowchart object
            FlowChart chart = new FlowChart();

            chart.MeasureUnit = GraphicsUnit.Pixel;
            chart.DrawBox    += this.DrawBox;

            System.Drawing.Brush back =
                new System.Drawing.SolidBrush(SystemColors.Control);

            // Populate the image list
            if (shapes == null || shapes.Length == 0)
            {
                // show all shapes
                foreach (ShapeTemplate template in ShapeTemplate.Shapes)
                {
                    createImage(template, back, chart);
                }
            }
            else
            {
                // show specified shapes
                foreach (string id in shapes)
                {
                    createImage(ShapeTemplate.FromId(id), back, chart);
                }
            }

            back.Dispose();
            chart.Dispose();
        }
예제 #4
0
 public ShapeTemplate ShapeTemplateFromId(string shapeId)
 {
     return(ShapeTemplate.FromId(shapeId));
 }
예제 #5
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();
        }