本文整理汇总了C#中RenderTarget.DrawLine方法的典型用法代码示例。如果您正苦于以下问题:C# RenderTarget.DrawLine方法的具体用法?C# RenderTarget.DrawLine怎么用?C# RenderTarget.DrawLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderTarget
的用法示例。
在下文中一共展示了RenderTarget.DrawLine方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
protected internal override void Draw(RenderTarget renderTarget)
{
if (StrokeStyle != null)
renderTarget.DrawLine(point0, point1, PenBrush, StrokeWidth, StrokeStyle);
else
renderTarget.DrawLine(point0, point1, PenBrush, StrokeWidth);
}
示例2: Render
public void Render(RenderTarget target)
{
target.FillRectangle(KeyboardGradient, new RectangleF(0, KeyboardY, target.Size.Width, KEY_HEIGHT));
target.DrawLine(DefaultBrushes[1], 0, KeyboardY, target.Size.Width, KeyboardY, 1f);
for (int i = 0; i < 128; i++)
{
float keyX = i * KeyWidth;
if (IsBlack[i % 12])
{
if (KeyPressed[i] > 0)
{
target.FillRectangle(DefaultBrushes[4], new RectangleF(keyX, KeyboardY, KeyWidth, BLACK_KEY_HEIGHT));
}
else
{
target.FillRectangle(DefaultBrushes[2], new RectangleF(keyX, KeyboardY, KeyWidth, BLACK_KEY_HEIGHT));
target.FillRectangle(DefaultBrushes[1], new RectangleF(keyX, KeyboardY + BLACK_KEY_HEIGHT * 4f / 5, KeyWidth, BLACK_KEY_HEIGHT / 5f));
}
}
else
{
if (KeyPressed[i] > 0)
{
target.FillRectangle(DefaultBrushes[3], new RectangleF(keyX, KeyboardY, KeyWidth, KEY_HEIGHT));
if (IsBlack[(i + 1) % 12])
target.FillRectangle(DefaultBrushes[3], new RectangleF(keyX + KeyWidth, KeyboardY + BLACK_KEY_HEIGHT, KeyWidth / 2, KEY_HEIGHT - BLACK_KEY_HEIGHT));
if (IsBlack[(i + 11) % 12])
target.FillRectangle(DefaultBrushes[3], new RectangleF(keyX - KeyWidth / 2, KeyboardY + BLACK_KEY_HEIGHT, KeyWidth / 2, KEY_HEIGHT - BLACK_KEY_HEIGHT));
}
else
{
target.FillRectangle(DefaultBrushes[2], new RectangleF(keyX, KeyboardY + KEY_HEIGHT * 7f / 8, KeyWidth, KEY_HEIGHT / 8f));
if (IsBlack[(i + 1) % 12])
target.FillRectangle(DefaultBrushes[2], new RectangleF(keyX + KeyWidth, KeyboardY + KEY_HEIGHT * 7f / 8, KeyWidth, KEY_HEIGHT / 8f));
if (IsBlack[(i + 11) % 12])
target.FillRectangle(DefaultBrushes[2], new RectangleF(keyX - KeyWidth / 2, KeyboardY + KEY_HEIGHT * 7f / 8, KeyWidth, KEY_HEIGHT / 8f));
}
}
if (IsBlack[i % 12])
target.DrawLine(DefaultBrushes[1], keyX + KeyWidth / 2, KeyboardY + BLACK_KEY_HEIGHT, i * KeyWidth + KeyWidth / 2, target.Size.Height, 1f);
else if (!IsBlack[(i + 11) % 12])
target.DrawLine(DefaultBrushes[1], keyX, KeyboardY, keyX, target.Size.Height, 1f);
}
}
示例3: Render
public override void Render(RenderTarget target, int[] KeyPressed)
{
target.FillRectangle(GFXResources.DefaultBrushes[0],
new RectangleF
(
0,
GFXResources.KeyboardY,
target.Size.Width,
GFXResources.KeyHeight
)
);
target.DrawLine(GFXResources.DefaultBrushes[1], 0, GFXResources.KeyboardY, target.Size.Width, GFXResources.KeyboardY, 1f);
for (int i = GFXResources.NoteOffset; i < GFXResources.NoteOffset + GFXResources.NoteCount; i++)
{
float keyX = i * GFXResources.KeyWidth - GFXResources.NoteOffset * GFXResources.KeyWidth;
if (GFXResources.IsBlack[i % 12])
{
if (KeyPressed[i] > 0) /* Black key which is pressed */
{
target.FillRectangle
(
// Fill the inside red
GFXResources.DefaultBrushes[4],
new RectangleF
(
keyX,
GFXResources.KeyboardY,
GFXResources.KeyWidth,
GFXResources.BlackKeyHeight
)
);
}
else /* Black key which is not pressed */
{
// Fill the top gray
target.FillRectangle
(
GFXResources.DefaultBrushes[2],
new RectangleF
(
keyX,
GFXResources.KeyboardY,
GFXResources.KeyWidth,
GFXResources.BlackKeyHeight
)
);
}
}
else
{
if (KeyPressed[i] > 0) /* White key which is pressed */
{
// Fill the middle white part red
target.FillRectangle
(
GFXResources.DefaultBrushes[3],
new RectangleF
(
keyX,
GFXResources.KeyboardY,
GFXResources.KeyWidth,
GFXResources.KeyHeight
)
);
if (GFXResources.IsBlack[(i + 1) % 12])
{
// Fill the next half section red if the next note is black
target.FillRectangle
(
GFXResources.DefaultBrushes[3],
new RectangleF
(
keyX + GFXResources.KeyWidth,
GFXResources.KeyboardY + GFXResources.BlackKeyHeight,
GFXResources.KeyWidth / 2,
GFXResources.KeyHeight - GFXResources.BlackKeyHeight
)
);
}
if (GFXResources.IsBlack[(i + 11) % 12])
{
// Fill the previous half section red if the previous note is black
target.FillRectangle
(
GFXResources.DefaultBrushes[3],
new RectangleF
(
keyX - GFXResources.KeyWidth / 2,
GFXResources.KeyboardY + GFXResources.BlackKeyHeight,
GFXResources.KeyWidth / 2,
GFXResources.KeyHeight - GFXResources.BlackKeyHeight
)
);
}
}
}
// Draw note separator lines
if (GFXResources.IsBlack[i % 12])
{
target.DrawLine
//.........这里部分代码省略.........
示例4: 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);
}
}