public static bool Intersects(this RawRectangleF rect, RawRectangleF rectTest)
        {
            RectangleF ef  = new RectangleF(rect.Left, rect.Top, rect.GetWidth(), rect.GetHeight());
            RectangleF ef2 = new RectangleF(rectTest.Left, rectTest.Top, rectTest.GetWidth(), rectTest.GetHeight());

            return(ef.IntersectsWith(ef2));
        }
        /// <summary>
        /// Gets the image for a specific sprite, animation and frame.
        /// </summary>
        /// <param name="spriteResourceId">The sprite resource identifier.</param>
        /// <param name="animationId">The animation identifier.</param>
        /// <param name="seqIndex">The animation sequence index.</param>
        /// <returns>The bitmap to render.</returns>
        public SharpDX.Direct2D1.Bitmap GetImageForSprite(int spriteResourceId, int animationId, int seqIndex, out RawRectangleF rect)
        {
            var retval = _notFound;

            rect = new RawRectangleF(0, 0, 16, 16);

            var sprite = _resourceService.GetResourceById <Sprite>(spriteResourceId);

            if (sprite != null)
            {
                // get the bitmap
                SharpDX.Direct2D1.Bitmap bmp;
                if (_spriteTextures.TryGetValue(spriteResourceId, out bmp))
                {
                    retval = bmp;

                    // now get the source rect for the animation frame
                    Dictionary <int, RawRectangleF[]> rectDict;
                    if (_animationRects.TryGetValue(spriteResourceId, out rectDict))
                    {
                        RawRectangleF[] rects;
                        if (rectDict.TryGetValue(animationId, out rects))
                        {
                            var frame = sprite.Animations[animationId].Sequence[seqIndex];
                            if (frame < rects.Length)
                            {
                                rect = rects[frame];
                            }
                        }
                    }
                }
            }

            return(retval);
        }
Пример #3
0
        public static RectangleF AsRectangleF(this RawRectangleF target)
        {
            var width  = target.Right - target.Left;
            var height = target.Bottom - target.Top;

            return(new RectangleF(target.Left, target.Top, width, height));
        }
Пример #4
0
        public void DrawVerticalBar(float percentage, float x, float y, float width, float height, float stroke, Direct2DColor interiorColor, Direct2DColor color)
        {
            float half    = stroke / 2.0f;
            float quarter = half / 2.0f;

            _sharedBrush.Color = color;

            var rect = new RawRectangleF(x - half, y - half, x + width + half, y + height + half);

            _device.DrawRectangle(rect, _sharedBrush, half);

            if (percentage == 0.0f)
            {
                return;
            }

            rect.Left   += quarter;
            rect.Right  -= width - (width / 100.0f * percentage) + quarter;
            rect.Top    += quarter;
            rect.Bottom -= quarter;

            _sharedBrush.Color = interiorColor;

            _device.FillRectangle(rect, _sharedBrush);
        }
Пример #5
0
 private Ball(Vector2 position, Vector2 size, RawRectangleF sprite, float speed, Vector2 direction, List <Ball> ballList)
     : base(position, size, sprite)
 {
     Speed     = speed;
     Direction = direction;
     BallList  = ballList;
 }
Пример #6
0
        /// <summary>
        ///     Draws the rectangle3 d.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="length">The length.</param>
        /// <param name="stroke">The stroke.</param>
        /// <param name="brush">The brush.</param>
        public void DrawRectangle3D(int x, int y, int width, int height, int length, float stroke, int brush)
        {
            var first  = new RawRectangleF(x, y, x + width, y + height);
            var second = new RawRectangleF(x + length, y - length, first.Right + length, first.Bottom - length);

            var lineStart = new RawVector2(x, y);
            var lineEnd   = new RawVector2(second.Left, second.Top);

            _device.DrawRectangle(first, _brushContainer[brush], stroke);
            _device.DrawRectangle(second, _brushContainer[brush], stroke);

            _device.DrawLine(lineStart, lineEnd, _brushContainer[brush], stroke);

            lineStart.X += width;
            lineEnd.X    = lineStart.X + length;

            _device.DrawLine(lineStart, lineEnd, _brushContainer[brush], stroke);

            lineStart.Y += height;
            lineEnd.Y   += height;

            _device.DrawLine(lineStart, lineEnd, _brushContainer[brush], stroke);

            lineStart.X -= width;
            lineEnd.X   -= width;

            _device.DrawLine(lineStart, lineEnd, _brushContainer[brush], stroke);
        }
