public IFigure GetFigure() { if (TabControlFigure.SelectedIndex == 0) { var ellipse = new ellipse(); ellipse.SemimajorAxis = Convert.ToInt32(Radius.Text); ellipse.MinorAxis = Convert.ToInt32(Radius.Text); return(ellipse); } else if (TabControlFigure.SelectedIndex == 1) { var ellipse = new ellipse(); ellipse.SemimajorAxis = Convert.ToInt32(Radius.Text); ellipse.MinorAxis = Convert.ToInt32(Radius.Text); return(ellipse); } else if (TabControlFigure.SelectedIndex == 2) { var ellipse = new ellipse(); ellipse.SemimajorAxis = Convert.ToInt32(Radius.Text); ellipse.MinorAxis = Convert.ToInt32(Radius.Text); return(ellipse); } else { throw new ArgumentException(); } }
static void Main(string[] args) { ShapeManager shM = new ShapeManager(); Circle c1 = new Circle(1, 1); ellipse e1 = new ellipse(1, 5); Rectangle r1 = new Rectangle(2, 7); shM.func(); shM.Add(c1); shM.Add(e1); shM.Add(r1); shM.DisplayAll(); StringBuilder sb = new StringBuilder(); e1.Write(sb); r1.Write(sb); if (sb != null) { shM.Save(sb); } Console.WriteLine(); Console.WriteLine("The stringBuilder text is : "); Console.WriteLine(sb); shM.arr.Sort(); Console.WriteLine(); Console.WriteLine("all the shapes sorted by their Area : "); shM.DisplayAll(); }
public static void Main() { my0926 my = new my0926(); my.assign(2, 3); my.add(); circle circle = new circle(); circle.setradius(10); circle.assign(5, 4); circle.move(1, 1); circle.area(); ellipse ellipse = new ellipse(); ellipse.setradius(10); ellipse.setradius2(20); ellipse.area(); }
public ellipse SvgEllipseDescription() { if (VerticesList.Count < 3) { return(null); } transform = new SVGtransform(rotateCx: centerPointD.X, rotateCy: centerPointD.Y, rotateAngleDegrees: (axisInclinationRad / Math.PI) * 180.0); ellipse retEllipse = new ellipse() { cx = centerPointD.X, cy = centerPointD.Y, rx = aRadius, ry = bRadius, fill = "none", stroke = Color, stroke_width = 2, transform = transform.ToString(), }; return(retEllipse); }
//--- protected void addInsertItem(int ind) { Item ob = new Item(); int sw = comboBoxItems.SelectedIndex; switch (sw) { case 0: ob = new point(); break; case 1: ob = new mLine(); break; case 2: ob = new circle(); break; case 3: ob = new ellipse(); break; case 4: ob = new triangle(); break; case 5: ob = new rectangle(); break; case 6: ob = new roundRect(); break; case 7: ob = new polygon(); break; case 8: ob = new arc(); break; case 9: ob = new color(); break; default: break; } if (ind < 0) { if (listBoxIcons.SelectedIndex < 0) { return; } icons[listBoxIcons.SelectedIndex].add(ob); listBoxItems.SelectedIndex = listBoxItems.Items.Count - 1; } else { icons[listBoxIcons.SelectedIndex].insert(ind, ob); listBoxItems.SelectedIndex = ind; } }
public void Generate_SVG() { _Svg = new svg { id = "svgPaint", width = par_width, height = par_height, xmlns = "http://www.w3.org/2000/svg", //style = "background-color: rgba(0, 0, 0, 0.0);", }; _Svg.Children.Add(new rect { width = par_width, height = par_height, fill = "none", stroke = "magenta", stroke_width = 1, }); CompBlazorPaint currParent = (Parent as CompBlazorPaint); #region drawing all the Selection rectangles if (currParent.bpSelectionRectangle != null) { rect bpSelectionRectangleSVGrect = new rect { x = Math.Min((double)currParent.bpSelectionRectangle.Position.x, (double)currParent.bpSelectionRectangle.end.x), y = Math.Min((double)currParent.bpSelectionRectangle.Position.y, (double)currParent.bpSelectionRectangle.end.y), width = Math.Abs((double)currParent.bpSelectionRectangle.end.x - currParent.bpSelectionRectangle.Position.x), height = Math.Abs((double)currParent.bpSelectionRectangle.end.y - currParent.bpSelectionRectangle.Position.y), fill = "#FAFAFA", stroke = currParent.bpSelectionRectangle.Color, stroke_width = currParent.bpSelectionRectangle.LineWidth, stroke_dasharray = "4", style = "opacity:0.8", }; _Svg.Children.Add(bpSelectionRectangleSVGrect); } #endregion #region drawing all the lines foreach (BPaintLine currLine in currParent.ObjectsList.Where(x => x.ObjectType == BPaintOpbjectType.Line)) { line l = new line() { x1 = currLine.Position.PtD.X, y1 = currLine.Position.PtD.Y, x2 = currLine.end.PtD.X, y2 = currLine.end.PtD.Y, stroke = currLine.Color, stroke_width = currLine.LineWidth, }; _Svg.Children.Add(l); if (currLine.Selected) { RectD p_rect = (currLine as BPaintLine).BoundingRectD(); _Svg.Children.Add(new rect { x = p_rect.x, y = p_rect.y, width = p_rect.width, height = p_rect.height, fill = "none", stroke = "magenta", stroke_width = 1, style = "opacity:0.7", }); } } #endregion #region drawing all the circles foreach (BPaintCircle currCircle in currParent.ObjectsList.Where(x => x.ObjectType == BPaintOpbjectType.Circle)) { circle currSVGCircle = new circle() { cx = currCircle.Position.x, cy = currCircle.Position.y, r = currCircle.Position.PtD.DistanceTo(currCircle.end.PtD), fill = "none", stroke = currCircle.Color, stroke_width = 2, }; //line circleAuxiliaryLine = new line() //{ // x1 = currCircle.Position.x, // y1 = currCircle.Position.y, // x2 = currCircle.end.x, // y2 = currCircle.end.y, // stroke = "magenta", // stroke_width = 1, // style = "opacity:0.7" //}; _Svg.Children.Add(currSVGCircle); //_Svg.Children.Add(circleAuxiliaryLine); if (currCircle.Selected) { RectD p_rect = BPaintFunctions.Get_Border_Points(currCircle); _Svg.Children.Add(new rect { x = p_rect.x, y = p_rect.y, width = p_rect.width, height = p_rect.height, fill = "none", stroke = "magenta", stroke_width = 1, style = "opacity:0.7", }); } } #endregion #region drawing all the ellipses foreach (BPaintEllipse currEllipse in currParent.ObjectsList.Where(x => x.ObjectType == BPaintOpbjectType.Ellipse)) { if (currEllipse.IsValid()) { ellipse currSVGCircle = currEllipse.SvgEllipseDescription(); _Svg.Children.Add(currSVGCircle); if (currEllipse.Selected) { RectD bRect = BPaintFunctions.Get_Border_Points(currEllipse); _Svg.Children.Add(new rect { x = bRect.x, y = bRect.y, width = bRect.width, height = bRect.height, fill = "none", stroke = "magenta", stroke_width = 1, style = "opacity:0.7", }); } line ellipseAuxiliaryLine1 = new line() { x1 = currEllipse.Position.x, y1 = currEllipse.Position.y, x2 = currEllipse.pt2.x, y2 = currEllipse.pt2.y, stroke = "magenta", stroke_width = 1, style = "opacity:0.7" }; line ellipseAuxiliaryLine2 = new line() { x1 = currEllipse.pt2.x, y1 = currEllipse.pt2.y, x2 = currEllipse.pt3.x, y2 = currEllipse.pt3.y, stroke = "magenta", stroke_width = 1, style = "opacity:0.7" }; line ellipseAuxiliaryLine3 = new line() { x1 = currEllipse.Position.x, y1 = currEllipse.Position.y, x2 = currEllipse.pt3.x, y2 = currEllipse.pt3.y, stroke = "magenta", stroke_width = 1, style = "opacity:0.7" }; _Svg.Children.Add(ellipseAuxiliaryLine1); _Svg.Children.Add(ellipseAuxiliaryLine2); _Svg.Children.Add(ellipseAuxiliaryLine3); } } #endregion #region Drawing all the Selection region vertices foreach (BPaintVertex vertex in currParent.SelectionVerticesList) { circle currVertexCircle = new circle() { cx = vertex.PtD.X, cy = vertex.PtD.Y, r = 5, fill = "none", stroke = vertex.Color, stroke_width = 2, }; _Svg.Children.Add(currVertexCircle); if (vertex.Selected) { RectD p_rect = BPaintFunctions.Get_Border_Points(vertex as BPaintVertex); rect currVertexBoundingRect = new rect { x = p_rect.x, y = p_rect.y, width = p_rect.width, height = p_rect.height, fill = "none", stroke = "magenta", stroke_width = 1, style = "opacity:0.7", }; _Svg.Children.Add(currVertexBoundingRect); } } #endregion #region Drawing all the vertices foreach (BPaintVertex vertex in currParent.VerticesList) { circle currVertexCircle = new circle() { cx = vertex.PtD.X, cy = vertex.PtD.Y, r = 5, fill = "wheat", stroke = vertex.Color, stroke_width = 2, }; _Svg.Children.Add(currVertexCircle); if (vertex.Selected) { RectD p_rect = BPaintFunctions.Get_Border_Points(vertex as BPaintVertex); rect currVertexBoundingRect = new rect { x = p_rect.x, y = p_rect.y, width = p_rect.width, height = p_rect.height, fill = "none", stroke = "magenta", stroke_width = 1, style = "opacity:0.7", }; _Svg.Children.Add(currVertexBoundingRect); } } #endregion }