private void listLegendLayers_SelectedIndexChanged(object sender, EventArgs e) { this.bool_0 = false; this.ilegendItem_0 = (this.listLegendLayers.Items[this.listLegendLayers.SelectedIndex] as LegendItemWrap).LegendItem; if (this.ilegendItem_0 != null) { ILegendClassFormat legendClassFormat = this.ilegendItem_0.LegendClassFormat; if (legendClassFormat.AreaPatch == null) { ILegendFormat format = this.ilegend_0.Format; legendClassFormat.AreaPatch = format.DefaultAreaPatch; legendClassFormat.LinePatch = format.DefaultLinePatch; legendClassFormat.PatchWidth = format.DefaultPatchWidth; legendClassFormat.PatchHeight = format.DefaultPatchHeight; } if (this.定制 == null) { this.定制 = new ServerStyleGalleryItemClass(); this.定制.Name = "定制"; this.定制.Item = legendClassFormat.LinePatch; } if (this.定制_1 == null) { this.定制_1 = new ServerStyleGalleryItemClass(); this.定制_1.Name = "定制"; this.定制_1.Item = legendClassFormat.AreaPatch; } this.cboLinePatches.SelectStyleGalleryItem(this.定制); this.cboAreaPatches.SelectStyleGalleryItem(this.定制_1); this.txtWidth.Text = legendClassFormat.PatchWidth.ToString("#.##"); this.txtHeight.Text = legendClassFormat.PatchHeight.ToString("#.##"); this.bool_0 = true; } }
/// <summary> /// 设置图例属性 /// </summary> /// <param name="pLegend">图例</param> /// <param name="pMap">地图</param> private static void SetLegendProperty(ILegend2 pLegend, IMap pMap) { pLegend.ClearItems(); pLegend.Title = "Legend"; pLegend.AutoVisibility = true; ILegendFormat lFormat = pLegend.Format; lFormat.DefaultPatchHeight = 20; lFormat.DefaultPatchWidth = 30; lFormat.TitleSymbol = GetTextSymbol(); for (int i = 0; i < pMap.LayerCount; i++) { ILegendItem pLegendItem = new HorizontalLegendItemClass(); pLegendItem.Layer = pMap.Layer[i]; //获取添加图例关联图层 pLegendItem.Columns = 2; ILegendClassFormat iClassFormat = pLegendItem.LegendClassFormat; iClassFormat.LabelSymbol = GetTextSymbol(); //iClassFormat.DescriptionSymbol = GetTextSymbol(); pLegendItem.HeadingSymbol = GetTextSymbol(); pLegendItem.ShowDescriptions = false; pLegendItem.ShowHeading = true; pLegendItem.ShowLabels = true; pLegendItem.ShowLayerName = false; pLegend.AddItem(pLegendItem); //添加图例内容 } }
public void SetObjects(object object_0) { this.imapSurroundFrame_0 = object_0 as IMapSurroundFrame; this.ilegend_0 = this.imapSurroundFrame_0.MapSurround as ILegend; ILegendFormat format = this.ilegend_0.Format; this.itextSymbol_0 = format.TitleSymbol; }
private void btnSymbol_Click(object sender, EventArgs e) { //图例的大标题字体; m_legend.Title = this.textBox1.Text; plegendFormat = m_legend.Format; pTitleElement = new TextElementClass(); pTitleElement.Text = m_legend.Title; pTitleElement.Symbol = plegendFormat.TitleSymbol; frmTextSymbol frmtext = new frmTextSymbol(ref pTitleElement); frmtext.ShowDialog(); this.textBox1.Text = pTitleElement.Text; plegendFormat.TitleSymbol = pTitleElement.Symbol; }
private void method_4(int int_0, string string_1, ILegendFormat ilegendFormat_0) { try { double num = double.Parse(string_1); switch (int_0) { case 0: ilegendFormat_0.HeadingGap = num; return; case 1: ilegendFormat_0.VerticalItemGap = num; return; case 2: ilegendFormat_0.HorizontalItemGap = num; return; case 3: ilegendFormat_0.LayerNameGap = num; return; case 4: ilegendFormat_0.GroupGap = num; return; case 5: ilegendFormat_0.TitleGap = num; return; case 6: ilegendFormat_0.TextGap = num; return; case 7: ilegendFormat_0.VerticalPatchGap = num; return; case 8: ilegendFormat_0.HorizontalPatchGap = num; return; } } catch { } }
private void method_3(int int_0, double double_0) { ILegendFormat format = this.ilegend_0.Format; switch (int_0) { case 0: format.HeadingGap = double_0; break; case 1: format.VerticalItemGap = double_0; break; case 2: format.HorizontalItemGap = double_0; break; case 3: format.LayerNameGap = double_0; break; case 4: format.GroupGap = double_0; break; case 5: format.TitleGap = double_0; break; case 6: format.TextGap = double_0; break; case 7: format.VerticalPatchGap = double_0; break; case 8: format.HorizontalPatchGap = double_0; break; } }
public void Apply() { if (this.bool_1) { this.bool_1 = false; ILegendFormat format = this.ilegend_0.Format; format.TitlePosition = (esriRectanglePosition)(this.cboTitlePosition.SelectedIndex + 1); format.TitleSymbol = this.itextSymbol_0; format.DefaultAreaPatch = this.cboAreaPatches.GetSelectStyleGalleryItem().Item as IAreaPatch; format.DefaultLinePatch = this.cboLinePatches.GetSelectStyleGalleryItem().Item as ILinePatch; format.DefaultPatchWidth = double.Parse(this.txtWidth.Text); format.DefaultPatchHeight = double.Parse(this.txtHeight.Text); (this.ilegend_0 as IReadingDirection).RightToLeft = this.chkRightToLeft.Checked; format.ShowTitle = this.chkShow.Checked; this.ilegend_0.Title = this.txtTitle.Text; for (int i = 0; i < this.listView1.Items.Count; i++) { this.method_4(i, this.listView1.Items[i].SubItems[1].Text, format); } } }
private void method_0() { this.txtTitle.Text = this.ilegend_0.Title; ILegendFormat format = this.ilegend_0.Format; this.chkShow.Checked = format.ShowTitle; this.txtTitle.Enabled = format.ShowTitle; this.cboTitlePosition.SelectedIndex = ((int)format.TitlePosition) - 1; this.txtWidth.Text = format.DefaultPatchWidth.ToString("#.##"); this.txtHeight.Text = format.DefaultPatchHeight.ToString("#.##"); this.listView1.Items[0].SubItems[1].Text = format.HeadingGap.ToString("#.##"); this.listView1.Items[1].SubItems[1].Text = format.VerticalItemGap.ToString("#.##"); this.listView1.Items[2].SubItems[1].Text = format.HorizontalItemGap.ToString("#.##"); this.listView1.Items[3].SubItems[1].Text = format.LayerNameGap.ToString("#.##"); this.listView1.Items[4].SubItems[1].Text = format.GroupGap.ToString("#.##"); this.listView1.Items[5].SubItems[1].Text = format.TitleGap.ToString("#.##"); this.listView1.Items[6].SubItems[1].Text = format.TextGap.ToString("#.##"); this.listView1.Items[7].SubItems[1].Text = format.VerticalPatchGap.ToString("#.##"); this.listView1.Items[8].SubItems[1].Text = format.HorizontalPatchGap.ToString("#.##"); IStyleGalleryItem oO = new MyStyleGalleryItem { Name = "<定制>" }; this.ilinePatch_0 = format.DefaultLinePatch; oO.Item = this.ilinePatch_0; this.cboLinePatches.SelectStyleGalleryItem(oO); oO = new MyStyleGalleryItem { Name = "<定制>" }; this.iareaPatch_0 = format.DefaultAreaPatch; oO.Item = this.iareaPatch_0; this.cboAreaPatches.SelectStyleGalleryItem(oO); this.chkRightToLeft.Checked = (this.ilegend_0 as IReadingDirection).RightToLeft; }
private void LegendWizard_Load(object sender, EventArgs e) { if (m_pageLayoutControl.ActiveView.FocusMap == null) { MessageBox.Show("请先添加地图"); return; } #region //点击 添加图例按钮 或在 PageLayoutControl中双击图例时 if (mapSurroundFrame == null) //当点击 添加图例按钮 或在 PageLayoutControl中双击图例时 先创建图例 或从地图上获得已经添加的图例; { //Get the GraphicsContainer IGraphicsContainer graphicsContainer = m_pageLayoutControl.GraphicsContainer; graphicsContainer.Reset(); IElementProperties pElementPerties = graphicsContainer.Next() as IElementProperties; //Get the MapFrame IMapFrame mapFrame = (IMapFrame)graphicsContainer.FindFrame(m_pageLayoutControl.ActiveView.FocusMap); if (mapFrame == null) { return; } while (pElementPerties != null) //从地图中获得已有的图例 { if (pElementPerties.Type == "Map Surround Frame") { pMapSurrounFrame = pElementPerties as IMapSurroundFrame; if (pMapSurrounFrame.MapSurround.Name == "Legend") { m_legend = pMapSurrounFrame.MapSurround as ILegend; break; } } pElementPerties = (IElementProperties)graphicsContainer.Next(); } if (m_legend == null) //当地图中没有添加图例时 创建新图例 { //Create a legend UID uID = new UIDClass(); uID.Value = "esriCarto.Legend"; //Create a MapSurroundFrame from the MapFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uID, null); if (mapSurroundFrame == null) { return; } if (mapSurroundFrame.MapSurround == null) { return; } m_legend = mapSurroundFrame.MapSurround as ILegend; } else { mapSurroundFrame = pMapSurrounFrame; } UID m_uid = new UIDClass(); m_uid.Value = "{34C20002-4D3C-11D0-92D8-00805F7C28B0}"; m_mapLayers = m_mapControl.Map as IMapLayers; m_emuLayer = m_mapLayers.get_Layers(m_uid, true);//获取图层 if (m_emuLayer != null) { m_emuLayer.Reset(); ILayer m_layer = null; while ((m_layer = m_emuLayer.Next()) != null) { this.listBox1.Items.Add(m_layer.Name);//将图层名添加到图例备选项中 } } } #endregion else //在双击任意范围打印框中图例时,获得图例,及图层信息; { if (m_Map == null) { MessageBox.Show("请先添加地图!"); } for (int k = 0; k < m_Map.LayerCount; k++) { listBox1.Items.Add(m_Map.get_Layer(k).Name.ToString()); } m_legend = mapSurroundFrame.MapSurround as ILegend; } //以下设置需要用到的变量 及初始化 对话框 plegendFormat = m_legend.Format as ILegendFormat; //设置图例格式需要用到的 pTextSymbol = new TextSymbolClass(); pTextSymbol.Size = 10; pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; //初始化图例标签的文本格式 if (m_legend.Title != null) { textBox1.Text = m_legend.Title.ToString(); //初始化对话框中的文本框 文本 } else { textBox1.Text = "Legend"; } this.textBoxWidth.Text = "36"; this.textBoxHeight.Text = "15"; IMapSurround mapSurround = m_legend as IMapSurround; mapSurroundFrame.MapSurround = mapSurround; m_FrameProperties = (IFrameProperties)mapSurroundFrame; ISymbolBackground pSymbolBack = m_FrameProperties.Background as ISymbolBackground; ISymbolBorder pSymbolBorder = m_FrameProperties.Border as ISymbolBorder; ISymbolShadow pSymbolShadow = m_FrameProperties.Shadow as ISymbolShadow; if (pSymbolBack != null) { this.btnBackGroundColor.BackColor = ColorTranslator.FromOle(pSymbolBack.FillSymbol.Color.RGB); } if (pSymbolBorder != null) { this.btnBolderColor.BackColor = ColorTranslator.FromOle(pSymbolBorder.LineSymbol.Color.RGB); } if (pSymbolShadow != null) { this.btnShadowColor.BackColor = ColorTranslator.FromOle(pSymbolShadow.FillSymbol.Color.RGB); } }
private void FrmLegendAttribute_Load(object sender, EventArgs e) { //图例界面要素信息加载 ILegendFormat pLegendFormat = Legend.Format; //标题 this.txtLegendTitle.Text = Legend.Title; if (pLegendFormat.ShowTitle == true) { this.cBoxShowTitle.Checked = true; this.txtLegendTitle.Enabled = true; } else { this.cBoxShowTitle.Checked = false; this.txtLegendTitle.Enabled = false; } pTitleSymbol = pLegendFormat.TitleSymbol; //图面 this.txtPatchWith.Text = pLegendFormat.DefaultPatchWidth.ToString(); this.txtPatchHeight.Text = pLegendFormat.DefaultPatchHeight.ToString(); if (pLegendFormat.DefaultLinePatch != null) { FrmPatchLineAndArea frmPatchLine = new FrmPatchLineAndArea(esriSymbologyStyleClass.esriStyleClassLinePatches); this.btLineShape.Image = frmPatchLine.GetImageByGiveLineSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassLinePatches, (ILinePatch)pLegendFormat.DefaultLinePatch, btLineShape.Width, btLineShape.Height); } if (pLegendFormat.DefaultAreaPatch != null) { FrmPatchLineAndArea frmPatchArea = new FrmPatchLineAndArea(esriSymbologyStyleClass.esriStyleClassAreaPatches); this.btAreaShape.Image = frmPatchArea.GetImageByGiveAreaSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassAreaPatches, (IAreaPatch)pLegendFormat.DefaultAreaPatch, btAreaShape.Width, btAreaShape.Height); } //间隔 this.txtTitleAndLegend.Text = pLegendFormat.TitleGap.ToString(); this.txtLegendItems.Text = pLegendFormat.VerticalItemGap.ToString(); this.txtColumns.Text = pLegendFormat.HorizontalItemGap.ToString(); this.txtLabelsAndDescription.Text = pLegendFormat.TextGap.ToString(); this.txtHeadings.Text = pLegendFormat.HeadingGap.ToString(); this.txtPatchesV.Text = pLegendFormat.VerticalPatchGap.ToString(); this.txtPatchAndLabels.Text = pLegendFormat.HorizontalPatchGap.ToString(); //图层加载 if (pMap.LayerCount > 0) { for (int i = 0; i < pMap.LayerCount; i++) { //将所有数据名称加载到ListView中 this.LViewMapLayer.Items.Add(pMap.get_Layer(i).Name); for (int j = 0; j < Legend.ItemCount; j++) { ILegendItem pLegendItem = Legend.Item[j]; if (pMap.get_Layer(i).Name == pLegendItem.Layer.Name) { this.LViewLegendLayer.Items.Add(pLegendItem.Layer.Name); pSelectedidx.Add(i); } } } } //各类文本样式 ILegendItem pLegendItem0 = Legend.Item[0]; pLayerNameSymbol = pLegendItem0.LayerNameSymbol; pHeadingSymbol = pLegendItem0.HeadingSymbol; ILegendClassFormat pLegendClassFormat = pLegendItem0.LegendClassFormat; pLabelSymbol = pLegendClassFormat.LabelSymbol; pDescriptionSymbol = pLegendClassFormat.DescriptionSymbol; ////图例列数 //ILegendItem pLegendItemff = new HorizontalLegendItemClass(); //this.LegendColumn.Text = pLegendItemff.Columns.ToString (); //文本样式下拉列表 this.cboBoxTextSymbol.SelectedIndex = 0; cBoxAddVisibleLayer.Checked = Legend.AutoVisibility; //只显示显示的图层 cBoxAddNewLayer.Checked = Legend.AutoAdd; //自动添加显示的图层 cBoxNewOrder.Checked = Legend.AutoReorder; //按照图层顺序排列图例 //地图框架 IFrameProperties pFrameProperties = pMapSurroundFrame as IFrameProperties; if (pMapSurroundFrame.Border != null) { FrmFrameBorder frm = new FrmFrameBorder(SymbolStyle, (ISymbolBorder)pMapSurroundFrame.Border); if (btBorder.Image != null) { btBorder.Image.Dispose(); } this.btBorder.Image = frm.GetImageByGiveSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassBorders, (ISymbolBorder)pMapSurroundFrame.Border, btBorder.Width, btBorder.Height); pSymbolBorder = pFrameProperties.Border as ISymbolBorder; txtBorderGap.Text = pFrameProperties.Border.Gap.ToString(); txtBorderAngle.Text = pSymbolBorder.CornerRounding.ToString(); } if (pMapSurroundFrame.Background != null) { FrmFrameBackground frm = new FrmFrameBackground(SymbolStyle, (ISymbolBackground)pMapSurroundFrame.Background); if (btBackground.Image != null) { btBackground.Image.Dispose(); } this.btBackground.Image = frm.GetImageByGiveSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassBackgrounds, (ISymbolBackground)pMapSurroundFrame.Background, btBackground.Width, btBackground.Height); pSymbolBackground = pFrameProperties.Background as ISymbolBackground; txtBackgroundGap.Text = pSymbolBackground.Gap.ToString(); txtBackgroundAngle.Text = pSymbolBackground.CornerRounding.ToString(); } if (pFrameProperties.Shadow != null) { FrmFrameShadow frm = new FrmFrameShadow(SymbolStyle, (ISymbolShadow)pFrameProperties.Shadow); if (btShadow.Image != null) { btShadow.Image.Dispose(); } this.btShadow.Image = frm.GetImageByGiveSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassShadows, (ISymbolShadow)pFrameProperties.Shadow, btShadow.Width, btShadow.Height); pSymbolShadow = pFrameProperties.Shadow as ISymbolShadow; txtShadowX.Text = pSymbolShadow.HorizontalSpacing.ToString(); txtShadowY.Text = pSymbolShadow.VerticalSpacing.ToString(); txtShadowAngle.Text = pSymbolShadow.CornerRounding.ToString(); } }
private void LegendWizard_Load(object sender, EventArgs e) { if (m_pageLayoutControl.ActiveView.FocusMap == null) { MessageBox.Show("请先添加地图"); return; } #region //点击 添加图例按钮 或在 PageLayoutControl中双击图例时 if (mapSurroundFrame == null) //当点击 添加图例按钮 或在 PageLayoutControl中双击图例时 先创建图例 或从地图上获得已经添加的图例; { //Get the GraphicsContainer IGraphicsContainer graphicsContainer = m_pageLayoutControl.GraphicsContainer; graphicsContainer.Reset(); IElementProperties pElementPerties = graphicsContainer.Next() as IElementProperties; //Get the MapFrame IMapFrame mapFrame = (IMapFrame)graphicsContainer.FindFrame(m_pageLayoutControl.ActiveView.FocusMap); if (mapFrame == null) return; while (pElementPerties != null) //从地图中获得已有的图例 { if (pElementPerties.Type == "Map Surround Frame") { pMapSurrounFrame = pElementPerties as IMapSurroundFrame; if (pMapSurrounFrame.MapSurround.Name == "Legend") { m_legend = pMapSurrounFrame.MapSurround as ILegend; break; } } pElementPerties = (IElementProperties)graphicsContainer.Next(); } if (m_legend == null) //当地图中没有添加图例时 创建新图例 { //Create a legend UID uID = new UIDClass(); uID.Value = "esriCarto.Legend"; //Create a MapSurroundFrame from the MapFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uID, null); if (mapSurroundFrame == null) return; if (mapSurroundFrame.MapSurround == null) return; m_legend = mapSurroundFrame.MapSurround as ILegend; } else { mapSurroundFrame = pMapSurrounFrame; } UID m_uid = new UIDClass(); m_uid.Value = "{34C20002-4D3C-11D0-92D8-00805F7C28B0}"; m_mapLayers = m_mapControl.Map as IMapLayers; m_emuLayer = m_mapLayers.get_Layers(m_uid, true);//获取图层 if (m_emuLayer != null) { m_emuLayer.Reset(); ILayer m_layer = null; while ((m_layer = m_emuLayer.Next()) != null) { this.listBox1.Items.Add(m_layer.Name);//将图层名添加到图例备选项中 } } } #endregion else //在双击任意范围打印框中图例时,获得图例,及图层信息; { if (m_Map == null) { MessageBox.Show("请先添加地图!"); } for (int k = 0; k < m_Map.LayerCount; k++) { listBox1.Items.Add(m_Map.get_Layer(k).Name.ToString()); } m_legend = mapSurroundFrame .MapSurround as ILegend; } //以下设置需要用到的变量 及初始化 对话框 plegendFormat = m_legend.Format as ILegendFormat; //设置图例格式需要用到的 pTextSymbol = new TextSymbolClass(); pTextSymbol.Size = 10; pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; //初始化图例标签的文本格式 if (m_legend.Title != null) textBox1.Text = m_legend.Title.ToString(); //初始化对话框中的文本框 文本 else textBox1.Text = "Legend"; this.textBoxWidth.Text = "36"; this.textBoxHeight.Text = "15"; IMapSurround mapSurround = m_legend as IMapSurround; mapSurroundFrame.MapSurround = mapSurround; m_FrameProperties = (IFrameProperties)mapSurroundFrame; ISymbolBackground pSymbolBack = m_FrameProperties.Background as ISymbolBackground; ISymbolBorder pSymbolBorder = m_FrameProperties.Border as ISymbolBorder; ISymbolShadow pSymbolShadow = m_FrameProperties.Shadow as ISymbolShadow; if (pSymbolBack !=null ) this.btnBackGroundColor.BackColor =ColorTranslator.FromOle ( pSymbolBack.FillSymbol.Color.RGB ) ; if (pSymbolBorder != null) this.btnBolderColor.BackColor = ColorTranslator.FromOle(pSymbolBorder.LineSymbol.Color.RGB); if (pSymbolShadow != null) this.btnShadowColor.BackColor = ColorTranslator.FromOle(pSymbolShadow.FillSymbol.Color.RGB); }
private void btnSymbol_Click(object sender, EventArgs e) { //图例的大标题字体; m_legend.Title = this.textBox1.Text; plegendFormat = m_legend.Format; pTitleElement = new TextElementClass(); pTitleElement.Text = m_legend.Title; pTitleElement.Symbol = plegendFormat.TitleSymbol; frmTextSymbol frmtext = new frmTextSymbol(ref pTitleElement); frmtext.ShowDialog(); this.textBox1.Text = pTitleElement.Text; plegendFormat.TitleSymbol = pTitleElement.Symbol; }