MapControl fires Maprefreshed-Event automatically

Topics: SharpMap v0.9 / v1.x
Apr 24, 2014 at 12:40 PM
Edited Apr 25, 2014 at 11:17 AM
Hello,
Sometimes, after Mouse-Click in MapBox fires Maprefreshed-Event.
No Tool ist active.
this.mapBox.ActiveTool = MapBox.Tools.None;

Why?

Thank's!
Coordinator
Apr 25, 2014 at 12:20 AM
Try disabling the statusbar.
Apr 25, 2014 at 8:12 AM
Hello,
how disabling statusbar?
I use SharpMap and WinForm.
When Clicking in the Map sometimes MapRefreshed Event fired.

Here is my Testcode

namespace SharpMapRendering
{
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

using SharpMap.Forms;
using SharpMap.Layers;
using SharpMap.Styles;

public partial class Form1 : Form
{
    private MapBox mapBox;

    public Form1()
    {
        InitializeComponent();
        this.InitializeControls();
    }

    private void InitializeControls()
    {
        this.mapBox = new MapBox
                          {
                              Size = new Size(this.Size.Width, this.Size.Height),
                              Location = new Point(0, 0),
                              PreviewMode = MapBox.PreviewModes.Fast,
                              Dock = DockStyle.Fill
                          };
        this.Controls.Add(this.mapBox);
        var vectorLayer = new VectorLayer("Polygon")
        {
            DataSource = new SharpMap.Data.Providers.ShapeFile("D:\\test.shp"),
        };

        var style = new VectorStyle
        {
            Fill = new SolidBrush(Color.FromArgb(127, 0, 150, 255)),
            Outline =
                new Pen(Color.FromArgb(0, 150, 255), 2)
                {
                    LineJoin = LineJoin.Bevel
                },
                EnableOutline = true
        };


        vectorLayer.Style = style;
        this.mapBox.Map.VariableLayers.Add(vectorLayer);
        this.mapBox.Map.ZoomToExtents();
        this.mapBox.Map.BackColor = Color.White;
        this.mapBox.ActiveTool = MapBox.Tools.None;
        this.mapBox.MapRefreshed += this.MapBoxOnMapRefreshed;
        this.mapBox.Refresh();
    }

    private void MapBoxOnMapRefreshed(object sender, EventArgs e)
    {
        Debug.Print("Maprefreshed: Fired when the map has been refreshed");
    }
}
}
Coordinator
Apr 25, 2014 at 9:53 AM
Why do you place your shapefile layer in the VariableLayerCollection? If there is no temporal component to it, at least your code don't show that. Use the default (static) layer collection
this.mapBox.Map.Layers.Add(vectorLayer);
Apr 25, 2014 at 11:13 AM
Edited Apr 25, 2014 at 11:14 AM
Hello,
no the shape ist only test-case!
the event also fired , when static.
original i have a Featureprovider for a VariableLayer
    
this.mapBox.Map.VariableLayers.Add(new VectorLayer("Digitize", this.layerFeatureProvider)
            {
                Style = new VectorStyle
                {
                    Outline = new Pen(this.colorDigitizeObjects, 3F)
                            {
                                  LineJoin = LineJoin.Round
                            },
                    PointSize = 8f,
                    PointColor = Brushes.Green,
                    Fill = new SolidBrush(Color.FromArgb(127, this.colorDigitizeObjects)),
                    EnableOutline = true
                }
            });
I click in the Map (no Tool is active) an sometimes the MapRefreshed-event is done.
Why?

Is that an Error on the MapBox?
Apr 28, 2014 at 12:55 PM
Hi,
i checked:
after clicking an move Mouse the MapRefresh-Event fires .
Ther isn't an active Tool in map!

Can I disable this?
Coordinator
Apr 28, 2014 at 1:59 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.