示例#1
0
        public void Do_Group()
        {
            List <BaseUMLObject> Target = new List <BaseUMLObject>();

            foreach (BaseUMLShape shape in UMLShapes)
            {
                if (shape as BaseUMLObject != null)
                {
                    BaseUMLObject obj = shape as BaseUMLObject;
                    if (obj.getSelected())
                    {
                        Target.Add(obj);
                    }
                }
            }
            foreach (BaseUMLObject obj in Target)
            {
                obj.setSelected(false);
                UMLShapes.Remove(obj);
            }
            GroupUMLObject Group = new GroupUMLObject(CoreRectRange.Default());

            Group.SetChildrens(Target);
            AddShape(Group);
        }
示例#2
0
        public void Do_ChangeObjectName()
        {
            List <BaseUMLObject> Target = new List <BaseUMLObject>();

            foreach (BaseUMLShape shape in UMLShapes)
            {
                if (shape as BaseUMLObject != null)
                {
                    BaseUMLObject obj = shape as BaseUMLObject;
                    if (obj.getSelected())
                    {
                        Target.Add(obj);
                    }
                }
            }
            if (Target.Count == 1)
            {
                if (Target.ElementAt(0) as ClassUMLObject != null)
                {
                    ClassUMLObject   temp        = Target.ElementAt(0) as ClassUMLObject;
                    BasicInputDialog inputDialog = new BasicInputDialog("Please enter your new class name:", temp.getTitleText());
                    if (inputDialog.ShowDialog() == true)
                    {
                        temp.setTitleText(inputDialog.Answer);
                    }
                }
                if (Target.ElementAt(0) as UseCaseUMLObject != null)
                {
                    UseCaseUMLObject temp        = Target.ElementAt(0) as UseCaseUMLObject;
                    BasicInputDialog inputDialog = new BasicInputDialog("Please enter your new usecase name:", temp.getName());
                    if (inputDialog.ShowDialog() == true)
                    {
                        temp.setName(inputDialog.Answer);
                    }
                }
                this.InvalidateVisual();
            }
        }
