private void AxTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { IBasicMap pMap = null; ILayer pLayer = null; object legendgp = null; object index = null; esriTOCControlItem pItem = esriTOCControlItem.esriTOCControlItemNone; axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref legendgp, ref index); //点击测试,点击图例打开符号选择器 if (e.button == 1) { ILegendGroup pLegendGroup = new LegendGroup(); ILegendClass pLegendClass = new LegendClass(); pLegendGroup = (ILegendGroup)legendgp; if (pItem == esriTOCControlItem.esriTOCControlItemLegendClass) { pLegendClass = pLegendGroup.get_Class(Convert.ToInt32(index.ToString())); if (pLegendClass == null) { return; } FormSymbolSelector dlg = new FormSymbolSelector(pLegendClass, pLayer); if (dlg != null) { dlg.ShowDialog(); m_pTocControl.Update(); m_mapControl.Refresh(esriViewDrawPhase.esriViewGeography, null, null); } } } }
//Create Legend public void CreateLegend() { clsSnippet pSnippet = new clsSnippet(); //Create Legend Group m_pLegendGroup = new LegendGroup(); m_pLegendGroup.Heading = "Robustness"; m_pLegendGroup.Editable = true; m_pLegendGroup.Visible = true; //For Values ILegendClass legendClass = new LegendClass(); ILineFillSymbol pLineFillSym = new LineFillSymbolClass(); double dblInstantSep = (dblFromSep - dblToSep) / Convert.ToDouble(intUncernBreakCount - 2); for (int i = 0; i < intUncernBreakCount; i++) { legendClass = new LegendClass(); if (i == intUncernBreakCount - 1) { legendClass.Label = "1"; } else if (i == intUncernBreakCount - 2) { legendClass.Label = arrRobustBrks[i].ToString() + " - " + (1 - (1 * Math.Pow(0.1, intRoundingDigits))).ToString(); } else { legendClass.Label = arrRobustBrks[i].ToString() + " - " + (arrRobustBrks[i + 1] - (1 * Math.Pow(0.1, intRoundingDigits))).ToString(); } pLineFillSym = new LineFillSymbolClass(); pLineFillSym.Angle = dblAngle; pLineFillSym.Color = pLineColor; pLineFillSym.LineSymbol.Width = dblLinewidth; if (i == (intUncernBreakCount - 1)) { pLineFillSym.Separation = double.MaxValue; } else { pLineFillSym.Separation = dblToSep + (dblInstantSep * Convert.ToDouble(i)); } legendClass.Symbol = pLineFillSym as ISymbol; m_pLegendGroup.AddClass(legendClass); } }
void ISpacingBreaksRenderer.CreateLegend() { //Create Legend Group m_pLegendGroup = new LegendGroup(); m_pLegendGroup.Heading = strHeading; m_pLegendGroup.Editable = true; m_pLegendGroup.Visible = true; intBrksCount = arrClassBrks.Length - 1; dblInstantSep = (dblFromSep - dblToSep) / Convert.ToDouble(intBrksCount - 1); //For Values ILegendClass legendClass = new LegendClass(); ILineFillSymbol pLineFillSym = new LineFillSymbolClass(); for (int i = 0; i < intBrksCount; i++) { legendClass = new LegendClass(); //if (i == intUncernBreakCount - 1) // legendClass.Label = "1"; //else if (i == intUncernBreakCount - 2) // legendClass.Label = arrClassBrks[i].ToString() + " - " + (1 - (1 * Math.Pow(0.1, intRoundingDigits))).ToString(); //else legendClass.Label = Math.Round(arrClassBrks[i], intRoundingDigits).ToString() + " - " + (Math.Round(arrClassBrks[i + 1], intRoundingDigits) - (1 * Math.Pow(0.1, intRoundingDigits))).ToString(); pLineFillSym = new LineFillSymbolClass(); pLineFillSym.Angle = dblLineAngle; pLineFillSym.Color = pLineRgb; pLineFillSym.LineSymbol.Width = dblLineWidth; pLineFillSym.Separation = dblToSep + (dblInstantSep * Convert.ToDouble(i)); legendClass.Symbol = pLineFillSym as ISymbol; m_pLegendGroup.AddClass(legendClass); } }
/// <summary> /// 双击TOC修改符号系统 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void axTOCControl1_OnDoubleClick(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnDoubleClickEvent e) { esriTOCControlItem pTocControlItem = esriTOCControlItem.esriTOCControlItemNone; ILayer pLayer = null; IBasicMap pBasicMap = null; object unk = null; object data = null; if (e.button == 1) { axTOCControl1.HitTest(e.x, e.y, ref pTocControlItem, ref pBasicMap, ref pLayer, ref unk, ref data); System.Drawing.Point pos = new System.Drawing.Point(e.x, e.y); if (pTocControlItem == esriTOCControlItem.esriTOCControlItemLegendClass) { ILegendClass pLegendClass = new LegendClass(); ILegendGroup pLegendGroup = new LegendGroup(); if (unk is ILegendGroup) { pLegendGroup = unk as ILegendGroup; } pLegendClass = pLegendGroup.get_Class((int)data); ISymbol pSymbol; pSymbol = pLegendClass.Symbol; ISymbolSelector pSymbolSelector = new SymbolSelector(); bool isOk = false; pSymbolSelector.AddSymbol(pSymbol); isOk = pSymbolSelector.SelectSymbol(0); if (isOk) { pLegendClass.Symbol = pSymbolSelector.GetSymbolAt(0); } this.axMapControl1.ActiveView.Refresh(); this.axTOCControl1.Refresh(); } } }
//Create Legend public void CreateLegend() { clsSnippet pSnippet = new clsSnippet(); //Create Legend Group m_pLegendGroup = new LegendGroup(); m_pLegendGroup.Heading = m_strOriRenderField; m_pLegendGroup.Editable = true; m_pLegendGroup.Visible = true; ILegendClass legendClass = new LegendClass(); legendClass.Label = Math.Round(dblMaxValue, 0).ToString(); IStackedChartSymbol stackedChartSymbol = new StackedChartSymbolClass(); //IBarChartSymbol barChartSymbol = new BarChartSymbolClass(); stackedChartSymbol.Width = 10; if (bln3Dfeature) { I3DChartSymbol p3DChartSymbol = stackedChartSymbol as I3DChartSymbol; p3DChartSymbol.Display3D = true; p3DChartSymbol.Thickness = 3; } //IMarkerSymbol markerSymbol = stackedChartSymbol as IMarkerSymbol; //markerSymbol.Size = 50; IChartSymbol chartSymbol = stackedChartSymbol as IChartSymbol; chartSymbol.MaxValue = dblMaxValue; ISymbolArray symbolArray = stackedChartSymbol as ISymbolArray; //Stacked Symbol IFillSymbol fillSymbol = new SimpleFillSymbolClass(); fillSymbol.Color = pSnippet.getRGB(255, 0, 0); fillSymbol.Outline.Color = pSnippet.getRGB(0, 0, 0); symbolArray.AddSymbol(fillSymbol as ISymbol); chartSymbol.set_Value(0, dblMaxUncern); //fillSymbol = new SimpleFillSymbolClass(); //fillSymbol.Color = pSnippet.getRGB(255, 0, 0); //fillSymbol.Outline.Color = pSnippet.getRGB(0, 0, 0); //symbolArray.AddSymbol(fillSymbol as ISymbol); //chartSymbol.set_Value(1, dblMaxUncern); fillSymbol = new SimpleFillSymbolClass(); fillSymbol.Color = pSnippet.getRGB(255, 255, 255); fillSymbol.Outline.Color = pSnippet.getRGB(0, 0, 0); symbolArray.AddSymbol(fillSymbol as ISymbol); chartSymbol.set_Value(1, dblMaxEstimate - dblMaxUncern); legendClass.Symbol = (ISymbol)chartSymbol; m_pLegendGroup.AddClass(legendClass); //Bounds legendClass = new LegendClass(); legendClass.Label = "Upper Bound"; ISimpleFillSymbol pLegendUncerSymbol = new SimpleFillSymbol(); pLegendUncerSymbol.Color = pSnippet.getRGB(0, 0, 255); pLegendUncerSymbol.Outline.Color = pSnippet.getRGB(0, 0, 0); legendClass.Symbol = (ISymbol)pLegendUncerSymbol; m_pLegendGroup.AddClass(legendClass); legendClass = new LegendClass(); legendClass.Label = "Lower Bound"; pLegendUncerSymbol = new SimpleFillSymbol(); pLegendUncerSymbol.Color = pSnippet.getRGB(255, 0, 0); pLegendUncerSymbol.Outline.Color = pSnippet.getRGB(0, 0, 0); legendClass.Symbol = (ISymbol)pLegendUncerSymbol; m_pLegendGroup.AddClass(legendClass); }
//符号选择器 private void AxTOCControl1_OnDoubleClick(object sender, ITOCControlEvents_OnDoubleClickEvent e) { ILayer pLayer = null; IBasicMap pMap = null; object legendgp = null; object index = null; esriTOCControlItem pItem = esriTOCControlItem.esriTOCControlItemNone; ILegendGroup pLegendGroup = new LegendGroup(); ILegendClass pLegendClass = new LegendClass(); try { axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref legendgp, ref index); } catch (Exception) { throw; } pLegendGroup = (ILegendGroup)legendgp; if (pItem == esriTOCControlItem.esriTOCControlItemLegendClass) { pLegendClass = pLegendGroup.get_Class(Convert.ToInt32(index.ToString())); if (pLegendClass == null) { return; } FrmSymbolLibrary dlg = new FrmSymbolLibrary(pLegendClass, pLayer); if (dlg != null) { try { dlg.ShowDialog(); axTOCControl1.Update(); mainMapControl.Refresh(esriViewDrawPhase.esriViewGeography, null, null); } catch (Exception) { throw; } } } //esriTOCControlItem toccItem = esriTOCControlItem.esriTOCControlItemNone; //ILayer iLayer = null; //IBasicMap iBasicMap = null; //object unk = null; //object data = null; //if (e.button == 1) //{ // axTOCControl1.HitTest(e.x, e.y, ref toccItem, ref iBasicMap, ref iLayer, ref unk, ref data); // System.Drawing.Point pos = new System.Drawing.Point(e.x, e.y); // if (toccItem == esriTOCControlItem.esriTOCControlItemLegendClass) // { // ILegendClass pLC = new LegendClassClass(); // ILegendGroup pLG = new LegendGroupClass(); // if (unk is ILegendGroup) // { // pLG = (ILegendGroup)unk; // } // pLC = pLG.get_Class((int)data); // ISymbol pSym = pLC.Symbol; // ISymbolSelector pSS = new SymbolSelectorClass(); // bool bOK = false; // pSS.AddSymbol(pSym); // bOK = pSS.SelectSymbol(0); // if (bOK) // { // pLC.Symbol = pSS.GetSymbolAt(0); // } // mainMapControl.ActiveView.Refresh(); // axTOCControl1.Refresh(); // } //} }
//int[,] IClassSeparabilityRenderer.arrColors //{ // get { return this.arrColors; } // set { this.arrColors = value; } //} //int[,] IClassSeparabilityRenderer.arrSepLineColors //{ // get { return this.arrSepLineColors; } // set { this.arrSepLineColors = value; } //} void IClassSeparabilityRenderer.CreateLegend() { double dblLinewidth = 2; clsSnippet pSnippet = new clsSnippet(); m_pTwoLegendGroup = new LegendGroupsClass(); //Create Legend Group ILegendGroup pLegendGroup = new LegendGroup(); pLegendGroup.Heading = null; pLegendGroup.Editable = true; pLegendGroup.Visible = true; //intBrksCount = (arrClassBrks.Length * 2) - 3; intBrksCount = (pCSMembers.ClassBrks.Length * 2) - 3; //For Values ILegendClass legendClass = new LegendClass(); ISimpleFillSymbol pSimpleFillSym = new SimpleFillSymbolClass(); ISimpleLineSymbol pLineSym = new SimpleLineSymbolClass(); int intValueIdx = 0; int intSepLineIdx = 0; int intLastIdx = pCSMembers.ClassBrks.Length - 2; legendClass = new LegendClass(); legendClass.Label = "Estimates"; pSimpleFillSym = new SimpleFillSymbolClass(); pSimpleFillSym.Color = (IColor)pSnippet.getRGB(pCSMembers.Colors[intLastIdx, 0], pCSMembers.Colors[intLastIdx, 1], pCSMembers.Colors[intLastIdx, 2]); legendClass.Symbol = pSimpleFillSym as ISymbol; pLegendGroup.AddClass(legendClass); legendClass = new LegendClass(); //legendClass.Label = "Separability Value"; legendClass.Label = "-- Separability Value"; pLineSym = new SimpleLineSymbolClass(); //pLineSym.Color = (IColor)pSnippet.getRGB(0, 0, 0); pLineSym.Color = (IColor)pSnippet.getRGB(255, 255, 255); pLineSym.Width = dblLinewidth; legendClass.Symbol = (ISymbol)pLineSym; pLegendGroup.AddClass(legendClass); m_pTwoLegendGroup.Add(pLegendGroup); //Create Legend Group pLegendGroup = new LegendGroup(); //pLegendGroup.Heading = "-----------------"; pLegendGroup.Heading = "_____________"; pLegendGroup.Editable = true; pLegendGroup.Visible = true; for (int i = 0; i < intBrksCount; i++) { legendClass = new LegendClass(); if (i % 2 == 0) { intValueIdx = i / 2; if (i == 0) { legendClass.Label = Math.Round(pCSMembers.ClassBrks[intValueIdx], intRoundingDigits).ToString() + " - " + (Math.Round(pCSMembers.ClassBrks[intValueIdx + 1], intRoundingDigits)).ToString(); } else { legendClass.Label = (Math.Round(pCSMembers.ClassBrks[intValueIdx], intRoundingDigits) + (1 * Math.Pow(0.1, intRoundingDigits))).ToString() + " - " + (Math.Round(pCSMembers.ClassBrks[intValueIdx + 1], intRoundingDigits)).ToString(); } pSimpleFillSym = new SimpleFillSymbolClass(); pSimpleFillSym.Color = (IColor)pSnippet.getRGB(pCSMembers.Colors[intValueIdx, 0], pCSMembers.Colors[intValueIdx, 1], pCSMembers.Colors[intValueIdx, 2]); legendClass.Symbol = pSimpleFillSym as ISymbol; } else { intValueIdx = (i - 1) / 2; legendClass.Label = "-- " + Math.Round(pCSMembers.Serabability[intValueIdx], intRoundingDigits).ToString(); intSepLineIdx = Convert.ToInt32(Math.Floor(pCSMembers.Serabability[intValueIdx] * 10)); pLineSym = new SimpleLineSymbolClass(); //pLineSym.Color = (IColor)pSnippet.getRGB(arrSepLineColors[intSepLineIdx, 0], arrSepLineColors[intSepLineIdx, 1], arrSepLineColors[intSepLineIdx, 2]); pLineSym.Color = (IColor)pSnippet.getRGB(255, 255, 255); pLineSym.Width = dblLinewidth; //ITextSymbol //ITextSymbol textSymbol = new TextSymbol(); //legendClass.Format.LabelSymbol = textSymbol; legendClass.Symbol = (ISymbol)pLineSym; } pLegendGroup.AddClass(legendClass); } m_pTwoLegendGroup.Add(pLegendGroup); }