Skip to content

Commit

Permalink
restore example code
Browse files Browse the repository at this point in the history
  • Loading branch information
jingwood committed Nov 5, 2022
1 parent 2ee597f commit d6fde2f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Examples/Demos/Whiteboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private void recreateMemoryGraphics()
}

private D2DBitmapGraphics memg;
private Vector2 lastPoint, cursorPoint;
private Point lastPoint, cursorPoint;
private bool isDrawing;
private Size penSize = new Size(5, 5);
private D2DColor penColor = D2DColor.Blue; // use white as eraser, other else as normal pen
Expand Down Expand Up @@ -143,9 +143,9 @@ protected override void OnMouseDown(MouseEventArgs e)
}

this.isDrawing = true;
this.lastPoint = new Vector2(e.X, e.Y);
this.cursorPoint = new Vector2(e.X, e.Y);
drawPen(new Vector2(e.Location.X, e.Location.Y));
this.lastPoint = e.Location;
this.cursorPoint = e.Location;
drawPen(e.Location);
this.showGettingStart = false;

// when we're in the eraser, we want to invalidate since the eraser is animated
Expand All @@ -156,22 +156,22 @@ protected override void OnMouseDown(MouseEventArgs e)

protected override void OnMouseMove(MouseEventArgs e)
{
this.cursorPoint = new Vector2(e.X, e.Y);
this.cursorPoint = e.Location;
if (this.isDrawing)
{
drawPen(new Vector2(e.Location.X, e.Location.Y));
drawPen(e.Location);
}
else
{
cursorPoint = new Vector2(e.X, e.Y);
cursorPoint = e.Location;
}
this.Invalidate();
}

protected override void OnMouseUp(MouseEventArgs e)
{
this.isDrawing = false;
this.cursorPoint = new Vector2(e.X, e.Y);
this.cursorPoint = e.Location;
}

protected override void OnMouseEnter(EventArgs e)
Expand Down Expand Up @@ -202,7 +202,7 @@ protected override void OnMouseWheel(MouseEventArgs e)
this.Invalidate();
}

private void drawPen(Vector2 currentPoint)
private void drawPen(Point currentPoint)
{
var diff = new Vector2(currentPoint.X - this.lastPoint.X, currentPoint.Y - this.lastPoint.Y);

Expand Down Expand Up @@ -240,7 +240,7 @@ private void drawPen(Vector2 currentPoint)

private float eraserDashOffset = 0.0f;

private void drawCursor(D2DGraphics g, Vector2 p)
private void drawCursor(D2DGraphics g, Point p)
{
if (this.penColor == D2DColor.White)
{
Expand All @@ -257,7 +257,7 @@ private void drawCursor(D2DGraphics g, Vector2 p)
else
{
// else draw pen
g.DrawEllipse(p, this.penSize, this.penColor, 2.0f);
g.DrawEllipse(new Vector2(p.X, p.Y), this.penSize, this.penColor, 2.0f);
}
}
}
Expand Down

0 comments on commit d6fde2f

Please sign in to comment.