Exemple #1
0
 public void DrawString(Rectangle pRectangle, IStringLayout pStringLayout, IBrush pBrush)
 {
     _renderer.DrawTextLayout(
         TransformPoint(pRectangle.Location),
         GetTextLayout(pStringLayout, pRectangle.Size),
         GetBrush(pBrush));
 }
Exemple #2
0
        protected override void OnRender(IRenderer pRenderer)
        {
            base.OnRender(pRenderer);

            if (_textString == null ||
                _textStyle == null)
            {
                return;
            }

            if (_stringBrush == null)
            {
                _stringBrush = pRenderer.CreateBrush(_textStyle.Color1 ?? Color.White);
            }
            //if (_textStyle.Format == null)
            //    _textStyle.Initialize(D2DStatic.StringFactory);


            if (_stringLayout == null || _invalidateTextLayout)
            {
                _invalidateTextLayout = false;
                if (_stringLayout != null)
                {
                    GraphicsHelper.DisposeIfImplementsIDisposable(_stringLayout);
                }
                _stringLayout = pRenderer.CreateStringLayout(_textString, _textStyle.Face, _textStyle.Size, _textStyle.Alignment);//D2DStatic.StringFactory.CreateTextLayout(_textString, _textStyle.Format, Bounds.Width, Bounds.Height);
            }

            pRenderer.DrawString(new Rectangle(TextPosition, Bounds.Size), _stringLayout, _stringBrush);
        }
Exemple #3
0
        public void DrawString(Geometry.Rectangle pRectangle, IStringLayout pStringLayout, IBrush pBrush)
        {
            var otkStringLayout = pStringLayout as OTKStringLayout;

            otkStringLayout.SetDimensions(pRectangle);
            otkStringLayout.SetBrush(pBrush);
            otkStringLayout.Draw();
        }
Exemple #4
0
        public void DrawString(Geometry.Rectangle pRectangle, IStringLayout pStringLayout, IBrush pBrush)
        {
            var rectangle = TransformRectangle(pRectangle);
            var color     = pBrush.Color;

            NativeDrawText((pStringLayout as OpenGLStringLayout).NativeTextLayoutPointer,
                           ref rectangle, ref color);
        }
