private void CLB_Fields_ItemCheck(object sender, ItemCheckEventArgs e) { if (!_isLoading) { if (CLB_Fields.SelectedItem == null) { return; } string selFieldStr = CLB_Fields.SelectedItem.ToString(); if (CLB_Fields.GetItemChecked(CLB_Fields.SelectedIndex)) { for (int i = 0; i < legendView_Chart.LegendScheme.BreakNum; i++) { if (legendView_Chart.LegendScheme.LegendBreaks[i].Caption == selFieldStr) { legendView_Chart.LegendScheme.LegendBreaks.RemoveAt(i); break; } } } else { PolygonBreak aPB = new PolygonBreak(); aPB.Caption = selFieldStr; aPB.Color = LegendManage.CreateRandomColors(1)[0]; legendView_Chart.LegendScheme.LegendBreaks.Add(aPB); } legendView_Chart.Refresh(); } }
/// <summary> /// Constructor /// </summary> /// <param name="aPGB"></param> public PolygonShapeSet(PolygonBreak aPGB) { m_Color = aPGB.Color; m_OutlineColor = aPGB.OutlineColor; m_DrawOutline = aPGB.DrawOutline; m_DrawFill = aPGB.DrawFill; m_DrawPolygon = aPGB.DrawShape; m_OutlineSize = aPGB.OutlineSize; _usingHatchStyle = aPGB.UsingHatchStyle; _style = aPGB.Style; _backColor = aPGB.BackColor; }
/// <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); }
private void AddLegend(ref XmlDocument doc, XmlElement parent, ColorBreak aLegend, ShapeTypes shapeType) { XmlElement legend = doc.CreateElement("Legend"); XmlAttribute color = doc.CreateAttribute("Color"); color.InnerText = ColorTranslator.ToHtml(aLegend.Color); legend.Attributes.Append(color); XmlAttribute legendType = doc.CreateAttribute("LegendType"); XmlAttribute size; XmlAttribute style; XmlAttribute outlineColor; XmlAttribute drawOutline; XmlAttribute drawFill; legendType.InnerText = aLegend.BreakType.ToString(); switch (aLegend.BreakType) { case BreakTypes.PointBreak: PointBreak aPB = (PointBreak)aLegend; outlineColor = doc.CreateAttribute("OutlineColor"); size = doc.CreateAttribute("Size"); style = doc.CreateAttribute("Style"); drawOutline = doc.CreateAttribute("DrawOutline"); drawFill = doc.CreateAttribute("DrawFill"); XmlAttribute markerType = doc.CreateAttribute("MarkerType"); XmlAttribute fontName = doc.CreateAttribute("FontName"); XmlAttribute charIndex = doc.CreateAttribute("CharIndex"); XmlAttribute imagePath = doc.CreateAttribute("ImagePath"); XmlAttribute angle = doc.CreateAttribute("Angle"); //legendType.InnerText = "PointBreak"; outlineColor.InnerText = ColorTranslator.ToHtml(aPB.OutlineColor); size.InnerText = aPB.Size.ToString(); style.InnerText = Enum.GetName(typeof(PointStyle), aPB.Style); drawOutline.InnerText = aPB.DrawOutline.ToString(); drawFill.InnerText = aPB.DrawFill.ToString(); markerType.InnerText = aPB.MarkerType.ToString(); fontName.InnerText = aPB.FontName; charIndex.InnerText = aPB.CharIndex.ToString(); imagePath.InnerText = aPB.ImagePath; angle.InnerText = aPB.Angle.ToString(); legend.Attributes.Append(legendType); legend.Attributes.Append(outlineColor); legend.Attributes.Append(size); legend.Attributes.Append(style); legend.Attributes.Append(drawOutline); legend.Attributes.Append(drawFill); legend.Attributes.Append(markerType); legend.Attributes.Append(fontName); legend.Attributes.Append(charIndex); legend.Attributes.Append(imagePath); legend.Attributes.Append(angle); break; case BreakTypes.LabelBreak: LabelBreak aLB = (LabelBreak)aLegend; XmlAttribute text = doc.CreateAttribute("Text"); angle = doc.CreateAttribute("Angle"); fontName = doc.CreateAttribute("FontName"); XmlAttribute fontSize = doc.CreateAttribute("FontSize"); XmlAttribute fontBold = doc.CreateAttribute("FontBold"); XmlAttribute yShift = doc.CreateAttribute("YShift"); //legendType.InnerText = "LabelBreak"; text.InnerText = aLB.Text; angle.InnerText = aLB.Angle.ToString(); fontName.InnerText = aLB.Font.Name; fontSize.InnerText = aLB.Font.Size.ToString(); fontBold.InnerText = aLB.Font.Bold.ToString(); yShift.InnerText = aLB.YShift.ToString(); legend.Attributes.Append(legendType); legend.Attributes.Append(text); legend.Attributes.Append(angle); legend.Attributes.Append(fontName); legend.Attributes.Append(fontSize); legend.Attributes.Append(fontBold); legend.Attributes.Append(yShift); break; case BreakTypes.ChartBreak: ChartBreak aChB = (ChartBreak)aLegend; XmlAttribute shapeIndex = doc.CreateAttribute("ShapeIndex"); XmlAttribute chartType = doc.CreateAttribute("ChartType"); XmlAttribute chartData = doc.CreateAttribute("ChartData"); XmlAttribute xShift = doc.CreateAttribute("XShift"); yShift = doc.CreateAttribute("YShift"); shapeIndex.InnerText = aChB.ShapeIndex.ToString(); //legendType.InnerText = "ChartBreak"; chartType.InnerText = aChB.ChartType.ToString(); string cdata = ""; for (int i = 0; i < aChB.ItemNum; i++) { if (i == 0) { cdata = aChB.ChartData[i].ToString(); } else { cdata += "," + aChB.ChartData[i].ToString(); } } chartData.InnerText = cdata; xShift.InnerText = aChB.XShift.ToString(); yShift.InnerText = aChB.YShift.ToString(); legend.Attributes.Append(legendType); legend.Attributes.Append(shapeIndex); legend.Attributes.Append(chartType); legend.Attributes.Append(chartData); legend.Attributes.Append(xShift); legend.Attributes.Append(yShift); break; case BreakTypes.VectorBreak: //legendType.InnerText = "VectorBreak"; legend.Attributes.Append(legendType); break; case BreakTypes.PolylineBreak: PolyLineBreak aPLB = (PolyLineBreak)aLegend; size = doc.CreateAttribute("Size"); style = doc.CreateAttribute("Style"); XmlAttribute drawSymbol = doc.CreateAttribute("DrawSymbol"); XmlAttribute symbolSize = doc.CreateAttribute("SymbolSize"); XmlAttribute symbolStyle = doc.CreateAttribute("SymbolStyle"); XmlAttribute symbolColor = doc.CreateAttribute("SymbolColor"); XmlAttribute symbolInterval = doc.CreateAttribute("SymbolInterval"); //legendType.InnerText = "PolylineBreak"; size.InnerText = aPLB.Size.ToString(); style.InnerText = Enum.GetName(typeof(LineStyles), aPLB.Style); drawSymbol.InnerText = aPLB.DrawSymbol.ToString(); symbolSize.InnerText = aPLB.SymbolSize.ToString(); symbolStyle.InnerText = aPLB.SymbolStyle.ToString(); symbolColor.InnerText = ColorTranslator.ToHtml(aPLB.SymbolColor); symbolInterval.InnerText = aPLB.SymbolInterval.ToString(); legend.Attributes.Append(legendType); legend.Attributes.Append(size); legend.Attributes.Append(style); legend.Attributes.Append(drawSymbol); legend.Attributes.Append(symbolSize); legend.Attributes.Append(symbolStyle); legend.Attributes.Append(symbolColor); legend.Attributes.Append(symbolInterval); break; case BreakTypes.PolygonBreak: PolygonBreak aPGB = (PolygonBreak)aLegend; outlineColor = doc.CreateAttribute("OutlineColor"); drawOutline = doc.CreateAttribute("DrawOutline"); drawFill = doc.CreateAttribute("DrawFill"); XmlAttribute outlineSize = doc.CreateAttribute("OutlineSize"); XmlAttribute usingHatchStyle = doc.CreateAttribute("UsingHatchStyle"); style = doc.CreateAttribute("Style"); XmlAttribute backColor = doc.CreateAttribute("BackColor"); //XmlAttribute transparencyPer = doc.CreateAttribute("TransparencyPercent"); XmlAttribute isMaskout = doc.CreateAttribute("IsMaskout"); //legendType.InnerText = "PolygonBreak"; outlineColor.InnerText = ColorTranslator.ToHtml(aPGB.OutlineColor); drawOutline.InnerText = aPGB.DrawOutline.ToString(); drawFill.InnerText = aPGB.DrawFill.ToString(); outlineSize.InnerText = aPGB.OutlineSize.ToString(); usingHatchStyle.InnerText = aPGB.UsingHatchStyle.ToString(); style.InnerText = aPGB.Style.ToString(); backColor.InnerText = ColorTranslator.ToHtml(aPGB.BackColor); //transparencyPer.InnerText = aPGB.TransparencyPercent.ToString(); isMaskout.InnerText = aPGB.IsMaskout.ToString(); legend.Attributes.Append(legendType); legend.Attributes.Append(outlineColor); legend.Attributes.Append(drawOutline); legend.Attributes.Append(drawFill); legend.Attributes.Append(outlineSize); legend.Attributes.Append(usingHatchStyle); legend.Attributes.Append(style); legend.Attributes.Append(backColor); //legend.Attributes.Append(transparencyPer); legend.Attributes.Append(isMaskout); break; } parent.AppendChild(legend); }