本文整理汇总了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));
}
示例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));
}
示例3: DrawScene
void DrawScene(DrawingContext dc) {
dc.DrawRectangle(Brushes.White, null, new Rect(0, 0, 500, 500));
DrawBall(dc);
}
示例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);
}
}
示例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);
}
}
示例6: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
drawingContext.DrawRectangle(
this.Brush,
this.Pen,
new Rect(10, 10, 180, 180.5));
}
示例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));
}
示例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);
}
}
示例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));
}
}