日期:2014-05-20 浏览次数:21216 次
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows;
using System.Globalization;
namespace CustomPaint
{
class MyCanvas : Canvas
{
protected override void OnRender(DrawingContext dc)
{
base.OnRender(dc);
dc.DrawRectangle(Brushes.LightBlue, new Pen(Brushes.Red, 1),
new Rect(new Point(10, 10), new Size(100, 50)));
dc.DrawText(new FormattedText("my canvas", CultureInfo.CurrentCulture,
FlowDirection.LeftToRight, new Typeface("Tahoma"), 20, Brushes.Green),
new Point(50,25));
}
}
}