예제 #1
0
        /// <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
            };
        }
예제 #2
0
        /// <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;
            // Visible = true, kalo ingin nampilin Arah Utara
            var northArrowTool = new NorthArrowTool(this)
            {
                Anchor  = AnchorStyles.Right | AnchorStyles.Top,
                Visible = false
            };

            Tools.Add(northArrowTool);

            var scaleBarTool = new ScaleBarTool(this)
            {
                Size    = new Size(230, 50),
                Anchor  = AnchorStyles.Right | AnchorStyles.Bottom,
                Visible = true
            };

            Tools.Add(scaleBarTool);
            // Visible = true, utuk menampilkan legend Map
            //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);

            wheelPanZoomTool = new PanZoomUsingMouseWheelTool(this)
            {
                WheelZoomMagnitude = 0.8
            };                                                                                   //-2};
            Tools.Add(wheelPanZoomTool);

            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);

            // Active = true, biar bisa move point...
            moveTool = new MoveTool {
                Name          = "Move selected vertices",
                FallOffPolicy = FallOffPolicyRule.None,
                IsActive      = true
            };
            Tools.Add(moveTool);

            linearMoveTool = new MoveTool
            {
                Name          = "Move selected vertices (linear)",
                FallOffPolicy = FallOffPolicyRule.Linear
            };
            Tools.Add(linearMoveTool);

            deleteTool = new DeleteTool();
            Tools.Add(deleteTool);

            measureTool = new MeasureTool(this);
            tools.Add(measureTool);

            profileTool = new CoverageProfileTool(this)
            {
                Name = "Make grid profile"
            };
            tools.Add(profileTool);

            curvePointTool = new CurvePointTool();
            Tools.Add(curvePointTool);

            drawPolygonTool = new DrawPolygonTool();
            Tools.Add(drawPolygonTool);

            snapTool = new SnapTool();
            Tools.Add(snapTool);

            var toolTipTool = new ToolTipTool();

            Tools.Add(toolTipTool);

            MapTool fileHandlerTool = new FileDragHandlerTool();

            Tools.Add(fileHandlerTool);

            Width  = 100;
            Height = 100;

            mapPropertyChangedEventHandler =
                new DelayedEventHandler <PropertyChangedEventArgs>(map_PropertyChanged_Delayed)
            {
                SynchronizingObject = this,
                FireLastEventOnly   = true,
                FullRefreshDelay    = 300,
                Filter = (sender, e) => sender is ILayer ||
                         sender is VectorStyle ||
                         sender is ITheme,
                Enabled = false
            };
            mapCollectionChangedEventHandler =
                new DelayedEventHandler <NotifyCollectionChangingEventArgs>(map_CollectionChanged_Delayed)
            {
                SynchronizingObject = this,
                FireLastEventOnly   = true,
                FullRefreshDelay    = 300,
                Filter = (sender, e) => sender is Map ||
                         sender is ILayer,
                Enabled = false
            };

            Map = new Map(ClientSize)
            {
                Zoom = 100
            };
        }