Exemple #5
0
        private void RenderEvent()
        {
            _renderer.Clear(Color.Black);

            _renderer.DrawRectangle(new OpenGLBrush
            {
                Color = new Color(Color.Gray, 1f)
            }, new Rectangle(20, 20, 200, 500), 50);

            _renderer.DrawRectangle(new OpenGLBrush
            {
                Color = new Color(Color.White, 1f)
            }, new Rectangle(30, 30, 50, 50), 18);

            _renderer.DrawRectangle(new OpenGLBrush
            {
                Color = new Color(Color.White, .75f)
            }, new Rectangle(30, 130, 50, 50), 18);

            _renderer.DrawRectangle(new OpenGLBrush
            {
                Color = new Color(Color.White, .55f)
            }, new Rectangle(30, 230, 50, 50), 18);

            _renderer.DrawRectangle(new OpenGLBrush
            {
                Color = new Color(Color.White, .25f)
            }, new Rectangle(30, 330, 50, 50), 18);

            if (stringLayout == null)
            {
                stringLayout = _renderer.CreateStringLayout("LOL THIS WORKS WOOHOO", "arial", 35);
            }

            _renderer.DrawString(new Rectangle(300, 300, 0, 0), stringLayout, new OpenGLBrush()
            {
                Color = Color.RoyalBlue
            });

            if (imageResource == null)
            {
                imageResource = _renderer.CreateImage(@"C:\source\CarMp\trunk\Images\Skins\BMW\pause.png");
            }

            _renderer.DrawImage(new Rectangle(100, 30, 50, 51), imageResource, 1);

            // DrawDirect2D();
            _fpsCalcFramesCurrent++;
            if (DateTime.Now > _fpsCalcDate)
            {
                _controlForm.FPS      = _fpsCalcFramesCurrent;
                _fpsCalcFramesCurrent = 0;
                _fpsCalcDate          = DateTime.Now.AddSeconds(1);
            }
        }
        protected override void OnRender(IRenderer pRenderer)
        {
            if (_stringLayout == null)
            {
                _stringLayout = pRenderer.CreateStringLayout(string.Empty, _textStyle.Face, _textStyle.Size);
            }

            if (_imageBitmap == null)
            {
                _imageBitmap = pRenderer.CreateImage(_imageBitmapPath);
            }

            if (_stringBrush == null)
            {
                _stringBrush = pRenderer.CreateBrush(Color.Gray);
            }
            // TODO: Gradients ? IGradientBrush? Or bitmaps?
            //if (LinearGradient == null)
            //{
            //    if (LinearGradient == null)
            //        LinearGradient = pRenderer.Renderer.CreateLinearGradientBrush(
            //                new LinearGradientBrushProperties()
            //                {
            //                    StartPoint = new Point(0, 0),
            //                    EndPoint = new Point(0, _bounds.Height)
            //                },
            //                pRenderer.Renderer.CreateGradientStopCollection(new GradientStop[] {
            //                    new GradientStop
            //                        {
            //                            Color = new ColorF(Colors.Gray, 1),
            //                            Position = 0
            //                        }
            //                        ,
            //                    new GradientStop
            //                        {
            //                            Color = new ColorF(Colors.White, 1),
            //                            Position = 1
            //                        }
            //                    },
            //                    Gamma.Gamma_10,
            //                    ExtendMode.Clamp
            //            ));

            //}

            //LinearGradient.EndPoint = new Point(0, 0);
            //LinearGradient.StartPoint = new Point(0, _bounds.Height);

            pRenderer.DrawString(new Rectangle(4, 0, _bounds.Width, this.Height), _stringLayout, _stringBrush);

            // Call base which will draw the selection is selected
            base.OnRender(pRenderer);
        }
        protected override void OnRender(IRenderer pRenderer)
        {
            if (_stringLayout == null)
            {
                _stringLayout = pRenderer.CreateStringLayout(_displayString, _textStyle.Face, _textStyle.Size);

                //_stringLayout = D2DStatic.StringFactory.CreateTextLayout(DisplayString, StringDrawFormat, _bounds.Width, _bounds.Height);
            }

            if (_linearGradient == null)
            {
                _linearGradient = pRenderer.CreateBrush(_textStyle.Color1 ?? Color.White);
            }
            // TODO: Gradients?

            //if (_linearGradient == null)
            //{
            //    if (_linearGradient == null)
            //        _linearGradient = pRenderer.Renderer.CreateLinearGradientBrush(
            //                new LinearGradientBrushProperties()
            //                {
            //                    StartPoint = new Point(0, 0),
            //                    EndPoint = new Point(0, _bounds.Height)
            //                },
            //                pRenderer.Renderer.CreateGradientStopCollection(new GradientStop[] {
            //                    new GradientStop
            //                        {
            //                            Color = new ColorF(Colors.Gray, 1),
            //                            Position = 0
            //                        }
            //                        ,
            //                    new GradientStop
            //                        {
            //                            Color = new ColorF(Colors.White, 1),
            //                            Position = 1
            //                        }
            //                    },
            //                    Gamma.Gamma_10,
            //                    ExtendMode.Clamp
            //            ));

            //}

            //_linearGradient.EndPoint = new Point(0, 0);
            //_linearGradient.StartPoint = new Point(0, _bounds.Height);

            pRenderer.DrawString(new Rectangle(4, 0, _bounds.Width, this.Height), _stringLayout, _linearGradient);

            // Call base which will draw the selection is selected
            base.OnRender(pRenderer);
        }
Exemple #8
0
 private TextLayout GetTextLayout(IStringLayout pStringLayout, Size pSize)
 {
     return((pStringLayout as D2DStringLayout).GetTextLayout(pSize));
 }