本文整理汇总了C#中System.Windows.Media.Imaging.WriteableBitmap.DrawEllipse方法的典型用法代码示例。如果您正苦于以下问题:C# WriteableBitmap.DrawEllipse方法的具体用法?C# WriteableBitmap.DrawEllipse怎么用?C# WriteableBitmap.DrawEllipse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Imaging.WriteableBitmap
的用法示例。
在下文中一共展示了WriteableBitmap.DrawEllipse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawLoop_Terminator
private void DrawLoop_Terminator(WriteableBitmap bitmap, System.Drawing.Rectangle r, String name)
{
bitmap.DrawEllipse(r.Left, r.Top, r.Width + r.Left, r.Height + r.Top, color);
bitmap.DrawEllipse(r.Left + 1, r.Top + 1, r.Width - 1 + r.Left, r.Height - 1 + r.Top, color);
bitmap.DrawEllipse(r.Left + 2, r.Top + 2, r.Width - 2 + r.Left, r.Height - 2 + r.Top, color);
var x1 = r.Left + r.Width / 2;
var y1 = r.Top;
bitmap.DrawLine(x1, y1, x1 + 50, y1 - 50, color);
bitmap.DrawLine(x1, y1 - 1, x1 + 50, y1 - 1 - 50, color);
bitmap.DrawLine(x1, y1 - 2, x1 + 50, y1 - 2 - 50, color);
bitmap.DrawLine(x1 + 50, y1 - 50, x1 + 100, y1 - 50, color);
bitmap.DrawLine(x1 + 50, y1 - 50 - 1, x1 + 100, y1 - 50 - 1, color);
bitmap.DrawLine(x1 + 50, y1 - 50 - 2, x1 + 100, y1 - 50 - 2, color);
DrawText(bitmap, name, 16, x1 + 100 + 5, y1 - 50 - 20);
}
示例2: Button_Click
/// <summary>
/// Randomise the layout of points.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Button_Click(object sender, RoutedEventArgs e)
{
// Create a new bitmap and set it as our canvas background.
pBitmap = BitmapFactory.New((int)cnvPoints.ActualWidth, (int)cnvPoints.ActualHeight);
var pBrush = new ImageBrush();
pBrush.ImageSource = pBitmap;
cnvPoints.Background = pBrush;
// Clear the bitmap to light blue.
using (pBitmap.GetBitmapContext())
pBitmap.Clear(Colors.LightBlue);
// Get the number we want to generate and update the UI.
var iResult = 0;
if (!int.TryParse(txtPoints.Text, out iResult))
{
txtPoints.Foreground = Brushes.Red;
return;
}
if (iResult < 0)
{
txtPoints.Foreground = Brushes.Red;
return;
}
txtPoints.Foreground = Brushes.Black;
// Clear the tree and canvas.
cnvPoints.Children.Clear();
pTree = new KDTree.KDTree<EllipseWrapper>(2);
// Create a list of points and draw a ghost ellipse for each one.
using (pBitmap.GetBitmapContext())
{
// Generate X new random items.
var pRandom = new Random();
for (int i = 0; i < iResult; ++i)
{
// Position it and add it to the canvas.
var x = pRandom.NextDouble() * cnvPoints.ActualWidth;
var y = pRandom.NextDouble() * cnvPoints.ActualHeight;
// Add it to the tree.
pTree.AddPoint(new double[] { x, y }, new EllipseWrapper(x, y));
// Draw a ghost visual for it.
//pBitmap.DrawEllipse((int)x - 2, (int)y - 2, (int)x + 2, (int)y + 2, Colors.Green);
pBitmap.DrawEllipse((int)x - 2, (int)y - 2, (int)x + 2, (int)y + 2, Colors.Orange);
}
}
}