public void Generate_SVG() { _Svg = new svg { id = "svgDoughnutChart", width = ComponentSettings.radius_2_Times, height = ComponentSettings.radius_2_Times, xmlns = "http://www.w3.org/2000/svg", }; _Svg.Children.Add(new rect { width = ComponentSettings.radius_2_Times, height = ComponentSettings.radius_2_Times, fill = ComponentSettings.BG_Color, stroke = "blue", stroke_width = ComponentSettings.radius_Origin * 0.01 }); _Svg.Children.Add(new circle { cx = 0, cy = 0, r = ComponentSettings.radius_BigCircle, fill = ComponentSettings.BigCircle_Color, transform = "translate(" + ComponentSettings.radius_Origin + "," + ComponentSettings.radius_Origin + ")", }); _Svg.Children.Add(new circle { cx = 0, cy = 0, r = ComponentSettings.radius_SmallCircle, fill = ComponentSettings.BG_Color, transform = "translate(" + ComponentSettings.radius_Origin + "," + ComponentSettings.radius_Origin + ")", }); _Svg.Children.Add(new text { content = ActualValue + "%", fill = GetColor(), font_size = 35, text_anchor = "middle", dominant_baseline = "middle", transform_origin = "center", font_weight = "bold", transform = "translate(" + ComponentSettings.radius_Origin + "," + ComponentSettings.radius_Origin + ")", }); _Svg.Children.Add(drawGauge()); }
public void Generate_SVG() { _Svg = new svg { id = "svgPaint", width = par_width, height = par_height, xmlns = "http://www.w3.org/2000/svg", }; _Svg.Children.Add(new rect { width = par_width, height = par_height, fill = "wheat", stroke = "red", stroke_width = 1, }); foreach (var item in (parent as CompBlazorPaint).ObjectsList.OrderBy(x => x.SequenceNumber)) { switch (item.ObjectType) { case BPaintOpbjectType.HandDraw: _Svg.Children.Add(drawPath(item as BPaintHandDraw)); if (item.Selected) { MyPointRect p_rect = BPaintFunctions.Get_Border_Points(item as BPaintHandDraw); _Svg.Children.Add(new rect { x = p_rect.x, y = p_rect.y, width = p_rect.width, height = p_rect.height, fill = "none", stroke = "red", stroke_width = 1, style = "opacity:0.2", }); } break; case BPaintOpbjectType.Line: BPaintLine currLine = item as BPaintLine; _Svg.Children.Add(drawLine(currLine)); if (item.Selected) { circle c1 = new circle() { cx = currLine.StartPosition.x + currLine.PositionChange.x, cy = currLine.StartPosition.y + currLine.PositionChange.y, r = currLine.width * 1.5, fill = "wheat", stroke = currLine.Color, stroke_width = 2, }; if (currLine.Scale.x != 0 || currLine.Scale.y != 0) { c1.transform = "scale(" + currLine.Scale.x + "," + currLine.Scale.y + ")"; } _Svg.Children.Add(c1); circle c2 = new circle() { cx = currLine.end.x + currLine.PositionChange.x, cy = currLine.end.y + currLine.PositionChange.y, r = currLine.width * 1.5, fill = "wheat", stroke = currLine.Color, stroke_width = 2, }; if (currLine.Scale.x != 0 || currLine.Scale.y != 0) { c2.transform = "scale(" + currLine.Scale.x + "," + currLine.Scale.y + ")"; } _Svg.Children.Add(c2); MyPointRect p_rect = BPaintFunctions.Get_Border_Points(item as BPaintLine); _Svg.Children.Add(new rect { x = p_rect.x, y = p_rect.y, width = p_rect.width, height = p_rect.height, fill = "none", stroke = "red", stroke_width = 1, style = "opacity:0.2", }); } break; default: break; } } }
public void Generate_Clock_SVG() { _Svg = new svg { id = "svgclock", width = ClockSettings.radius_2_Times, height = ClockSettings.radius_2_Times, xmlns = "http://www.w3.org/2000/svg", }; defs _defs1 = new defs(); radialGradient _radialGradient = new radialGradient { id = "grad1", //cx = "50%", //cy = "50%", r = "53%", //fx = "50%", //fy = "50%", fr = "50%", }; _radialGradient.Children.Add(new stop { stop_color = "blue", offset = "0", }); _radialGradient.Children.Add(new stop { stop_color = "LightSkyBlue", offset = "1", }); _defs1.Children.Add(_radialGradient); radialGradient _radialGradient2 = new radialGradient { id = "grad2", //cx = "50%", //cy = "50%", r = "55%", //fx = "50%", //fy = "50%", fr = "44%", }; _radialGradient2.Children.Add(new stop { stop_color = "blue", offset = "0", }); _radialGradient2.Children.Add(new stop { stop_color = "wheat", offset = "1", stop_opacity = "0.8", }); _defs1.Children.Add(_radialGradient2); radialGradient _radialGradient3 = new radialGradient { id = "grad3", //cx = "50%", //cy = "50%", //r = "55%", //fx = "50%", //fy = "50%", //fr = "44%", }; _radialGradient3.Children.Add(new stop { stop_color = "wheat", offset = "0", }); _radialGradient3.Children.Add(new stop { stop_color = "DarkSlateBlue", offset = "1", }); _defs1.Children.Add(_radialGradient3); radialGradient _radialGradient4 = new radialGradient { id = "grad4", //cx = "50%", //cy = "50%", //r = "55%", //fx = "50%", //fy = "50%", //fr = "44%", }; _radialGradient4.Children.Add(new stop { stop_color = "white", offset = "0", }); _radialGradient4.Children.Add(new stop { stop_color = "lightblue", offset = "1", }); _defs1.Children.Add(_radialGradient4); radialGradient _radialGradient5 = new radialGradient { id = "grad5", //cx = "50%", //cy = "50%", //r = "55%", //fx = "50%", //fy = "50%", //fr = "44%", }; _radialGradient5.Children.Add(new stop { stop_color = "white", offset = "0", }); _radialGradient5.Children.Add(new stop { stop_color = "yellow", offset = "1", }); _defs1.Children.Add(_radialGradient5); radialGradient _radialGradient6 = new radialGradient { id = "grad6", //cx = "50%", //cy = "50%", //r = "55%", //fx = "50%", //fy = "50%", //fr = "44%", }; _radialGradient6.Children.Add(new stop { stop_color = "white", offset = "0", }); _radialGradient6.Children.Add(new stop { stop_color = "green", offset = "1", }); _defs1.Children.Add(_radialGradient6); _Svg.Children.Add(_defs1); _Svg.Children.Add(new rect { width = ClockSettings.radius_2_Times, height = ClockSettings.radius_2_Times, fill = "wheat", stroke = "url(#grad1)", stroke_width = ClockSettings.radius_Origin * 0.01 }); image img1 = new image { x = 0, y = 0, width = ClockSettings.radius_Origin * 0.6, height = ClockSettings.radius_Origin * 0.6, href = "content/1.png", opacity = 0, }; img1.Children.Add(new animate() { attributeName = "opacity", attributeType = "xml", from = 0, to = 1, dur = 2, repeatCount = "1", fill = "freeze", }); _Svg.Children.Add(img1); double wh = ClockSettings.radius_Origin * 0.6; double wh2 = wh / 2; double x1 = ClockSettings.radius_2_Times - wh; double y1 = ClockSettings.radius_2_Times - wh; image img2 = new image { x = 0, y = 0, width = wh, height = wh, href = ClockSettings.Image_Url, transform = "translate (" + x1 + "," + 0 + ") rotate(" + 90 + ", " + wh2 + "," + wh2 + ")", }; img2.Children.Add(new animate() { attributeName = "opacity", attributeType = "xml", from = 0, to = 1, dur = 2, repeatCount = "1", fill = "freeze", }); _Svg.Children.Add(img2); image img3 = new image { x = 0, y = 0, width = wh, height = wh, href = ClockSettings.Image_Url, transform = "translate (" + x1 + "," + y1 + ") rotate(" + 180 + ", " + wh2 + "," + wh2 + ")", }; img3.Children.Add(new animate() { attributeName = "opacity", attributeType = "xml", from = 0, to = 1, dur = 2, repeatCount = "1", fill = "freeze", }); _Svg.Children.Add(img3); image img4 = new image { x = 0, y = 0, width = wh, height = wh, href = ClockSettings.Image_Url, transform = "translate (" + 0 + "," + y1 + ") rotate(" + 270 + ", " + wh2 + "," + wh2 + ")", }; img4.Children.Add(new animate() { attributeName = "opacity", attributeType = "xml", from = 0, to = 1, dur = 2, repeatCount = "1", fill = "freeze", }); _Svg.Children.Add(img4); _Svg.Children.Add(new circle { cx = 0, cy = 0, r = ClockSettings.radius_90_Percent, stroke = "url(#grad2)", stroke_width = ClockSettings.radius_Origin * 0.06, fill = "Gainsboro", transform = "translate(" + ClockSettings.radius_Origin + "," + ClockSettings.radius_Origin + ")", }); _Svg.Children.Add(new circle { cx = 0, cy = 0, r = ClockSettings.radius_90_Percent * 0.9, fill = "wheat", transform = "translate(" + ClockSettings.radius_Origin + "," + ClockSettings.radius_Origin + ")", stroke = "DarkSlateBlue", stroke_width = ClockSettings.radius_90_Percent * 0.01, }); _Svg.Children.Add(cmd_Draw_60_Lines()); cmd_drawTime(); _Svg.Children.Add(new circle { cx = 0, cy = 0, r = ClockSettings.radius_90_Percent * 0.085, fill = "url(#grad3)", transform = "translate(" + ClockSettings.radius_Origin + "," + ClockSettings.radius_Origin + ")", }); }
internal static svg CmdCreateDynamicIcon(TreeItem Pardynamic) { svg svg1 = new svg(); svg1.id = Pardynamic.ID.ToString(); svg1.width = Pardynamic.Level * LocalData.IconWithAndHeigth + 10; svg1.height = LocalData.IconWithAndHeigth; g g1 = null; int TmpIconType = -1; #region DetectIconType if (Pardynamic.HasChildren) { //svg1.onclick = BoolOptionsEnum.Yes; if (Pardynamic.IsExpanded) { TmpIconType = 0; } else { TmpIconType = 1; } } else { if (Pardynamic.Level > 1) { if (!Pardynamic.IsLastItemInLevel) { TmpIconType = 2; } else { TmpIconType = 3; } } else { TmpIconType = -1; } } #endregion if (TmpIconType > -1) { #region GetRelevantIcon switch (TmpIconType) { case 0: if (Pardynamic.Level > 1) { if (Pardynamic.IsLastItemInLevel) { g1 = LocalData.IconMinusTop; } else { g1 = LocalData.IconMinusTopBottom; } } else { if (Pardynamic.IsLastItemInLevel) { g1 = LocalData.IconMinus; } else { g1 = LocalData.IconMinusBottom; } } break; case 1: if (Pardynamic.Level > 1) { if (Pardynamic.IsLastItemInLevel) { g1 = LocalData.IconPlusTop; } else { g1 = LocalData.IconPlusTopBottom; } } else { if (Pardynamic.IsLastItemInLevel) { g1 = LocalData.IconPlus; } else { g1 = LocalData.IconPlusBottom; } } break; case 2: g1 = LocalData.IconItem; break; case 3: g1 = LocalData.IconLastItem; break; default: g1 = LocalData.IconMinus; break; } #endregion g1.transform = "translate(" + (Pardynamic.Level * LocalData.IconWithAndHeigth - LocalData.IconWithAndHeigth) + ",0) scale(0.5, 0.5)"; svg1.Children.Add(g1); } #region AddLinesIfNeeds if (Pardynamic.Level > 1) { for (int i = 1; i < Pardynamic.Level - 1; i++) { int k = CmdGetParentIDBySteps(Pardynamic.ID, Pardynamic.Level - i - 1); if (k > 0) { if (LocalData.dynamicList.Any(x => x.ID == k)) { TreeItem tmpdynamics = LocalData.dynamicList.Single(x => x.ID == k); if (!tmpdynamics.IsLastItemInLevel) { g g2 = LocalData.IconLine; g2.transform = "translate(" + (i * LocalData.IconWithAndHeigth) + ",0) scale(0.5, 0.5)"; svg1.Children.Add(g2); } } } else { break; } } } #endregion return(svg1); }
internal static svg CmdCreateDynamicIcon(List <TreeItem> SourceList, TreeItem Pardynamic) { svg svg1 = new svg { id = Pardynamic.ID.ToString(), //width = Pardynamic.Level * LocalData.VisualParams.TreeIconBoxSize, //height = LocalData.VisualParams.TreeIconBoxSize style = "width:" + Pardynamic.Level * LocalData.VisualParams.TreeIconBoxSize + "px;height:" + LocalData.VisualParams.TreeIconBoxSize + "px;" }; g g1 = null; int TmpIconType = -1; #region DetectIconType if (Pardynamic.HasChildren) { if (Pardynamic.IsExpanded) { TmpIconType = 0; } else { TmpIconType = 1; } } else { if (Pardynamic.Level > 1) { if (!Pardynamic.IsLastItemInLevel) { TmpIconType = 2; } else { TmpIconType = 3; } } else { TmpIconType = -1; } } #endregion if (TmpIconType > -1) { #region GetRelevantIcon switch (TmpIconType) { case 0: if (Pardynamic.Level > 1) { if (Pardynamic.IsLastItemInLevel) { g1 = LocalData.IconMinusTop; } else { g1 = LocalData.IconMinusTopBottom; } } else { if (Pardynamic.IsLastItemInLevel) { g1 = LocalData.IconMinus; } else { g1 = LocalData.IconMinusBottom; } } break; case 1: if (Pardynamic.Level > 1) { if (Pardynamic.IsLastItemInLevel) { g1 = LocalData.IconPlusTop; } else { g1 = LocalData.IconPlusTopBottom; } } else { if (Pardynamic.IsLastItemInLevel) { g1 = LocalData.IconPlus; } else { g1 = LocalData.IconPlusBottom; } } break; case 2: g1 = LocalData.IconItem; break; case 3: g1 = LocalData.IconLastItem; break; default: g1 = LocalData.IconMinus; break; } #endregion g1.transform = "translate(" + (Pardynamic.Level * LocalData.VisualParams.TreeIconBoxSize - LocalData.VisualParams.TreeIconBoxSize) + ",0)"; svg1.Children.Add(g1); } #region AddLinesIfNeeds if (Pardynamic.Level > 1) { for (int i = 1; i < Pardynamic.Level - 1; i++) { int k = CmdGetParentIDBySteps(SourceList, Pardynamic.ID, Pardynamic.Level - i - 1); if (k > 0) { if (SourceList.Any(x => x.ID == k)) { TreeItem tmpdynamics = SourceList.Single(x => x.ID == k); if (!tmpdynamics.IsLastItemInLevel) { g g2 = LocalData.IconLine; g2.transform = "translate(" + (i * LocalData.VisualParams.TreeIconBoxSize) + ",0)"; svg1.Children.Add(g2); } } } else { break; } } } #endregion return(svg1); }
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 }
internal static svg Cmd_Create_Dynamic_Icon(TreeItem Par_dynamic) { svg svg1 = new svg(); svg1.id = Par_dynamic.Tree_ID.ToString(); svg1.width = Par_dynamic.Tree_Level * LocalData.My_Tree_Icon_With_And_Heigth + 10; svg1.height = LocalData.My_Tree_Icon_With_And_Heigth; // svg1.onclick = "aaa"; g g1 = null; int Tmp_IconType = -1; #region Detect_Icon_Type if (Par_dynamic.Tree_HasChildren) { if (Par_dynamic.Tree_IsExpanded) { Tmp_IconType = 0; } else { Tmp_IconType = 1; } } else { if (Par_dynamic.Tree_Level > 1) { if (!Par_dynamic.Tree_IsLastItemInLevel) { Tmp_IconType = 2; } else { Tmp_IconType = 3; } } else { Tmp_IconType = -1; } } #endregion if (Tmp_IconType > -1) { #region Get_Relevant_Icon switch (Tmp_IconType) { case 0: if (Par_dynamic.Tree_Level > 1) { if (Par_dynamic.Tree_IsLastItemInLevel) { g1 = LocalData.Tree_Icon_Minus_Top; } else { g1 = LocalData.Tree_Icon_Minus_Top_Bottom; } } else { if (Par_dynamic.Tree_IsLastItemInLevel) { g1 = LocalData.Tree_Icon_Minus; } else { g1 = LocalData.Tree_Icon_Minus_Bottom; } } break; case 1: if (Par_dynamic.Tree_Level > 1) { if (Par_dynamic.Tree_IsLastItemInLevel) { g1 = LocalData.Tree_Icon_Plus_Top; } else { g1 = LocalData.Tree_Icon_Plus_Top_Bottom; } } else { if (Par_dynamic.Tree_IsLastItemInLevel) { g1 = LocalData.Tree_Icon_Plus; } else { g1 = LocalData.Tree_Icon_Plus_Bottom; } } break; case 2: g1 = LocalData.Tree_Icon_Item; break; case 3: g1 = LocalData.Tree_Icon_LastItem; break; default: g1 = LocalData.Tree_Icon_Minus; break; } #endregion g1.transform = "translate(" + (Par_dynamic.Tree_Level * LocalData.My_Tree_Icon_With_And_Heigth - LocalData.My_Tree_Icon_With_And_Heigth) + ",0) scale(0.5, 0.5)"; svg1.Children.Add(g1); } #region Add_Lines_If_Needs if (Par_dynamic.Tree_Level > 1) { for (int i = 1; i < Par_dynamic.Tree_Level - 1; i++) { int k = Cmd_Get_ParentID_By_Steps(Par_dynamic.Tree_ID, Par_dynamic.Tree_Level - i - 1); if (k > 0) { if (LocalData.dynamic_List.Any(x => x.Tree_ID == k)) { TreeItem tmp_dynamics = LocalData.dynamic_List.Single(x => x.Tree_ID == k); if (!tmp_dynamics.Tree_IsLastItemInLevel) { g g2 = LocalData.Tree_Icon_Line; g2.transform = "translate(" + (i * LocalData.My_Tree_Icon_With_And_Heigth) + ",0) scale(0.5, 0.5)"; svg1.Children.Add(g2); } } } else { break; } } } #endregion return(svg1); }