Ejemplo n.º 1
0
    /// <summary>
    /// Attaches handers for all map events
    /// </summary>
    public static void AttachMap(AxMapWinGIS.AxMap axMap1)
    {
        axMap1.MouseDownEvent += delegate(object sender, AxMapWinGIS._DMapEvents_MouseDownEvent e)
        {
            var param = new[] { sender, e };
            Invoke(_mouseDownDelegate, param);
        };

        axMap1.MouseMoveEvent += delegate(object sender, AxMapWinGIS._DMapEvents_MouseMoveEvent e)
        {
            var param = new[] { sender, e };
            Invoke(_mouseMoveDelegate, param);
        };

        axMap1.MouseUpEvent += delegate(object sender, AxMapWinGIS._DMapEvents_MouseUpEvent e)
        {
            var param = new[] { sender, e };
            Invoke(_mouseUpDelegate, param);
        };

        axMap1.SelectBoxFinal += delegate(object sender, AxMapWinGIS._DMapEvents_SelectBoxFinalEvent e)
        {
            var param = new[] { sender, e };
            Invoke(_selectBoxDelegate, param);
        };

        axMap1.ShapeHighlighted += delegate(object sender, AxMapWinGIS._DMapEvents_ShapeHighlightedEvent e)
        {
            var param = new[] { sender, e };
            Invoke(_shapeHighlightedDelegate, param);
        };
    }
Ejemplo n.º 2
0
        public DBConnectionTool(AxMapWinGIS.AxMap axMap, MapControlTools mapControlTool) : base(axMap, mapControlTool)
        {
            try
            {
                if (ConfigurationManager.AppSettings["UseOfflineDB"] == "true")
                {
                    ConfigDBConnectionName = "ResTBLocalDB";
                }
                else
                {
                    ConfigDBConnectionName = "ResTBOnlineDB";
                }


                string appconnection = ConfigurationManager.ConnectionStrings[ConfigDBConnectionName].ConnectionString;
                ParseEFConnectionString(appconnection);
            }
            catch (Exception e)
            {
                Events.MapControl_Error error = new Events.MapControl_Error()
                {
                    ErrorCode = Events.ErrorCodes.MissingDBConfiguration, InMethod = "DBConnectionTool", InnerException = e
                };
                On_Error(error);
            }
        }
Ejemplo n.º 3
0
 public DBConnectionTool(AxMapWinGIS.AxMap axMap, MapControlTools mapControlTool, string EFConnectionString, bool parseEFConnection) : base(axMap, mapControlTool)
 {
     if (parseEFConnection)
     {
         ParseEFConnectionString(EFConnectionString);
     }
 }
        private void MapControl_Initialized(object sender, EventArgs e)
        {
            // Create the interop host control.
            System.Windows.Forms.Integration.WindowsFormsHost host =
                new System.Windows.Forms.Integration.WindowsFormsHost();

            axMap1     = new AxMapWinGIS.AxMap();
            host.Child = axMap1;

            new GlobalSettings()
            {
                BingApiKey = "AimcXg9FM3tvlLlm3DJlO7kw_8QRFCJI5BkRA0IWJQP-Y5wtZJGJw81C-YuTcMMF"
            };

            string localData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

            //new GlobalSettings().StartLogTileRequests(localData + @"\ResTBDesktop\tiles.txt");


            new GlobalSettings().AllowLayersWithoutProjections         = true;
            new GlobalSettings().AllowLayersWithIncompleteReprojection = true;
            new GlobalSettings().ReprojectLayersOnAdding = true;

            this.ResTBMap.Children.Add(host);
            _tools = new MapControlTools(axMap1);
        }
