Пример #1
0
        public void Init()
        {
            this.DoubleBuffered = true;
            CommonEventHandler();
            _square        = CanvasUtil.GetPrimeSquare(this.Parent.Width, this.Parent.Height);
            _dSquare       = _square;
            this.BackColor = Color.White;
            InitRightClickMenu();
            InitPanTool();

            _deleteTool = new DeleteTool();
            _deleteTool.StopWorking();
        }
Пример #2
0
        protected override void SetEnabledStateOfControls()
        {
            base.SetEnabledStateOfControls();
            DeleteTool deleteTool = (DeleteTool)this.Controller.Tools.Where(t => t.Name == ControllerBase.DeleteToolName).FirstOrDefault();

            HeuristicLab.Netron.Controller controller = this.Controller as HeuristicLab.Netron.Controller;
            if (Content == null && deleteTool != null && controller != null)
            {
                controller.RemoveTool(deleteTool);
            }
            else
            {
                if ((ReadOnly || Locked) && deleteTool != null && controller != null)
                {
                    controller.RemoveTool(deleteTool);
                }
                else if ((!ReadOnly && !Locked) && deleteTool == null)
                {
                    this.Controller.AddTool(new DeleteTool(ControllerBase.DeleteToolName));
                }
            }
        }
Пример #3
0
        public void CanDeleteWithoutEditableObject()
        {
            MapControl mapControl = new MapControl();

            SelectTool selectTool = mapControl.SelectTool;
            //mapControl.ActivateTool(selectTool);

            VectorLayer       vectorLayer = new VectorLayer();
            FeatureCollection layer2Data  = new FeatureCollection();

            vectorLayer.DataSource = layer2Data;
            layer2Data.FeatureType = typeof(Feature);

            layer2Data.Add(new Point(4, 5));
            layer2Data.Add(new Point(0, 1));
            mapControl.Map.Layers.Add(vectorLayer);

            selectTool.Select((IFeature)layer2Data.Features[0]);

            DeleteTool deleteTool = (DeleteTool)mapControl.GetToolByType(typeof(DeleteTool));

            deleteTool.DeleteSelection();
        }
Пример #4
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
            };
        }
Пример #5
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
            };
        }