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


C# DrawingContext.DrawRectangle方法代码示例

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


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

示例1: DrawScene

 void DrawScene(DrawingContext dc) {
   dc.DrawEllipse(new SolidColorBrush(Color.FromArgb(255, 200, 200, 200)), null, new Point(50, 18), 12, 12);
   dc.DrawEllipse(new SolidColorBrush(Color.FromArgb(255, 200, 200, 200)), new Pen(new SolidColorBrush(Color.FromArgb(255, 100, 100, 100)), 3), new Point(50, 51), 12, 12);
   dc.DrawEllipse(null, new Pen(new SolidColorBrush(Color.FromArgb(255, 100, 100, 100)), 3), new Point(50, 87), 12, 12);
   
   dc.DrawRectangle(new SolidColorBrush(Color.FromArgb(255, 200, 200, 200)), null, new Rect(25, 111, 24, 24));
   dc.DrawRectangle(new SolidColorBrush(Color.FromArgb(255, 200, 200, 200)), new Pen(new SolidColorBrush(Color.FromArgb(255, 100, 100, 100)), 3), new Rect(25, 147, 24, 24));
   dc.DrawRectangle(null, new Pen(new SolidColorBrush(Color.FromArgb(255, 100, 100, 100)), 3), new Rect(25, 184, 24, 24));
   
   dc.DrawRoundedRectangle(new SolidColorBrush(Color.FromArgb(255, 200, 200, 200)), null, new Rect(25, 237, 24, 24), 5, 5);
   dc.DrawRoundedRectangle(new SolidColorBrush(Color.FromArgb(255, 200, 200, 200)), new Pen(new SolidColorBrush(Color.FromArgb(255, 100, 100, 100)), 3), new Rect(25, 270, 24, 24), 5, 5);
   dc.DrawRoundedRectangle(null, new Pen(new SolidColorBrush(Color.FromArgb(255, 100, 100, 100)), 3), new Rect(25, 307, 24, 24), 5, 5);
   
   dc.DrawLine(new Pen(new SolidColorBrush(Color.FromArgb(255, 100, 100, 100)), 3), new Point(50, 340), new Point (70, 360));
 }
开发者ID:iamnp,项目名称:CSharpLiveCodingEnvironment,代码行数:15,代码来源:Shapes.cs

示例2: OnRender

            protected override void OnRender(DrawingContext dc)
            {
                string testString = "Formatted MML Document is displayed here!\nPlease implement the user oriented layout logic.";

                FormattedText formattedText = new FormattedText(testString, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 30, Brushes.Black);

                formattedText.MaxTextWidth = 280;
                formattedText.MaxTextHeight = 280;

                formattedText.SetForegroundBrush(new LinearGradientBrush(Colors.Blue, Colors.Teal, 90.0), 10, 12);

                formattedText.SetFontStyle(FontStyles.Italic, 36, 5);
                formattedText.SetForegroundBrush(new LinearGradientBrush(Colors.Pink, Colors.Crimson, 90.0), 36, 5);
                formattedText.SetFontSize(36, 36, 5);

                formattedText.SetFontWeight(FontWeights.Bold, 42, 48);

                dc.DrawRectangle(Brushes.White, null, new Rect(0, 0, 300, 300));

                dc.DrawText(formattedText, new Point(10, 10));
            }
开发者ID:anhlai,项目名称:EMR-MML,代码行数:21,代码来源:SampleMmlLayout.cs

示例3: DrawScene

 void DrawScene(DrawingContext dc) {
   dc.DrawRectangle(Brushes.White, null, new Rect(0, 0, 500, 500));
   DrawBall(dc);
 }
开发者ID:iamnp,项目名称:CSharpLiveCodingEnvironment,代码行数:4,代码来源:Tutorial.cs

示例4: OnRender

 /// <summary>
 /// When overriden in a class, renders the visual
 /// </summary>
 /// <param name="drawingContext">The <see cref="DrawingContext"/> in whihc to render the visual</param>
 protected override void OnRender(DrawingContext drawingContext)
 {
     if(this.Background != null || this.BorderBrush != null)
     {
         drawingContext.DrawRectangle(this.RenderTarget, this.BorderThickness, this.Background, this.BorderBrush);
     }
     if (this.Child != null)
     {
         this.Child.Render(drawingContext);
     }
 }
开发者ID:yonglehou,项目名称:Photon,代码行数:15,代码来源:Border.cs