Ejemplo n.º 5
0
 public LegendEditorForm(int handle, bool isLayer, AxMapWinGIS.AxMap axmap)
 {
     InitializeComponent();
     LoadProperties(handle, isLayer);
     map           = axmap;
     this.ShowHint = WeifenLuo.WinFormsUI.Docking.DockState.Float;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Runs caching
        /// </summary>
        private void btnRunCaching_Click(object sender, EventArgs e)
        {
            string filename = Application.StartupPath + @"\TilesPrefetcher.exe";

            if (!File.Exists(filename))
            {
                MessageBox.Show("File is missing: " + filename);
            }
            else
            {
                AxMapWinGIS.AxMap map = mapWin.GetOCX as AxMapWinGIS.AxMap;
                Extents           ext = map.GeographicExtents;
                if (ext == null)
                {
                    MessageBox.Show("Geographic extents of the map aren't set.");
                }
                else
                {
                    double xMin, xMax, yMin, yMax, zMin, zMax;
                    ext.GetBounds(out xMin, out yMin, out zMin, out xMax, out yMax, out zMax);
                    String s = String.Format("{0} {1} {2} {3} {4} {5}", yMin, yMax, xMin, xMax, tiles.ProviderId, tiles.DiskCacheFilename);
                    Debug.Print(s);

                    ProcessStartInfo startInfo = new ProcessStartInfo();
                    startInfo.FileName  = filename;
                    startInfo.Arguments = s;
                    Process.Start(startInfo);
                }
            }
        }
Ejemplo n.º 7
0
        public AttributesForm(AxMapWinGIS.AxMap axMap, Shapefile sf, int shapeIndex, int layerHandle)
        {
            _axMap       = axMap;
            _sf          = sf;
            _shapeIndex  = shapeIndex;
            _layerHandle = layerHandle;

            InitializeComponent();
        }
Ejemplo n.º 8
0
        public ExportImportTool(AxMapWinGIS.AxMap axMap, MapControlTools mapControlTool) : base(axMap, mapControlTool)
        {
            string localData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

            if (!System.IO.Directory.Exists(localData + "\\ResTBDesktop"))
            {
                System.IO.Directory.CreateDirectory(localData + "\\ResTBDesktop");
            }

            localDirectory = localData + "\\ResTBDesktop";
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates a new instance of the selection object tuned to a specific map
        /// </summary>
        /// <param name="Map"></param>
        public Selection(AxMapWinGIS.AxMap Map)
        {
            m_Map = Map;

            // Appearance
            m_SelectionColor         = System.Drawing.Color.Cyan;
            m_SelectionLineThickness = 3;
            m_ShowSelection          = true;
            m_SelectionMode          = MapWinGIS.SelectMode.INTERSECTION;
            // No current layer assumes that we should select shapes from all layers
            m_CurrentLayer        = -1;
            m_Map.MouseDownEvent += new AxMapWinGIS._DMapEvents_MouseDownEventHandler(m_Map_MouseDownEvent);
            m_Map.MouseUpEvent   += new AxMapWinGIS._DMapEvents_MouseUpEventHandler(m_Map_MouseUpEvent);
            m_Map.SelectBoxFinal += new AxMapWinGIS._DMapEvents_SelectBoxFinalEventHandler(m_Map_SelectBoxFinal);
        }
Ejemplo n.º 10
0
 public DBConnectionTool(AxMapWinGIS.AxMap axMap, MapControlTools mapControlTool, string configDBConnectionName) : base(axMap, mapControlTool)
 {
     try
     {
         ConfigDBConnectionName = configDBConnectionName;
         string appconnection = ConfigurationManager.ConnectionStrings[ConfigDBConnectionName].ConnectionString;
         ParseEFConnectionString(appconnection);
     }
     catch (Exception e)
     {
         Events.MapControl_Error error = new Events.MapControl_Error()
         {
             ErrorCode = Events.ErrorCodes.MissingDBConfiguration, InMethod = "DBConnectionTool", InnerException = e
         };
         On_Error(error);
     }
 }
Ejemplo n.º 11
0
        internal static bool RunOgrDatasourceTest(string textfileLocation, Form1 theForm)
        {
            form = theForm;
            map  = Fileformats.Map;

            Debug.Print("\nStart OGR datasource test");

            //ListDriverCapability();

            //ListLayers();

            //TestMetadata();

            //DisplayAllLayers();

            //TestSpatialQuery();

            //ImportShapefilesFromFolder();

            //TestExecuteSQL();

            Debug.Print("End OGR datasource test");
            return(true);
        }
Ejemplo n.º 12
0
        public void setStyleForLayer(AxMapWinGIS.AxMap axMap, int layerHandle)
        {
            Shapefile sf = axMap.get_OgrLayer(layerHandle).GetBuffer();

            createStyle(sf);
        }
Ejemplo n.º 13
0
 public SelectObjectTool(AxMapWinGIS.AxMap axMap, MapControlTools mapControlTool) : base(axMap, mapControlTool)
 {
 }
Ejemplo n.º 14
0
 public virtual void ApplyStyle(AxMapWinGIS.AxMap AxMap)
 {
 }
Ejemplo n.º 15
0
        AxMapWinGIS.AxMap m_Map; // A local pointer to the map this toolbox works with


        #endregion

        #region Constructor
        /// <summary>
        /// Creates a new toolbox that is tuned to a specific ActiveX Map
        /// </summary>
        /// <param name="Map">This specifies an ActiveX Map for the tools to work on.</param>
        public Toolbox(AxMapWinGIS.AxMap Map)
        {
            m_Map = Map; // Set the local copy
        }
Ejemplo n.º 16
0
 public BaseTool(AxMapWinGIS.AxMap axMap, MapControlTools mapControlTools)
 {
     this.AxMap           = axMap;
     this.MapControlTools = mapControlTools;
 }
Ejemplo n.º 17
0
        private void Map(Round t)
        {
            AxMapWinGIS.AxMap map = new AxMapWinGIS.AxMap();
            map.Width  = 380;
            map.Height = 380;
            host.Child = map;
            map.Show();
            map.CreateControl();
            map.ShowZoomBar     = false;
            map.ShowCoordinates = MapWinGIS.tkCoordinatesDisplay.cdmNone;
            map.CursorMode      = MapWinGIS.tkCursorMode.cmNone;

            MapWinGIS.Shapefile shapeFileMap = new MapWinGIS.Shapefile();
            shapeFileMap.Open(@"D:\Projets\TheManager\TheManager_GUI\bin\Debug\gis\world\World_Countries.shp", null);
            map.AddLayer(shapeFileMap, true);
            ILocalisation localisation = Session.Instance.Game.kernel.LocalisationTournament(t.Tournament);
            double        logoSize     = 30.0;

            if (localisation as Country != null)
            {
                map.ZoomToShape(0, (localisation as Country).ShapeNumber);
            }
            else
            {
                if (localisation.Name() == "Europe")
                {
                    map.ZoomToShape(0, 68 /*12 101*/);
                    map.CurrentZoom = 4;
                }
                else if (localisation.Name() == "Africa")
                {
                    map.ZoomToShape(0, 40);
                    map.CurrentZoom = 3;
                }
                logoSize = 15.0;
            }

            foreach (Club c in t.clubs)
            {
                CityClub cc = c as CityClub;
                if (cc != null)
                {
                    double projX = -1;
                    double projY = -1;
                    map.DegreesToProj(cc.city.Position.Longitude, cc.city.Position.Latitude, ref projX, ref projY);

                    MapWinGIS.Image img = new MapWinGIS.Image();
                    img.Open(Utils.Logo(c));

                    MapWinGIS.Shapefile sf = new MapWinGIS.Shapefile();
                    sf.CreateNew("", MapWinGIS.ShpfileType.SHP_POINT);
                    sf.DefaultDrawingOptions.AlignPictureByBottom = false;
                    sf.DefaultDrawingOptions.PointType            = MapWinGIS.tkPointSymbolType.ptSymbolPicture;
                    sf.DefaultDrawingOptions.Picture       = img;
                    sf.DefaultDrawingOptions.PictureScaleX = Math.Round(logoSize / img.OriginalWidth, 2);
                    sf.DefaultDrawingOptions.PictureScaleY = Math.Round(logoSize / img.OriginalHeight, 2);
                    sf.CollisionMode = MapWinGIS.tkCollisionMode.AllowCollisions;

                    MapWinGIS.Shape shp = new MapWinGIS.Shape();
                    shp.Create(MapWinGIS.ShpfileType.SHP_POINT);
                    shp.AddPoint(projX, projY);
                    sf.EditAddShape(shp);

                    map.AddLayer(sf, true);
                }
            }
            if (_competition.rounds[_indexTour].clubs.Count > 0 && _competition.rounds[_indexTour].clubs[0] as NationalTeam != null)
            {
                shapeFileMap.StartEditingTable();
                int fieldIndex = shapeFileMap.EditAddField("Qualification", MapWinGIS.FieldType.INTEGER_FIELD, 1, 1);
                shapeFileMap.DefaultDrawingOptions.FillType = MapWinGIS.tkFillType.ftStandard;
                for (int i = 0; i < shapeFileMap.NumShapes; i++)
                {
                    shapeFileMap.EditCellValue(fieldIndex, i, 0);
                }
                Dictionary <NationalTeam, int> clubCourses = new Dictionary <NationalTeam, int>();
                for (int i = 0; i < _competition.rounds.Count; i++)
                {
                    Round round = _competition.rounds[i];
                    foreach (Club c in round.clubs)
                    {
                        NationalTeam nt = c as NationalTeam;
                        if (!clubCourses.ContainsKey(nt))
                        {
                            clubCourses.Add(nt, 1);
                        }
                        clubCourses[nt] = i + 1;
                    }
                }
                foreach (KeyValuePair <NationalTeam, int> kvp in clubCourses)
                {
                    shapeFileMap.EditCellValue(fieldIndex, kvp.Key.country.ShapeNumber, kvp.Value);
                }
                shapeFileMap.Categories.Generate(fieldIndex, MapWinGIS.tkClassificationType.ctUniqueValues, _competition.rounds.Count + 1);
                shapeFileMap.Categories.ApplyExpressions();
                MapWinGIS.ColorScheme colorScheme = new MapWinGIS.ColorScheme();
                colorScheme.SetColors2(MapWinGIS.tkMapColor.AliceBlue, MapWinGIS.tkMapColor.DarkBlue);
                shapeFileMap.Categories.ApplyColorScheme(MapWinGIS.tkColorSchemeType.ctSchemeGraduated, colorScheme);
            }
            map.Redraw();
        }
 public LayerHandlingTool(AxMapWinGIS.AxMap axMap, MapControlTools mapControlTool) : base(axMap, mapControlTool)
 {
 }
Ejemplo n.º 19
0
 public PrintTool(AxMapWinGIS.AxMap axMap, MapControlTools mapControlTool) : base(axMap, mapControlTool)
 {
 }
Ejemplo n.º 20
0
        private void Map()
        {
            AxMapWinGIS.AxMap map = new AxMapWinGIS.AxMap();
            map.Width           = 450;
            map.MouseDownEvent += Map_MouseDownEvent;
            map.Height          = 600;
            host.Child          = map;
            map.Show();
            map.ShapeHighlighted += Map_ShapeHighlighted;
            map.CreateControl();
            map.ShowZoomBar     = false;
            map.ShowCoordinates = MapWinGIS.tkCoordinatesDisplay.cdmNone;
            map.CursorMode      = MapWinGIS.tkCursorMode.cmIdentify;

            MapWinGIS.Shapefile shapeFileMap = new MapWinGIS.Shapefile();
            shapeFileMap.Open(@"D:\Projets\TheManager\TheManager_GUI\bin\Debug\gis\world\World_Countries.shp", null);
            shapeFileMap.Identifiable = false;
            map.AddLayer(shapeFileMap, true);
            map.ZoomToShape(0, 77);

            MapWinGIS.Shapefile sf = new MapWinGIS.Shapefile();
            sf.Identifiable = true;
            sf.CreateNew("", MapWinGIS.ShpfileType.SHP_POINT);
            sf.DefaultDrawingOptions.AlignPictureByBottom = false;
            sf.DefaultDrawingOptions.PointType            = MapWinGIS.tkPointSymbolType.ptSymbolStandard;
            sf.CollisionMode = MapWinGIS.tkCollisionMode.AllowCollisions;

            List <City> takenCities = new List <City>();

            foreach (Journalist journalist in _media.journalists)
            {
                double projX = -1;
                double projY = -1;
                map.DegreesToProj(journalist.baseCity.Position.Longitude, journalist.baseCity.Position.Latitude, ref projX, ref projY);

                if (takenCities.Contains(journalist.baseCity))
                {
                    projY += Session.Instance.Random(3, 12) / 10.0;
                }

                MapWinGIS.Shape shp = new MapWinGIS.Shape();
                shp.Create(MapWinGIS.ShpfileType.SHP_POINT);
                shp.AddPoint(projX, projY);
                _indexOrders.Add(sf.EditAddShape(shp));
                takenCities.Add(journalist.baseCity);
            }
            int layer = map.AddLayer(sf, true);

            foreach (Journalist journalist in _media.journalists)
            {
                int    handle = map.NewDrawing(MapWinGIS.tkDrawReferenceList.dlScreenReferencedList);
                double pixX   = -1;
                double pixY   = -1;
                map.DegreesToPixel(journalist.baseCity.Position.Longitude, journalist.baseCity.Position.Latitude, ref pixX, ref pixY);

                float maxDistance = -1;
                foreach (Match m in journalist.CommentedGames)
                {
                    float dist = Utils.Distance(m.home.stadium.city, journalist.baseCity);
                    if (dist > maxDistance)
                    {
                        maxDistance = dist;
                    }
                }

                map.DrawCircleEx(handle, pixX, pixY, maxDistance / 2, 2883, true, 25);
            }

            map.ShapeIdentified += Map_ShapeIdentified;
            map.Redraw();
        }