private void DrawBreaks(Graphics g, int sHeight) { Point sP = new Point(0, sHeight + _breakHeight); for (int i = 0; i < _legendScheme.BreakNum; i++) { if (sP.Y + _breakHeight > _breakHeight) { ColorBreak aCB = _legendScheme.LegendBreaks[i]; Rectangle rect = new Rectangle(sP.X, sP.Y, _symbolWidth, _breakHeight); bool selected = _selectedRows.Contains(i); DrawBreakSymbol(aCB, _legendScheme.ShapeType, rect, selected, g); sP.Y += _breakHeight; } else if (sP.Y > this.Height) { break; } else { sP.Y += _breakHeight; continue; } } }
private ColorBreak GetBreakByPosition(int x, int y, ref int curTop) { ColorBreak aCB = null; int idx = GetBreakIndexByPosition(x, y, ref curTop); if (idx >= 0) { aCB = _legendScheme.LegendBreaks[idx]; } return(aCB); }
/// <summary> /// Clone /// </summary> /// <returns>object</returns> public virtual object Clone() { //return MemberwiseClone(); ColorBreak aCB = new ColorBreak(); aCB.Caption = _caption; aCB.Color = _color; aCB.DrawShape = _drawShape; aCB.EndValue = _endValue; aCB.IsNoData = _isNoData; aCB.StartValue = _startValue; return(aCB); }
private void ShowSymbolSetForm(ColorBreak aCB) { switch (_legendScheme.ShapeType) { case ShapeTypes.Point: PointBreak aPB = (PointBreak)aCB; if (!_frmPointSymbolSet.Visible) { _frmPointSymbolSet = new frmPointSymbolSet(this); _frmPointSymbolSet.Show(this); } _frmPointSymbolSet.PointBreak = aPB; break; case ShapeTypes.Polyline: case ShapeTypes.PolylineZ: PolyLineBreak aPLB = (PolyLineBreak)aCB; if (!_frmPolylineSymbolSet.Visible) { _frmPolylineSymbolSet = new frmPolylineSymbolSet(this); _frmPolylineSymbolSet.Show(this); } _frmPolylineSymbolSet.PolylineBreak = aPLB; break; case ShapeTypes.Polygon: PolygonBreak aPGB = (PolygonBreak)aCB; if (!_frmPolygonSymbolSet.Visible) { _frmPolygonSymbolSet = new frmPolygonSymbolSet(this); _frmPolygonSymbolSet.Show(this); } _frmPolygonSymbolSet.PolygonBreak = aPGB; break; case ShapeTypes.Image: if (!_frmColorSymbolSet.Visible) { _frmColorSymbolSet = new frmColorSymbolSet(this); _frmColorSymbolSet.Show(this); } _frmColorSymbolSet.ColorBreak = aCB; break; } }
/// <summary> /// Import legend scheme from an image color palette file /// </summary> /// <param name="aFile">file path</param> public void ImportFromPaletteFile_Unique(string aFile) { StreamReader sr = new StreamReader(aFile); this.ShapeType = ShapeTypes.Image; this.LegendType = LegendType.UniqueValue; this.LegendBreaks = new List <ColorBreak>(); ColorBreak aCB = new ColorBreak(); string[] dataArray; int lastNonEmpty, i; sr.ReadLine(); string aLine = sr.ReadLine(); while (aLine != null) { dataArray = aLine.Split(); lastNonEmpty = -1; List <int> dataList = new List <int>(); for (i = 0; i < dataArray.Length; i++) { if (dataArray[i] != string.Empty) { lastNonEmpty++; dataList.Add(int.Parse(dataArray[i])); } } Color aColor = Color.FromArgb(255, dataList[3], dataList[2], dataList[1]); aCB = new ColorBreak(); aCB.Color = aColor; aCB.StartValue = dataList[0]; aCB.EndValue = dataList[0]; aCB.Caption = aCB.StartValue.ToString(); this.LegendBreaks.Add(aCB); aLine = sr.ReadLine(); } sr.Close(); }
/// <summary> /// Import legend scheme from an image color palette file /// </summary> /// <param name="aFile">file path</param> public void ImportFromPaletteFile_Graduated(string aFile) { StreamReader sr = new StreamReader(aFile); this.ShapeType = ShapeTypes.Image; this.LegendType = LegendType.GraduatedColor; this.LegendBreaks = new List <ColorBreak>(); List <Color> colorList = new List <Color>(); List <int> values = new List <int>(); ColorBreak aCB = new ColorBreak(); string[] dataArray; int lastNonEmpty, i; sr.ReadLine(); string aLine = sr.ReadLine(); while (aLine != null) { dataArray = aLine.Split(); lastNonEmpty = -1; List <int> dataList = new List <int>(); for (i = 0; i < dataArray.Length; i++) { if (dataArray[i] != string.Empty) { lastNonEmpty++; dataList.Add(int.Parse(dataArray[i])); } } Color aColor = Color.FromArgb(255, dataList[3], dataList[2], dataList[1]); if (colorList.Count == 0) { colorList.Add(aColor); } else { if (!colorList.Contains(aColor)) { aCB = new ColorBreak(); aCB.Color = aColor; aCB.StartValue = values.Min(); aCB.EndValue = values.Max(); if (aCB.StartValue.ToString() == aCB.EndValue.ToString()) { aCB.Caption = aCB.StartValue.ToString(); } else { if (this.LegendBreaks.Count == 0) { aCB.Caption = "< " + aCB.EndValue.ToString(); } else { aCB.Caption = aCB.StartValue.ToString() + " - " + aCB.EndValue.ToString(); } } this.LegendBreaks.Add(aCB); values.Clear(); colorList.Add(aColor); } } values.Add(dataList[0]); aLine = sr.ReadLine(); } sr.Close(); aCB = new ColorBreak(); aCB.Color = colorList[colorList.Count - 1]; aCB.StartValue = values.Min(); aCB.EndValue = values.Max(); aCB.Caption = "> " + aCB.StartValue.ToString(); this.LegendBreaks.Add(aCB); }
private void ImportBreaks(XmlNode parent, bool sameShapeType) { XmlNode breaks = parent.ChildNodes[0]; if (sameShapeType) { switch (ShapeType) { case ShapeTypes.Point: foreach (XmlNode brk in breaks.ChildNodes) { PointBreak aPB = new PointBreak(); try { aPB.Caption = brk.Attributes["Caption"].InnerText; aPB.StartValue = brk.Attributes["StartValue"].InnerText; aPB.EndValue = brk.Attributes["EndValue"].InnerText; aPB.Color = ColorTranslator.FromHtml(brk.Attributes["Color"].InnerText); aPB.DrawShape = Convert.ToBoolean(brk.Attributes["DrawShape"].InnerText); aPB.DrawFill = Convert.ToBoolean(brk.Attributes["DrawFill"].InnerText); aPB.DrawOutline = Convert.ToBoolean(brk.Attributes["DrawOutline"].InnerText); aPB.IsNoData = Convert.ToBoolean(brk.Attributes["IsNoData"].InnerText); aPB.OutlineColor = ColorTranslator.FromHtml(brk.Attributes["OutlineColor"].InnerText); aPB.Size = Convert.ToSingle(brk.Attributes["Size"].InnerText); aPB.Style = (PointStyle)Enum.Parse(typeof(PointStyle), brk.Attributes["Style"].InnerText, true); aPB.MarkerType = (MarkerType)Enum.Parse(typeof(MarkerType), brk.Attributes["MarkerType"].InnerText, true); aPB.FontName = brk.Attributes["FontName"].InnerText; aPB.CharIndex = int.Parse(brk.Attributes["CharIndex"].InnerText); aPB.ImagePath = brk.Attributes["ImagePath"].InnerText; aPB.Angle = float.Parse(brk.Attributes["Angle"].InnerText); } catch { } finally { LegendBreaks.Add(aPB); } } break; case ShapeTypes.Polyline: case ShapeTypes.PolylineZ: foreach (XmlNode brk in breaks.ChildNodes) { PolyLineBreak aPLB = new PolyLineBreak(); try { aPLB.Caption = brk.Attributes["Caption"].InnerText; aPLB.StartValue = brk.Attributes["StartValue"].InnerText; aPLB.EndValue = brk.Attributes["EndValue"].InnerText; aPLB.Color = ColorTranslator.FromHtml(brk.Attributes["Color"].InnerText); aPLB.DrawPolyline = Convert.ToBoolean(brk.Attributes["DrawShape"].InnerText); aPLB.Size = Convert.ToSingle(brk.Attributes["Size"].InnerText); aPLB.Style = (LineStyles)Enum.Parse(typeof(LineStyles), brk.Attributes["Style"].InnerText, true); aPLB.DrawSymbol = bool.Parse(brk.Attributes["DrawSymbol"].InnerText); aPLB.SymbolSize = Single.Parse(brk.Attributes["SymbolSize"].InnerText); aPLB.SymbolStyle = (PointStyle)Enum.Parse(typeof(PointStyle), brk.Attributes["SymbolStyle"].InnerText, true); aPLB.SymbolColor = ColorTranslator.FromHtml(brk.Attributes["SymbolColor"].InnerText); aPLB.SymbolInterval = int.Parse(brk.Attributes["SymbolInterval"].InnerText); } catch { } finally { LegendBreaks.Add(aPLB); } } break; case ShapeTypes.Polygon: foreach (XmlNode brk in breaks.ChildNodes) { PolygonBreak aPGB = new PolygonBreak(); try { aPGB.Caption = brk.Attributes["Caption"].InnerText; aPGB.StartValue = brk.Attributes["StartValue"].InnerText; aPGB.EndValue = brk.Attributes["EndValue"].InnerText; aPGB.Color = ColorTranslator.FromHtml(brk.Attributes["Color"].InnerText); aPGB.DrawShape = Convert.ToBoolean(brk.Attributes["DrawShape"].InnerText); aPGB.DrawFill = Convert.ToBoolean(brk.Attributes["DrawFill"].InnerText); aPGB.DrawOutline = Convert.ToBoolean(brk.Attributes["DrawOutline"].InnerText); aPGB.OutlineSize = Convert.ToSingle(brk.Attributes["OutlineSize"].InnerText); aPGB.OutlineColor = ColorTranslator.FromHtml(brk.Attributes["OutlineColor"].InnerText); aPGB.UsingHatchStyle = bool.Parse(brk.Attributes["UsingHatchStyle"].InnerText); aPGB.Style = (HatchStyle)Enum.Parse(typeof(HatchStyle), brk.Attributes["Style"].InnerText, true); aPGB.BackColor = ColorTranslator.FromHtml(brk.Attributes["BackColor"].InnerText); } catch { } finally { LegendBreaks.Add(aPGB); } } break; case ShapeTypes.Image: foreach (XmlNode brk in breaks.ChildNodes) { ColorBreak aCB = new ColorBreak(); aCB.Caption = brk.Attributes["Caption"].InnerText; aCB.StartValue = double.Parse(brk.Attributes["StartValue"].InnerText); aCB.EndValue = double.Parse(brk.Attributes["EndValue"].InnerText); aCB.Color = ColorTranslator.FromHtml(brk.Attributes["Color"].InnerText); aCB.IsNoData = bool.Parse(brk.Attributes["IsNoData"].InnerText); LegendBreaks.Add(aCB); } break; } } else { switch (ShapeType) { case ShapeTypes.Point: foreach (XmlNode brk in breaks.ChildNodes) { PointBreak aPB = new PointBreak(); aPB.Caption = brk.Attributes["Caption"].InnerText; aPB.StartValue = brk.Attributes["StartValue"].InnerText; aPB.EndValue = brk.Attributes["EndValue"].InnerText; aPB.Color = ColorTranslator.FromHtml(brk.Attributes["Color"].InnerText); aPB.DrawShape = Convert.ToBoolean(brk.Attributes["DrawShape"].InnerText); LegendBreaks.Add(aPB); } break; case ShapeTypes.Polyline: case ShapeTypes.PolylineZ: foreach (XmlNode brk in breaks.ChildNodes) { if (brk.Attributes["Caption"].InnerText != "NoData") { PolyLineBreak aPLB = new PolyLineBreak(); aPLB.Caption = brk.Attributes["Caption"].InnerText; aPLB.StartValue = brk.Attributes["StartValue"].InnerText; aPLB.EndValue = brk.Attributes["EndValue"].InnerText; aPLB.Color = ColorTranslator.FromHtml(brk.Attributes["Color"].InnerText); aPLB.DrawPolyline = Convert.ToBoolean(brk.Attributes["DrawShape"].InnerText); LegendBreaks.Add(aPLB); } } break; case ShapeTypes.Polygon: foreach (XmlNode brk in breaks.ChildNodes) { if (brk.Attributes["Caption"].InnerText != "NoData") { PolygonBreak aPGB = new PolygonBreak(); aPGB.Caption = brk.Attributes["Caption"].InnerText; aPGB.StartValue = Convert.ToDouble(brk.Attributes["StartValue"].InnerText); aPGB.EndValue = Convert.ToDouble(brk.Attributes["EndValue"].InnerText); aPGB.Color = ColorTranslator.FromHtml(brk.Attributes["Color"].InnerText); aPGB.DrawShape = Convert.ToBoolean(brk.Attributes["DrawShape"].InnerText); aPGB.DrawFill = true; LegendBreaks.Add(aPGB); } } break; case ShapeTypes.Image: foreach (XmlNode brk in breaks.ChildNodes) { ColorBreak aCB = new ColorBreak(); aCB.Caption = brk.Attributes["Caption"].InnerText; aCB.StartValue = double.Parse(brk.Attributes["StartValue"].InnerText); aCB.EndValue = double.Parse(brk.Attributes["EndValue"].InnerText); aCB.Color = ColorTranslator.FromHtml(brk.Attributes["Color"].InnerText); LegendBreaks.Add(aCB); } break; } //breakNum = LegendBreaks.Count; } }
/// <summary> /// Override OnMouseDoubleClick event /// </summary> /// <param name="e">MouseEventArgs</param> protected override void OnMouseDoubleClick(MouseEventArgs e) { base.OnMouseDoubleClick(e); if (e.Button == MouseButtons.Left) { if (TB_Editor.Visible) { AfterCellEdit(); } int curTop = 0; int bIdx = GetBreakIndexByPosition(e.X, e.Y, ref curTop); if (bIdx >= 0) { if ((ModifierKeys & Keys.Control) == Keys.Control) { if (_selectedRows.Contains(bIdx)) { _selectedRows.Remove(bIdx); } else { _selectedRows.Add(bIdx); _startRow = bIdx; } } else if ((ModifierKeys & Keys.Shift) == Keys.Shift) { _selectedRows.Clear(); if (_startRow == -1) { _selectedRows.Add(bIdx); } else { if (bIdx > _startRow) { for (int i = _startRow; i <= bIdx; i++) { _selectedRows.Add(i); } } else { for (int i = bIdx; i <= _startRow; i++) { _selectedRows.Add(i); } } } } else { _selectedRows.Clear(); _selectedRows.Add(bIdx); _startRow = bIdx; } ColorBreak aCB = _legendScheme.LegendBreaks[bIdx]; _curBreak = aCB; if (IsInSymbol(e.X)) { ShowSymbolSetForm(aCB); } else if (IsInValue(e.X)) { TB_Editor.Left = _symbolWidth; TB_Editor.Top = curTop; TB_Editor.Width = _valueWidth; TB_Editor.Height = _breakHeight; TB_Editor.Text = aCB.GetValueString(); TB_Editor.Tag = "Value"; TB_Editor.Visible = true; } else if (IsInLabel(e.X)) { if (_legendScheme.LegendType == LegendType.SingleSymbol) { TB_Editor.Left = _symbolWidth; } else { TB_Editor.Left = _symbolWidth + _valueWidth; } TB_Editor.Top = curTop; TB_Editor.Width = _valueWidth; TB_Editor.Height = _breakHeight; TB_Editor.Text = aCB.Caption; TB_Editor.Tag = "Label"; TB_Editor.Visible = true; } } } }
private void DrawBreakSymbol(ColorBreak aCB, ShapeTypes shapeType, Rectangle rect, bool selected, Graphics g) { g.SmoothingMode = SmoothingMode.HighQuality; Single aSize; PointF aP = new Point(0, 0); Single width, height; aP.X = rect.Left + rect.Width / 2; aP.Y = rect.Top + rect.Height / 2; //Draw selected back color if (selected) { g.FillRectangle(Brushes.LightGray, new Rectangle(_symbolWidth, rect.Top, _valueWidth + _labelWidth, rect.Height)); } //Draw symbol switch (shapeType) { case ShapeTypes.Point: case ShapeTypes.PointZ: case ShapeTypes.WindArraw: case ShapeTypes.WindBarb: case ShapeTypes.WeatherSymbol: case ShapeTypes.StationModel: PointBreak aPB = (PointBreak)aCB; aSize = aPB.Size; if (aPB.DrawShape) { //Draw.DrawPoint(aPB.Style, aP, aPB.Color, aPB.OutlineColor, // aPB.Size, aPB.DrawOutline, aPB.DrawFill, g); if (aPB.MarkerType == MarkerType.Character) { TextRenderingHint aTextRendering = g.TextRenderingHint; g.TextRenderingHint = TextRenderingHint.AntiAlias; Draw.DrawPoint(aP, aPB, g); g.TextRenderingHint = aTextRendering; } else { Draw.DrawPoint(aP, aPB, g); } } break; case ShapeTypes.Polyline: case ShapeTypes.PolylineZ: PolyLineBreak aPLB = (PolyLineBreak)aCB; aSize = aPLB.Size; width = rect.Width / 3 * 2; height = rect.Height / 3 * 2; Draw.DrawPolyLineSymbol(aP, width, height, aPLB, g); break; case ShapeTypes.Polygon: PolygonBreak aPGB = (PolygonBreak)aCB; width = rect.Width / 3 * 2; height = rect.Height / 5 * 4; if (aPGB.DrawShape) { //Draw.DrawPolygonSymbol(aP, aPGB.Color, aPGB.OutlineColor, width, // height, aPGB.DrawFill, aPGB.DrawOutline, g); Draw.DrawPolygonSymbol(aP, width, height, aPGB, 0, g); } break; case ShapeTypes.Image: width = rect.Width / 3 * 2; height = rect.Height / 3 * 2; Draw.DrawPolygonSymbol(aP, aCB.Color, Color.Black, width, height, true, true, g); break; } //Draw value and label int sX = _symbolWidth; Font aFont = new Font("Arial", 8); string str = aCB.Caption; SizeF size = g.MeasureString(str, aFont); aP.X = sX; aP.Y -= size.Height / 2; //if (size.Width > _labelWidth) // str = str.Substring(0, 16) + "..."; if (_legendScheme.LegendType == LegendType.SingleSymbol) { //Label //g.DrawString(str, aFont, Brushes.Black, aP); g.DrawString(str, aFont, Brushes.Black, new RectangleF(aP, new SizeF(_valueWidth, size.Height))); } else { //Label aP.X += _valueWidth; g.DrawString(str, aFont, Brushes.Black, aP); //Value if (aCB.StartValue.ToString() == aCB.EndValue.ToString()) { str = aCB.StartValue.ToString(); } else { str = aCB.StartValue.ToString() + " - " + aCB.EndValue.ToString(); } size = g.MeasureString(str, aFont); aP.X = sX; //if (size.Width > _labelWidth) // str = str.Substring(0, 16) + "..."; //g.DrawString(str, aFont, Brushes.Black, aP); g.DrawString(str, aFont, Brushes.Black, new RectangleF(aP, new SizeF(_valueWidth, size.Height))); } }
/// <summary> /// Create Graduated color legend scheme /// </summary> /// <param name="CValues"></param> /// <param name="colors"></param> /// <param name="aST"></param> /// <param name="min"></param> /// <param name="max"></param> /// <param name="hasNodata"></param> /// <param name="unDef"></param> /// <returns></returns> public static LegendScheme CreateGraduatedLegendScheme(double[] CValues, Color[] colors, ShapeTypes aST, double min, double max, Boolean hasNodata, double unDef) { LegendScheme legendScheme = new LegendScheme(aST); legendScheme.LegendType = LegendType.GraduatedColor; legendScheme.ShapeType = aST; legendScheme.LegendBreaks = new List <ColorBreak>(); legendScheme.MinValue = min; legendScheme.MaxValue = max; legendScheme.MissingValue = unDef; int i; switch (aST) { case ShapeTypes.Point: for (i = 0; i < colors.Length; i++) { PointBreak aPB = new PointBreak(); aPB.Color = colors[i]; aPB.OutlineColor = Color.Black; aPB.IsNoData = false; aPB.DrawOutline = true; aPB.DrawFill = true; aPB.DrawShape = true; if (i == 0) { aPB.StartValue = min; } else { aPB.StartValue = CValues[i - 1]; } if (i == colors.Length - 1) { aPB.EndValue = max; } else { aPB.EndValue = CValues[i]; } aPB.Size = (Single)i / 2 + 2; aPB.Style = PointStyle.Circle; if (aPB.StartValue == aPB.EndValue) { aPB.Caption = aPB.StartValue.ToString(); } else { if (i == 0) { aPB.Caption = "< " + aPB.EndValue.ToString(); } else if (i == colors.Length - 1) { aPB.Caption = "> " + aPB.StartValue.ToString(); } else { aPB.Caption = aPB.StartValue.ToString() + " - " + aPB.EndValue.ToString(); } } legendScheme.LegendBreaks.Add(aPB); } legendScheme.HasNoData = false; if (hasNodata) { PointBreak aPB = new PointBreak(); aPB.Color = Color.Gray; aPB.OutlineColor = Color.Black; aPB.StartValue = unDef; aPB.EndValue = aPB.StartValue; aPB.Size = 1; aPB.Style = PointStyle.Circle; aPB.Caption = "NoData"; aPB.IsNoData = true; aPB.DrawShape = true; aPB.DrawOutline = true; legendScheme.LegendBreaks.Add(aPB); legendScheme.HasNoData = true; } break; case ShapeTypes.Polyline: case ShapeTypes.PolylineZ: for (i = 0; i < colors.Length; i++) { PolyLineBreak aPLB = new PolyLineBreak(); aPLB.Color = colors[i]; aPLB.Size = 1.0F; aPLB.Style = LineStyles.Solid; aPLB.DrawPolyline = true; if (i == 0) { aPLB.StartValue = min; } else { aPLB.StartValue = CValues[i - 1]; } if (i == colors.Length - 1) { aPLB.EndValue = max; } else { aPLB.EndValue = CValues[i]; } if (aPLB.StartValue == aPLB.EndValue) { aPLB.Caption = aPLB.StartValue.ToString(); } else { if (i == 0) { aPLB.Caption = "< " + aPLB.EndValue.ToString(); } else if (i == colors.Length - 1) { aPLB.Caption = "> " + aPLB.StartValue.ToString(); } else { aPLB.Caption = aPLB.StartValue.ToString() + " - " + aPLB.EndValue.ToString(); } } aPLB.SymbolColor = aPLB.Color; if (Enum.IsDefined(typeof(PointStyle), i)) { aPLB.SymbolStyle = (PointStyle)i; } legendScheme.LegendBreaks.Add(aPLB); } legendScheme.HasNoData = false; break; case ShapeTypes.Polygon: for (i = 0; i < colors.Length; i++) { PolygonBreak aPGB = new PolygonBreak(); aPGB.Color = colors[i]; aPGB.OutlineColor = Color.Gray; aPGB.OutlineSize = 1.0F; aPGB.DrawFill = true; aPGB.DrawOutline = false; aPGB.DrawShape = true; if (i == 0) { aPGB.StartValue = min; } else { aPGB.StartValue = CValues[i - 1]; } if (i == colors.Length - 1) { aPGB.EndValue = max; } else { aPGB.EndValue = CValues[i]; } if (aPGB.StartValue == aPGB.EndValue) { aPGB.Caption = aPGB.StartValue.ToString(); } else { if (i == 0) { aPGB.Caption = "< " + aPGB.EndValue.ToString(); } else if (i == colors.Length - 1) { aPGB.Caption = "> " + aPGB.StartValue.ToString(); } else { aPGB.Caption = aPGB.StartValue.ToString() + " - " + aPGB.EndValue.ToString(); } } if (Enum.IsDefined(typeof(HatchStyle), i)) { aPGB.Style = (HatchStyle)i; } legendScheme.LegendBreaks.Add(aPGB); } legendScheme.HasNoData = false; break; case ShapeTypes.Image: for (i = 0; i < colors.Length; i++) { ColorBreak aCB = new ColorBreak(); aCB.Color = colors[i]; if (i == 0) { aCB.StartValue = min; } else { aCB.StartValue = CValues[i - 1]; } if (i == colors.Length - 1) { aCB.EndValue = max; } else { aCB.EndValue = CValues[i]; } if (aCB.StartValue == aCB.EndValue) { aCB.Caption = aCB.StartValue.ToString(); } else { if (i == 0) { aCB.Caption = "< " + aCB.EndValue.ToString(); } else if (i == colors.Length - 1) { aCB.Caption = "> " + aCB.StartValue.ToString(); } else { aCB.Caption = aCB.StartValue.ToString() + " - " + aCB.EndValue.ToString(); } } legendScheme.LegendBreaks.Add(aCB); } legendScheme.HasNoData = false; if (hasNodata) { ColorBreak aCB = new ColorBreak(); aCB.Color = Color.Gray; aCB.StartValue = unDef; aCB.EndValue = aCB.StartValue; aCB.Caption = "NoData"; aCB.IsNoData = true; legendScheme.LegendBreaks.Add(aCB); legendScheme.HasNoData = true; } break; } //legendScheme.breakNum = legendScheme.LegendBreaks.Count; return(legendScheme); }
private void TSB_Add_Click(object sender, EventArgs e) { switch (_legendScheme.ShapeType) { case ShapeTypes.Polyline: case ShapeTypes.PolylineZ: PolyLineBreak aPLB = new PolyLineBreak(); //if (_legendScheme.breakNum > 0) //{ // aPLB = ((PolyLineBreak)_legendScheme.LegendBreaks[0]; //} aPLB.DrawPolyline = true; aPLB.Size = 0.1F; aPLB.Color = Color.Red; aPLB.StartValue = 0; aPLB.EndValue = 0; aPLB.Caption = ""; _legendScheme.LegendBreaks.Add(aPLB); //_legendScheme.BreakNum = _legendScheme.LegendBreaks.Count; break; case ShapeTypes.Point: PointBreak aPB = new PointBreak(); //if (_legendScheme.breakNum > 0) //{ // aPB = (PointBreak)_legendScheme.LegendBreaks[0]; //} aPB.DrawShape = true; aPB.DrawFill = true; aPB.Size = 5; aPB.Color = Color.Red; aPB.StartValue = 0; aPB.EndValue = 0; aPB.Caption = ""; _legendScheme.LegendBreaks.Add(aPB); //_legendScheme.BreakNum = _legendScheme.LegendBreaks.Count; break; case ShapeTypes.Polygon: PolygonBreak aPGB = new PolygonBreak(); //if (_legendScheme.breakNum > 0) //{ // aPGB = (PolygonBreak)_legendScheme.LegendBreaks[0]; //} aPGB.DrawShape = true; aPGB.DrawFill = true; aPGB.Color = Color.Red; aPGB.StartValue = 0; aPGB.EndValue = 0; aPGB.Caption = ""; _legendScheme.LegendBreaks.Add(aPGB); //_legendScheme.breakNum = _legendScheme.LegendBreaks.Count; break; case ShapeTypes.Image: ColorBreak aCB = new ColorBreak(); aCB.Color = Color.Red; aCB.StartValue = 0; aCB.EndValue = 0; aCB.Caption = ""; _legendScheme.LegendBreaks.Add(aCB); //_legendScheme.breakNum = _legendScheme.LegendBreaks.Count; break; } legendView1.Update(_legendScheme); }