Beispiel #1
0
        public static Vector <float> Transform(this System.Drawing.Drawing2D.Matrix matrix, Vector <float> vec)
        {
            var a = AsArray(vec.AsBCL());

            matrix.TransformVectors(a);
            return(a[0].AsLoycVector());
        }
        /// <summary>
        /// Converts a <see cref="SizeF"/> from destination to source coordinates.
        /// </summary>
        /// <remarks>
        /// Only scale and rotation are applied when converting sizes; this is equivalent
        /// to converting a direction vector, as direction vectors have only magnitude
        /// and direction information, but no position.
        /// </remarks>
        public SizeF ConvertToSource(SizeF destinationDimensions)
        {
            PointF[] transformed = new PointF[] { destinationDimensions.ToPointF() };
            Matrix   inverse     = this.CumulativeTransform.Clone();

            inverse.Invert();
            inverse.TransformVectors(transformed);
            return(new SizeF(transformed[0]));
        }
Beispiel #3
0
        public override void Move(float dx, float dy)
        {
            // convert dx, dy to vector in object space
            System.Drawing.Drawing2D.Matrix mat = this.Owner.DrawMatrix.Clone();
            mat.Multiply(this.TransformationMatrix, System.Drawing.Drawing2D.MatrixOrder.Append);
            mat.Multiply(this.Owner.ViewMatrix, System.Drawing.Drawing2D.MatrixOrder.Append);
            mat.Invert();

            PointF tmpPoint = new PointF(dx, dy);

            PointF[] points = new PointF[1];
            points[0] = tmpPoint;
            mat.TransformVectors(points);

            tmpPoint = points[0];

            dx = tmpPoint.X;
            dy = tmpPoint.Y;
            float udx = UnitsManager.Instance.ConvertUnit(tmpPoint.X, MeasureUnits.pixel, this.Owner.MeasureUnit);
            float udy = UnitsManager.Instance.ConvertUnit(tmpPoint.Y, MeasureUnits.pixel, this.Owner.MeasureUnit);

            //dx = UnitsManager.Instance.ConvertUnit(tmpPoint.X, MeasureUnits.pixel, this.Owner.MeasureUnit);
            //dy = UnitsManager.Instance.ConvertUnit(tmpPoint.Y, MeasureUnits.pixel, this.Owner.MeasureUnit);

            switch (this.CommandPosition)
            {
            case CommandPosition.TopLeft:
                this.Owner.LocationInUnitsX = startLocX + udx;
                this.Owner.LocationInUnitsY = startLocY + udy;
                this.Owner.WidthInPixels    = startWidth - dx;
                this.Owner.HeightInPixels   = startHeight - dy;
                this.Owner.AnchorAll(udx, udy, -dx, -dy);
                break;

            case CommandPosition.TopCenter:
                this.Owner.LocationInUnitsY = startLocY + udy;
                this.Owner.HeightInPixels   = startHeight - dy;
                this.Owner.AnchorAll(0.0f, udy, 0.0f, -dy);
                break;

            case CommandPosition.TopRight:
                this.Owner.LocationInUnitsY = startLocY + udy;
                this.Owner.WidthInPixels    = startWidth + dx;
                this.Owner.HeightInPixels   = startHeight - dy;
                this.Owner.AnchorAll(0.0f, udy, dx, -dy);
                break;

            case CommandPosition.MiddleLeft:
                this.Owner.LocationInUnitsX = startLocX + udx;
                this.Owner.WidthInPixels    = startWidth - dx;
                this.Owner.AnchorAll(udx, 0.0f, -dx, 0.0f);
                break;

            case CommandPosition.MiddleRight:
                this.Owner.WidthInPixels = startWidth + dx;
                this.Owner.AnchorAll(0.0f, 0.0f, dx, 0.0f);
                break;

            case CommandPosition.BottomLeft:
                this.Owner.LocationInUnitsX = startLocX + udx;
                this.Owner.WidthInPixels    = startWidth - dx;
                this.Owner.HeightInPixels   = startHeight + dy;
                this.Owner.AnchorAll(udx, 0.0f, -dx, dy);
                break;

            case CommandPosition.BottomCenter:
                this.Owner.HeightInPixels = startHeight + dy;
                this.Owner.AnchorAll(0.0f, 0.0f, 0.0f, dy);
                break;

            case CommandPosition.BottomRight:
                this.Owner.WidthInPixels  = startWidth + dx;
                this.Owner.HeightInPixels = startHeight + dy;
                this.Owner.AnchorAll(0.0f, 0.0f, dx, dy);
                break;
            }

            if (this.Owner.WidthInPixels < UnitsManager.Instance.ConvertUnit(1.0f, MeasureUnits.mm, MeasureUnits.pixel))
            {
                this.Owner.WidthInPixels = UnitsManager.Instance.ConvertUnit(1.0f, MeasureUnits.mm, MeasureUnits.pixel);
            }
            if (this.Owner.HeightInPixels < UnitsManager.Instance.ConvertUnit(1.0f, MeasureUnits.mm, MeasureUnits.pixel))
            {
                this.Owner.HeightInPixels = UnitsManager.Instance.ConvertUnit(1.0f, MeasureUnits.mm, MeasureUnits.pixel);
            }

            this.Owner.DockAll();
            if (this.Owner.Parent != null)
            {
                this.Owner.Parent.DockAll();
            }
        }