/// <summary> /// Paint graphics /// </summary> /// <param name="g">graphics</param> /// <param name="pageLocation">page location</param> /// <param name="zoom">zoom</param> public void PaintGraphics(Graphics g, PointF pageLocation, float zoom) { switch (_graphic.Shape.ShapeType) { case ShapeTypes.Point: PointD dPoint = _graphic.Shape.GetPoints()[0]; PointF aPoint = PageToScreen((float)dPoint.X, (float)dPoint.Y, pageLocation, zoom); if (_graphic.Legend.GetType() == typeof(PointBreak)) { PointBreak aPB = (PointBreak)((PointBreak)_graphic.Legend).Clone(); float size = aPB.Size; aPB.Size = aPB.Size * zoom; //PointF aPoint = new PointF(this.Left + (float)this.Width / 2, this.Top + (float)this.Height / 2); g.SmoothingMode = SmoothingMode.HighQuality; Draw.DrawPoint(aPoint, aPB, g); aPB.Size = size; g.SmoothingMode = _smoothingMode; } else if (_graphic.Legend.GetType() == typeof(LabelBreak)) { LabelBreak aLB = (LabelBreak)((LabelBreak)_graphic.Legend).Clone(); Font font = (Font)aLB.Font.Clone(); aLB.Font = new Font(font.Name, font.Size * zoom, font.Style); Rectangle rect = new Rectangle(); //Draw.DrawLabelPoint(new PointF(this.Left + (float)this.Width / 2, this.Top + (float)this.Height / 2), aLB, g, ref rect); Draw.DrawLabelPoint(aPoint, aLB, g, ref rect); aLB.Font = font; //g.DrawString(aLB.Text, aLB.Font, new SolidBrush(aLB.Color), new PointF(0, 0)); } break; case ShapeTypes.WindArraw: dPoint = _graphic.Shape.GetPoints()[0]; aPoint = PageToScreen((float)dPoint.X, (float)dPoint.Y, pageLocation, zoom); WindArraw aArraw = (WindArraw)_graphic.Shape; VectorBreak aVB = (VectorBreak)_graphic.Legend; Draw.DrawArraw(aVB.Color, aPoint, aArraw, g, aVB.Zoom * zoom); Font drawFont = new Font("Arial", 8 * zoom); g.DrawString(aArraw.length.ToString(), drawFont, new SolidBrush(aVB.Color), aPoint.X, aPoint.Y); break; case ShapeTypes.Polyline: case ShapeTypes.Polygon: case ShapeTypes.Rectangle: case ShapeTypes.Circle: case ShapeTypes.CurveLine: case ShapeTypes.CurvePolygon: case ShapeTypes.Ellipse: List <PointD> pList = _graphic.Shape.GetPoints(); PointF[] points = new PointF[pList.Count]; for (int i = 0; i < pList.Count; i++) { points[i] = PageToScreen((float)pList[i].X, (float)pList[i].Y, pageLocation, zoom); } switch (_graphic.Shape.ShapeType) { case ShapeTypes.Polyline: PolyLineBreak aPLB = (PolyLineBreak)((PolyLineBreak)_graphic.Legend).Clone(); float size = aPLB.Size; aPLB.Size = size * zoom; Draw.DrawPolyline(points, (PolyLineBreak)_graphic.Legend, g); aPLB.Size = size; break; case ShapeTypes.Polygon: case ShapeTypes.Rectangle: PolygonBreak aPGB = (PolygonBreak)((PolygonBreak)_graphic.Legend).Clone(); size = aPGB.OutlineSize; aPGB.OutlineSize = size * zoom; Draw.DrawPolygon(points, (PolygonBreak)_graphic.Legend, g); aPGB.OutlineSize = size; break; case ShapeTypes.Circle: aPGB = (PolygonBreak)((PolygonBreak)_graphic.Legend).Clone(); size = aPGB.OutlineSize; aPGB.OutlineSize = size * zoom; Draw.DrawCircle(points, (PolygonBreak)_graphic.Legend, g); aPGB.OutlineSize = size; break; case ShapeTypes.CurveLine: aPLB = (PolyLineBreak)((PolyLineBreak)_graphic.Legend).Clone(); size = aPLB.Size; aPLB.Size = size * zoom; Draw.DrawCurveLine(points, (PolyLineBreak)_graphic.Legend, g); aPLB.Size = size; break; case ShapeTypes.CurvePolygon: aPGB = (PolygonBreak)((PolygonBreak)_graphic.Legend).Clone(); size = aPGB.OutlineSize; aPGB.OutlineSize = size * zoom; Draw.DrawCurvePolygon(points, (PolygonBreak)_graphic.Legend, g); aPGB.OutlineSize = size; break; case ShapeTypes.Ellipse: aPGB = (PolygonBreak)((PolygonBreak)_graphic.Legend).Clone(); size = aPGB.OutlineSize; aPGB.OutlineSize = size * zoom; Draw.DrawEllipse(points, (PolygonBreak)_graphic.Legend, g); aPGB.OutlineSize = size; break; } break; } }
private ColorBreak LoadLegend(XmlNode legendNode, ShapeTypes shapeType) { ColorBreak legend = new ColorBreak(); try { Color color = ColorTranslator.FromHtml(legendNode.Attributes["Color"].InnerText); string legendType = legendNode.Attributes["LegendType"].InnerText; BreakTypes breakType = (BreakTypes)Enum.Parse(typeof(BreakTypes), legendType); switch (breakType) { case BreakTypes.PointBreak: PointBreak aPB = new PointBreak(); try { aPB.Color = color; aPB.DrawFill = bool.Parse(legendNode.Attributes["DrawFill"].InnerText); aPB.DrawOutline = bool.Parse(legendNode.Attributes["DrawOutline"].InnerText); aPB.OutlineColor = ColorTranslator.FromHtml(legendNode.Attributes["OutlineColor"].InnerText); aPB.Size = float.Parse(legendNode.Attributes["Size"].InnerText); aPB.Style = (PointStyle)Enum.Parse(typeof(PointStyle), legendNode.Attributes["Style"].InnerText); aPB.MarkerType = (MarkerType)Enum.Parse(typeof(MarkerType), legendNode.Attributes["MarkerType"].InnerText, true); aPB.FontName = legendNode.Attributes["FontName"].InnerText; aPB.CharIndex = int.Parse(legendNode.Attributes["CharIndex"].InnerText); aPB.ImagePath = legendNode.Attributes["ImagePath"].InnerText; aPB.Angle = float.Parse(legendNode.Attributes["Angle"].InnerText); } catch { } finally { legend = aPB; } break; case BreakTypes.LabelBreak: LabelBreak aLB = new LabelBreak(); try { aLB.Color = color; aLB.Angle = float.Parse(legendNode.Attributes["Angle"].InnerText); aLB.Text = legendNode.Attributes["Text"].InnerText; string fontName = legendNode.Attributes["FontName"].InnerText; float fontSize = float.Parse(legendNode.Attributes["FontSize"].InnerText); bool fontBold = bool.Parse(legendNode.Attributes["FontBold"].InnerText); if (fontBold) { aLB.Font = new Font(fontName, fontSize, FontStyle.Bold); } else { aLB.Font = new Font(fontName, fontSize); } aLB.YShift = float.Parse(legendNode.Attributes["YShift"].InnerText); } catch { } finally { legend = aLB; } break; case BreakTypes.ChartBreak: ChartBreak aChB = new ChartBreak(ChartTypes.BarChart); try { ChartTypes chartType = (ChartTypes)Enum.Parse(typeof(ChartTypes), legendNode.Attributes["ChartType"].InnerText); aChB = new ChartBreak(chartType); aChB.ShapeIndex = int.Parse(legendNode.Attributes["ShapeIndex"].InnerText); List <float> cData = new List <float>(); string[] cDataStr = legendNode.Attributes["ChartData"].InnerText.Split(','); for (int i = 0; i < cDataStr.Length; i++) { cData.Add(float.Parse(cDataStr[i])); } aChB.ChartData = cData; aChB.XShift = int.Parse(legendNode.Attributes["XShift"].InnerText); aChB.YShift = int.Parse(legendNode.Attributes["YShift"].InnerText); } catch { } finally { legend = aChB; } break; case BreakTypes.VectorBreak: VectorBreak aVB = new VectorBreak(); try { aVB.Color = color; } catch { } finally { legend = aVB; } break; case BreakTypes.PolylineBreak: PolyLineBreak aPLB = new PolyLineBreak(); try { aPLB.Color = color; aPLB.Size = Convert.ToSingle(legendNode.Attributes["Size"].InnerText); aPLB.Style = (LineStyles)Enum.Parse(typeof(LineStyles), legendNode.Attributes["Style"].InnerText, true); aPLB.DrawSymbol = bool.Parse(legendNode.Attributes["DrawSymbol"].InnerText); aPLB.SymbolSize = Single.Parse(legendNode.Attributes["SymbolSize"].InnerText); aPLB.SymbolStyle = (PointStyle)Enum.Parse(typeof(PointStyle), legendNode.Attributes["SymbolStyle"].InnerText, true); aPLB.SymbolColor = ColorTranslator.FromHtml(legendNode.Attributes["SymbolColor"].InnerText); aPLB.SymbolInterval = int.Parse(legendNode.Attributes["SymbolInterval"].InnerText); } catch { } finally { legend = aPLB; } break; case BreakTypes.PolygonBreak: PolygonBreak aPGB = new PolygonBreak(); try { aPGB.Color = color; aPGB.DrawFill = Convert.ToBoolean(legendNode.Attributes["DrawFill"].InnerText); aPGB.DrawOutline = Convert.ToBoolean(legendNode.Attributes["DrawOutline"].InnerText); aPGB.OutlineSize = Convert.ToSingle(legendNode.Attributes["OutlineSize"].InnerText); aPGB.OutlineColor = ColorTranslator.FromHtml(legendNode.Attributes["OutlineColor"].InnerText); aPGB.UsingHatchStyle = bool.Parse(legendNode.Attributes["UsingHatchStyle"].InnerText); aPGB.Style = (HatchStyle)Enum.Parse(typeof(HatchStyle), legendNode.Attributes["Style"].InnerText, true); aPGB.BackColor = ColorTranslator.FromHtml(legendNode.Attributes["BackColor"].InnerText); //aPGB.TransparencyPercent = int.Parse(legendNode.Attributes["TransparencyPercent"].InnerText); aPGB.IsMaskout = bool.Parse(legendNode.Attributes["IsMaskout"].InnerText); } catch { } { legend = aPGB; } break; } } catch { } return(legend); }