Exemplo n.º 1
0
        public SimpleShape CreateShape(ShapeType shapeType, Point position)
        {
            SimpleShape shape = null;

            switch (shapeType)
            {
            case ShapeType.Rectangle:
                shape = new SimpleRectangle()
                {
                    FillBrush   = Brushes.Blue,
                    StrokeBrush = Brushes.DarkBlue
                };
                break;

            case ShapeType.Ellipse:
                shape = new SimpleEllipse()
                {
                    FillBrush   = Brushes.Red,
                    StrokeBrush = Brushes.DarkRed
                };
                break;

            default:
                throw new ArgumentException("Invalid shape mode to create a shape");
            }

            shape.Width  = 100;
            shape.Height = 50;
            shape.Left   = position.X - shape.Width / 2;
            shape.Top    = position.Y - shape.Height / 2;

            return(shape);
        }
Exemplo n.º 2
0
        public void AddNodeElement(Point point)
        {
            NodeElement nodeEle = new SimpleRectangle(point, new Size(80, 60), this);

            this._nodes.Add(nodeEle);
            this._nodes.ForEach(ele => ele.Invalidate());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Only a utility function which returns a specific type of (handcrafted) tree.
        /// </summary>
        /// <returns></returns>
        public static Bundle CreateSpecificTree()
        {
            Bundle bundle = new Bundle();

            SimpleRectangle rec1 = new SimpleRectangle();

            rec1.Location = new Point(100, 30);

            SimpleRectangle rec2 = new SimpleRectangle();

            rec2.Location = new Point(50, 80);

            SimpleRectangle rec3 = new SimpleRectangle();

            rec3.Location = new Point(150, 80);


            Connection cn1 = new Connection();

            rec1.Connectors[2].AttachConnector(cn1.From);
            rec2.Connectors[0].AttachConnector(cn1.To);

            Connection cn2 = new Connection();

            rec1.Connectors[2].AttachConnector(cn2.From);
            rec3.Connectors[0].AttachConnector(cn2.To);

            bundle.Entities.Add(rec1);
            bundle.Entities.Add(rec2);
            bundle.Entities.Add(rec3);
            bundle.Entities.Add(cn1);
            bundle.Entities.Add(cn2);

            return(bundle);
        }
Exemplo n.º 4
0
    public static void Main(string[] args)
    {
        SimpleRectangle[] rects = new SimpleRectangle[4];

        rects[0] = new SimpleRectangle(1, 10);
        rects[1] = new SimpleRectangle(20, 1);
        rects[2] = new SimpleRectangle(4, 6);
        rects[3] = new SimpleRectangle(5, 5);
        Console.WriteLine("MAX WIDTH: " + findMax(rects, new OrderRectByWidth( )));
        Console.WriteLine("MAX AREA: " + findMax(rects, new OrderRectByArea( )));
    }
Exemplo n.º 5
0
            public UIElement Create(Rect rect)
            {
                SimpleRectangle shape = new SimpleRectangle();

                shape.Width      = rect.Width;
                shape.Height     = rect.Height;
                shape.Background = Brushes.LightYellow;
                Canvas.SetLeft(shape, rect.X);
                Canvas.SetTop(shape, rect.Y);
                shape.Text = "The shadow effect is a killer and a software rendering process unless you are running Vista. You can use the font formatting toolbar buttons to change the appearance of this text. There are so many possibilities, this box is just too small to highlight it all.";
                return(shape);
            }
Exemplo n.º 6
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            #region Creation of a sample diagram

            #region The shapes

            SimpleRectangle ent = new SimpleRectangle();
            this.diagramControl1.AddShape(ent);
            ent.X               = 82;
            ent.Y               = 80;
            ent.Text            = "Entity";
            ent.Height          = 33;
            ent.BackGroundColor = Color.SteelBlue;

            SimpleRectangle conn = new SimpleRectangle();
            this.diagramControl1.AddShape(conn);
            conn.X               = -73;
            conn.Y               = 219;
            conn.Text            = "Connection";
            conn.Height          = 33;
            conn.BackGroundColor = Color.LightSteelBlue;

            SimpleRectangle shbase = new SimpleRectangle();
            this.diagramControl1.AddShape(shbase);
            shbase.X               = 82;
            shbase.Y               = 219;
            shbase.Text            = "ShapeBase";
            shbase.Height          = 33;
            shbase.BackGroundColor = Color.LightSteelBlue;

            SimpleRectangle con = new SimpleRectangle();
            this.diagramControl1.AddShape(con);
            con.X               = 247;
            con.Y               = 219;
            con.Text            = "Connector";
            con.Height          = 33;
            con.BackGroundColor = Color.LightSteelBlue;

            OvalShape oval = new OvalShape();
            this.diagramControl1.AddShape(oval);
            oval.X               = -89;
            oval.Y               = 376;
            oval.Text            = "Oval";
            oval.Height          = 33;
            oval.BackGroundColor = Color.AliceBlue;

            OvalShape rec = new OvalShape();
            this.diagramControl1.AddShape(rec);
            rec.X               = 32;
            rec.Y               = 376;
            rec.Text            = "SimpleRectangle";
            rec.Height          = 33;
            rec.Width           = 150;
            rec.BackGroundColor = Color.AliceBlue;

            OvalShape tl = new OvalShape();
            this.diagramControl1.AddShape(tl);
            tl.X               = 207;
            tl.Y               = 376;
            tl.Text            = "TextLabel";
            tl.Height          = 33;
            tl.BackGroundColor = Color.AliceBlue;

            #endregion

            #region The connections

            this.diagramControl1.AddConnection(ent.Connectors[0], conn.Connectors[3]);
            this.diagramControl1.AddConnection(ent.Connectors[0], con.Connectors[3]);
            this.diagramControl1.AddConnection(ent.Connectors[0], shbase.Connectors[3]);
            this.diagramControl1.AddConnection(shbase.Connectors[0], oval.Connectors[3]);
            this.diagramControl1.AddConnection(shbase.Connectors[0], rec.Connectors[3]);
            this.diagramControl1.AddConnection(shbase.Connectors[0], tl.Connectors[3]);

            #endregion

            #endregion
        }
