コード例 #1
0
        public override void DrawText(Geometry.PointF dest_pt, string text)
        {
            Geometry.PointF dest = Origin.CalcF(DisplayAlignment, StringDisplaySize(text));

            dest_pt.X -= dest.X;
            dest_pt.Y -= dest.Y;

            Drawing_Display disp = Display.Impl as Drawing_Display;
            Graphics        g    = disp.FrameGraphics;

            GraphicsState state = g.Save();
            double        scalex, scaley;

            GetScale(out scalex, out scaley);

            g.TranslateTransform(dest_pt.X, dest_pt.Y);
            g.ScaleTransform((float)scalex, (float)scaley);

            g.DrawString(text, mFont,
                         new SolidBrush(Interop.Convert(Color)), Point.Empty);

            g.Restore(state);
        }
コード例 #2
0
        public override void Draw(float destX, float destY, Geometry.Rectangle srcRect, float rotationCenterX, float rotationCenterY)
        {
            mDisplay.CheckInFrame("Surface.Draw");

            PointF destPt = new PointF(destX, destY);


            System.Diagnostics.Debug.Assert(mImage != null);

            Drawing_Display disp  = Display.Impl as Drawing_Display;
            Graphics        g     = disp.FrameGraphics;
            GraphicsState   state = g.Save();

            Geometry.PointF translatePoint = Origin.CalcF(DisplayAlignment, DisplaySize);


            if (DisplaySize.Width < 0)
            {
                translatePoint.X += DisplaySize.Width;
                rotationCenterX  += DisplaySize.Width;
            }

            if (DisplaySize.Height < 0)
            {
                translatePoint.Y += DisplaySize.Height;
                rotationCenterY  += DisplaySize.Height;
            }

            // translate to rotation point, rotate, and translate back.
            // System.Drawing rotates Clockwise!  So we must reverse the
            // rotation angle.
            g.TranslateTransform(-rotationCenterX, -rotationCenterY, MatrixOrder.Append);
            g.RotateTransform(-(float)RotationAngleDegrees, MatrixOrder.Append);
            g.TranslateTransform(rotationCenterX, rotationCenterY, MatrixOrder.Append);

            SetInterpolation(g);

            g.TranslateTransform(destPt.X - translatePoint.X,
                                 destPt.Y - translatePoint.Y, MatrixOrder.Append);

            if (Color != Geometry.Color.White)
            {
                ImageAttributes imageAttributes = new ImageAttributes();

                ColorMatrix colorMatrix = new ColorMatrix(new float[][] {
                    new float[] { Color.R / 255.0f, 0.0f, 0.0f, 0.0f, 0.0f },
                    new float[] { 0.0f, Color.G / 255.0f, 0.0f, 0.0f, 0.0f },
                    new float[] { 0.0f, 0.0f, Color.B / 255.0f, 0.0f, 0.0f },
                    new float[] { 0.0f, 0.0f, 0.0f, (float)Alpha, 0.0f },
                    new float[] { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }
                });

                imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);

                g.DrawImage(mImage, Interop.Convert(DestRect(0, 0, srcRect)),
                            srcRect.X,
                            srcRect.Y,
                            srcRect.Width,
                            srcRect.Height,
                            GraphicsUnit.Pixel,
                            imageAttributes);
            }
            else
            {
                g.DrawImage(mImage, Interop.Convert(DestRect(0, 0, srcRect)),
                            srcRect.X,
                            srcRect.Y,
                            srcRect.Width,
                            srcRect.Height,
                            GraphicsUnit.Pixel);
            }

            g.Restore(state);
        }
コード例 #3
0
        /// <summary>
        /// For function use, see documentation of Surface.
        ///
        /// Info for developers:
        /// This method should draw the surface to the screen, using all the
        /// scaling, rotation, etc. state data in the stored Surface object.
        /// </summary>
        /// <param name="destX"></param>
        /// <param name="destY"></param>
        public virtual void Draw(float destX, float destY)
        {
            Geometry.PointF rotatePoint = Origin.CalcF(RotationCenter, DisplaySize);

            Draw(destX, destY, rotatePoint.X, rotatePoint.Y);
        }