Quantcast
Channel: MapWinGIS ActiveX Map and GIS Component
Viewing all articles
Browse latest Browse all 2341

New Post: problem with ShowDialog()

$
0
0
No, I do like you. The only difference is that in the "axMap1_MouseDownEvent" function I have :
        private void AxMap_MouseDownEvent(object sender, AxMapWinGIS._DMapEvents_MouseDownEvent e)
        {
            bool endState = false;
            if (e.button == 1)
            {
                _clickButton = 1;
                endState = _currentState.MouseLeftDown(e.x, e.y);
            }

            if (e.button == 2)
            {
                _clickButton = 2;
                endState = _currentState.MouseRightDown();
            }

            if (endState == true)
            {
                _currentState = new StateNeutral(_axMap);
            }
        }
cause I use desing pattern state. But, for example when I draw a polygon I display two messageBox and it works without problem (here the code in the state drawArea) :
public override bool MouseRightDblClick()
        {
            //Il faut au minimum trois points pour créer un polygone
            if (_numberOfPoint >= 3)
            {
                CreateAreaOfInterest popupCreateAreaOfInterest = new CreateAreaOfInterest();

                while (__DialogResult.OK == popupCreateAreaOfInterest.ShowDialog()__)
                {

                    if (_manager.CheckIfIntelligenceFeatureCanBeCreated(popupCreateAreaOfInterest.GetName().ToLower(), MainManager.TypeOfFeatureIntelligence.areaOfInterest) == true)
                    {

                        //Création du shape représentant la zone
                        Shape newAreaOfInterest = new Shape();
                        newAreaOfInterest.Create(ShpfileType.SHP_POLYGON);
                        int i;
                        for (i = 0; i < _numberOfPoint; i++)
                        {
                            Point newPoint = new Point();
                            newPoint.x = _listOfPoints[i].Longitude;
                            newPoint.y = _listOfPoints[i].Latitude;
                            newPoint.Z = _listOfPoints[i].Altitude;
                            newAreaOfInterest.InsertPoint(newPoint, ref i);
                        }
                        i++;
                        MapWinGIS.Point firstPoint = new MapWinGIS.Point();
                        firstPoint.x = _listOfPoints[0].Longitude;
                        firstPoint.y = _listOfPoints[0].Latitude;
                        firstPoint.Z = _listOfPoints[0].Altitude;
                        newAreaOfInterest.InsertPoint(firstPoint, ref i);

                        //Ajout du shape dans le shapefile
                        int handlerLayerOfAreaOfInterest = _manager.GetHandleStaticLayer(MainManager.TypeOfFeatureIntelligence.areaOfInterest);
                        Shapefile layerOfAreaOfInterest = _axMap.get_Shapefile(handlerLayerOfAreaOfInterest);
                        int indexOfNewAreaOfInterest = layerOfAreaOfInterest.NumShapes;
                        layerOfAreaOfInterest.EditInsertShape(newAreaOfInterest, ref indexOfNewAreaOfInterest);

                        //Changement des propriétés d'affichage
                        ShapefileCategory cat = layerOfAreaOfInterest.Categories.Add("display" + popupCreateAreaOfInterest.GetName());
                        cat.DrawingOptions.FillColor = System.Convert.ToUInt32(System.Drawing.ColorTranslator.ToOle(popupCreateAreaOfInterest.GetColorBackground()));
                        cat.DrawingOptions.FillTransparency = popupCreateAreaOfInterest.GetOpacity();
                        cat.DrawingOptions.LineVisible = popupCreateAreaOfInterest.GetCheckStateBorder();
                        cat.DrawingOptions.LineColor = System.Convert.ToUInt32(System.Drawing.ColorTranslator.ToOle(popupCreateAreaOfInterest.GetColorBorder()));
                        cat.DrawingOptions.LineWidth = popupCreateAreaOfInterest.GetWitdhBorder();
                        layerOfAreaOfInterest.set_ShapeCategory(indexOfNewAreaOfInterest, layerOfAreaOfInterest.Categories.get_CategoryIndex(cat));

                        //Ajout de la nouvelle zone dans le manager
                        _listOfPoints.Add(new Point3D(_listOfPoints[0].Latitude, _listOfPoints[0].Longitude, _listOfPoints[0].Altitude, _listOfPoints[0].Name));
                        _manager.AddAreaOfInterestToList(_manager.CreateAreaOfInterest(_listOfPoints, popupCreateAreaOfInterest.GetName(), popupCreateAreaOfInterest.GetCheckStateFill(), popupCreateAreaOfInterest.GetColorBackground(), popupCreateAreaOfInterest.GetOpacity(), popupCreateAreaOfInterest.GetColorBorder(), popupCreateAreaOfInterest.GetWitdhBorder()), handlerLayerOfAreaOfInterest, indexOfNewAreaOfInterest, popupCreateAreaOfInterest.GetName());

                        __MessageBox.Show("Polygon created");__

                        _axMap.ClearDrawing(_handleDrawingLayer);
                        _listOfPoints.Clear();
                        _numberOfPoint = 0;
                        _lastPoint = new Point3D();
                        _mapLocked = false;     
        }
When I try to draw a point (in the state DrawPoint) with the code following, it doesn't works : the cursor of the map become the cursor of the whole application (I have a treeview and a propertyGrid), I can't move the map and If I resize, the map become black.
public override bool MouseLeftDown(int x, int y)
        {
            MessageBox.Show("Testing");
            //Ajout du shape dans le shapefile
            int handlerLayerOfPlatform = _manager.GetHandleStaticLayer(MainManager.TypeOfFeatureIntelligence.platform);
            Shapefile layerOfPlatform = _axMap.get_Shapefile(handlerLayerOfPlatform);
            int indexOfNewPlatform = layerOfPlatform.NumShapes;

            //Création du shape représentant la plafeforme
            Shape newPlatform = new Shape();
            newPlatform.Create(ShpfileType.SHP_POINT);
            Point newPoint = new Point();
            double longitudeOrX = 0.0;
            double latitudeOrY = 0.0;
            _axMap.PixelToProj(x, y, ref longitudeOrX, ref latitudeOrY);
            newPlatform.AddPoint(longitudeOrX, latitudeOrY);

            //Ajout du nouveau point dans la couche correspondante
            layerOfPlatform.EditInsertShape(newPlatform, ref indexOfNewPlatform);
            _axMap.Redraw();
        }
See this image to understand : http://www.hostingpics.net/viewer.php?id=484073Sanstitre.png

Viewing all articles
Browse latest Browse all 2341

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>