예제 #1
0
파일: RendererGDI.cs 프로젝트: iayucar/PANG
        /// <summary>
        ///
        /// </summary>
        /// <param name="pText"></param>
        /// <param name="pSize"></param>
        /// <param name="pX"></param>
        /// <param name="pY"></param>
        /// <param name="pColor"></param>
        public override void DrawText(string pText, eTextSize pSize, int pX, int pY, SMX.Maths.Color4 pColor)
        {
            System.Drawing.Font font  = new Font("Arial", (int)pSize, FontStyle.Bold);
            SolidBrush          brush = new SolidBrush(pColor.ToGDI());

            SMX.Maths.Rectangle r = GetScreenCoords(pX, pY, 0, 0);
            mGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bilinear;
            mGraphics.DrawString(pText, font, brush, new PointF(r.X, r.Y));
        }
예제 #2
0
        ///// <summary>
        /////
        ///// </summary>
        ///// <param name="pText"></param>
        ///// <param name="pSize"></param>
        ///// <returns></returns>
        //public override SMX.Maths.Vector2 MeasureText(string pText, eTextSize pSize, float pMaxWidth = 99999, float pMaxHeight = 99999)
        //{
        //    SharpDX.DirectWrite.TextLayout layout = new SharpDX.DirectWrite.TextLayout(mFactoryDWrite, pText, mTextFormats[pSize], pMaxWidth, pMaxHeight);
        //    try
        //    {
        //        return new SMX.Maths.Vector2(layout.Metrics.Width, layout.Metrics.Height);
        //    }
        //    finally
        //    {
        //        if (layout != null)
        //            layout.Dispose();
        //    }
        //}
        ///// <summary>
        /////
        ///// </summary>
        ///// <param name="pText"></param>
        ///// <param name="pSize"></param>
        ///// <returns></returns>
        //public override SMX.Maths.Vector2 MeasureText(string[] pText, eTextSize pSize, float pLineMargin = 5, float pMaxWidth = 99999, float pMaxHeight = 99999)
        //{
        //    float maxWidth = float.MinValue, height = 0;
        //    foreach (string str in pText)
        //    {
        //        SharpDX.DirectWrite.TextLayout layout = new SharpDX.DirectWrite.TextLayout(mFactoryDWrite, str, mTextFormats[pSize], pMaxWidth, pMaxHeight);
        //        try
        //        {
        //            maxWidth = Math.Max(maxWidth, layout.Metrics.Width);
        //            height += layout.Metrics.Height + pLineMargin;
        //        }
        //        finally
        //        {
        //            if (layout != null)
        //                layout.Dispose();
        //        }
        //    }

        //    return new SMX.Maths.Vector2(maxWidth, height);
        //}

        /// <summary>
        ///
        /// </summary>
        /// <param name="pX"></param>
        /// <param name="pY"></param>
        /// <param name="pWidth"></param>
        /// <param name="pHeight"></param>
        /// <param name="pColor"></param>
        public override void FillRectangle(float pX, float pY, float pWidth, float pHeight, SMX.Maths.Color4 pColor)
        {
            Brush brush = new SolidColorBrush(mRenderTarget2D, pColor.ToSDX());

            mRenderTarget2D.FillRectangle(GetScreenCoords(pX, pY, pWidth, pHeight).ToSDXRectangleF(), brush);
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pText"></param>
        /// <param name="pSize"></param>
        /// <param name="pX"></param>
        /// <param name="pY"></param>
        /// <param name="pColor"></param>
        public override void DrawText(string pText, eTextSize pSize, int pX, int pY, SMX.Maths.Color4 pColor)
        {
            SharpDX.RectangleF r = GetScreenCoords(pX, pY, 9999, 9999).ToSDXRectangleF();

            mRenderTarget2D.DrawText(pText, mTextFormats[pSize], r, new SolidColorBrush(mRenderTarget2D, pColor.ToSDX()));
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pX"></param>
        /// <param name="pY"></param>
        /// <param name="pRadius"></param>
        /// <param name="pColor"></param>
        public override void DrawCircle(float pX, float pY, float pRadius, float pWidth, bool pDashed, Maths.Color4 pColor)
        {
            SolidColorBrush brush = new SolidColorBrush(mRenderTarget2D, pColor.ToSDX());

            SharpDX.Vector2   start     = GetScreenCoords(pX, pY).ToSDX();
            SMX.Maths.Vector2 radScreen = GetScreenCoords(pRadius, pRadius);

            if (pDashed)
            {
                StrokeStyleProperties props = new StrokeStyleProperties();
                props.DashCap    = CapStyle.Flat;
                props.EndCap     = CapStyle.Flat;
                props.StartCap   = CapStyle.Flat;
                props.DashOffset = 0;
                props.DashStyle  = DashStyle.Dash;
                props.LineJoin   = LineJoin.Round;
                SharpDX.Direct2D1.StrokeStyle strokeStyle = new StrokeStyle(mFactory2D, props);
                mRenderTarget2D.DrawEllipse(new Ellipse(start, radScreen.X, radScreen.X), brush, pWidth, strokeStyle);
            }
            else
            {
                mRenderTarget2D.DrawEllipse(new Ellipse(start, radScreen.X, radScreen.X), brush, pWidth);
            }
        }
예제 #5
0
파일: RendererGDI.cs 프로젝트: iayucar/PANG
        /// <summary>
        ///
        /// </summary>
        /// <param name="pX"></param>
        /// <param name="pY"></param>
        /// <param name="pRadius"></param>
        /// <param name="pColor"></param>
        public override void DrawCircle(float pX, float pY, float pRadius, float pWidth, bool pDashed, Maths.Color4 pColor)
        {
            SMX.Maths.Vector2 start     = GetScreenCoords(pX, pY);
            SMX.Maths.Vector2 radScreen = GetScreenCoords(pRadius, pRadius);


            Pen pen = new Pen(pColor.ToGDI(), pWidth);

            if (pDashed)
            {
                pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
            }
            else
            {
                pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
            }

            float width = radScreen.X * 2;

            mGraphics.DrawEllipse(pen, start.X - width / 2, start.Y - width / 2, width, width);
        }
예제 #6
0
파일: RendererGDI.cs 프로젝트: iayucar/PANG
        /// <summary>
        ///
        /// </summary>
        /// <param name="pX"></param>
        /// <param name="pY"></param>
        /// <param name="pDestX"></param>
        /// <param name="pDestY"></param>
        /// <param name="pWidth"></param>
        /// <param name="pDashed"></param>
        /// <param name="pColor"></param>
        public override void DrawLine(float pX, float pY, float pDestX, float pDestY, float pWidth, bool pDashed, SMX.Maths.Color4 pColor)
        {
            Pen pen = new Pen(pColor.ToGDI(), pWidth);

            if (pDashed)
            {
                pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
            }
            else
            {
                pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
            }

            System.Drawing.Point start = GetScreenCoords(pX, pY, 1, 1).ToGDI().Location;
            System.Drawing.Point end   = GetScreenCoords(pDestX, pDestY, 1, 1).ToGDI().Location;
            mGraphics.DrawLine(pen, start, end);
        }