Beispiel #1
0
 private void EditMapConfigViewModel_EditMapConfigHander(object sender, MapConfigAttribute e)
 {
     if (MapSelectedItem != null && MapSelectedItem.MapName == e.MapName)
     {
         MapSelectedItem.Zoom    = e.Zoom;
         MapSelectedItem.MaxZoom = e.MaxZoom;
         MapSelectedItem.MinZoom = e.MinZoom;
         MapSelectedItem.Center  = e.Center;
         LoadMap();
     }
 }
Beispiel #2
0
        public void LoadMapConfig()
        {
            var path = AppDomain.CurrentDomain.BaseDirectory + @"caches\TileDBv5\en";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            var mapfiles = Directory.GetFiles(path);

            foreach (var mapfile in mapfiles)
            {
                var fileExtens = Path.GetExtension(mapfile);
                if (fileExtens == ".INI")
                {
                    IniHelper iniHelper = new IniHelper(mapfile);
                    if (iniHelper.ExistINIFile())
                    {
                        var mapName     = Path.GetFileName(mapfile).Replace(fileExtens, "");
                        var minZoom     = iniHelper.IniReadValue("地图配置", "minZoom");
                        var maxZoom     = iniHelper.IniReadValue("地图配置", "maxZoom");
                        var zoom        = iniHelper.IniReadValue("地图配置", "zoom");
                        var bounds      = iniHelper.IniReadValue("地图配置", "bounds");
                        var mapProvider = iniHelper.IniReadValue("地图配置", "mapProvider");
                        var center      = iniHelper.IniReadValue("地图配置", "center");
                        MapConfigAttribute mapConfigAttribute = new MapConfigAttribute();
                        mapConfigAttribute.MapName     = mapName;
                        mapConfigAttribute.MinZoom     = int.Parse(minZoom);
                        mapConfigAttribute.MaxZoom     = int.Parse(maxZoom);
                        mapConfigAttribute.Zoom        = int.Parse(zoom);
                        mapConfigAttribute.MapBound    = bounds;
                        mapConfigAttribute.Center      = center;
                        mapConfigAttribute.MapProvider = mapProvider;
                        MapConfigAttributes.Add(mapConfigAttribute);
                    }
                }
            }
            if (MapConfigAttributes.Count > 0)
            {
                MapSelectedItem = MapConfigAttributes[0];
            }
        }
Beispiel #3
0
        private void CopyMapFiles(string[] files)
        {
            if (files.Length != 2)
            {
                MessageBoxX.Show("地图文件必须包含两个文件(.INI .gmdb)", "Warning", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations()
                {
                    MessageBoxStyle = MessageBoxStyle.Classic,
                    MessageBoxIcon  = MessageBoxIcon.Warning,
                    ButtonBrush     = "#F1C825".ToColor().ToBrush(),
                });
                return;
            }
            var extens1 = Path.GetExtension(files[0]);
            var extens2 = Path.GetExtension(files[1]);

            if (extens1 == extens2)
            {
                MessageBoxX.Show("地图文件必须包含两个文件(.INI .gmdb)", "Warning", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations()
                {
                    MessageBoxStyle = MessageBoxStyle.Classic,
                    MessageBoxIcon  = MessageBoxIcon.Warning,
                    ButtonBrush     = "#F1C825".ToColor().ToBrush(),
                });
                return;
            }

            var name1 = Path.GetFileName(files[0]).Replace(extens1, "");
            var name2 = Path.GetFileName(files[1]).Replace(extens2, "");

            if (name1 != name2)
            {
                MessageBoxX.Show("地图文件和配置文件的名称必须相同!", "Warning", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations()
                {
                    MessageBoxStyle = MessageBoxStyle.Classic,
                    MessageBoxIcon  = MessageBoxIcon.Warning,
                    ButtonBrush     = "#F1C825".ToColor().ToBrush(),
                });
                return;
            }
            var path     = AppDomain.CurrentDomain.BaseDirectory + @"caches\TileDBv5\en";
            var mapfiles = Directory.GetFiles(path, "*.gmdb");
            var desfile1 = path + "\\" + name1 + extens1;
            var desfile2 = path + "\\" + name2 + extens2;

            if (mapfiles.Contains(desfile1) || mapfiles.Contains(desfile2))
            {
                MessageBoxX.Show("当前离线地图文件中已包含相同名称的地图,请修改地图文件和地图配置文件名!", "Warning", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations()
                {
                    MessageBoxStyle = MessageBoxStyle.Classic,
                    MessageBoxIcon  = MessageBoxIcon.Warning,
                    ButtonBrush     = "#F1C825".ToColor().ToBrush(),
                });
                return;
            }
            if (File.Exists(desfile1))
            {
                File.Delete(desfile1);
            }
            File.Copy(files[0], desfile1);
            if (File.Exists(desfile2))
            {
                File.Delete(desfile2);
            }
            File.Copy(files[1], desfile2);
            var configFile = desfile1;

            if (desfile2.IndexOf(".INI") > 0)
            {
                configFile = desfile2;
            }

            IniHelper iniHelper  = new IniHelper(configFile);
            var       fileExtens = Path.GetExtension(configFile);
            var       mapName    = Path.GetFileName(configFile).Replace(fileExtens, "");

            if (iniHelper.ExistINIFile())
            {
                var minZoom     = iniHelper.IniReadValue("地图配置", "minZoom");
                var maxZoom     = iniHelper.IniReadValue("地图配置", "maxZoom");
                var zoom        = iniHelper.IniReadValue("地图配置", "zoom");
                var bounds      = iniHelper.IniReadValue("地图配置", "bounds");
                var mapProvider = iniHelper.IniReadValue("地图配置", "mapProvider");
                MapConfigAttribute mapConfigAttribute = new MapConfigAttribute();
                mapConfigAttribute.MapName     = mapName;
                mapConfigAttribute.MinZoom     = int.Parse(minZoom);
                mapConfigAttribute.MaxZoom     = int.Parse(maxZoom);
                mapConfigAttribute.Zoom        = int.Parse(zoom);
                mapConfigAttribute.MapBound    = bounds;
                mapConfigAttribute.MapProvider = mapProvider;
                MapConfigAttributes.Add(mapConfigAttribute);
                if (MapSelectedItem == null)
                {
                    MapSelectedItem = MapConfigAttributes[0];
                }
            }
            Notice.Show("离线地图(" + mapName + ")导入成功!", "地图消息", 3, MessageBoxIcon.Success);
        }