private ShapeRectangle ConvertShape(ButtonBorder border) { ShapeRectangle shape = null; switch (border) { case ButtonBorder.Rectangle: shape = new ShapeRectangle(0, 0, _width - 1, _height - 1); break; case ButtonBorder.RoundRectangle: shape = new ShapeRoundRectangle(0, 0, _width - 1, _height - 1, _cornerRadius); break; case ButtonBorder.Ellipse: shape = new ShapeEllipse(0, 0, _width - 1, _height - 1); break; } if (shape != null) { shape.Brush = _fillBrushNormal; shape.Pen = _borderPenNormal; } return(shape); }
public CanvasFigure() { ShapeEllipse ellipse = new ShapeEllipse(); ellipse.Center = new Point (20, 20); ellipse.Width = 20; ellipse.Height = 20; ellipse.LineWidth = 1; }
public override void OnMouseDown(Canvas drawArea, MouseEventArgs e) { UndoService.BeginTransaction("Add a ellipse"); Point p = drawArea.BackTrackMouse(new Point(e.X, e.Y)); ShapeEllipse shapeEllipse = new ShapeEllipse( drawArea.Document.Zoom , p.X , p.Y , 1 , 1 , drawArea.Document.CurrentShapePaintInfo , drawArea.MessageControl.Sign.Type); AddNewObject(drawArea, shapeEllipse); }
public string ModelShapes = "圆角矩形"; //模板的形状 #endregion Fields #region Methods /// <summary> /// 绘制一个背景 /// </summary> /// <param name="g"></param> /// <param name="fx">这个背景偏移相当于这个模板的X坐标</param> /// <param name="fy">这个背景偏移相当于这个模板的Y坐标</param> /// <param name="Zoom"></param> /// <param name="listMatrix"></param> public void DrawModelBackground(Graphics g, float fx, float fy, float Zoom, List<Matrix> listMatrix) { //比如说背景是一张A4大小的纸张,那么其X,Y坐标就是画布的偏移。。。 //单位一定要是MM。 g.PageUnit = GraphicsUnit.Millimeter; //如下被认为可以清晰文字。 g.SmoothingMode = SmoothingMode.HighQuality; g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.PixelOffsetMode = PixelOffsetMode.HighQuality; g.CompositingQuality = CompositingQuality.HighQuality; float fltPenWidth = 0.5f / Zoom;//绘制纸张边距的画笔宽度 //基本上只是一个调用ShapeEle来绘图的方法 switch (ModelShapes) { case "方形": ShapeRect shapeRect = new ShapeRect(); shapeRect.X = fx ; shapeRect.Y = fy ; shapeRect.Width = BarcodePaperLayout.ModelWidth ; shapeRect.Height = BarcodePaperLayout.ModelHeight ; shapeRect.Zoom = Zoom; shapeRect.FillColor = Color.White; shapeRect.isFill = true; shapeRect.PenWidth = fltPenWidth; shapeRect.Draw(g,listMatrix); break; case "圆角矩形": ShapeRoundRect shapeRouneRect = new ShapeRoundRect(); shapeRouneRect.X = fx ; shapeRouneRect.Y = fy ; shapeRouneRect.Width = BarcodePaperLayout.ModelWidth ; shapeRouneRect.Height = BarcodePaperLayout.ModelHeight ; shapeRouneRect.Zoom = Zoom; shapeRouneRect.CornerRadius = BarcodePaperLayout.CornerRadius; shapeRouneRect.FillColor = Color.White; shapeRouneRect.isFill = true; shapeRouneRect.PenWidth = fltPenWidth; shapeRouneRect.Draw(g,listMatrix); break; case "椭圆形": ShapeEllipse shapeEllipse = new ShapeEllipse(); shapeEllipse.X = fx ; shapeEllipse.Y = fy ; shapeEllipse.Width = BarcodePaperLayout.ModelWidth ; shapeEllipse.Height = BarcodePaperLayout.ModelHeight ; shapeEllipse.Zoom = Zoom; shapeEllipse.FillColor = Color.White; shapeEllipse.isFill = true; shapeEllipse.PenWidth = fltPenWidth; shapeEllipse.Draw(g,listMatrix); break; case "CD": break; default: break; } }
public override void VisitEllipse(ShapeEllipse ellipse) { VisitShape(ellipse); }
public virtual void VisitEllipse(ShapeEllipse ellipse) { }