Example #1
0
        /// <summary>
        /// 通过开关状态给开关对应的首结点加边
        /// </summary>
        /// <param name="drawArea"></param>
        /// <param name="drawBreak"></param>
        public void AddEdge(DrawArea drawArea, DrawBreak drawBreak)
        {
            //开关之前关闭则可以调用该方法
            int StartVertexID, EndVertexID;

            //得到首结点的ID
            StartVertexID = FindVertextID(drawArea, drawBreak.ObjectID, 1);
            EndVertexID   = FindVertextID(drawArea, drawBreak.ObjectID, 2);
            //调用连线函数
            drawArea.GraphicsNodeList.AddEdge(StartVertexID, EndVertexID);
            drawArea.GraphicsNodeList.AddEdge(EndVertexID, StartVertexID);
        }
Example #2
0
        /// <summary>
        /// 通过开关状态给开关对应的首结点减边
        /// </summary>
        /// <param name="drawArea"></param>
        /// <param name="drawBreak"></param>
        public void ReduceEdge(DrawArea drawArea, DrawBreak drawBreak)
        {
            //如果开关之前打开则可以减边
            int StartVertexID, EndVertexID;

            //得到首结点的ID
            StartVertexID = FindVertextID(drawArea, drawBreak.ObjectID, 1);
            EndVertexID   = FindVertextID(drawArea, drawBreak.ObjectID, 2);
            //调用连线函数
            drawArea.GraphicsNodeList.ReduceEdge(StartVertexID, EndVertexID);
            drawArea.GraphicsNodeList.ReduceEdge(EndVertexID, StartVertexID);
        }
Example #3
0
 public void BreakOperate(DrawArea drawArea, DrawBreak drawBreak)
 {
     if (drawBreak.OpenOrClose == true)
     {
         AddEdge(drawArea, drawBreak);//给开关两端的首结点连线
         Do_DFS(drawArea);
         BeginTest(drawArea);
     }
     else
     {
         ReduceEdge(drawArea, drawBreak);//断开开关两端的首结点连线
         Do_DFS(drawArea);
         BeginTest(drawArea);
     }
 }
Example #4
0
        public override void OnMouseDown(DrawArea drawArea, System.Windows.Forms.MouseEventArgs e)
        {
            DrawBreak bre = new DrawBreak(e.X, e.Y, 80, 53);

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

            temp1.BelongsIndex = bre.ObjectID;
            temp2.BelongsIndex = bre.ObjectID;
            base.AddNewNode(drawArea, temp1);
            base.AddNewNode(drawArea, 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
        public override void OnMouseUp(DrawArea drawArea, System.Windows.Forms.MouseEventArgs e)
        {
            if (drawArea.GraphicsList.Selection != null)
            {
                for (int i = 0; i < drawArea.GraphicsList.Selection.Count; i++)
                {
                    if (drawArea.GraphicsList.Selection[i] is DrawLine)
                    {
                        //如果线发生改变则需要判断线两端连接的结点状态以及重新进行深度优先搜索
                        DrawLine drawLine = drawArea.GraphicsList.Selection[i] as DrawLine;
                        CF.ChangeLineLink(drawArea, drawLine, e);
                    }
                    else if (drawArea.GraphicsList.Selection[i] is DrawBreak)
                    {
                        //如果是开关
                        DrawBreak drawBreak = drawArea.GraphicsList.Selection[i] as DrawBreak;
                        //根据开关开闭状态给开关对应的结点加边
                        if (drawBreak.OpenOrClose == true)
                        {
                            //给开关两端的首结点连线
                            CF.AddEdge(drawArea, drawBreak);
                        }
                        else
                        {
                            //断开开关两端的首结点连线
                            CF.ReduceEdge(drawArea, drawBreak);
                        }
                    }
                    else if (drawArea.GraphicsList.Selection[i] is DrawKnife)
                    {
                        //如果是刀闸
                        DrawKnife drawKnife = drawArea.GraphicsList.Selection[i] as DrawKnife;
                        //根据开关开闭状态给开关对应的结点加边
                        if (drawKnife.OpenOrClose == true)
                        {
                            //给开关两端的首结点连线
                            CF.AddEdge(drawArea, drawKnife);
                        }
                        else
                        {
                            //断开开关两端的首结点连线
                            CF.ReduceEdge(drawArea, drawKnife);
                        }
                    }
                }
            }
            if (drawArea.IsTest == true)
            {
                //进行测试
                CF.BeginTest(drawArea);
            }


            //空画矩形
            if (pointerMode == PointerMode.Net)
            {
                // 移除旧的矩形
                ControlPaint.DrawReversibleFrame(
                    drawArea.RectangleToScreen(DrawRectanlge.GetNormalizedRectangle(startPoint, lastPoint)),
                    Color.Black,
                    FrameStyle.Dashed);

                // 选择在矩形框中的图元
                drawArea.GraphicsList.SelectInRectangle(DrawRectanlge.GetNormalizedRectangle(startPoint, lastPoint));
                pointerMode = PointerMode.None;
            }

            if (resizedObject != null)
            {
                //改变大小之后
                resizedObject.Normalize();
                resizedObject = null;
            }
            drawArea.Capture = false;
            drawArea.Refresh();
        }