/// <summary> /// 画矩形 /// </summary> private void DrawSquare(Point endP) { try { List <Point> pointList = new List <Point> { new Point(startPoint.X, startPoint.Y), new Point(startPoint.X, endP.Y), new Point(endP.X, endP.Y), new Point(endP.X, startPoint.Y), new Point(startPoint.X, startPoint.Y), }; StylusPointCollection point = new StylusPointCollection(pointList); if (stroke != null) { InkStrokes.Remove(stroke); } stroke = new Stroke(point) { DrawingAttributes = inkCanvasMeasure.DefaultDrawingAttributes.Clone() }; InkStrokes.Add(stroke); point = null; } catch (Exception ex) { logger.Error($"DrawSquare:{ex.Message}"); } }
private void DrawPen(Point endP) { try { penCollection.Add(new StylusPoint(endP.X, endP.Y)); if (stroke != null) { InkStrokes.Remove(stroke); } stroke = new Stroke(penCollection) { DrawingAttributes = inkCanvasMeasure.DefaultDrawingAttributes.Clone() }; InkStrokes.Add(stroke); } catch (Exception ex) { logger.Error($"DrawEllipse:{ex.Message}"); } }
/// <summary> /// 画椭圆 /// </summary> /// <param name="endP"></param> private void DrawEllipse(Point endP) { try { List <Point> pointList = GenerateEclipseGeometry(startPoint, endP); StylusPointCollection point = new StylusPointCollection(pointList); if (stroke != null) { InkStrokes.Remove(stroke); } stroke = new Stroke(point) { DrawingAttributes = inkCanvasMeasure.DefaultDrawingAttributes.Clone() }; InkStrokes.Add(stroke); point = null; } catch (Exception ex) { logger.Error($"DrawEllipse:{ex.Message}"); } }