Example #1
0
        public override void OnMouseDown(DrawArea drawArea, System.Windows.Forms.MouseEventArgs e)
        {
            DrawPower pow = new DrawPower(e.X, e.Y, 80, 53);
            //在结点链表里加结点
            VertexNode temp = new VertexNode(ComFunction.NewNodeNumber());

            pow.ObjectID      = ComFunction.NewEquipmentNumber();
            temp.BelongsIndex = pow.ObjectID;

            base.AddNewObject(drawArea, pow);
            base.AddNewNode(drawArea, temp);
        }
Example #2
0
        public override void OnMouseDown(DrawArea drawArea, System.Windows.Forms.MouseEventArgs e)
        {
            DrawKnife knf = new DrawKnife(e.X, e.Y, 80, 53);

            knf.ObjectID = ComFunction.NewEquipmentNumber();
            base.AddNewObject(drawArea, knf);
            //ÐèҪѧÉúÌîд
            VertexNode temp1 = new VertexNode(ComFunction.NewNodeNumber());
            VertexNode temp2 = new VertexNode(ComFunction.NewNodeNumber());

            temp1.BelongsIndex = knf.ObjectID;
            temp2.BelongsIndex = knf.ObjectID;
            base.AddNewNode(drawArea, temp1);
            base.AddNewNode(drawArea, temp2);
        }
Example #3
0
        public override void OnMouseDown(DrawArea drawArea, System.Windows.Forms.MouseEventArgs e)
        {
            DrawTransformer2 dt2 = new DrawTransformer2(e.X, e.Y, 80, 53);

            dt2.ObjectID = ComFunction.NewEquipmentNumber();
            base.AddNewObject(drawArea, dt2);

            VertexNode temp1 = new VertexNode(ComFunction.NewNodeNumber());
            VertexNode temp2 = new VertexNode(ComFunction.NewNodeNumber());

            temp1.BelongsIndex = dt2.ObjectID;
            temp2.BelongsIndex = dt2.ObjectID;
            base.AddNewNode(drawArea, temp1);
            base.AddNewNode(drawArea, temp2);
            CF.AddEdge(drawArea, temp1, temp2);
        }
Example #4
0
        public override void OnMouseDown(DrawArea drawArea, System.Windows.Forms.MouseEventArgs e)
        {
            DrawCapacitor cap = new DrawCapacitor(e.X, e.Y, 80, 53);

            cap.ObjectID = ComFunction.NewEquipmentNumber();
            base.AddNewObject(drawArea, cap);
            //ÐèҪѧÉúÌîд
            VertexNode temp1 = new VertexNode(ComFunction.NewNodeNumber());
            VertexNode temp2 = new VertexNode(ComFunction.NewNodeNumber());

            temp1.BelongsIndex = cap.ObjectID;
            temp2.BelongsIndex = cap.ObjectID;
            base.AddNewNode(drawArea, temp1);
            base.AddNewNode(drawArea, temp2);
            CF.AddEdge(drawArea, temp1, temp2);
        }
