コード例 #1
0
ファイル: UmlDesigner.cs プロジェクト: attila3453/alsing
        private void MainCanvas_MouseUp(object sender, MouseEventArgs e)
        {
            var x = (int) ((e.X - MainCanvas.AutoScrollPosition.X)/Zoom);
            var y = (int) ((e.Y - MainCanvas.AutoScrollPosition.Y)/Zoom);

            if (EditMode == EditMode.DrawRelation)
            {
                relationEnd = null;


                for (int i = BoundingItemes.Count - 1; i >= 0; i--)
                {
                    BoundingItem bitem = BoundingItemes[i];
                    if (bitem.HitTest(x, y))
                    {
                        if (bitem.Target is Shape)
                        {
                            relationEnd = bitem.Target as Shape;
                        }
                    }
                }

                endDrawRelation(relationStart, relationEnd);

                //end drawing
                EditMode = EditMode.Normal;
                MainCanvas.Refresh();
            }
            else if (EditMode == EditMode.Normal)
            {
                Cursor = Cursors.Default;
                currentBoundingItem = null;
                isPanning = false;
                for (int i = BoundingItemes.Count - 1; i >= 0; i--)
                {
                    BoundingItem bitem = BoundingItemes[i];
                    if (bitem.HitTest(x, y))
                    {
                        if (bitem.Target is Shape)
                        {
                            var shape = (Shape) bitem.Target;
                            var args = new ShapeMouseEventArgs
                                       {
                                           BoundingItem = bitem,
                                           X = x,
                                           Y = y,
                                           Button = e.Button,
                                           Sender = this,
                                           GridSize = GridSize,
                                           SnapToGrid = SnapToGrid
                                       };
                            shape.OnMouseUp(args);
                            if (args.Redraw)
                                Refresh();
                        }

                        return;
                    }
                }
            }
        }
コード例 #2
0
ファイル: UmlDesigner.cs プロジェクト: attila3453/alsing
        private void MainCanvas_MouseDown(object sender, MouseEventArgs e)
        {
            EndInput();
            var x = (int) ((e.X - MainCanvas.AutoScrollPosition.X)/Zoom);
            var y = (int) ((e.Y - MainCanvas.AutoScrollPosition.Y)/Zoom);

            if (EditMode == EditMode.BeginDrawRelation)
            {
                mouseDownPoint = new Point(e.X, e.Y);
                EditMode = EditMode.DrawRelation;
                relationStart = null;

                for (int i = BoundingItemes.Count - 1; i >= 0; i--)
                {
                    BoundingItem bitem = BoundingItemes[i];
                    if (bitem.HitTest(x, y))
                    {
                        if (bitem.Target is Shape)
                        {
                            relationStart = bitem.Target as Shape;
                        }
                    }
                }
            }
            else if (EditMode == EditMode.Normal)
            {
                mouseDownPoint = new Point(e.X, e.Y);
                mouseDownAutoscrollPoint = new Point(-MainCanvas.AutoScrollPosition.X, -MainCanvas.AutoScrollPosition.Y);

                for (int i = BoundingItemes.Count - 1; i >= 0; i--)
                {
                    BoundingItem bitem = BoundingItemes[i];
                    if (bitem.HitTest(x, y))
                    {
                        if (bitem.Target is Shape)
                        {
                            currentBoundingItem = bitem;
                            var shape = (Shape) bitem.Target;
                            currentShape = shape;
                            var args = new ShapeMouseEventArgs
                                       {
                                           BoundingItem = bitem,
                                           X = x,
                                           Y = y,
                                           Button = e.Button,
                                           Sender = this,
                                           GridSize = GridSize,
                                           SnapToGrid = SnapToGrid
                                       };
                            shape.OnMouseDown(args);
                            if (args.Redraw)
                                Refresh();
                        }

                        return;
                    }
                }
                isPanning = true;
            }
        }
コード例 #3
0
ファイル: UmlDesigner.cs プロジェクト: attila3453/alsing
        private void MainCanvas_DoubleClick(object sender, EventArgs e)
        {
            var x = (int) ((mouseDownPoint.X - MainCanvas.AutoScrollPosition.X)/Zoom);
            var y = (int) ((mouseDownPoint.Y - MainCanvas.AutoScrollPosition.Y)/Zoom);

            for (int i = BoundingItemes.Count - 1; i >= 0; i--)
            {
                BoundingItem bitem = BoundingItemes[i];
                if (bitem.HitTest(x,y))
                {
                    if (bitem.Target is Shape)
                    {
                        currentBoundingItem = bitem;
                        var shape = (Shape) bitem.Target;
                        var args = new ShapeMouseEventArgs
                                   {BoundingItem = bitem, X = x, Y = y, Button = MouseButtons.Left, Sender = this};
                        shape.OnDoubleClick(args);
                        if (args.Redraw)
                            Refresh();
                    }

                    return;
                }
            }
        }