Beispiel #1
0
            public void UpdateGeometries(RawVector2 center, RawVector2 size)
            {
                Center = center;
                Size   = size;

                BorderRect  = SharpDXUtils.CenteredRect(center, size);
                ContentRect = BorderWidth > 0 ? BorderRect.Shrink(BorderWidth) : BorderRect;

                var absoluteMargins = FlickerMargins.GetAbsolute(ContentRect.Width(), ContentRect.Height());

                FlickerRect = absoluteMargins.IsEmpty(0.1) ? ContentRect
                    : ContentRect.Shrink((float)absoluteMargins.Left, (float)absoluteMargins.Top, (float)absoluteMargins.Right, (float)absoluteMargins.Bottom);

                FixationPoint = new D2D1.Ellipse(FlickerRect.Center(), FixationPointSize, FixationPointSize);
            }
Beispiel #2
0
        private void OnRender()
        {
            lock (_renderContextLock)
            {
                if (_renderTarget?.IsDisposed ?? true)
                {
                    return;
                }

                _renderTarget.BeginDraw();
                _renderTarget.Clear(_backgroundColor);

                if (_paradigmStarted && _trialStarted) // Draw blocks
                {
                    var borderRect  = SharpDXUtils.CenteredRect(Width / 2f, Height / 2f, _paradigm.Config.Gui.ButtonSize);
                    var buttonRect  = borderRect.Shrink(Math.Max((float)_paradigm.Config.Gui.ButtonBorder.Width, 0));
                    var paddings    = _paradigm.Config.Gui.ButtonPaddings;
                    var contentRect = buttonRect.Shrink((float)paddings.Left, (float)paddings.Top, (float)paddings.Right, (float)paddings.Bottom);

                    if (_paradigm.Config.Gui.ButtonBorder.Width > 0)
                    {
                        _solidColorBrush.Color = _blockBorderColor;
                        _renderTarget.FillRectangle(borderRect, _solidColorBrush);
                    }

                    _solidColorBrush.Color = _blockNormalColor;
                    _renderTarget.FillRectangle(buttonRect, _solidColorBrush);

                    _solidColorBrush.Color = _foregroundColor;
                    _renderTarget.DrawText(_displayText, _textFormat, contentRect, _solidColorBrush, D2D1.DrawTextOptions.None);
                }
                else if (_displayText?.IsNotBlank() ?? false) // Draw text
                {
                    _solidColorBrush.Color = _foregroundColor;
                    _renderTarget.DrawText(_displayText, _textFormat, new RawRectangleF(0, 0, Width, Height),
                                           _solidColorBrush, D2D1.DrawTextOptions.None);
                }

                _renderTarget.EndDraw();

                _swapChain.Present(1, DXGI.PresentFlags.None, _presentParameters);
            }
        }