Пример #7
0
            public void UpdateGeometries(float borderWidth, float fixationPointSize)
            {
                float halfWidth = Size.X / 2, halfHeight = Size.Y / 2;
                var   outerRect = new RawRectangleF
                {
                    Left   = Center.X - halfWidth,
                    Right  = Center.X + halfWidth,
                    Top    = Center.Y - halfHeight,
                    Bottom = Center.Y + halfHeight
                };

                if (borderWidth > 0)
                {
                    BorderRect         = outerRect;
                    ContentRect.Left   = outerRect.Left + borderWidth;
                    ContentRect.Right  = outerRect.Right - borderWidth;
                    ContentRect.Top    = outerRect.Top + borderWidth;
                    ContentRect.Bottom = outerRect.Bottom - borderWidth;
                }
                else
                {
                    BorderRect  = null;
                    ContentRect = outerRect;
                }
                FixationEllipse = fixationPointSize > 0 ? new D2D1.Ellipse(Center, fixationPointSize, fixationPointSize) : (D2D1.Ellipse?)null;
            }
Пример #8
0
        static void ResizeBar(RawRectangleF m)
        {
            float w   = m.Right - m.Left;
            float dx  = w * 0.5f - 20;
            float top = m.Bottom - 50;

            PSB.Back.Size       = new Size2F(w, m.Bottom - m.Top);
            PSB.border.Location = new Vector2(m.Left, top);
            PSB.border.Size     = new Size2F(w, 50);
            top += 2;
            PSB.progressA.Location = new Vector2(m.Left, top);
            PSB.progressA.Size     = new Size2F(w, 6);
            PSB.progressB.Location = new Vector2(m.Left, top);
            PSB.progressC.Location = new Vector2(m.Left, top);
            top += 8;
            PSB.ellipse.Location = new Vector2(dx, top);
            PSB.play.Location    = new Vector2(dx, top);
            top += 5;
            dx   = m.Left;
            PSB.Sharp.Location     = new Vector2(dx, top);
            PSB.sharpback.Location = new Vector2(dx, top);
            dx += 120;
            PSB.Site.Location     = new Vector2(dx, top);
            PSB.siteback.Location = new Vector2(dx, top);
        }
Пример #9
0
 public void Create(SwapChain p, RawRectangleF m)
 {
     Create(App.Main);
     CreateBar(p);
     Resize();
     ThreadManage.UpdateUI = true;
 }
Пример #10
0
 internal UIElement(UIElement parent, string name, RawRectangleF bounds)
 {
     Name        = name;
     Parent      = parent;
     LocalBounds = bounds;
     ComputeBounds();
 }
Пример #11
0
 public ImmutableObject(
     char colorBrushIndex,
     RawRectangleF rectangle)
 {
     ColorBrushIndex = colorBrushIndex;
     Rectangle       = rectangle;
 }
Пример #12
0
        void FillIn2(D2DGraphics g, Color boxColor)
        {
            RawRectangleF rect = new RawRectangleF(0, 0, Width, Height);
            RadialGradientBrushProperties props2 = new RadialGradientBrushProperties()
            {
                Center = new RawVector2((rect.Left + rect.Right) / 2, (rect.Top + rect.Bottom) / 2),
                GradientOriginOffset = new RawVector2(0, 0),
                RadiusX = Width / 2,
                RadiusY = Height / 2
            };

            GradientStop[] gradientStops2 = new GradientStop[2];

            gradientStops2[0].Color    = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(55, boxColor.R, boxColor.G, boxColor.B));
            gradientStops2[0].Position = 0f;


            //gradientStops2[1].Color = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(40, 0,0,255));
            //gradientStops2[1].Position = 0.5f;

            gradientStops2[1].Color    = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(55, boxColor.R, boxColor.G, boxColor.B));
            gradientStops2[1].Position = 1f;

            //
            GradientStopCollection gradientStopCollection2 = new GradientStopCollection(g.RenderTarget, gradientStops2, Gamma.StandardRgb, ExtendMode.Clamp);
            RadialGradientBrush    radialGradientBrush     = new RadialGradientBrush(g.RenderTarget, props2, gradientStopCollection2);

            g.RenderTarget.FillRectangle(rect, radialGradientBrush);

            gradientStopCollection2.Dispose();
            radialGradientBrush.Dispose();
        }
