private void toolStripButton1_Click(object sender, EventArgs e) { GeoText text = new GeoText(); // 设置文本子对象的属性 TextPart textPart = new TextPart(); textPart.AnchorPoint = new Point2D(250, 500); textPart.Rotation = 30; textPart.Text = "城市地籍图"; textPart.X = 250; textPart.Y = 500; textPart.Offset(10.0, 20.0); // 设置文本风格 TextStyle textStyle = new TextStyle(); textStyle.Shadow = true; textStyle.Alignment = TextAlignment.TopCenter; textStyle.FontName = "宋体"; textStyle.FontHeight = 10.0; textStyle.FontWidth = 10.0; textStyle.Weight = 500; textStyle.BackColor = System.Drawing.Color.White; textStyle.ForeColor = System.Drawing.Color.Black; Geometry geometry = new GeoText(textPart, textStyle); LayoutElements elements = mapLayoutControl1.MapLayout.Elements; elements.AddNew(geometry); }
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); }
private void Initialize() { try { layersControl1.Map = mapControl1.Map; mapControl1.Action = Action.Pan; m_mapControlEagleEye.Map.ViewEntire(); m_mapControlEagleEye.MarginPanEnabled = false; m_mapControlEagleEye.IsWaitCursorEnabled = false; m_mapControlEagleEye.InteractionMode = InteractionMode.CustomAll; m_mapControlEagleEye.Cursor = Cursors.Arrow; workspaceControl1.WorkspaceTree.NodeMouseDoubleClick += new TreeNodeMouseClickEventHandler(WorkspaceTree_NodeMouseDoubleClick); mapControl1.IsWaitCursorEnabled = false; mapControl1.TrackMode = TrackMode.Track; m_mapLayoutControl.TrackMode = TrackMode.Edit; m_mapLayoutControl.MapLayout.Zoom(4); elements = m_mapLayoutControl.MapLayout.Elements; geoMap = new GeoMap(); m_myAction = MeasureAction.None; mapControl1.MouseMove += new MouseEventHandler(MouseMoveHandler); mapControl1.Tracking += new TrackingEventHandler(TrackingHandler); mapControl1.Tracked += new TrackedEventHandler(TrackedHandler); } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
public async Task <PageLayoutViewModel> GetLayoutElement(string pageName, int siteID) { var ds = await new BlockDataProvider().GetLayoutElement(pageName, siteID); PageLayoutViewModel obj = new PageLayoutViewModel() { Elements = new List <LayoutElements>(), }; IList <LayoutElement> lstElements = DataSourceHelper.FillCollection <LayoutElement>(ds.Tables[0]); IList <ViewModule> lstModule = DataSourceHelper.FillCollection <ViewModule>(ds.Tables[1]); foreach (var e in lstElements) { if (e.HasInnerElement) { LayoutElements ele = CreateElements(e); ele.InnerElements = GetInnerElement(e.ElementID, lstElements, lstModule); obj.Elements.Add(ele); } else { break; } } return(obj); }
/// <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); } }
/// <summary> /// Suggest layout for two objects... /// </summary> /// <param name="store"></param> /// <param name="ObjectX"></param> /// <param name="ObjectY"></param> /// <param name="ConstType"></param> /// <returns></returns> public List <DomElement> SuggestLayout(Guid ObjectX, Guid ObjectY, byte ConstType) { var allXelements = Query.Where(o => o.OwnerObjectId == ObjectX && o.OwnerObjectType == ConstType).SelectAll(); var allYelements = Query.Where(o => o.OwnerObjectId == ObjectY && o.OwnerObjectType == ConstType).SelectAll(); return(LayoutElements.FindPlaceHolders(allXelements, allYelements)); // return FindPlaceHolders(allXelements, allYelements); }
public LayoutMap GetMainMap() { var maps = LayoutElements.OfType <LayoutMap>().ToList(); if (maps.Count() > 1 && maps.Any(m => m.IsMain)) { return(maps.FirstOrDefault(m => m.IsMain)); } return(maps.FirstOrDefault()); }
private void SelectFirstElement() { ClearSelection(); var el = LayoutElements.OfType <LayoutMap>().FirstOrDefault() ?? LayoutElements.FirstOrDefault(); if (el != null) { AddToSelection(new List <LayoutElement> { el }); } }
private LayoutElements CreateElements(LayoutElement e) { LayoutElements ele = new LayoutElements() { ID = e.ID, ElementID = e.ElementID, ParentID = e.ParentID, DisplayOrder = e.DisplayOrder, Attributes = e.Attributes, EleType = e.EleType, HasInnerElement = e.HasInnerElement, HasModules = e.HasModules }; return(ele); }
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); } }
public gk065() { InitializeComponent(); workspace1 = new SuperMap.Data.Workspace(); /* WorkspaceConnectionInfo workspaceConnectionInfo = new WorkspaceConnectionInfo(); * workspaceConnectionInfo.Type = WorkspaceType.Oracle; * workspaceConnectionInfo.Server = "ORCL"; * workspaceConnectionInfo.Database = ""; * workspaceConnectionInfo.Name = "workspace"; * workspaceConnectionInfo.User = "******"; * workspaceConnectionInfo.Password = "******"; * workspace1.Open(workspaceConnectionInfo);*/ workspace1.Open(gkfqd.Common.Tool.GetConnectionInfo()); mapLayoutControl1.MapLayout.Workspace = workspace1; mapLayoutControl1.IsHorizontalScrollbarVisible = true; mapLayoutControl1.IsVerticalScrollbarVisible = true; try { LayoutElements elements = mapLayoutControl1.MapLayout.Elements; //构造GeoMap GeoMap geoMap = new GeoMap(); geoMap.MapName = "temp"; //设置GeoMap对象的外切矩形 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(); } catch (Exception ex) { Trace.WriteLine(ex.Message); } mapLayoutControl1.TrackMode = TrackMode.Edit; mapLayoutControl1.MapLayout.Zoom(4); }
private void AddMap(string mapName) { try { LayoutElements elements = mapLayoutControl1.MapLayout.Elements; //构造GeoMap GeoMap geoMapUse = new GeoMap(); geoMapUse.MapName = mapName; // geoMapUse. = m_mapControl.Map; //设置GeoMap对象的外切矩形 Rectangle2D rect = new Rectangle2D(new Point2D(850, 1300), new Size2D( 1500, 1500)); GeoRectangle geoRect = new GeoRectangle(rect, 0); geoMapUse.Shape = geoRect; elements.AddNew(geoMapUse); m_mapID = elements.GetID(); } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
public void InitializeLayout(string mapName) { try { LayoutElements elements = m_mapLayoutControl.MapLayout.Elements; // 构造GeoMap GeoMap geoMap = new GeoMap(); //设置地图名称,在工作空间内的地图 geoMap.MapName = mapName; // 设置GeoMap对象的外切矩形 Rectangle2D rect = new Rectangle2D(new Point2D(1000, 1300), new Size2D(1500, 1500)); GeoRectangle geoRect = new GeoRectangle(rect, 0); geoMap.Shape = geoRect; elements.AddNew(geoMap); m_mapID = elements.GetID(); } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
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); }
/// <summary> /// Gets requested element from the layout /// </summary> protected T GetElement <T>(ElementType role) where T : LayoutElement { return(LayoutElements.FirstOrDefault(item => item is T && item.Type == role) as T); }