Exemplo n.º 1
0
        public override void OnMouseUp(object sender, MouseEventArgs e)
        {
            if (Element.Image == null || !this.IsSelected || isDrawn)
            {
                return;
            }

            var vertices = roi.Vertices();

            this.Annotation.Polygon = vertices;
            isDrawn = true;
        }
Exemplo n.º 2
0
        public override void OnMouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left || !this.IsSelected || isDrawn)
            {
                return;
            }

            var ptSecond = Element.ToImageCoordinate(e.Location.ToPt()).Round();

            roi = new Rectangle
            {
                X      = System.Math.Min(ptFirst.X, ptSecond.X),
                Y      = System.Math.Min(ptFirst.Y, ptSecond.Y),
                Width  = System.Math.Abs(ptFirst.X - ptSecond.X),
                Height = System.Math.Abs(ptFirst.Y - ptSecond.Y)
            };

            roi.Width  = Math.Max(MIN_RECT_SIZE, roi.Width);
            roi.Height = Math.Max(MIN_RECT_SIZE, roi.Height);

            var imageSize = Element.Image.Size.ToSize();

            this.Annotation.Polygon = roi.Vertices().Select(x => x.Clamp(imageSize)).ToArray();
        }
        public override void OnMouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left || !this.IsSelected || isDrawn)
                return;

            var ptSecond = Element.ToImageCoordinate(e.Location.ToPt()).Round();

            roi = new Rectangle
            {
                X = System.Math.Min(ptFirst.X, ptSecond.X),
                Y = System.Math.Min(ptFirst.Y, ptSecond.Y),
                Width = System.Math.Abs(ptFirst.X - ptSecond.X),
                Height = System.Math.Abs(ptFirst.Y - ptSecond.Y)
            };

            roi.Width = Math.Max(MIN_RECT_SIZE, roi.Width);
            roi.Height = Math.Max(MIN_RECT_SIZE, roi.Height);

            var imageSize = Element.Image.Size.ToSize();
            this.Annotation.Polygon = roi.Vertices().Select(x => x.Clamp(imageSize)).ToArray();
        }