コード例 #1
0
 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;
     }
 }
コード例 #2
0
ファイル: MyLegendClass.cs プロジェクト: Mengzuozhu/AeHelper
        /// <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); //添加图例内容
            }
        }
コード例 #3
0
        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();
            }
        }