示例5: OnRender

 /// <summary>
 /// When overriden in a class, renders the visual
 /// </summary>
 /// <param name="drawingContext">The <see cref="DrawingContext"/> in whihc to render the visual</param>
 protected override void OnRender(DrawingContext drawingContext)
 {
     if (this.Background != null)
     {
         drawingContext.DrawRectangle(this.RenderTarget, Thickness.Empty, this.Background, null);
     }
     if(this.Child != null)
     {
         this.Child.Render(drawingContext);
     }
 }
开发者ID:yonglehou,项目名称:Photon,代码行数:15,代码来源:Decorator.cs

示例6: OnRender

 protected override void OnRender(DrawingContext drawingContext)
 {
     drawingContext.DrawRectangle(
         this.Brush,
         this.Pen,
         new Rect(10, 10, 180, 180.5));
 }
开发者ID:modulexcite,项目名称:Avalonia,代码行数:7,代码来源:DrawingContextTests.cs

示例7: OnRender

		/// <summary>
		/// Renders the contents of the image
		/// </summary>
		/// <param name="dc">An instance of <see cref="T:Windows.UI.Xaml.Media.DrawingContext"/> used to render the control.</param>
		protected override void OnRender (DrawingContext dc)
		{
			if (background != null)
				dc.DrawRectangle (background, null, new Rect (0, 0, RenderSize.Width, RenderSize.Height));

			if (Source == null)
				return;

			ImageSource src = Source;
			var ourSize = RenderSize.Width * RenderSize.Height;
			foreach (var frame in _availableFrames)
			{
				src = frame;
				if (frame.PixelWidth * frame.PixelHeight >= ourSize)
					break;
			}
			dc.DrawImage (src, new Rect (new Point (0, 0), RenderSize));
		}
开发者ID:mhusen,项目名称:Eto,代码行数:22,代码来源:MultiSizeImage.cs

示例8: OnRender

 /// <summary>
 /// When overriden in a class, this method allows the execution of code whenever the element has been rendered
 /// </summary>
 ///<param name="drawingContext">The <see cref="DrawingContext"/> in which the element has been rendered</param>
 protected override void OnRender(DrawingContext drawingContext)
 {
     if (this.Background != null)
     {
         drawingContext.DrawRectangle(this.RenderTarget, Thickness.Empty, this.Background, null);
     }
     foreach (UIElement element in this.Children)
     {
         element.Render(drawingContext);
     }
 }
开发者ID:yonglehou,项目名称:Photon,代码行数:15,代码来源:StackPanel.cs

示例9: OnRender

        protected override void OnRender(DrawingContext dc)
        {
            /*var text_lines = new List<string>();

            int maxlength = 0;
            string indent_string = new string(' ', _textView.FormattedLineSource.TabSize);
            var lines = _textView.TextBuffer.CurrentSnapshot.Lines;
            foreach (var line in lines)
            {
                string text = line.GetText();
                text = text.Replace("\t", indent_string);
                text_lines.Add(text);
                maxlength = Math.Max(maxlength, text.Length);
            }

            double symbol_size = this.Width/maxlength;
            int line_index = 0;
            foreach (var line in text_lines)
            {
                int symbol_index = 0;
                foreach (var c in line)
                {
                    if (c != ' ')
                    {
                        double left = symbol_index * symbol_size;
                        var brush = new SolidColorBrush(Color.FromArgb(127, 0, 0, 0));
                        dc.DrawRectangle(brush, null, new Rect(left, line_index * 1.6 + 1, symbol_size, 1))
                    }
                    symbol_index++;
                }
                line_index++;
            }*/

            var snapshot = _textView.TextSnapshot;
            var segments = _textParser.Parse(_textView);

            //	calculate max string length
            int maxlength = 0;
            foreach (var line in snapshot.Lines)
            {
                string text = line.GetText();
                maxlength = Math.Max(maxlength, text.Length);
            }

            double symbol_size = this.Width / maxlength;
            foreach (var segment in segments)
            {
                string text = snapshot.GetText(segment.span);
                ITextSnapshotLine line = snapshot.GetLineFromPosition(segment.span.Start);

                double x = (segment.span.Start - line.Start.Position) * symbol_size;
                double y = line.LineNumber * 2.0;
                double w = (segment.span.Length) * symbol_size;
                double h = 1;

                var brush = new SolidColorBrush(segment.color);
                dc.DrawRectangle(brush, null, new Rect(x, y, w, h));
            }
        }
开发者ID:shashClp,项目名称:RockMargin,代码行数:59,代码来源:Test_huge.cs


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