/// <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); } }
private void 指南针ToolStripMenuItem_Click(object sender, EventArgs e) { Rectangle2D rectangle2D = new Rectangle2D( new Point2D(200, 1900), new Size2D(150, 150)); GeoNorthArrow geoNorthArrow = new GeoNorthArrow( NorthArrowStyleType.ArrowWithShadow, rectangle2D, 0); geoNorthArrow.BindingGeoMapID = GetMapID(); mapLayoutControl1.MapLayout.Elements.AddNew(geoNorthArrow); }
private void InitializeLayout() { try { LayoutElements elements = mapLayoutControl1.MapLayout.Elements; // 构造GeoMap // Create the GeoMap object. GeoMap geoMap = new GeoMap(); geoMap.MapName = "地籍图"; // 设置GeoMap对象的外切矩形 // Set the exterior rectangle. Rectangle2D rect = new Rectangle2D(new Point2D(850, 1300), new Size2D( 1500, 1500)); GeoRectangle geoRect = new GeoRectangle(rect, 0); geoMap.Shape = geoRect; elements.AddNew(geoMap); m_mapID = elements.GetID(); // 构造指北针 // Initialize the GeoNorthArrow GeoNorthArrow northArrow = new GeoNorthArrow( NorthArrowStyleType.EightDirection, new Rectangle2D(new Point2D(1400, 2250), new Size2D(350, 350)), 0); northArrow.BindingGeoMapID = m_mapID; elements.AddNew(northArrow); // 构造比例尺 // Initialize the scale GeoMapScale scale = new GeoMapScale(m_mapID, new Point2D(125, 400), 50, 50); scale.LeftDivisionCount = 2; scale.ScaleUnit = Unit.Kilometer; scale.SegmentCount = 4; elements.AddNew(scale); } catch (Exception ex) { MessageBox.Show(ex.Message); } }