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


C# RenderTarget.DrawRectangle方法代码示例

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


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

示例1: Draw

 protected internal override void Draw(RenderTarget renderTarget)
 {
     if (FillBrush != null)
     {
         renderTarget.FillRectangle(rect, FillBrush);
     }
     if (PenBrush != null)
     {
         if (StrokeStyle != null)
             renderTarget.DrawRectangle(rect, PenBrush, StrokeWidth, StrokeStyle);
         else
             renderTarget.DrawRectangle(rect, PenBrush, StrokeWidth);
     }
 }
开发者ID:Corillian,项目名称:Windows-API-Code-Pack-1.1,代码行数:14,代码来源:RectangleShape.cs

示例2: Draw

        protected internal override void Draw(RenderTarget renderTarget)
        {
            if (_drawBorder)
            {

                renderTarget.DrawRectangle(
                    new RectF(_point0.X, _point0.Y, _point0.X + _textLayout.MaxWidth, _point0.Y + _textLayout.MaxHeight), 
                    _parent.brushes[0],
                    1.5f, _parent.TextBoxStroke);
            }

            renderTarget.DrawTextLayout(
                _point0, _textLayout, _parent.brushes[_selectedBrushIndex], DrawTextOptions.Clip);
        }
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:14,代码来源:TextShape.cs

示例3: UserDrawingDelegate

        private void UserDrawingDelegate(RenderTarget target)
        {
            if (showLiveRectangleFlag)
            {

                target.DrawRectangle(new RectF(liveRectangleOrigin.X, liveRectangleOrigin.Y, liveRectangleOrigin.X + liveRectangleSize.Width, liveRectangleOrigin.Y + liveRectangleSize.Height), target.CreateSolidColorBrush(new ColorF(Color.Red.ToArgb())), 1);
            }
            if (sampleColor)
            {
                int dif = 5;
                Microsoft.WindowsAPICodePack.DirectX.Direct2D1.Brush brush = target.CreateSolidColorBrush(new ColorF(Color.Red.ToArgb()));
                Microsoft.WindowsAPICodePack.DirectX.Direct2D1.Point2F p1 = new Microsoft.WindowsAPICodePack.DirectX.Direct2D1.Point2F(sampleLocation.X - dif, sampleLocation.Y);
                Microsoft.WindowsAPICodePack.DirectX.Direct2D1.Point2F p2 = new Microsoft.WindowsAPICodePack.DirectX.Direct2D1.Point2F(sampleLocation.X + dif, sampleLocation.Y);
                target.DrawLine(p1, p2, brush, 1);
                p1 = new Microsoft.WindowsAPICodePack.DirectX.Direct2D1.Point2F(sampleLocation.X, sampleLocation.Y - dif);
                p2 = new Microsoft.WindowsAPICodePack.DirectX.Direct2D1.Point2F(sampleLocation.X, sampleLocation.Y + dif);
                target.DrawLine(p1, p2, brush, 1);
            }
        }
开发者ID:xmuhcd,项目名称:Image-Cropper-For-Computer-Vision,代码行数:19,代码来源:ImageCropper.cs

示例4: Render

        /// <summary>
        /// Renders rectangle represented by current instance to render target.
        /// </summary>
        /// <param name="renderTarget">The render target.</param>
        public void Render(RenderTarget renderTarget)
        {
            if (this.stroke != null)
            {
                renderTarget.DrawRectangle(this.rectangle, this.stroke, this.thickness);
            }

            if (this.fill != null)
            {
                renderTarget.FillRectangle(this.rectangle, this.fill);
            }
        }
开发者ID:huoxudong125,项目名称:oxyplot,代码行数:16,代码来源:RectangleRenderUnit.cs

