Example #1
0
    override public bool HitTest(ShapeBox other)
    {
        float nx = Mathf.Abs(transform.position.x - other.transform.position.x);
        float ny = Mathf.Abs(transform.position.y - other.transform.position.y);

        return((nx < (size.x + other.size.x) / 2) && (ny < (size.y + other.size.y) / 2));
    }
Example #2
0
    public GroupBox(IList <BaseShapeViewModel> shapes)
    {
        Boxes = new ShapeBox[shapes.Count];

        for (int i = 0; i < shapes.Count; i++)
        {
            Boxes[i] = new ShapeBox(shapes[i]);
        }

        Bounds = new Box();

        Update();
    }
Example #3
0
    override public bool HitTest(ShapeBox other)
    {
        Vector2 hsize = other.size * 0.5f;

        float   nx = Mathf.Abs(transform.position.x - other.transform.position.x);
        float   ny = Mathf.Abs(transform.position.y - other.transform.position.y);
        Vector2 n  = new Vector2(nx, ny);

        if (nx < hsize.x)
        {
            return(ny < (radius + hsize.y));
        }
        if (ny < hsize.y)
        {
            return(nx < (radius + hsize.x));
        }

        Vector2 d   = n - hsize;
        float   len = Mathf.Sqrt(Vector2.Dot(d, d));

        return(len <= radius);
    }
Example #4
0
 abstract public bool HitTest(ShapeBox other);
Example #5
0
 override public bool HitTest(ShapeBox other)
 {
     return(other.HitTest(this));
 }
Example #6
0
 public static int CompareHeight(ShapeBox box1, ShapeBox box2)
 {
     return((box1.Bounds.Height > box2.Bounds.Height) ? 1 : ((box1.Bounds.Height < box2.Bounds.Height) ? -1 : 0));
 }
Example #7
0
 public static int CompareWidth(ShapeBox box1, ShapeBox box2)
 {
     return((box1.Bounds.Width > box2.Bounds.Width) ? 1 : ((box1.Bounds.Width < box2.Bounds.Width) ? -1 : 0));
 }
Example #8
0
 public static int CompareCenterY(ShapeBox box1, ShapeBox box2)
 {
     return((box1.Bounds.CenterY > box2.Bounds.CenterY) ? 1 : ((box1.Bounds.CenterY < box2.Bounds.CenterY) ? -1 : 0));
 }
Example #9
0
 public static int CompareBottom(ShapeBox box1, ShapeBox box2)
 {
     return((box1.Bounds.Bottom > box2.Bounds.Bottom) ? 1 : ((box1.Bounds.Bottom < box2.Bounds.Bottom) ? -1 : 0));
 }
Example #10
0
 public static int CompareTop(ShapeBox box1, ShapeBox box2)
 {
     return((box1.Bounds.Top > box2.Bounds.Top) ? 1 : ((box1.Bounds.Top < box2.Bounds.Top) ? -1 : 0));
 }
Example #11
0
 public static int CompareLeft(ShapeBox box1, ShapeBox box2)
 {
     return((box1.Bounds.Left > box2.Bounds.Left) ? 1 : ((box1.Bounds.Left < box2.Bounds.Left) ? -1 : 0));
 }
Example #12
0
        public DrawingControl()
        {
            _shapeDrawer = new ShapeDrawer();
            _transformBox = new ShapeBox();
            _directBox = new DirectBox();
            _transformBox.LocationChanged += ControlBox_LocationChanged;
            _transformBox.SizeChanged += ControlBox_SizeChanged;
            //_shapeDrawer = shapeDrawer;
            _controlMode = ControlMode.None;
            //_isEditing = false;
            _isSelected = false;
            _isShowBox = false;
            IsRegularShape = false;
            Visible = true;

            _text = "";

            _selectionRecColor = Color.Blue;
            _selectionRecWidth = 1F;
        }