public void ForceRebind(DownloadMapsViewModel vm) { MapManager = vm.MapManager; Server = vm.Server; Maps = vm.Maps; ReplaceExistingMaps = vm.ReplaceExistingMaps; MapsToDownload = vm.MapsToDownload; DownloadInProgress = vm.DownloadInProgress; MapsSelectionStatus = $"{Maps.Count(x => !x.SkipOnDownload)} / {Maps.Count()} maps"; }
public void BindServerObject(ServerModel server) { Server = server; MapManager = new MapManager(Server); MapManager.MapsDirectory = server.GetMapsDirectory(); var listMaps = Server.GetMapsToDownload() .Select(x => new MapModel(x, Server)) .ToList(); Maps.Clear(); foreach (var map in listMaps) { Maps.Add(map); } MapsSelectionStatus = $"{Maps.Count(x => !x.SkipOnDownload)} / {Maps.Count()} maps"; }
private async Task SaveFile() { DataLoaded = false; StatusText = "Saving..."; ///* Might need something like this to prevent bad data. for (int m = 0; m < Maps.Count(); m++) { for (int i = 0; i < Maps.ElementAt(m).MapBlockValues.Count(); i++) { if (Maps.ElementAt(m).MapBlockValues[i] >= BlockSets.ElementAt((int)Maps.ElementAt(m).TileSetID).Tiles.Count()) { Maps.ElementAt(m).MapBlockValues[i] = 0; } } } //*/ await Task.Run(() => romConverter.SaveROMDataToFile(romFile, Moves, Pokemons, TypeStrengths, AllTMs, EncounterZones, Trainers, Shops, Items, Maps, PokeTypes)); DataLoaded = true; }
public IList <T> ExecuteReader <T>(String sql, bool isType, Dictionary <string, object> dic = null, CommandType commandType = CommandType.Text) where T : class, new() { List <T> list = null; var fields = typeof(T).GetFields(BindingFlags.NonPublic | BindingFlags.Instance); List <MySqlParameter> parameters = new List <MySqlParameter>(); if (dic != null) { foreach (var item in dic) { object type = item.Value; type = type ?? DBNull.Value; MySqlParameter parm = new MySqlParameter(item.Key, type); parameters.Add(parm); } } MySqlConnection connection = MySQLConnection.GetMySqlConnection(); var commond = MySQLConnection.GetMySqlCommand(connection, sql, parameters.ToArray(), commandType); Type ts = Activator.CreateInstance <T>().GetType(); var obj = ts.GetProperties(); var reader = commond.ExecuteReader(); if (reader.Read()) { Dictionary <string, int> Maps = null; for (int i = 0; i < reader.FieldCount; i++) { foreach (var item in obj) { if (item.Name.Equals(reader.GetName(i)))//名称相同 { if (Maps == null) { Maps = new Dictionary <string, int>(); } Maps.Add(item.Name, i); } } } if (Maps != null) { list = new List <T>(); do { T t = new T(); for (int i = 0; i < Maps.Count(); i++) { var val = reader.GetValue(i) == DBNull.Value ? null : reader.GetValue(i); obj[i].SetValue((object)t, val, null); } list.Add(t); } while (reader.Read()); } } reader.Close(); commond.Dispose(); MySQLConnection.ReturnConnection(connection); return(list); }