示例#3
0
        public override void ProcessEvent(CoreMouseEventArgs e)
        {
            switch (e.Type)
            {
            case CoreMouseEventProcessor.MouseEnter:
            {
                CoreMouseEnterEventArgs args = e as CoreMouseEnterEventArgs;
                //Console.WriteLine("SelectMode::MouseEnter{" + args.Location.X + "," + args.Location.Y + "}");
                break;
            }

            case CoreMouseEventProcessor.MouseLeave:
            {
                CoreMouseLeaveEventArgs args = e as CoreMouseLeaveEventArgs;
                //Console.WriteLine("SelectMode::MouseLeave{" + args.Location.X + "," + args.Location.Y + "}");
                break;
            }

            case CoreMouseEventProcessor.MouseDown:
            {
                CoreMouseDownEventArgs args = e as CoreMouseDownEventArgs;
                if (args.Button == CoreMouseDownEventArgs.LeftButton)
                {
                    //Console.WriteLine("SelectMode::MouseLeftButtonDown{" + args.Location.X + "," + args.Location.Y + "} : " + args.Count);
                    BaseUMLObject       TopUMLObject = Panel.TopBaseUMLObjectsAt(args.Location);
                    List <BaseUMLShape> Shapes       = Panel.AllBaseUMLShapes();
                    foreach (BaseUMLShape s in Shapes)
                    {
                        s.setSelected(false);
                    }
                    if (TopUMLObject != null)
                    {
                        TopUMLObject.setSelected(true);
                        LockTarget       = TopUMLObject;
                        LockTargetShiftX = args.Location.X - LockTarget.GetLocation().X;
                        LockTargetShiftY = args.Location.Y - LockTarget.GetLocation().Y;
                    }
                    else
                    {
                        LockTarget = null;
                    }
                }
                if (args.Button == CoreMouseDownEventArgs.RightButton)
                {
                    //Console.WriteLine("SelectMode::MouseRightButtonDown{" + args.Location.X + "," + args.Location.Y + "} : " + args.Count);
                }
                break;
            }

            case CoreMouseEventProcessor.MouseUp:
            {
                CoreMouseUpEventArgs args = e as CoreMouseUpEventArgs;
                if (args.Button == CoreMouseUpEventArgs.LeftButton)
                {
                    Panel.getForeground().Children.Clear();
                    //Console.WriteLine("SelectMode::MouseLeftButtonUp{" + args.Location.X + "," + args.Location.Y + "}");
                }
                if (args.Button == CoreMouseUpEventArgs.RightButton)
                {
                    //Console.WriteLine("SelectMode::MouseRightButtonUp{" + args.Location.X + "," + args.Location.Y + "}");
                }
                break;
            }

            case CoreMouseEventProcessor.MouseMove:
            {
                CoreMouseMoveEventArgs args = e as CoreMouseMoveEventArgs;
                //BaseUMLShape TopUMLShape = Panel.getTopShapesAt(args.Location);
                //if(TopUMLShape==null)
                //    return;
                //Console.WriteLine("TopUMLShape:" + TopUMLShape.getID() + " Depth:" + TopUMLShape.getDepth());
                //Console.WriteLine("SelectMode::MouseMove{" + args.Location.X + "," + args.Location.Y + "}");
                break;
            }

            case CoreMouseEventProcessor.MouseDragging:
            {
                CoreMouseDraggingEventArgs args = e as CoreMouseDraggingEventArgs;
                //Console.WriteLine("SelectMode::MouseDragging{(" + args.Start.X + "," + args.Start.Y + ")->(" + args.End.X + "," + args.End.Y + ")," + args.Distance + ",key=" + args.Button + "}");
                if (args.Button == CoreMouseDragEndEventArgs.LeftButton)
                {
                    if (LockTarget != null)
                    {
                        double dx = args.End.X - LockTargetShiftX - LockTarget.GetLocation().X;
                        double dy = args.End.Y - LockTargetShiftY - LockTarget.GetLocation().Y;
                        LockTarget.Move(new Point(dx, dy), BaseUMLObject.Move_Relative);
                        //鄰居連帶機制啟動

                        /*
                         * foreach(ConnectionPort port in LockTarget.AllConnectionPort())
                         * {
                         *  List<Connection> conns = port.AllConnection();
                         *  foreach(Connection conn in conns)
                         *  {
                         *      if(conn.getConnShape().IsStartConn(conn))
                         *      {
                         *          BaseUMLObject UndirectlyObj = conn.getConnShape().getEndConn().getPort().getParent();
                         *          if(UndirectlyObj != LockTarget)
                         *              UndirectlyObj.Move(new Point(dx, dy), BaseUMLObject.Move_Relative);
                         *      }
                         *      else
                         *      {
                         *          BaseUMLObject UndirectlyObj = conn.getConnShape().getStartConn().getPort().getParent();
                         *          if (UndirectlyObj != LockTarget)
                         *              UndirectlyObj.Move(new Point(dx, dy), BaseUMLObject.Move_Relative);
                         *      }
                         *
                         *  }
                         * }*/
                    }
                    else
                    {
                        DrawingGroup Group = Panel.getForeground();
                        using (DrawingContext dc = Group.Open())
                        {
                            CoreDraw.DrawBorder(dc, new CoreRectRange(args.Start, args.End), 1, Brushes.Black, CoreDraw.LineStyle_StraightLine);
                        }
                    }
                }
                break;
            }

            case CoreMouseEventProcessor.MouseDragEnd:
            {
                CoreMouseDragEndEventArgs args = e as CoreMouseDragEndEventArgs;
                //Console.WriteLine("SelectMode::MouseDragEnd{(" + args.Start.X + "," + args.Start.Y + ")->("+args.End.X + "," + args.End.Y + "),"+args.Distance+",key="+args.Button+"}");
                if (args.Button == CoreMouseDragEndEventArgs.LeftButton)
                {
                    if (LockTarget == null)
                    {
                        List <BaseUMLObject> Objects = Panel.AllBaseUMLObjects();
                        if (Objects != null)
                        {
                            if (Objects.Count != 0)
                            {
                                foreach (BaseUMLObject s in Objects)
                                {
                                    if (s.Inside(new CoreRectRange(args.Start, args.End)))
                                    {
                                        s.setSelected(true);
                                    }
                                }
                                return;
                            }
                        }
                    }
                    else
                    {
                        LockTarget = null;
                    }
                }
                break;
            }
            }
        }
