当前位置: 首页>>代码示例>>C#>>正文


C# RenderTarget.DrawRectangle方法代码示例

本文整理汇总了C#中SharpDX.Direct2D1.RenderTarget.DrawRectangle方法的典型用法代码示例。如果您正苦于以下问题:C# RenderTarget.DrawRectangle方法的具体用法?C# RenderTarget.DrawRectangle怎么用?C# RenderTarget.DrawRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SharpDX.Direct2D1.RenderTarget的用法示例。


在下文中一共展示了RenderTarget.DrawRectangle方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnRender

        public void OnRender(RenderTarget target)
        {
            if(gBorderBrush == null)
            {
                gBackgroundBrush = Brushes.Solid[0xCC555555];
                gBackgroundHoverBrush = Brushes.Solid[0xCC888888];
                gClickBrush = Brushes.Solid[0xFFFF7F00];
                gBackgroundClickedBrush = Brushes.Solid[0xCCBBBBBB];
                gBorderBrush = Brushes.White;
            }

            target.DrawTextLayout(new Vector2(Position.X + Size + 7, Position.Y - 2), mTextDraw, Brushes.White);

            var brush = gBackgroundBrush;
            if (mIsPressed)
                brush = gBackgroundClickedBrush;
            else if (mIsHovered)
                brush = gBackgroundHoverBrush;

            target.FillRectangle(mTargetRect, brush);
            target.DrawRectangle(mTargetRect, gBorderBrush);
            if (!Checked) return;

            target.DrawLine(Position + new Vector2(3, 3), Position + new Vector2(mSize - 3, mSize - 3), gClickBrush,
                mSize / 4.0f);
            target.DrawLine(new Vector2(Position.X + 3, Position.Y + mSize - 3),
                new Vector2(Position.X + mSize - 3, Position.Y + 3), gClickBrush, mSize / 4.0f);
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:28,代码来源:Checkbox.cs

示例2: Render

        public override void Render(RenderTarget pRender, float pPercent)
        {
            pRender.Transform = Matrix3x2.Identity;

            RectangleF rect = new RectangleF(x, y, width, height);
            pRender.FillRectangle(rect, highlight ? highlightBrush : backBrush);
            pRender.DrawRectangle(rect, borderBrush);
            pRender.DrawTextLayout(new Vector2(x + dx * (pPercent - 1), y + dy * (pPercent - 1)), textLayout, textBrush);
        }
开发者ID:jonathandlo,项目名称:deep-space-dive,代码行数:9,代码来源:Button.cs

示例3: Draw

 public void Draw(RenderTarget g)
 {
     g.DrawRectangle(Bounds, Resources.SCBRUSH_RED, 2f);
     foreach(BaseEntity ent in Objects)
     {
         g.DrawText(Level.ToString(), Resources.TEXT_FORMAT, ent.Hitbox, Resources.SCBRUSH_RED);
     }
     for (int i = 0; i < Nodes.Length; i++)
     {
         if (Nodes[i] != null)
         {
             Nodes[i].Draw(g);
         }
     }
 }
开发者ID:Harrum,项目名称:TestGamePlsIgnore,代码行数:15,代码来源:QuadTree.cs

示例4: OnRender

        public void OnRender(RenderTarget target)
        {
            if (gBorder == null)
                InitBrushes();

            if(mIsHovered || mIsClicked)
            {
                if (mIsClicked)
                    target.FillRectangle(mTargetRect, gClick);
                else if (mIsHovered)
                    target.FillRectangle(mTargetRect, gHover);

                target.DrawRectangle(mTargetRect, gBorder);
            }

            target.DrawBitmap(mImage.GetBitmap(), mImageRect, 1.0f, BitmapInterpolationMode.Linear);
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:17,代码来源:ImageButton.cs

示例5: Render

        public override void Render( RenderTarget target ) {
            target.Clear( new RawColor4( 1.0f, 1.0f, 1.0f, 1.0f ) );
            Brush brush = null;
            switch( rnd.Next( 3 ) ) {
                case 0: brush = resCache["RedBrush"  ] as Brush; break;
                case 1: brush = resCache["GreenBrush"] as Brush; break;
                case 2: brush = resCache["BlueBrush" ] as Brush; break;
            }
            target.DrawRectangle( new RawRectangleF( x, y, x + w, y + h ), brush );

            x = x + dx;
            y = y + dy;
            if ( x >= ActualWidth - w || x <= 0 ) {
                dx = -dx;
            }
            if ( y >= ActualHeight - h || y <= 0 ) {
                dy = -dy;
            }
        }
开发者ID:Korhog,项目名称:D2dControl,代码行数:19,代码来源:SampleControl.cs

示例6: OnRender

        public void OnRender(RenderTarget target)
        {
            UpdateCaret();

            var transform = target.Transform;
            target.Transform *= Matrix3x2.Translation(Position);

            target.AntialiasMode = AntialiasMode.Aliased;
            target.FillRectangle(new RectangleF(0, 0, mSize.X, mSize.Y), Brushes.Solid[0xCC111111]);
            target.DrawRectangle(new RectangleF(0, 0, mSize.X, mSize.Y), Brushes.Solid[System.Drawing.Color.White]);
            target.PushAxisAlignedClip(new RectangleF(4, 0, mSize.X - 8, mSize.Y), AntialiasMode.Aliased);
            target.DrawTextLayout(new Vector2(mStartPosition, 0), mTextDraw, Brushes.Solid[0xFFFFFFFF]);
            target.PopAxisAlignedClip();
            if (mCaretVisible && mIsFocused)
            {
                target.DrawLine(new Vector2(mCaretOffset, 4), new Vector2(mCaretOffset, 23),
                    Brushes.Solid[0xFFFFFFFF], 2.0f);
            }

            target.Transform = transform;
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:21,代码来源:EditBox.cs

示例7: OnRender

        public void OnRender(RenderTarget target)
        {
            target.AntialiasMode = AntialiasMode.Aliased;
            target.FillRectangle(mClientRectangle, gBackground);
            target.DrawRectangle(mClientRectangle, gBorder);

            if (HasCaption)
            {
                target.FillRectangle(mCaptionRect, gBorder);
                target.DrawTextLayout(new Vector2(Position.X + 5, Position.Y - 18.0f), mCaptionText, gCaptionText);
            }

            var oldTransform = target.Transform;
            target.Transform *= mTransform;

            target.PushAxisAlignedClip(mClipRect, AntialiasMode.Aliased);

            lock(Children)
                foreach (var child in Children) child.OnRender(target);

            target.PopAxisAlignedClip();

            target.Transform = oldTransform;
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:24,代码来源:Frame.cs

示例8: OnEditViewportDrawPrimitives

        private void OnEditViewportDrawPrimitives(Device device, RenderTarget target2D, Rectangle cliprectangle)
        {
            UiEncodingWindowSource source = _currentSource;

            WflContent info = source?.Info;
            if (info?.Header.TableType != WflHeader.LargeTable)
                return;

            int viewportX = _editViewport.X;
            int viewportY = _editViewport.Y;

            RectangleF rectangle = new RectangleF {Height = info.Header.LineHeight};

            target2D.BeginDraw();

            for (int i = 0; i < 256 * 2; i++)
            {
                if (i % 256 < 0x20)
                    continue;

                int x, y;
                info.GetOffsets(i, out x, out y);
                x -= viewportX;
                y -= viewportY;

                byte before, width, after;
                info.GetSizes(i, out before, out width, out after);

                rectangle.X = x;
                rectangle.Y = y;
                rectangle.Width = width & 0x7F;

                if (_charactersControl.CurrentMainIndices.Contains(i))
                {
                    target2D.FillRectangle(rectangle, _selectedColorBrush);

                    if (before > 0x7F)
                    {
                        rectangle.Width = (0xFF - before) + 1;
                        rectangle.X = x;
                    }
                    else
                    {
                        rectangle.Width = before;
                        rectangle.X = x - before;
                    }
                    target2D.FillRectangle(rectangle, _spacingColorBrush);

                    if (after > 0x7F)
                    {
                        rectangle.Width = (0xFF - after) + 1;
                        rectangle.X = x + (width & 0x7F) - rectangle.Width;
                    }
                    else
                    {
                        rectangle.Width = after;
                        rectangle.X = x + width & 0x7F;
                    }

                    target2D.FillRectangle(rectangle, _spacingColorBrush);
                }
                else if (source.Chars[i % 256] == 0x00)
                {
                    target2D.FillRectangle(rectangle, _notMappedColorBrush);
                }
                else
                {
                    target2D.DrawRectangle(rectangle, _gridColorBrush, 1.0f);
                }
            }

            int squareSize = info.Header.LineSpacing + info.Header.SquareDiff;
            rectangle.Height = squareSize;
            rectangle.Width = squareSize;
            for (int i = 0; i < info.AdditionalTable.Length; i++)
            {
                int value = info.AdditionalTable[i];
                if (value == 0)
                    continue;

                rectangle.Y = (value >> 8) * squareSize - viewportY;
                rectangle.X = (value & 0xFF) * squareSize - viewportX;

                if (_charactersControl.CurrentAdditionalIndices.Contains(i))
                    target2D.FillRectangle(rectangle, _selectedColorBrush);
                else if (source.Chars[i + 256] == 0x00)
                    target2D.FillRectangle(rectangle, _notMappedColorBrush);
                else
                    target2D.DrawRectangle(rectangle, _gridColorBrush, 1.0f);
            }

            target2D.EndDraw();
        }
开发者ID:akimoto-akira,项目名称:Pulse,代码行数:93,代码来源:UiEncodingWindow.cs

示例9: OnRender

        public void OnRender(RenderTarget target)
        {
            ++mFrameCount;

            var now = DateTime.Now;
            if((now - mLastMemorySample).TotalSeconds > 0.5f)
            {
                mLastMemorySample = now;
                mMemorySamples.Add(Environment.WorkingSet);
                while (mMemorySamples.Count > 20)
                    mMemorySamples.RemoveAt(0);
            }

            if((now - mLastFpsSample).TotalSeconds >= 1.0f)
            {
                mFpsSamples.Add(mFrameCount / (float) (now - mLastFpsSample).TotalSeconds);
                mLastFpsSample = now;
                mFrameCount = 0;

                while (mFpsSamples.Count > 20)
                    mFpsSamples.RemoveAt(0);
            }

            target.FillRectangle(mMemoryRectangle, Brushes.Solid[0xBB333333]);
            target.DrawRectangle(mMemoryRectangle, Brushes.White);
            target.FillRectangle(mFpsRectangle, Brushes.Solid[0xBB333333]);
            target.DrawRectangle(mFpsRectangle, Brushes.White);

            DrawMemorySamples(target);
            DrawFpsSamples(target);

            target.DrawTextLayout(new Vector2(Position.X, mMemoryRectangle.Top - 20.0f), mMemoryCaption, Brushes.White);
            target.DrawTextLayout(new Vector2(Position.X, mFpsRectangle.Top - 20.0f), mFpsCaption, Brushes.White);
        }
开发者ID:Linrasis,项目名称:WoWEditor,代码行数:34,代码来源:PerformanceControl.cs

示例10: Draw

        public virtual void Draw(RenderTarget g)
        {
            //Texture draw call
            if (Texture != null)
            {
                DrawingPositionRect = new RectangleF(X - Game.VIEWPORT.X, Y - Game.VIEWPORT.Y, Width, Height);
                Texture.DrawTexture(g, new RectangleF(X, Y, Width, Height));
            }

            //Debug drawing options
            if (Config.DEBUG_MODE == DebugMode.DISPLAY_HITBOX)
            {
                g.DrawRectangle(new RectangleF(Hitbox.X, Hitbox.Y, Hitbox.Width, Hitbox.Height), Resources.SCBRUSH_RED);
            }
            else if (Config.DEBUG_MODE == DebugMode.DISPLAY_RECT)
            {
                g.DrawRectangle(new RectangleF(X, Y, Width, Height), Resources.SCBRUSH_RED);
                g.DrawLine(new Vector2(X, Y), new Vector2(X + Width, Y + Height), Resources.SCBRUSH_RED);
                g.DrawLine(new Vector2(X, Y + Height), new Vector2(X + Width, Y), Resources.SCBRUSH_RED);
            }
            /* Used for debug purposes
            if (drawHitbox)
                g.DrawRectangle(Hitbox, Resources.SCBRUSH_BLACK, 3f);
            */
        }
开发者ID:Harrum,项目名称:TestGamePlsIgnore,代码行数:25,代码来源:BaseEntity.cs


注:本文中的SharpDX.Direct2D1.RenderTarget.DrawRectangle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。