/// <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 comboBox1_SelectedIndexChanged(object sender, EventArgs e) { string s_type = comboBox1.SelectedItem.ToString(); GeoMapScale geomapscale = new GeoMapScale(); if (s_type == "1:5000") { geomapscale.Scale = 1 / 5000; mapControl1.Map.Scale = 0.0002; mapControl1.Map.Refresh(); } else if (s_type == "1:10000") { geomapscale.Scale = 1 / 10000; mapControl1.Map.Scale = 0.0001; mapControl1.Map.Refresh(); } else if (s_type == "1:25000") { geomapscale.Scale = 1 / 25000; mapControl1.Map.Scale = 0.00004; mapControl1.Map.Refresh(); } else if (s_type == "1:50000") { geomapscale.Scale = 1 / 50000; mapControl1.Map.Scale = 0.00002; mapControl1.Map.Refresh(); } else if (s_type == "1:100000") { geomapscale.Scale = 1 / 100000; mapControl1.Map.Scale = 0.00001; mapControl1.Map.Refresh(); } else if (s_type == "1:250000") { geomapscale.Scale = 1 / 250000; mapControl1.Map.Scale = 0.000004; mapControl1.Map.Refresh(); } else if (s_type == "1:500000") { geomapscale.Scale = 1 / 500000; mapControl1.Map.Scale = 0.000002; mapControl1.Map.Refresh(); } else if (s_type == "1:1000000") { geomapscale.Scale = 1 / 1000000; mapControl1.Map.Scale = 0.00000001; mapControl1.Map.Refresh(); } }
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); } }
private void 添加标题ToolStripMenuItem_Click(object sender, EventArgs e) { gk066 addTitle = new gk066(); addTitle.StartPosition = FormStartPosition.CenterScreen; //窗体居中 addTitle.ShowDialog(); #region 添加标文本题 //标题添加 TextStyle textStyle = new TextStyle(); textStyle.Alignment = TextAlignment.TopCenter; textStyle.BackColor = Color.FromArgb(65, 65, 65); textStyle.ForeColor = Color.FromArgb(174, 241, 176); textStyle.BackOpaque = false; textStyle.Bold = true; textStyle.FontName = "楷体"; textStyle.FontHeight = addTitle.FontHeight; textStyle.FontWidth = addTitle.FontWidth; textStyle.IsSizeFixed = false; textStyle.Italic = true; textStyle.Outline = true; textStyle.Weight = 500; //添加文本 TextPart textPart = new TextPart(addTitle.title, new Point2D(850, 2150), 0); geoText = new GeoText(textPart, textStyle); //先删除后添加实现刷新效果 if (ElementsId != -1) { ElementsIdS[0] = ElementsId; mapLayoutControl1.MapLayout.Elements.Delete(ElementsIdS); } //添加地图 mapLayoutControl1.MapLayout.Elements.AddNew(geoText); //取得id 下次设定时删除用 ElementsId = mapLayoutControl1.MapLayout.Elements.GetID(); mapLayoutControl1.MapLayout.Elements.Refresh(); #endregion #region 设定图层颜色 与显示比例尺 geoMapUse = mapLayoutControl1.MapLayout.Elements.GetGeometry() as GeoMap; Map map = new Map(); map.Workspace = workspace1; map.FromXML(workspace1.Maps.GetMapXML(geoMapUse.MapName)); LayerSettingVector setting = map.Layers[0].AdditionalSetting as LayerSettingVector; setting.Style.FillForeColor = addTitle.selectColor; map.Layers[0].AdditionalSetting = setting; workspace1.Maps.SetMapXML(geoMapUse.MapName, map.ToXML()); workspace1.Save(); geoMapUse = new GeoMap(); geoMapUse.MapName = "temp"; //设置GeoMap对象的外切矩形 Rectangle2D rect = new Rectangle2D(new Point2D(850, 1300), new Size2D( 1500, 1500)); GeoRectangle geoRect = new GeoRectangle(rect, 0); geoMapUse.Shape = geoRect; //动态设置缩放比例尺 geoMapUse.MapScale = addTitle.scaleNumerator / addTitle.scaleDenominato; mapLayoutControl1.MapLayout.Elements.AddNew(geoMapUse); //记录下mapid ElementsIdMap = mapLayoutControl1.MapLayout.Elements.GetID(); mapLayoutControl1.MapLayout.Elements.Refresh(); #endregion #region 添加地图比例标尺 //添加地图带比例标尺 geoMapScale = new GeoMapScale(ElementsIdMap, new Point2D(1050, 515), 550, 18); geoMapScale.ScaleUnit = Unit.Kilometer; geoMapScale.LeftDivisionCount = 2; geoMapScale.SegmentCount = 2; geoMapScale.ScaleType = GeoMapScaleType.Railway; ////先删除后添加实现刷新效果 if (ElementsIdScale != -1) { ElementsIdScaleArrar[0] = ElementsIdScale; mapLayoutControl1.MapLayout.Elements.Delete(ElementsIdScaleArrar); } //取得id 下次设定时删除用 mapLayoutControl1.MapLayout.Elements.AddNew(geoMapScale); ElementsIdScale = mapLayoutControl1.MapLayout.Elements.GetID(); mapLayoutControl1.MapLayout.Elements.Refresh(); #endregion addTitle.Close(); }