Exemplo n.º 1
0
        public int GetMapID()
        {
            int mapID = -1;

            int count = 0;

            LayoutSelection layoutSelection = mapLayoutControl1.MapLayout.Selection;

            LayoutElements layoutElements = mapLayoutControl1.MapLayout.Elements;

            layoutElements.Refresh();

            for (int i = 0; i < layoutSelection.Count; i++)
            {
                int ID = layoutSelection[i];

                layoutElements.SeekID(ID);

                Geometry geometry = layoutElements.GetGeometry();

                if (geometry.Type == GeometryType.GeoMap)
                {
                    mapID = ID;

                    count++;
                }

                if (count > 1)
                {
                    mapID = -1;
                }
            }

            return(mapID);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 对象添加事件
        /// Maplayout tracked eventhandle
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void m_mapLayoutControl_ElementAdded(object sender, ElementEventArgs e)
        {
            try
            {
                LayoutElements elements = m_mapLayoutControl.MapLayout.Elements;
                if (elements.SeekID(e.ID))
                {
                    Geometry gemetry = elements.GetGeometry();
                    if (gemetry != null)
                    {
                        GeoNorthArrow northArrow = gemetry as GeoNorthArrow;
                        if (northArrow != null)
                        {
                            northArrow.BindingGeoMapID = m_mapID;
                        }

                        GeoMapScale mapScale = gemetry as GeoMapScale;
                        if (mapScale != null)
                        {
                            mapScale.BindingGeoMapID = m_mapID;
                        }

                        elements.SetGeometry(gemetry);
                        elements.Refresh();
                        m_mapLayoutControl.MapLayout.Refresh();
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Exemplo n.º 3
0
        private void 图例ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutElements layoutElements = mapLayoutControl1.MapLayout.Elements;

            layoutElements.SeekID(GetMapID());

            GeoMap geoMapUse = (GeoMap)layoutElements.GetGeometry();

            string geoMapName = geoMapUse.MapName;

            GeoLegend geoLegend = new GeoLegend(geoMapName, workspace1);

            geoLegend.Height = 175;

            geoLegend.Width = 350;

            geoLegend.Center = new Point2D(1375, 1855);

            GeoStyle geoLegendStyle = new GeoStyle();

            geoLegendStyle.FillForeColor = Color.FromArgb(255, 235, 175);

            geoLegendStyle.FillOpaqueRate = 30;

            geoLegendStyle.LineWidth = 0.5;

            geoLegendStyle.LineColor = Color.FromArgb(65, 65, 65);

            geoLegend.BackGroundStyle = geoLegendStyle;

            geoLegend.ColumnCount = 3;


            //设置图例项和图例子项的说明文本的风格

            TextStyle geoLegendtextStyle = new TextStyle();

            geoLegendtextStyle.BackColor = Color.Yellow;

            geoLegendtextStyle.ForeColor = Color.Blue;

            geoLegendtextStyle.FontName = "宋体";

            geoLegendtextStyle.FontHeight = 20.0;

            geoLegendtextStyle.FontWidth = 12.0;

            geoLegendtextStyle.IsSizeFixed = false;

            geoLegend.ItemTextStyle = geoLegendtextStyle;

            geoLegend.SubItemTextStyle = geoLegendtextStyle;

            //设置图例标题风格

            TextStyle titleTextStyle = new TextStyle();

            titleTextStyle.BackColor = Color.Yellow;

            titleTextStyle.ForeColor = Color.Blue;

            titleTextStyle.FontName = "宋体";

            titleTextStyle.FontHeight = 40.0;

            titleTextStyle.FontWidth = 25.0;

            titleTextStyle.Italic = true;

            titleTextStyle.Bold = true;

            titleTextStyle.IsSizeFixed = false;

            titleTextStyle.Weight = 200;

            geoLegend.Title = "图例";

            geoLegend.TitleStyle = titleTextStyle;

            //将图例添加到布局图层,而非屏幕图层。

            geoLegend.Load(false);

            mapLayoutControl1.MapLayout.Elements.AddNew(geoLegend);
        }