Пример #13
0
        void PaintState2(D2DGraphics g)
        {
            g.RenderTarget.AntialiasMode = AntialiasMode.Aliased;
            RawRectangleF rect = new RawRectangleF(1, 1, Width - 1, Height - 1);

            int a = Math.Min(BoxColor.A + 100, 255);
            int R = Math.Max(BoxColor.R - 130, 0);
            int G = Math.Max(BoxColor.G - 130, 0);
            int B = Math.Max(BoxColor.B - 130, 0);

            RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(a, R, G, B));
            SolidColorBrush brush    = new SolidColorBrush(g.RenderTarget, rawColor);

            g.RenderTarget.DrawRectangle(rect, brush, boxSideWidth);
            brush.Dispose();


            R = Math.Max(FillInBoxColor.R - 50, 0);
            G = Math.Max(FillInBoxColor.G - 50, 0);
            B = Math.Max(FillInBoxColor.B - 50, 0);

            if (IsUseInFill)
            {
                FillIn(g, Color.FromArgb(FillInBoxColor.A, R, G, B));
            }

            if (IsUseInFill2)
            {
                FillIn2(g, Color.FromArgb(FillInBoxColor.A, R, G, B));
            }
        }
Пример #14
0
        public ConfirmBoxOverlay(string Text)
        {
            Debug.Assert(Elements.Exists <DefaultSource>());

            this.sText = Text;
            InitText();
            var boxX = this.Text.Metrics.Width + 40.0f;
            var boxY = this.Text.Metrics.Height + 20.0f;

            BoxRect = new RawRectangleF(
                (Screen.ScreenSize.Width / 2) - (boxX / 2),
                (Screen.ScreenSize.Height / 2) - (boxY / 2),
                (Screen.ScreenSize.Width / 2) + (boxX / 2),
                (Screen.ScreenSize.Height / 2) + (boxY / 2) + 20.0f + Base.DefaultTextFormat.FontSize
                );
            TextOrigin = new RawVector2(BoxRect.Left + 20.0f, BoxRect.Top + 10.0f);

            YesRect = new RawRectangleF(
                BoxRect.Left + 20.0f,
                BoxRect.Bottom - 40.0f,
                BoxRect.Left + 70.0f,
                BoxRect.Bottom - 10.0f
                );

            NoRect = new RawRectangleF(
                BoxRect.Right - 70.0f,
                BoxRect.Bottom - 40.0f,
                BoxRect.Right - 20.0f,
                BoxRect.Bottom - 10.0f
                );
        }
        static void ReSizeInfoPanel(RawRectangleF m)
        {
            float w = m.Right - m.Left;
            float h = m.Bottom - m.Top;
            float dx;
            float ph;

            if (w < 280)
            {
                ph       = w * 0.714f;
                pic.Size = new Size2F(w, ph);
                dx       = 0;
            }
            else
            {
                pic.Size = new Size2F(280, 200);
                dx       = w - 280;
                dx      *= 0.5f;
                ph       = 200;
            }
            pic.Location       = new Vector2(dx + m.Left, m.Top);
            m.Top             += ph;
            title.Location     = new Vector2(m.Left, m.Top);
            title.Size         = new Size2F(140, 24);
            titleback.Size     = new Size2F(140, 24);
            titleback.Location = new Vector2(m.Left, m.Top);
            m.Top             += 24;
            //float dh = 80000 / w;
            detail.Size     = new Size2F(w, m.Bottom - m.Top);
            detail.Location = new Vector2(m.Left, m.Top);
            //m.Top += dh;
            //float gh = m.Bottom - m.Top;
            //gb.Size = new Size2F(w,gh-3);
            //gb.Location = new Vector2(m.Left,m.Top);
        }
 private void DrawCorners(RenderTarget target, RawRectangleF bounds)
 {
     target.DrawBitmap(_topLeftCorner, new RawRectangleF(
                           bounds.Left,
                           bounds.Top,
                           bounds.Left + _topLeftCornerSize.Width,
                           bounds.Top + _topLeftCornerSize.Height),
                       1, BitmapInterpolationMode.Linear);
     target.DrawBitmap(_topRightCorner, new RawRectangleF(
                           bounds.Right - _topRightCornerSize.Width,
                           bounds.Top,
                           bounds.Right,
                           bounds.Top + _topRightCornerSize.Height),
                       1, BitmapInterpolationMode.Linear);
     target.DrawBitmap(_bottomLeftCorner, new RawRectangleF(
                           bounds.Left,
                           bounds.Bottom - _bottomLeftCornerSize.Height,
                           bounds.Left + _bottomLeftCornerSize.Width,
                           bounds.Bottom),
                       1, BitmapInterpolationMode.Linear);
     target.DrawBitmap(_bottomRightCorner, new RawRectangleF(
                           bounds.Right - _bottomRightCornerSize.Width,
                           bounds.Bottom - _bottomRightCornerSize.Height,
                           bounds.Right,
                           bounds.Bottom),
                       1, BitmapInterpolationMode.Linear);
 }
        static void Resize(RawRectangleF m)
        {
            if (margin.Left == m.Left)
            {
                if (margin.Right == m.Right)
                {
                    if (margin.Top == m.Top)
                    {
                        if (margin.Bottom == m.Bottom)
                        {
                            return;
                        }
                    }
                }
            }
            margin = m;
            float w = m.Right - m.Left;
            float h = m.Bottom - m.Top;

            videolist.Size       = new Size2F(140, h);
            videolist.ItemWidth  = 136;
            videolist.ItemHeight = 100;
            DataModA.ReSize(videolist.ItemTemplate, new Size2F(136, 100));

            videolist.Location = new Vector2(m.Right - 140, m.Top);
            m.Right           -= 140;
            ReSizeInfoPanel(m);
        }
