Exemplo n.º 1
0
 private void _viewer_MouseMove(object sender, MouseEventArgs e)
 {
     if (_annAutomation.Container != null)
     {
         AnnPoint       physical    = new AnnPoint(e.X, e.Y, AnnUnit.Pixel);
         AnnTransformer transformer = new AnnTransformer(_annAutomation.Container.UnitConverter, _annAutomation.Container.Transform);
         AnnPoint       logical     = transformer.PointToLogical(physical);
     }
 }
Exemplo n.º 2
0
 private void _viewer_MouseMove(object sender, MouseEventArgs e)
 {
     if (_annAutomation.Container != null)
     {
         AnnPoint physical = new AnnPoint(e.X, e.Y, AnnUnit.Pixel);
         AnnTransformer transformer = new AnnTransformer(_annAutomation.Container.UnitConverter, _annAutomation.Container.Transform);
         AnnPoint logical = transformer.PointToLogical(physical);
     }
 }
Exemplo n.º 3
0
        public void RotateImageAndAnnotations(int angle, AnnContainer container)
        {
            // round the angle
            angle %= 360;

            if (angle == 0)
            {
                return;  // nothing to do
            }
            // when we rotate an image, this is what happens:
            //  1. the image is rotated around its center (width/2, height/2)
            //  2. the image is translated so that its top,left position is at 0,0

            // to calculate this translation, we:
            //  1. find the 4 end points of the container
            //  2. rotate these points
            //  3. find the minimum/maximum "out of range" point
            //  4. calculate the translation (amount to bring this "out of range" point back into view)
            PointF[] pts =
            {
                new PointF(0,                                              0),
                new PointF(viewer.Image.ImageWidth,                        0),
                new PointF(viewer.Image.ImageWidth, viewer.Image.ImageHeight),
                new PointF(0,                       viewer.Image.ImageHeight)
            };

            PointF origin = new PointF(viewer.Image.ImageWidth / 2, viewer.Image.ImageHeight / 2);

            using (Matrix m = new Matrix())
            {
                m.RotateAt(angle, origin);
                m.TransformPoints(pts);
            }

            float xMin = pts[0].X;
            float yMin = pts[0].Y;

            for (int i = 1; i < pts.Length; i++)
            {
                if (pts[i].X < xMin)
                {
                    xMin = pts[i].X;
                }

                if (pts[i].Y < yMin)
                {
                    yMin = pts[i].Y;
                }
            }

            float xTranslate = -xMin;
            float yTranslate = -yMin;

            // now, rotate the image
            // Note, in this demo we will rotate only the view perspective, but you can use the RotateCommand to rotate
            // the annotations and the image around angle angle
            viewer.Image.RotateViewPerspective(angle);

            AnnPoint annOrigin = new AnnPoint(origin, AnnUnit.Pixel);

            // rotate and translate the annotations
            foreach (AnnObject obj in container.Objects)
            {
                obj.Rotate(angle, annOrigin);

                if (xTranslate != 0 || yTranslate != 0)
                {
                    obj.Translate(xTranslate, yTranslate);
                }
            }

            // re-set the container bounds
            container.Bounds = new AnnRectangle(0, 0, viewer.Image.ImageWidth, viewer.Image.ImageHeight);
        }
Exemplo n.º 4
0
        public void RotateImageAndAnnotations(int angle, AnnContainer container)
        {
            
            // round the angle
            angle %= 360;

            if (angle == 0)
                return;  // nothing to do

            // when we rotate an image, this is what happens:
            //  1. the image is rotated around its center (width/2, height/2)
            //  2. the image is translated so that its top,left position is at 0,0

            // to calculate this translation, we:
            //  1. find the 4 end points of the container
            //  2. rotate these points
            //  3. find the minimum/maximum "out of range" point
            //  4. calculate the translation (amount to bring this "out of range" point back into view)
            PointF[] pts =
         {
            new PointF(0, 0),
            new PointF(viewer.Image.ImageWidth, 0),
            new PointF(viewer.Image.ImageWidth, viewer.Image.ImageHeight),
            new PointF(0, viewer.Image.ImageHeight)
         };

            PointF origin = new PointF(viewer.Image.ImageWidth / 2, viewer.Image.ImageHeight / 2);

            using (Matrix m = new Matrix())
            {
                m.RotateAt(angle, origin);
                m.TransformPoints(pts);
            }

            float xMin = pts[0].X;
            float yMin = pts[0].Y;

            for (int i = 1; i < pts.Length; i++)
            {
                if (pts[i].X < xMin)
                    xMin = pts[i].X;

                if (pts[i].Y < yMin)
                    yMin = pts[i].Y;
            }

            float xTranslate = -xMin;
            float yTranslate = -yMin;

            // now, rotate the image
            // Note, in this demo we will rotate only the view perspective, but you can use the RotateCommand to rotate
            // the annotations and the image around angle angle
            viewer.Image.RotateViewPerspective(angle);

            AnnPoint annOrigin = new AnnPoint(origin, AnnUnit.Pixel);

            // rotate and translate the annotations
            foreach (AnnObject obj in container.Objects)
            {
                obj.Rotate(angle, annOrigin);

                if (xTranslate != 0 || yTranslate != 0)
                    obj.Translate(xTranslate, yTranslate);
            }

            // re-set the container bounds
            container.Bounds = new AnnRectangle(0, 0, viewer.Image.ImageWidth, viewer.Image.ImageHeight);
        }