예제 #1
0
        public static VectorRect containingThreePoints(Vector A, Vector B, Vector C)
        {
            double minx = min(A.x, B.x, C.x);
            double miny = min(A.y, B.y, C.y);
            double maxx = max(A.x, B.x, C.x);
            double maxy = max(A.y, B.y, C.y);

            return(VectorRect.FromTwoPoints(minx, miny, maxx, maxy));
        }
예제 #2
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            switch (dragMode)
            {
            case DragMode.None:
                break;

            case DragMode.MouseDown:
                // Just Mouse up again --> a click
                Vector mp = fromScreen(new Vector(e.Location.X, e.Location.Y));
                foreach (ProcessingNet n in nets)
                {
                    n.selectOnHit(mp, selection);
                }
                if (selection.items > 0)
                {
                    Invalidate();
                }
                dragMode = DragMode.None;
                break;

            case DragMode.MouseDownRight:
                // Click
                Vector mpr = fromScreen(new Vector(e.Location.X, e.Location.Y));
                foreach (ProcessingNet n in nets)
                {
                    n.selectOnHit(mpr, selection);
                }
                if (selection.items > 0)
                {
                    Invalidate();
                }
                dragMode = DragMode.None;
                if (selection.items == 1)
                {
                    ProcessingNet n = selection.getNet(0);
                    if (n != null)
                    {
                        showNetContextMenu(e.Location, n);
                    }
                }
                selection.unselect();
                break;

            case DragMode.SelectWin:
                // unSelectAll();
                dragStop = fromScreen(new Vector(e.Location.X, e.Location.Y));
                VectorRect selwin = VectorRect.FromTwoPoints(dragStart, dragStop);
                foreach (RTForm f in elements)
                {
                    f.selectOnContained(selwin, selection);
                }
                foreach (ProcessingNet n in nets)
                {
                    n.selectOnContained(selwin, selection);
                }
                showCaret = false;
                dragMode  = DragMode.None;
                Invalidate();
                break;
            }
        }
예제 #3
0
        Rectangle getShapeRect()
        {
            double atop, abottom, aleft, aright;

            atop    = Height / 2 - _shapeDim.Height * scale / 2;
            abottom = atop + _shapeDim.Height * scale - 1;
            double textheight  = _titleFont.GetHeight() * scale * 1.1;
            double scaleHeight = _scaleFont.GetHeight() * scale * 1.1;

            switch (_titlePos)
            {
            case RTTitlePos.Off:
                if (_showXScale)
                {
                    if (_showYScale)
                    {
                        atop = scaleHeight / 2;
                    }
                    else
                    {
                        atop = 0;
                    }
                    abottom = atop + _shapeDim.Height * scale - 1;
                }
                else
                {
                    atop    = Height / 2 - _shapeDim.Height * scale / 2;
                    abottom = atop + _shapeDim.Height * scale - 1;
                }
                break;

            case RTTitlePos.TopLeft:
            case RTTitlePos.TopCenter:
            case RTTitlePos.TopRight:
                atop    = textheight;
                abottom = atop + _shapeDim.Height * scale - 1;
                break;

            case RTTitlePos.BottomLeft:
            case RTTitlePos.BottomCenter:
            case RTTitlePos.BottomRight:
                if (_showYScale)
                {
                    atop = scaleHeight / 2;
                }
                else
                {
                    atop = 0;
                }
                abottom = atop + _shapeDim.Height * scale - 1;
                break;
            }
            if (_showYScale)
            {
                if (_showXScale)
                {
                    aright = Width - 1 - scaleHeight / 2;
                }
                else
                {
                    aright = Width - 1;
                }
                aleft = aright - (_shapeDim.Width * scale + 1);
            }
            else
            {
                aleft  = Width / 2 - _shapeDim.Width * scale / 2;
                aright = aleft + _shapeDim.Width * scale - 1;
            }
            //aleft = Width / 2 - _shapeDim.Width * scale / 2;
            //aright = aleft + _shapeDim.Width * scale - 1;
            return(VectorRect.FromTwoPoints(aleft, atop, aright, abottom).rectangle);
        }