Exemplo n.º 7
0
        /// <summary>
        /// 动态流程图
        /// </summary>
        private void NetronLightGraph()
        {
            try
            {
                this.groupbox_graph.Controls.Clear();
                GraphControl graphControl1 = new GraphControl();
                graphControl1.Dock      = DockStyle.Fill;
                graphControl1.Enabled   = false;
                graphControl1.ShowGrid  = false;
                graphControl1.BackColor = Color.SteelBlue;
                graphControl1.Font      = new Font("宋体", 10);
                this.groupbox_graph.Controls.Add(graphControl1);
                int             x           = 50;//this is left margin
                int             y           = 30;
                SimpleRectangle srSharpLast = null;

                for (int i = 0; i < this.radGridView1.Rows.Count; i++)
                {
                    var stationName = this.radGridView1.Rows[i].Cells[1].Value.ToString();

                    SimpleRectangle srSharp  = graphControl1.AddShape(ShapeTypes.Rectangular, new Point(x, y)) as SimpleRectangle;
                    Graphics        graphics = CreateGraphics();
                    SizeF           sizeF    = graphics.MeasureString(stationName, new Font("宋体", 10));
                    srSharp.Text   = stationName;
                    srSharp.Height = 50;
                    srSharp.Width  = (int)sizeF.Width + (int)sizeF.Width / 2;
                    graphics.Dispose();
                    srSharp.ShapeColor = Color.LightSteelBlue;
                    if (i % 2 == 0 && i > 1)
                    {
                        graphControl1.AddConnection(srSharpLast.Connectors[2], srSharp.Connectors[1]);
                    }
                    if (i + 1 < this.radGridView1.Rows.Count)
                    {
                        x += srSharp.Width + 80;
                        var      stationNameLast = this.radGridView1.Rows[i + 1].Cells[1].Value.ToString();
                        Graphics graphicsLast    = CreateGraphics();
                        SizeF    sizeFLast       = graphicsLast.MeasureString(stationNameLast, new Font("宋体", 10));

                        srSharpLast        = graphControl1.AddShape(ShapeTypes.Rectangular, new Point(x, y)) as SimpleRectangle;
                        srSharpLast.Text   = stationNameLast;
                        srSharpLast.Height = 50;
                        srSharpLast.Width  = (int)sizeFLast.Width + (int)sizeFLast.Width / 2;
                        graphicsLast.Dispose();
                        srSharpLast.ShapeColor = Color.LightSteelBlue;

                        graphControl1.AddConnection(srSharp.Connectors[2], srSharpLast.Connectors[1]);
                        i++;
                    }
                    if (srSharpLast == null)
                    {
                        return;
                    }
                    x += srSharpLast.Width + 80;
                }
            }
            catch (Exception ex)
            {
                LogHelper.Log.Error(ex.Message);
            }
        }