Example #5
0
        /// <summary>
        /// 开始测试
        /// </summary>
        /// <param name="drawAreaClient"></param>
        public void BeginTest(DrawArea drawAreaClient)
        {
            //将所有的元器件带电状态设为false
            for (int i = 0; i < drawAreaClient.GraphicsList.Count; i++)
            {
                drawAreaClient.GraphicsList[i].IsPowerOn = false;
            }

            //先进行深度优先搜索
            Do_DFS(drawAreaClient);
            for (int j = 0; j < drawAreaClient.GraphicsList.Count; j++)
            {
                bool judge = false;
                if (drawAreaClient.GraphicsList[j] is DrawLine)
                {
                    //如果元器件是母线,母线任意一端的元器件结点带电则该母线带点
                    DrawLine drawLine = drawAreaClient.GraphicsList[j] as DrawLine;
                    for (int k = 0; k < 2; k++)
                    {
                        int ID = FindVertextID(drawAreaClient, drawLine.FindEquipmentID[k], drawLine.FindNodeID[k]);
                        if (ID != -1)
                        {
                            int        index = drawAreaClient.GraphicsNodeList.FindIndex(ID);
                            VertexNode VNode = drawAreaClient.GraphicsNodeList[index];
                            if (VNode.Visited == true)
                            {
                                judge = true;
                                break;
                            }
                        }
                    }
                    drawLine.IsPowerOn = judge;
                }
                else if (drawAreaClient.GraphicsList[j] is DrawBreak)
                {
                    //如果是开关则需要看开关是否打开
                    DrawBreak DB = drawAreaClient.GraphicsList[j] as DrawBreak;

                    //如果开关打开
                    if (DB.OpenOrClose)
                    {
                        int count = 0;
                        //如果说某元器件里所有的首结点都带电则该元器件带电
                        for (int k = 1; k <= drawAreaClient.GraphicsList[j].NodeCount; k++)
                        {
                            int        ID    = FindVertextID(drawAreaClient, DB.ObjectID, k);
                            int        index = drawAreaClient.GraphicsNodeList.FindIndex(ID);
                            VertexNode VNode = drawAreaClient.GraphicsNodeList[index];
                            if (VNode.Visited == true)
                            {
                                count += 1;
                            }
                        }
                        if (count == DB.NodeCount)
                        {
                            judge = true;
                        }
                        DB.IsPowerOn = judge;
                    }
                    else
                    {
                        DB.IsPowerOn = false;
                    }
                }
                else if (drawAreaClient.GraphicsList[j] is DrawKnife)
                {
                    //如果是刀闸则需要看开关是否打开
                    DrawKnife DK = drawAreaClient.GraphicsList[j] as DrawKnife;

                    //如果刀闸打开
                    if (DK.OpenOrClose)
                    {
                        int count = 0;
                        //如果说某元器件里所有的首结点都带电则该元器件带电
                        for (int k = 1; k <= drawAreaClient.GraphicsList[j].NodeCount; k++)
                        {
                            int        ID    = FindVertextID(drawAreaClient, DK.ObjectID, k);
                            int        index = drawAreaClient.GraphicsNodeList.FindIndex(ID);
                            VertexNode VNode = drawAreaClient.GraphicsNodeList[index];
                            if (VNode.Visited == true)
                            {
                                count += 1;
                            }
                        }
                        if (count == DK.NodeCount)
                        {
                            judge = true;
                        }
                        DK.IsPowerOn = judge;
                    }
                    else
                    {
                        DK.IsPowerOn = false;
                    }
                }
                else
                {
                    int        count = 0;
                    DrawObject DO    = drawAreaClient.GraphicsList[j];
                    //如果说某元器件里所有的首结点都带电则该元器件带电
                    for (int k = 1; k <= drawAreaClient.GraphicsList[j].NodeCount; k++)
                    {
                        int        ID    = FindVertextID(drawAreaClient, DO.ObjectID, k);
                        int        index = drawAreaClient.GraphicsNodeList.FindIndex(ID);
                        VertexNode VNode = drawAreaClient.GraphicsNodeList[index];
                        if (VNode.Visited == true)
                        {
                            count += 1;
                        }
                    }
                    if (count == DO.NodeCount)
                    {
                        judge = true;
                    }
                    DO.IsPowerOn = judge;
                }
            }
            drawAreaClient.Refresh();
        }
Example #6
0
 /// <summary>
 /// 通过结点信息给首结点加边
 /// </summary>
 /// <param name="drawArea">画图区域</param>
 /// <param name="VerNode1">首结点</param>
 /// <param name="VerNode2">另一个首结点</param>
 public void AddEdge(DrawArea drawArea, VertexNode VerNode1, VertexNode VerNode2)
 {
     //调用加边函数
     drawArea.GraphicsNodeList.AddEdge(VerNode1.VertexName, VerNode2.VertexName);
     drawArea.GraphicsNodeList.AddEdge(VerNode2.VertexName, VerNode1.VertexName);
 }
Example #7
0
 /// <summary>
 /// 添加结点
 /// </summary>
 /// <param name="snode"></param>
 public void Add(VertexNode snode)
 {
     vertexList.Add(snode);
 }
Example #8
0
 /// <summary>
 /// 把该结点添加到绘图区域中
 /// </summary>
 /// <param name="drawArea"></param>
 /// <param name="Ver"></param>
 protected void AddNewNode(DrawArea drawArea, VertexNode Ver)
 {
     drawArea.GraphicsNodeList.Add(Ver);
     drawArea.Refresh();
 }