Пример #18
0
        public virtual void OnD2DPaint(ScGraphics g)
        {
            D2DGraphics d2dGraph = (D2DGraphics)g;

            if (d2dGraph == null)
            {
                return;
            }

            if (BackgroundColor != null && BackgroundColor.Value.A != 0)
            {
                if (BackgroundColor.Value.A == 255)
                {
                    RawColor4 color = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(BackgroundColor.Value.ToArgb()));
                    d2dGraph.RenderTarget.Clear(color);
                }
                else
                {
                    d2dGraph.RenderTarget.AntialiasMode = AntialiasMode.Aliased;
                    RawRectangleF   rect     = new RawRectangleF(0, 0, Width, Height);
                    RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(BackgroundColor.Value);
                    SolidColorBrush brush    = new SolidColorBrush(d2dGraph.RenderTarget, rawColor);
                    d2dGraph.RenderTarget.FillRectangle(rect, brush);
                    brush.Dispose();
                }
            }

            if (D2DPaint != null)
            {
                D2DPaint(d2dGraph);
            }
        }
Пример #19
0
        static void Render()
        {
            while (running)
            {
                BeginScene();
                ClearScene();

                RawRectangleF rectF;
                if (TargetWindow == IntPtr.Zero)
                {
                    rectF = new RawRectangleF(50, 50, OverlayRect.Right, OverlayRect.Bottom);
                }
                else
                {
                    GetWindowRect(TargetWindow, out RECT TargetRect);
                    //rectF = new RawRectangleF(50, 50, OverlayRect.Right, OverlayRect.Bottom);
                    rectF = new RawRectangleF(50 + TargetRect.Left, 50 + TargetRect.Top, OverlayRect.Right, OverlayRect.Bottom);
                    WindowSetAbove();

                    SetWindowLongPtr(OverlayWindow, (int)GWL_STYLE, new IntPtr((long)nv_edit));
                    SetWindowLongPtr(OverlayWindow, (int)GWL_EXSTYLE, new IntPtr((long)nv_ex_edit));
                }

                target.DrawText("Hello my name is Zhengyu Wu", format, rectF, brushes["red"]);

                EndScene();

                Thread.Sleep(1000 / 144);
            }

            Console.WriteLine("End of render thread");
        }