示例#4
0
        public override void ProcessEvent(CoreMouseEventArgs e)
        {
            switch (e.Type)
            {
            case CoreMouseEventProcessor.MouseDown:
            {
                CoreMouseDownEventArgs args            = e as CoreMouseDownEventArgs;
                BaseUMLObject          LastStartTarget = Panel.TopBaseUMLObjectsAt(args.Location);
                break;
            }

            case CoreMouseEventProcessor.MouseDragging:
            {
                CoreMouseDraggingEventArgs args = e as CoreMouseDraggingEventArgs;
                //Console.WriteLine("BaseConnShape_Mode::MouseDragging{(" + args.Start.X + "," + args.Start.Y + ")->(" + args.End.X + "," + args.End.Y + ")," + args.Distance + ",key=" + args.Button + "}");
                BaseUMLObject  StartTarget = Panel.TopBaseUMLObjectsAt(args.Start);
                BaseUMLObject  EndTarget = Panel.TopBaseUMLObjectsAt(args.End);
                ConnectionPort StartPort = null, EndPort = null;
                DrawingGroup   PanelForeground = Panel.getForeground();
                if (StartTarget != null)
                {
                    StartPort = StartTarget.NearConnectionPort(args.Start);
                }
                if (EndTarget != null)
                {
                    EndPort = EndTarget.NearConnectionPort(args.End);
                }
                if (StartTarget != null)          //開始點在BaseUMLObject上
                {
                    if (LastEndTarget != null)    //上次的EndTarget不為空,將他的Ports顏色還原並取消選取
                    {
                        foreach (ConnectionPort port in LastEndTarget.AllConnectionPort())
                        {
                            port.setHighLight(false);
                        }
                        LastEndTarget.setSelected(false);
                        LastEndTarget = null;
                    }
                    if (EndTarget != null)                                               //開始點在BaseUMLObject上,結束點在BaseUMLObject上,把開始BaseUMLObject和結束BaseUMLObject的目標Port來HighLight
                    {
                        foreach (ConnectionPort port in StartTarget.AllConnectionPort()) //將開始BaseUMLObject顏色還原
                        {
                            port.setHighLight(false);
                        }
                        if (StartPort != null)          //設定開始BaseUMLObject目標Port顏色
                        {
                            StartPort.setHighLight(true);
                        }
                        StartTarget.setSelected(true);
                        if (EndTarget != StartTarget)                                      //結束和開始不相同
                        {
                            foreach (ConnectionPort port in EndTarget.AllConnectionPort()) //將結束BaseUMLObject顏色還原
                            {
                                port.setHighLight(false);
                            }
                            if (EndPort != null)          //設定結束BaseUMLObject目標Port顏色
                            {
                                EndPort.setHighLight(true);
                            }
                            EndTarget.setSelected(true);
                            LastEndTarget = EndTarget;          //設定上次的EndTarget為此次的EndTarget
                        }
                    }
                    else          //開始點在BaseUMLObject上,結束點不在BaseUMLObject上
                    {
                        //開始點在BaseUMLObject上,結束點不在BaseUMLObject上
                        //將開始BaseUMLObject顏色還原
                        foreach (ConnectionPort port in StartTarget.AllConnectionPort())
                        {
                            port.setHighLight(false);
                        }
                        //選取開始BaseUMLObject讓其能繪出Port顏色
                        StartTarget.setSelected(true);
                    }
                    using (DrawingContext dc = PanelForeground.Open())          //要求子類別畫出預覽圖形
                    {
                        ProcessPreviewConnShape(dc, args.Start, args.End);
                    }
                }
                else
                {
                    if (LastStartTarget != null)          //開始點不在BaseUMLObject上,將上次StartTarget的Port顏色還原
                    {
                        foreach (ConnectionPort port in LastStartTarget.AllConnectionPort())
                        {
                            port.setHighLight(false);
                        }
                        LastStartTarget = null;
                    }
                }
                break;
            }

            case CoreMouseEventProcessor.MouseDragEnd:
            {
                CoreMouseDragEndEventArgs args = e as CoreMouseDragEndEventArgs;
                //Console.WriteLine("BaseConnShape_Mode::MouseDragEnd{(" + args.Start.X + "," + args.Start.Y + ")->(" + args.End.X + "," + args.End.Y + ")," + args.Distance + ",key=" + args.Button + "}");
                BaseUMLObject  StartTarget = Panel.TopBaseUMLObjectsAt(args.Start);
                BaseUMLObject  EndTarget = Panel.TopBaseUMLObjectsAt(args.End);
                ConnectionPort StartPort = null, EndPort = null;
                DrawingGroup   PanelForeground = Panel.getForeground();
                if (StartTarget != null)
                {
                    foreach (ConnectionPort port in StartTarget.AllConnectionPort())          //將開始BaseUMLObject顏色還原
                    {
                        port.setHighLight(false);
                    }
                    StartTarget.setSelected(false);          //將開始BaseUMLObject取消選取
                    StartPort = StartTarget.NearConnectionPort(args.Start);
                }
                if (EndTarget != null)
                {
                    foreach (ConnectionPort port in EndTarget.AllConnectionPort())          //將開始BaseUMLObject顏色還原
                    {
                        port.setHighLight(false);
                    }
                    EndTarget.setSelected(false);          //將開始BaseUMLObject取消選取
                    EndPort = EndTarget.NearConnectionPort(args.End);
                }
                if (StartPort != null && EndPort != null && StartTarget != EndTarget)
                {
                    ProcessAddConnShape(StartPort, EndPort);
                }
                break;
            }

            case CoreMouseEventProcessor.MouseUp:
            {
                Panel.getForeground().Children.Clear();
                break;
            }
            }
        }