/// <summary> /// Initializes a new map /// </summary> public MapControl() { SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true); LostFocus += MapBox_LostFocus; AllowDrop = true; tools = new EventedList <IMapTool>(); tools.CollectionChanged += tools_CollectionChanged; var northArrowTool = new NorthArrowTool(this); northArrowTool.Anchor = AnchorStyles.Right | AnchorStyles.Top; northArrowTool.Visible = false; // activate using commands Tools.Add(northArrowTool); var scaleBarTool = new ScaleBarTool(this); scaleBarTool.Size = new Size(230, 50); scaleBarTool.Anchor = AnchorStyles.Right | AnchorStyles.Bottom; scaleBarTool.Visible = true; Tools.Add(scaleBarTool); legendTool = new LegendTool(this) { Anchor = AnchorStyles.Left | AnchorStyles.Top, Visible = false }; Tools.Add(legendTool); queryTool = new QueryTool(this); Tools.Add(queryTool); // add commonly used tools zoomHistoryTool = new ZoomHistoryTool(this); Tools.Add(zoomHistoryTool); panZoomTool = new PanZoomTool(this); Tools.Add(panZoomTool); wheelZoomTool = new ZoomUsingMouseWheelTool(this); wheelZoomTool.WheelZoomMagnitude = 0.8; Tools.Add(wheelZoomTool); rectangleZoomTool = new ZoomUsingRectangleTool(this); Tools.Add(rectangleZoomTool); fixedZoomInTool = new FixedZoomInTool(this); Tools.Add(fixedZoomInTool); fixedZoomOutTool = new FixedZoomOutTool(this); Tools.Add(fixedZoomOutTool); selectTool = new SelectTool { IsActive = true }; Tools.Add(selectTool); moveTool = new MoveTool(); moveTool.Name = "Move selected vertices"; moveTool.FallOffPolicy = FallOffPolicyRule.None; Tools.Add(moveTool); linearMoveTool = new MoveTool(); linearMoveTool.Name = "Move selected vertices (linear)"; linearMoveTool.FallOffPolicy = FallOffPolicyRule.Linear; Tools.Add(linearMoveTool); deleteTool = new DeleteTool(); Tools.Add(deleteTool); measureTool = new MeasureTool(this); tools.Add(measureTool); profileTool = new GridProfileTool(this); profileTool.Name = "Make grid profile"; tools.Add(profileTool); curvePointTool = new CurvePointTool(); Tools.Add(curvePointTool); snapTool = new SnapTool(); Tools.Add(snapTool); var toolTipTool = new ToolTipTool(); Tools.Add(toolTipTool); MapTool fileHandlerTool = new FileDragHandlerTool(); Tools.Add(fileHandlerTool); Tools.Add(new ExportMapToImageMapTool()); Width = 100; Height = 100; mapPropertyChangedEventHandler = new SynchronizedDelayedEventHandler <PropertyChangedEventArgs>(map_PropertyChanged_Delayed) { FireLastEventOnly = true, Delay2 = 300, Filter = (sender, e) => sender is ILayer || sender is VectorStyle || sender is ITheme, SynchronizeInvoke = this, Enabled = false }; mapCollectionChangedEventHandler = new SynchronizedDelayedEventHandler <NotifyCollectionChangedEventArgs>(map_CollectionChanged_Delayed) { FireLastEventOnly = true, Delay2 = 300, Filter = (sender, e) => sender is Map || sender is ILayer, SynchronizeInvoke = this, Enabled = false }; Map = new Map(ClientSize) { Zoom = 100 }; }
/// <summary> /// Initializes a new map /// </summary> public MapControl() { SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true); LostFocus += MapBox_LostFocus; base.AllowDrop = true; tools = new EventedList <IMapTool>(); tools.CollectionChanged += tools_CollectionChanged; var northArrowTool = new NorthArrowTool() { Anchor = AnchorStyles.Right | AnchorStyles.Top, Visible = false }; Tools.Add(northArrowTool); var scaleBarTool = new ScaleBarTool() { Size = new Size(230, 50), Anchor = AnchorStyles.Right | AnchorStyles.Bottom, Visible = true }; Tools.Add(scaleBarTool); legendTool = new LegendTool { Anchor = AnchorStyles.Left | AnchorStyles.Top, Visible = false }; Tools.Add(legendTool); queryTool = new QueryTool(); Tools.Add(queryTool); // add commonly used tools zoomHistoryTool = new ZoomHistoryTool(); Tools.Add(zoomHistoryTool); panZoomTool = new PanZoomTool(); Tools.Add(panZoomTool); wheelPanZoomTool = new PanZoomUsingMouseWheelTool() { WheelZoomMagnitude = 0.8 }; Tools.Add(wheelPanZoomTool); rectangleZoomTool = new ZoomUsingRectangleTool(); Tools.Add(rectangleZoomTool); fixedZoomInTool = new FixedZoomInTool(); Tools.Add(fixedZoomInTool); fixedZoomOutTool = new FixedZoomOutTool(); Tools.Add(fixedZoomOutTool); selectTool = new SelectTool { IsActive = true }; Tools.Add(selectTool); deleteTool = new DeleteTool(); Tools.Add(deleteTool); moveTool = new MoveTool { Name = "Move selected vertices", FallOffPolicy = FallOffType.None }; Tools.Add(moveTool); linearMoveTool = new MoveTool { Name = "Move selected vertices (linear)", FallOffPolicy = FallOffType.Linear }; Tools.Add(linearMoveTool); measureTool = new MeasureTool(); tools.Add(measureTool); profileTool = new CoverageProfileTool { Name = "Make grid profile" }; tools.Add(profileTool); curvePointTool = new CurvePointTool(); Tools.Add(curvePointTool); snapTool = new SnapTool(); Tools.Add(snapTool); var toolTipTool = new ToolTipTool(); Tools.Add(toolTipTool); Width = 100; Height = 100; mapPropertyChangedEventHandler = new DelayedEventHandler <PropertyChangedEventArgs>(map_PropertyChanged_Delayed) { SynchronizingObject = this, FireLastEventOnly = true, Delay = 300, Filter = (sender, e) => sender is ILayer || sender is VectorStyle || sender is ITheme || sender is IList <ILayer>, Enabled = false }; mapCollectionChangedEventHandler = new DelayedEventHandler <NotifyCollectionChangingEventArgs>(map_CollectionChanged_Delayed) { SynchronizingObject = this, FireLastEventOnly = true, Delay = 300, FullRefreshEventHandler = (sender, e) => OnFullRefresh(sender, e), Filter = (sender, e) => sender is Map || sender is ILayer || sender is IList <ILayer>, Enabled = false }; Map = new Map(ClientSize) { Zoom = 100 }; }