Пример #20
0
            public void UpdateGeometries()
            {
                float halfWidth = Size.X / 2, halfHeight = Size.Y / 2;

                BorderRect.Left   = Center.X - halfWidth;
                BorderRect.Right  = Center.X + halfWidth;
                BorderRect.Top    = Center.Y - halfHeight;
                BorderRect.Bottom = Center.Y + halfHeight;

                if (BorderWidth > 0)
                {
                    ContentRect.Left   = BorderRect.Left + BorderWidth;
                    ContentRect.Right  = BorderRect.Right - BorderWidth;
                    ContentRect.Top    = BorderRect.Top + BorderWidth;
                    ContentRect.Bottom = BorderRect.Bottom - BorderWidth;
                }
                else
                {
                    ContentRect = BorderRect;
                }

                DualFlickerRects = new []
                {
                    new RawRectangleF(ContentRect.Left, ContentRect.Top, ContentRect.Left + ContentRect.Width() / 2, ContentRect.Bottom),
                    new RawRectangleF(ContentRect.Left + ContentRect.Width() / 2, ContentRect.Top, ContentRect.Right, ContentRect.Bottom),
                };

                CenterPointEllipse = new SharpDX.Direct2D1.Ellipse(Center, FixationPointSize, FixationPointSize);
            }
Пример #21
0
        public Brick(float x, float y, List <Brick> listReference, Kinds?kind = null)
            : base(new Vector2(50, 20), default, new Vector2(x, y))
        {
            if (kind.HasValue)
            {
                Kind = kind.Value;
            }
            else
            {
                Kind = GetRandomKind();
            }

            ListReference = listReference;

            DamageOnHit = FullHP / (1 + (int)Kind);
            if (Kind == Kinds.Indestructible)
            {
                DamageOnHit = 0;
            }
            else if (Kind == Kinds.PowerUP)
            {
                DamageOnHit = FullHP;
            }

            TileLocation = new RawRectangleF(1, 1 + 18 * (int)Kind, 33, 17 + 18 * (int)Kind);
        }
Пример #22
0
        private void DrawInternal(DeviceContext pContext, BitmapResource pBitmap, Vector2 pPosition, Size pSize)
        {
            _effects[0].SetInput(0, pBitmap.DirectXBitmap, false);

            float widthFactor;
            float heightFactor;

            if (_useTiledScaling)
            {
                widthFactor  = Game.ActiveCamera.Zoom;
                heightFactor = Game.ActiveCamera.Zoom;
            }
            else
            {
                widthFactor  = pSize.Width / pBitmap.Width;
                heightFactor = pSize.Height / pBitmap.Height;
            }

            var scale = new SharpDX.Direct2D1.Effect(_context, Scale);

            scale.SetValue(0, new RawVector2(widthFactor, heightFactor));
            scale.SetInput(0, _effects[_effects.Count - 1].Output, false);

            if (pBitmap.Source.HasValue)
            {
                var r      = pBitmap.Source.Value;
                var source = new RawRectangleF(r.Left, r.Top, r.Left + pSize.Width, r.Top + pSize.Height);
                pContext.DrawImage(scale.Output, pPosition, source, InterpolationMode.Linear, CompositeMode.SourceOver);
            }
            else
            {
                pContext.DrawImage(_effects[_effects.Count - 1].Output, pPosition);
            }
        }