示例5: Paint

        public void Paint(RenderTarget target)
        {
            target.BeginDraw();
            target.Transform = Matrix3x2.Identity;
            if (Fancy)
                target.FillRectangle(BackgroundGradient, new RectangleF(PointF.Empty, target.Size));
            else
                target.Clear(Color.Black);
            #region draw_notes
            lock (notes)
            {
                foreach (Note n in notes)
                {
                    float wheelOffset = (Keyboard.Pitchwheel[n.Channel] - 8192) / 8192f * 2 * KeyWidth;
                    float bottom = n.Position + n.Length;
                    float left = n.Key * KeyWidth + (bottom >= KeyboardY ? wheelOffset : 0);
                    if (Fancy)
                    {
                        NoteRoundRect.Left = left;
                        NoteRoundRect.Top = n.Position;
                        NoteRoundRect.Right = left + KeyWidth;
                        NoteRoundRect.Bottom = bottom;

                        float alpha = n.Velocity / 127f * (Keyboard.ChannelVolume[n.Channel] / 127f);
                        alpha *= alpha;
                        var gradientBrush = ChannelGradientBrushes[n.Channel];
                        gradientBrush.Opacity = alpha;
                        GradientPoint.X = NoteRoundRect.Left;
                        gradientBrush.StartPoint = GradientPoint;
                        GradientPoint.X = NoteRoundRect.Right;
                        gradientBrush.EndPoint = GradientPoint;
                        target.FillRoundedRectangle(ChannelGradientBrushes[n.Channel], NoteRoundRect);
                    }
                    else
                    {
                        NoteRect.X = left;
                        NoteRect.Y = n.Position;
                        NoteRect.Width = KeyWidth;
                        NoteRect.Height = n.Length;
                        target.FillRectangle(ChannelBrushes[n.Channel], NoteRect);
                    }
                }
            }
            #endregion

            Keyboard.Render(target);

            // Draw time progress bar
            if (sequence?.GetLength() > 0)
            {
                float percentComplete = 1f*sequencer.Position/sequence.GetLength();
                target.FillRectangle(DefaultBrushes[5],
                    new RectangleF(ProgressBarBounds.X, ProgressBarBounds.Y, ProgressBarBounds.Width*percentComplete, ProgressBarBounds.Height));
                target.DrawRectangle(DefaultBrushes[2], ProgressBarBounds, .8f);
            }


            string[] debug =
            {
                "      file: " + MIDIFile,
                "note_count: " + notes.Count,
                "  renderer: " + (Fancy ? "fancy" : UserFancy ? "forced-fast" : "fast"),
                "      note: " + (sequence == null ? "? / ?" : sequencer.Position + " / " + sequence.GetLength()),
                "     delay: " + Delay
            };
            string debugText = debug.Aggregate("", (current, ss) => current + ss + '\n');
            target.DrawText(debugText, DebugFormat, DebugRectangle, DefaultBrushes[0], DrawTextOptions.None, MeasuringMethod.Natural);

            if (Loading == 0)
                target.DrawText("INITIALIZING MIDI DEVICES", HugeFormat, FullRectangle, DefaultBrushes[0], DrawTextOptions.None, MeasuringMethod.Natural);
            else if (Loading > 0)
                target.DrawText("LOADING " + Loading + "%", HugeFormat, FullRectangle, DefaultBrushes[0], DrawTextOptions.None, MeasuringMethod.Natural);
            target.EndDraw();
        }
开发者ID:HuYang719,项目名称:MIDITrailer,代码行数:74,代码来源:MIDITrailer.cs

示例6: Render

        public void Render(RenderTarget target)
        {
            // Fill background depending on render mode
            if (NoteManager.RenderFancy)
                target.FillRectangle(GFXResources.BackgroundGradient, new RectangleF(PointF.Empty, target.Size));
            else
                target.Clear(Color.Black);

            // Render notes and keyboard display
            lock (NoteManager.Notes)
            {
                if (NoteManager.RenderFancy)
                    NoteRenderers[1].Render(target, NoteManager.Notes, Keyboard);
                else
                    NoteRenderers[0].Render(target, NoteManager.Notes, Keyboard);
            }
            lock (Keyboard.KeyPressed)
            {
                if (NoteManager.RenderFancy)
                    KeyRenderers[1].Render(target, Keyboard.KeyPressed);
                else
                    KeyRenderers[0].Render(target, Keyboard.KeyPressed);
            }

            // Draw time progress bar
            if (sequence?.GetLength() > 0)
            {
                float percentComplete = 1f * sequencer.Position / sequence.GetLength();
                target.FillRectangle(GFXResources.DefaultBrushes[5],
                    new RectangleF(GFXResources.ProgressBarBounds.X, GFXResources.ProgressBarBounds.Y, GFXResources.ProgressBarBounds.Width * percentComplete, GFXResources.ProgressBarBounds.Height));
                target.DrawRectangle(GFXResources.DefaultBrushes[2], GFXResources.ProgressBarBounds, .8f);
            }

            // Render debug information
            string[] debug;
            string usage = Application.ProductName + " " + Application.ProductVersion + " (c) " + Application.CompanyName;
            if (ShowDebug)
            {
                debug = new[]
                {
                    usage,
                    "      file: " + MIDIFile,
                    "note_count: " + NoteManager.Notes.Count,
                    "  frames/s: " + (Kazedan.Elapsed == 0 ? "NaN" : 1000 / Kazedan.Elapsed + "") +" fps",
                    "  renderer: " + (NoteManager.RenderFancy ? "fancy" : NoteManager.UserEnabledFancy ? "forced-fast" : "fast"),
                    "  seq_tick: " + (sequence == null ? "? / ?" : sequencer.Position + " / " + sequence.GetLength()),
                    "     delay: " + Delay+"ms",
                    "       kbd: " + GFXResources.NoteCount + " key(s) +" + GFXResources.NoteOffset + " offset",
                    "   stopped: " + Stopped
                };

            }
            else
            {
                debug = new[] { usage };
            }
            string debugText = debug.Aggregate("", (current, ss) => current + ss + '\n');
            target.DrawText(debugText, GFXResources.DebugFormat, GFXResources.DebugRectangle, GFXResources.DefaultBrushes[0], DrawTextOptions.None,
                MeasuringMethod.Natural);

            // Render large title text
            if (Loading == 0)
                target.DrawText("INITIALIZING MIDI DEVICES", GFXResources.HugeFormat, GFXResources.FullRectangle, GFXResources.DefaultBrushes[0], DrawTextOptions.None, MeasuringMethod.Natural);
            else if (Loading > 0 && Loading < 100)
                target.DrawText("LOADING " + Loading + "%", GFXResources.HugeFormat, GFXResources.FullRectangle, GFXResources.DefaultBrushes[0], DrawTextOptions.None, MeasuringMethod.Natural);
        }
开发者ID:Netdex,项目名称:Kazedan,代码行数:66,代码来源:MIDISequencer.cs


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