using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace 试验版
{
    [Serializable]//可序列化
    public class dian
    {
        public PointF pos;
        public element fatherelement;
        public RectangleF rectt;
        public bool ispower;
        

        public List<dian> linkpoints = new List<dian>();

        public Pen pen = new Pen(Color.Black);
        public Graphics g;
        public String sbname;

        public liness line1;

        public dian(element fe, Graphics gra)
        {
            fatherelement = fe;
            g = gra;
            sbname = "dd";

            PointF h1 = new PointF(50, 50);
            PointF h2 = new PointF(60, 60);
            line1 = new liness(h1, h2, this, g);
            ispower = false;


        }


        public bool IsSelect(Point e)
        {
            if (new RectangleF(pos.X - 5, pos.Y - 5, 15, 15).Contains(e))
            {
                return true;
            }
            else
                return false;
        }

        public void DrawLine(dian nextNode, Graphics g, Pen mypen)
        {
            if (this == nextNode)
            {
                return;
            }
            rectt = new RectangleF(this.pos.X, this.pos.Y, nextNode.pos.X - this.pos.X, nextNode.pos.Y - this.pos.Y);

            line1.pos = this.pos;
            line1.pos2 = nextNode.pos;
            //line1.draw(g,pen);




            PointF middlePos = new PointF(rectt.X + rectt.Width / 2, rectt.X + rectt.Height / 2);
            g.DrawLine(mypen, rectt.X, rectt.Y, middlePos.X, rectt.Y);
            g.DrawLine(mypen, middlePos.X, rectt.Y, middlePos.X, rectt.Y + rectt.Height);
            g.DrawLine(mypen, middlePos.X, rectt.Y + rectt.Height, rectt.X + rectt.Width, rectt.Y + rectt.Height);
        }

    }

}