Пример #23
0
        /// <summary>
        /// Gets the effect required input rectangles.
        /// </summary>
        /// <param name="renderEffect">The render effect.</param>
        /// <param name="renderImageRectangle">The render image rectangle.</param>
        /// <param name="inputDescriptions">The input descriptions.</param>
        /// <returns></returns>
        /// <unmanaged>HRESULT ID2D1DeviceContext::GetEffectRequiredInputRectangles([In] ID2D1Effect* renderEffect,[In, Optional] const D2D_RECT_F* renderImageRectangle,[In, Buffer] const D2D1_EFFECT_INPUT_DESCRIPTION* inputDescriptions,[Out, Buffer] D2D_RECT_F* requiredInputRects,[In] unsigned int inputCount)</unmanaged>
        public RawRectangleF[] GetEffectRequiredInputRectangles(SharpDX.Direct2D1.Effect renderEffect, RawRectangleF renderImageRectangle, SharpDX.Direct2D1.EffectInputDescription[] inputDescriptions)
        {
            var result = new RawRectangleF[inputDescriptions.Length];

            GetEffectRequiredInputRectangles(renderEffect, renderImageRectangle, inputDescriptions, result, inputDescriptions.Length);
            return(result);
        }
Пример #24
0
        public RawRectangleF[] GetEffectRequiredInputRectangles(ID2D1Effect renderEffect, EffectInputDescription[] inputDescriptions)
        {
            var result = new RawRectangleF[inputDescriptions.Length];

            GetEffectRequiredInputRectangles(renderEffect, null, inputDescriptions, result, inputDescriptions.Length);
            return(result);
        }
Пример #25
0
        private void PrePlane_D2DPaint(D2DGraphics g)
        {
            RawRectangleF rect = new RawRectangleF(0, 0, prePlane.Width, prePlane.Height);

            Color color    = Color.Black;
            Color orgColor = Color.FromArgb(158, 105, 7);

            switch (preBtnMouseState)
            {
            case 0:
                color = Color.FromArgb(200, orgColor);
                break;

            case 1:
                color = Color.FromArgb(100, orgColor);
                break;

            case 2:
                color = Color.FromArgb(50, orgColor);
                break;
            }


            RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(color);

            SharpDX.Direct2D1.Brush brush = new SolidColorBrush(g.RenderTarget, rawColor);
            g.RenderTarget.FillRectangle(rect, brush);
        }
Пример #26
0
        public void Draw(Renderer renderer, RawRectangleF rect, int c, int textx, ref int texty)
        {
            D2D1.Brush brush = renderer.Brushes[Colors[c % Colors.Length]];

            renderer.D2DContext.FillRectangle(rect, brush);
            renderer.Consolas14.TextAlignment = DWrite.TextAlignment.Leading;
            renderer.D2DContext.DrawText(
                Name + " (" + Stopwatch.Elapsed.TotalMilliseconds.ToString("F1") + "ms)",
                renderer.Consolas14, new RawRectangleF(textx, rect.Bottom + texty, textx + 100, rect.Bottom + texty + lineHeight), brush, D2D1.DrawTextOptions.None, D2D1.MeasuringMode.GdiNatural);

            int lineA = texty + 2;
            int lineC = c;

            texty += lineHeight;
            int x = 0;

            foreach (Profiler p in Children)
            {
                c++;

                //if (p.ParentTickOffset > 0)
                //    x += (int)((p.ParentTickOffset / (double)Stopwatch.Elapsed.Ticks) * (rect.Right - rect.Left));

                int w = (int)((p.Stopwatch.Elapsed.Ticks / (double)Stopwatch.Elapsed.Ticks) * (rect.Right - rect.Left));
                p.Draw(renderer, new RawRectangleF(rect.Left + x, rect.Top, rect.Left + x + w, rect.Bottom), c, textx + 10, ref texty);

                x += w;
            }

            if (Children.Count > 0)
            {
                renderer.D2DContext.FillRectangle(new RawRectangleF(textx - 3, rect.Bottom + lineA, textx - 2, rect.Bottom + texty - 2), renderer.Brushes[Colors[lineC % Colors.Length]]);
            }
        }
Пример #27
0
        public void FillAndDrawRectangle(float x0, float y0, float x1, float y1, Brush fillBrush, Brush lineBrush)
        {
            var rect = new RawRectangleF(x0, y0, x1, y1);

            renderTarget.FillRectangle(rect, fillBrush);
            DrawRectangle(rect, lineBrush);
        }
