本文整理汇总了C#中ICanvas类的典型用法代码示例。如果您正苦于以下问题:C# ICanvas类的具体用法?C# ICanvas怎么用?C# ICanvas使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ICanvas类属于命名空间,在下文中一共展示了ICanvas类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PaintNonGrouped
protected override void PaintNonGrouped(float cx, float cy, ICanvas canvas)
{
var res = Renderer.Resources;
canvas.Font = res.EffectFont;
canvas.TextAlign = TextAlign.Left;
canvas.FillText(_label, cx + X, cy + Y);
}
示例2: PaintGrouped
protected override void PaintGrouped(float cx, float cy, float endX, ICanvas canvas)
{
PaintNonGrouped(cx, cy, canvas);
var lineSpacing = LineSpacing * Scale;
var textWidth = canvas.MeasureText(_label);
var startX = cx + X + textWidth + lineSpacing;
var lineY = cy + Y + (LineTopPadding * Scale);
var lineSize = LineSize * Scale;
if (endX > startX)
{
var lineX = startX;
while (lineX < endX)
{
canvas.BeginPath();
canvas.MoveTo(lineX, (int)lineY);
canvas.LineTo(Math.Min(lineX + lineSize, endX), (int)lineY);
lineX += lineSize + lineSpacing;
canvas.Stroke();
}
canvas.BeginPath();
canvas.MoveTo(endX, (int)(lineY - LineTopOffset * Scale));
canvas.LineTo(endX, (int)(lineY + LineTopOffset * Scale));
canvas.Stroke();
}
}
示例3: DrawElement
protected override void DrawElement(ICanvas canvas)
{
foreach (var c in Children)
{
c.Draw(canvas);
}
}
示例4: InitializeScene
public override void InitializeScene(ICanvas canvas)
{
// Connect with simulator
connection = new NetworkClient();
if (!connection.Connect("ganberg2", 9999))
{
throw new ApplicationException("Unable to establish connection with host.");
}
else
{
connection.Subscribe("TimeTick");
connection.Subscribe("ViewProUpdate");
}
// Create and initialize Gameboard.
background = new Obj_Sprite(texture_file, SpriteFlags.SortTexture | SpriteFlags.AlphaBlend);
background.Initialize(canvas);
background.Position = new Vector3(0, 0, 0);
background.Rotation = new Vector3(0, 0, 0);
background.Scaling = new Vector3(1, 1, 1);
background.Texture(canvas);
// Initialize and create Font;
this._myFont = canvas.CreateFont(new System.Drawing.Font("Arial", 10));
message = string.Empty;
//f16 = new Obj_Sprite("f16.png", SpriteFlags.AlphaBlend);
//f16.Initialize(canvas);
//f16.Texture(canvas);
//f16.Position = new Vector3(0, 0, 0);
//f16.Rotation = new Vector3(0, 0, 0);
//f16.Scaling = new Vector3(1, 1, 1);
}
示例5: WhenEnteringEditor
public void WhenEnteringEditor( ICanvas canvas, DraggingContext context)
{
if (_whenEnteringEditor != null)
{
_whenEnteringEditor(context);
}
}
示例6: Paint
public override void Paint(float cx, float cy, ICanvas canvas)
{
var blockWidth = 4 * Scale;
var top = cy + Y + Renderer.TopPadding;
var bottom = cy + Y + Renderer.Height - Renderer.BottomPadding;
var left = cx + X + 0.5f;
// big bar
var h = bottom - top;
canvas.FillRect(left, top, blockWidth, h);
// line
left += (blockWidth * 2) - 0.5f;
canvas.BeginPath();
canvas.MoveTo(left, top);
canvas.LineTo(left, bottom);
canvas.Stroke();
//circles
left += 3 * Scale;
var circleSize = _circleSize * Scale;
var middle = (top + bottom) / 2;
canvas.FillCircle(left, middle - (circleSize * _dotOffset), circleSize);
canvas.FillCircle(left, middle + (circleSize * _dotOffset), circleSize);
}
示例7: Paint
public override void Paint(float cx, float cy, ICanvas canvas)
{
// if we are linked with the previous, the first glyph of the group will also render this one.
if (IsLinkedWithPrevious)
{
return;
}
// we are not linked with any glyph therefore no expansion is required, we render a simple glyph.
if (!IsLinkedWithNext)
{
PaintNonGrouped(cx, cy, canvas);
return;
}
// find last linked glyph that can be
var lastLinkedGlyph = (GroupedEffectGlyph)NextGlyph;
while (lastLinkedGlyph.IsLinkedWithNext)
{
lastLinkedGlyph = (GroupedEffectGlyph)lastLinkedGlyph.NextGlyph;
}
// calculate end X-position
var cxRenderer = cx - Renderer.X;
var endRenderer = lastLinkedGlyph.Renderer;
var endBeatX = endRenderer.GetBeatX(lastLinkedGlyph.Beat, _endPosition);
var endX = cxRenderer + endRenderer.X + endBeatX;
PaintGrouped(cx, cy, endX, canvas);
}
示例8: Paint
public override void Paint(float cx, float cy, ICanvas canvas)
{
if (_noteString != null)
{
canvas.FillText(_noteString.ToLower(), cx + X, cy + Y);
}
}
示例9: Draw
public override void Draw(ICanvas canvas, RectangleF unitrect)
{
Color color = Color;
Pen pen = canvas.CreatePen(color, Width);
if (Highlighted || Selected)
{
pen = Canvas.DrawTools.DrawUtils.SelectedPen;
if (m_p1.IsEmpty == false) Canvas.DrawTools.DrawUtils.DrawNode(canvas, m_p1);
if (m_p2.IsEmpty == false) Canvas.DrawTools.DrawUtils.DrawNode(canvas, m_p2);
if (m_p3.IsEmpty == false) Canvas.DrawTools.DrawUtils.DrawNode(canvas, m_p3);
if (m_p4.IsEmpty == false) Canvas.DrawTools.DrawUtils.DrawNode(canvas, m_p4);
}
canvas.DrawLine(canvas, pen, m_p1, m_p2);
if (m_p3 != m_p4) canvas.DrawLine(canvas, pen, m_p3, m_p4);
pen = new Pen(pen.Color, (float)3);
if (horizontal)
{
canvas.DrawLine(canvas, pen, m_p2, new UnitPoint(m_p2.X+0.2,m_p2.Y));
canvas.DrawLine(canvas, pen, m_p3, new UnitPoint(m_p2.X + 0.8, m_p2.Y));
canvas.DrawArc(canvas, pen, new UnitPoint(m_p2.X + 0.61, m_p2.Y), (float)0.19, 0, 360);
canvas.DrawArc(canvas, pen, new UnitPoint(m_p2.X + 0.39, m_p2.Y), (float)0.19, 0, 360);
}
else
{
canvas.DrawLine(canvas, pen, m_p2, new UnitPoint(m_p2.X , m_p2.Y- 0.2));
canvas.DrawLine(canvas, pen, m_p3, new UnitPoint(m_p2.X , m_p2.Y- 0.8));
canvas.DrawArc(canvas, pen, new UnitPoint(m_p2.X , m_p2.Y-0.61), (float)0.19, 0, 360);
canvas.DrawArc(canvas, pen, new UnitPoint(m_p2.X , m_p2.Y-0.39), (float)0.19, 0, 360);
}
}
示例10: Scene
/// <summary>
/// Manages a scene to be rendered and updated.
/// </summary>
/// <param name="camera">Camera of the scene</param>
/// <param name="canvas">Canvas that this scene binds to.</param>
/// <param name="objects">Objects to be rendered</param>
public Scene(ICamera camera, ICanvas canvas, params SceneObject[] objects)
{
if (camera == null || canvas == null) { throw new ArgumentNullException(); }
this.Canvas = canvas;
{
this.rootUI = new SceneRootUI();
}
{
var rootObject = new SceneRootObject(this);
rootObject.Children.AddRange(objects);
this.rootObject = rootObject;
}
{
var rootViewPort = new SceneRootViewPort(
AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Top, new Padding(0, 0, 0, 0), canvas.Size);
rootViewPort.Children.Add(new ViewPort(camera,
AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom,
new Padding(0, 0, 0, 0), canvas.Size));
this.rootViewPort = rootViewPort;
}
//var cursor = UICursor.CreateDefault();
//cursor.Enabled = false;
//this.rootCursor.Children.Add(cursor);
//this.Cursor = cursor;
}
示例11: Draw
public override void Draw(ICanvas canvas, RectangleF unitrect)
{
Color color = Color;
Pen pen = canvas.CreatePen(color, Width);
if (Highlighted || Selected)
{
pen = Canvas.DrawTools.DrawUtils.SelectedPen;
if (m_p1.IsEmpty == false) Canvas.DrawTools.DrawUtils.DrawNode(canvas, m_p1);
if (m_p2.IsEmpty == false) Canvas.DrawTools.DrawUtils.DrawNode(canvas, m_p2);
//if ((m_p3.X != m_p2.X + 1 || m_p3.Y != m_p2.Y) && this.horizontal) m_p3 = new UnitPoint(m_p2.X + 1, m_p2.Y);
//if (m_p3.Y != m_p2.Y + 1 && !this.horizontal) m_p3 = new UnitPoint(m_p2.X, m_p2.Y + 1);
if (m_p3.IsEmpty == false) Canvas.DrawTools.DrawUtils.DrawNode(canvas, m_p3);
if (m_p4.IsEmpty == false) Canvas.DrawTools.DrawUtils.DrawNode(canvas, m_p4);
}
canvas.DrawLine(canvas, pen, m_p1, m_p2);
pen = new Pen(pen.Color, (float)4);
if (horizontal)
{
canvas.DrawLine(canvas, pen, new UnitPoint(m_p2.X + 0.1, m_p2.Y), new UnitPoint(m_p2.X + 0.51, m_p2.Y + 0.4));
canvas.DrawLine(canvas, pen, new UnitPoint(m_p2.X + 0.9, m_p2.Y), new UnitPoint(m_p2.X + 0.49, m_p2.Y + 0.4));
canvas.Graphics.DrawRectangle(pen, canvas.ToScreen(new UnitPoint(m_p2.X + 0.2, 1)).X, canvas.ToScreen(new UnitPoint(1, m_p2.Y + 0.1)).Y, canvas.ToScreen(new UnitPoint(m_p2.X + 0.8, 1)).X - canvas.ToScreen(new UnitPoint(m_p2.X + 0.2, 1)).X, canvas.ToScreen(new UnitPoint(1, m_p2.Y - 0.6)).Y - canvas.ToScreen(new UnitPoint(1, m_p2.Y - 0.1)).Y);
}
else
{
canvas.DrawLine(canvas, pen, new UnitPoint(m_p2.X - 0.4, m_p2.Y-0.5), new UnitPoint(m_p2.X + 0.01, m_p2.Y ));
canvas.DrawLine(canvas, pen, new UnitPoint(m_p2.X + 0.4, m_p2.Y-0.5), new UnitPoint(m_p2.X + -0.01, m_p2.Y ));
canvas.Graphics.DrawRectangle(pen, canvas.ToScreen(new UnitPoint(m_p2.X - 0.3, 1)).X, canvas.ToScreen(new UnitPoint(1, m_p2.Y - 0.4)).Y, canvas.ToScreen(new UnitPoint(m_p2.X + 0.8, 1)).X - canvas.ToScreen(new UnitPoint(m_p2.X + 0.2, 1)).X, canvas.ToScreen(new UnitPoint(1, m_p2.Y - 0.6)).Y - canvas.ToScreen(new UnitPoint(1, m_p2.Y - 0.1)).Y);
}
}
示例12: WinFormsCanvas
public WinFormsCanvas(ICanvas canvas, WinFormsCanvasPanel panel)
{
Background = canvas.Background;
SnapX = canvas.SnapX;
SnapY = canvas.SnapY;
EnableSnap = canvas.EnableSnap;
History = canvas.History;
Children = new List<INative>();
_panel = panel;
_panel.Layers.Add(this);
Downs = Observable.FromEventPattern<MouseEventArgs>(_panel, "MouseDown")
.Where(e => e.EventArgs.Button == MouseButtons.Left)
.Select(e => Snap(e.EventArgs.Location));
Ups = Observable.FromEventPattern<MouseEventArgs>(_panel, "MouseUp")
.Where(e => e.EventArgs.Button == MouseButtons.Left)
.Select(e => Snap(e.EventArgs.Location));
Moves = Observable.FromEventPattern<MouseEventArgs>(_panel, "MouseMove")
.Select(e => Snap(e.EventArgs.Location));
Native = _panel;
}
示例13: Clip
public bool Clip(ICanvas canvas, CRectangleF clipRect)
{
if (canvas.Bound.Left < clipRect.Left)
{
canvas.Bound.Left = clipRect.Left;
canvas.Content.Left = clipRect.Left - canvas.Bound.Left;
}
if (canvas.Bound.Top < clipRect.Top)
{
canvas.Bound.Top = clipRect.Top;
canvas.Content.Top = clipRect.Top - canvas.Bound.Top;
}
if (canvas.Bound.Right < clipRect.Right)
{
canvas.Bound.Right = clipRect.Right;
canvas.Content.Right = clipRect.Right - canvas.Bound.Right;
}
if (canvas.Bound.Bottom < clipRect.Bottom)
{
canvas.Bound.Bottom = clipRect.Bottom;
canvas.Content.Bottom = clipRect.Bottom - canvas.Bound.Bottom;
}
return !canvas.Bound.IsEmpty;
}
示例14: Draw
public void Draw(ICanvas canvas)
{
canvas.SaveState ();
//
// Scale the viewBox into the size
//
var sx = 1.0;
if (ViewBox.Width > 0) {
sx = Size.Width / ViewBox.Width;
}
var sy = 1.0;
if (ViewBox.Height > 0) {
sy = Size.Height / ViewBox.Height;
}
canvas.Scale (sx, sy);
canvas.Translate (-ViewBox.X, -ViewBox.Y);
//
// Draw
//
foreach (var c in Children) {
c.Draw (canvas);
}
canvas.RestoreState ();
}
示例15: Draw
public override void Draw(ICanvas canvas, RectangleF unitrect)
{
Color color = Color;
Brush B = Brushes.Black;
Pen pen = canvas.CreatePen(color, Width);
if (Highlighted || Selected)
{
pen = Canvas.DrawTools.DrawUtils.SelectedPen;
if (m_p1.IsEmpty == false) Canvas.DrawTools.DrawUtils.DrawNode(canvas, m_p1);
if (m_p2.IsEmpty == false) Canvas.DrawTools.DrawUtils.DrawNode(canvas, m_p2);
if (m_p3.IsEmpty == false) Canvas.DrawTools.DrawUtils.DrawNode(canvas, m_p3);
B = Brushes.Magenta;
}
canvas.DrawLine(canvas, pen, m_p1, m_p2);
pen = new Pen(pen.Color, (float)3);
if (horizontal)
{
canvas.DrawLine(canvas, pen, m_p2, new UnitPoint(m_p2.X + 0.2, m_p2.Y));
canvas.Graphics.DrawRectangle(pen, canvas.ToScreen(new UnitPoint(m_p2.X + 0.2, 1)).X, canvas.ToScreen(new UnitPoint(1, m_p2.Y + 0.1)).Y, canvas.ToScreen(m_p3).X - canvas.ToScreen(new UnitPoint(m_p2.X + 0.2, 1)).X, canvas.ToScreen(new UnitPoint(1, m_p2.Y - 0.1)).Y - canvas.ToScreen(new UnitPoint(1, m_p2.Y + 0.1)).Y);
float size = (canvas.ToScreen(new UnitPoint(m_p1.X + 1, m_p1.Y)).X - canvas.ToScreen(m_p1).X) / 10;
Font m_font = new System.Drawing.Font("Arial Black", size, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
canvas.Graphics.DrawString("Recorder", m_font, B, canvas.ToScreen(new UnitPoint(m_p2.X + 0.25, m_p2.Y - 0.1)).X, canvas.ToScreen(new UnitPoint(m_p2.X - 0.3, m_p2.Y + 0.1)).Y);
}
else
{
canvas.DrawLine(canvas, pen, m_p2, new UnitPoint(m_p2.X, m_p2.Y - 0.2));
canvas.Graphics.DrawRectangle(pen, canvas.ToScreen(new UnitPoint(m_p2.X - 0.4, 1)).X, canvas.ToScreen(new UnitPoint(1, m_p2.Y - 0.2)).Y, canvas.ToScreen(new UnitPoint(m_p2.X + 0.4, 1)).X - canvas.ToScreen(new UnitPoint(m_p2.X - 0.4, 1)).X, canvas.ToScreen(new UnitPoint(1, m_p2.Y - 0.4)).Y - canvas.ToScreen(new UnitPoint(1, m_p2.Y - 0.2)).Y);
float size = (canvas.ToScreen(new UnitPoint(m_p1.X + 1, m_p1.Y)).X - canvas.ToScreen(m_p1).X) / 10;
Font m_font = new System.Drawing.Font("Arial Black", size, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
canvas.Graphics.DrawString("Recorder", m_font, B, canvas.ToScreen(new UnitPoint(m_p2.X - 0.35, 1)).X, canvas.ToScreen(new UnitPoint(1, m_p2.Y - 0.2)).Y);
}
}