Пример #28
0
            public void UpdateGeometries()
            {
                float halfWidth = Size.X / 2, halfHeight = Size.Y / 2;

                BorderRect.Left   = Center.X - halfWidth;
                BorderRect.Right  = Center.X + halfWidth;
                BorderRect.Top    = Center.Y - halfHeight;
                BorderRect.Bottom = Center.Y + halfHeight;

                if (BorderWidth > 0)
                {
                    ContentRect.Left   = BorderRect.Left + BorderWidth;
                    ContentRect.Right  = BorderRect.Right - BorderWidth;
                    ContentRect.Top    = BorderRect.Top + BorderWidth;
                    ContentRect.Bottom = BorderRect.Bottom - BorderWidth;
                }
                else
                {
                    ContentRect = BorderRect;
                }

                var radius = Math.Min(Size.X, Size.Y) / 100;

                CenterPointEllipse = new D2D1.Ellipse(Center, radius, radius);
            }
Пример #29
0
        void DrawAxisX(D2DGraphics g)
        {
            g.RenderTarget.AntialiasMode = AntialiasMode.PerPrimitive;

            int startIdx = dataRange.startIdx;
            int endIdx   = dataRange.endIdx;
            StrokeStyleProperties ssp = new StrokeStyleProperties();

            ssp.DashStyle = DashStyle.DashDot;
            StrokeStyle     strokeStyle = new StrokeStyle(D2DGraphics.d2dFactory, ssp);
            SolidColorBrush brush2      = new SolidColorBrush(g.RenderTarget, GDIDataD2DUtils.TransToRawColor4(XAxisColor));

            g.RenderTarget.DrawLine(new RawVector2(0, Height / 2), new RawVector2(Width, Height / 2), brush2, 0.5f, strokeStyle);

            //
            float widthStep = Width / xAxisSeqCount;

            float numSeq   = GetAxisXSeq();
            float startNum = startIdx * numSeq;
            float numWidth = (endIdx - startIdx) * numSeq;
            float numStep  = numWidth / xAxisSeqCount;

            RawRectangleF rect;

            for (int i = 0; i < xAxisSeqCount; i++)
            {
                float x = (widthStep * i - 100 + widthStep * i + 100) / 2f;
                g.RenderTarget.DrawLine(new RawVector2(x, Height / 2), new RawVector2(x, Height / 2 + 3), brush2, 1f);

                //
                rect = new RawRectangleF(widthStep * i - 100, Height / 2, widthStep * i + 100, Height / 2 + 15);
                string str = (startNum + i * numStep).ToString("#.##");
                g.RenderTarget.DrawText(str, textFormat, rect, brush2, DrawTextOptions.Clip);
            }
        }
Пример #30
0
        public static void ActiveWeapon(RenderTarget Device, DrawArea drawArea, Entity player)
        {
            using (SolidColorBrush brush = new SolidColorBrush(Device, Color.Empty.toRawColor4()))
            {
                txtForm.SetTextAlignment(TextAlignment.Center);
                txtForm.SetWordWrapping(WordWrapping.NoWrap);

                RawRectangleF rect = new RawRectangleF(
                    drawArea.x,
                    drawArea.y + drawArea.height,
                    drawArea.x + drawArea.width,
                    drawArea.y + drawArea.height + 30);

                if (visuals.HealthPostion == Settings.HealthDisplay.Bottom)
                {
                    rect.Top += 5;
                }
                rect.Bottom += 5;

                brush.Color = Color.FromArgb(1, 1, 1).toRawColor4();

                Device.DrawText(player.ActiveWeapon.WeaponName, txtForm, rect, brush, DrawTextOptions.NoSnap);

                if (player.isTeam)
                {
                    brush.Color = visColors.Team_Text.toRawColor4();
                }
                else
                {
                    brush.Color = visColors.Enemy_Text.toRawColor4();
                }

                Device.DrawText("[" + player.ActiveWeapon.WeaponName + "]", txtForm, rect, brush, DrawTextOptions.EnableColorFont | DrawTextOptions.DisableColorBitmapSnapping | DrawTextOptions.NoSnap);
            };
        }