async Task ExecuteLoadHousesCommand() { if (IsBusy) { return; } IsBusy = true; try { Houses.Clear(); var items = await DataStore.GetItemsAsync(true); foreach (var House in items) { Houses.Add(House); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public void Apply(Models.EphemerisResult ephemerisResult) { DateUTC = ephemerisResult.DateUTC; JulianDay = ephemerisResult.JulianDay; EphemerisTime = ephemerisResult.EphemerisTime; SideralTime = ephemerisResult.SideralTime; MeanEclipticObliquity = ephemerisResult.MeanEclipticObliquity; TrueEclipticObliquity = ephemerisResult.TrueEclipticObliquity; NutationLongitude = ephemerisResult.NutationLongitude; NutationObliquity = ephemerisResult.NutationObliquity; Planets.Clear(); foreach (var p in ephemerisResult.Planets) { Planets.Add(p); } Houses.Clear(); foreach (var h in ephemerisResult.Houses) { Houses.Add(h); } ASMCs.Clear(); foreach (var h in ephemerisResult.ASMCs) { ASMCs.Add(h); } }
public virtual void CopyFrom(Person other) { Cars.Clear(); Cars.AddRange(other.Cars); Name = other.Name; Houses.Clear(); Houses.AddRange(other.Houses); Any.Clear(); Any.AddRange(other.Any); }
/// <summary> /// Reset the result /// </summary> public void Reset() { DateUTC = new DateUT(); JulianDay = new JulianDay(); EphemerisTime = new EphemerisTime(); SideralTime = 0; MeanEclipticObliquity = 0; TrueEclipticObliquity = 0; NutationLongitude = 0; NutationObliquity = 0; Planets.Clear(); Houses.Clear(); ASMCs.Clear(); }
async void GetHouses() { //IsBusy = true; try { var houseList = await remoteService.GetAllProperty(); Houses.Clear(); foreach (var item in houseList) { if (item.ItemType.ToLower() == "house") { if (Houses.Count < 3) { Houses.Add(item); } } } } catch (Exception ex) { Debug.WriteLine(ex); } }
/// <summary> /// Refresh the list property /// </summary> /// <param name="parameter"></param> public void LoadPage(String parameter) { Houses.Clear(); SetHousesList(parameter); }
public static void Load() { BuildSets.Clear(); Houses.Clear(); Guardlines.Clear(); FileInfo[] files = _definitionsPath.GetFiles("*.txt").Where(s => !_ignored.Contains(s.Name)).ToArray(); Bitmap[] images = new Bitmap[files.Length]; FileInfo[] icons = _iconsPath.GetFiles("*.png"); for (int i = 0; i < files.Length; i++) { FileInfo definition = files[i]; FileInfo icon = icons.FirstOrDefault(s => s.Name.Contains(Path.GetFileNameWithoutExtension(definition.Name))); if (icon == null) { continue; // found an icon } Image img = Image.FromFile(icon.FullName); images[i] = new Bitmap(img.Width, img.Height, PixelFormat.Format32bppPArgb); using (Graphics g = Graphics.FromImage(images[i])) { g.PageUnit = GraphicsUnit.Pixel; g.InterpolationMode = InterpolationMode.NearestNeighbor; g.PixelOffsetMode = PixelOffsetMode.HighQuality; g.SmoothingMode = SmoothingMode.AntiAlias; g.DrawImage(img, 0, 0, img.Width, img.Height); } string setName = Path.GetFileNameWithoutExtension(definition.Name); BuildSet buildSet = new BuildSet(setName, images[i], !_smarts.Contains(setName)); bool istown = setName.ToLower() == "town"; using (StreamReader reader = new StreamReader(definition.OpenRead())) { while (!reader.EndOfStream) { string line = reader.ReadLine(); if (string.IsNullOrEmpty(line)) { continue; } string[] parts = line.Split('\t'); if (parts.Length >= 5) { bool enabled = parts[0] == "+"; string description = parts[1].TrimEnd().TrimStart(); Position position = Position.Parse(parts[2] + "." + parts[3]); int map = parts[4].ToInt(); BuildingEntry entry = new BuildingEntry(buildSet, description, position, map) { IsEnabled = enabled, IsTown = istown }; if (parts.Length >= 6) { entry.ShowName = parts[5] == "true"; } buildSet.Entries.Add(entry); } } } BuildSets.Add(buildSet); } // patch for towns BuildSet townSet = BuildSets.FirstOrDefault(s => s.Name.ToLower() == "town"); if (townSet != null) { BuildSets.Remove(townSet); BuildSets.Add(townSet); } // end patch // load houses FileInfo housesDef = _definitionsPath.GetFiles().FirstOrDefault(s => s.Name == _ignored[1]); if (housesDef != null) { using (StreamReader reader = new StreamReader(housesDef.FullName)) { while (!reader.EndOfStream) { string line = reader.ReadLine(); if (string.IsNullOrEmpty(line)) { continue; } string[] data = line.Split('\t'); if (data.Length <= 0 || data.Length < 5) { continue; } if (!ushort.TryParse(data[0], out ushort graphic)) { graphic = ushort.Parse(data[0], NumberStyles.HexNumber); } Position loc = Position.Parse(data[1] + "." + data[2]); Size size = new Size(data[3].ToInt(), data[4].ToInt()); int map = data[5].ToInt(); string descr = data[6]; HouseEntry house = new HouseEntry(descr, graphic, loc, size, map); Houses.Add(house); } } } else { new FileInfo(Path.Combine(_definitionsPath.FullName, _ignored[1])).Create().Close(); } // load guardlines FileInfo guardlinesDef = _definitionsPath.GetFiles().FirstOrDefault(s => s.Name == _ignored[0]); if (guardlinesDef != null) { using (StreamReader reader = new StreamReader(guardlinesDef.FullName)) { while (!reader.EndOfStream) { string line = reader.ReadLine(); if (string.IsNullOrEmpty(line)) { continue; } string[] data = line.Split('\t'); if (data.Length <= 0 || data.Length < 5) { continue; } if (data[0].StartsWith("#")) { continue; } Position loc = Position.Parse(data[0] + "." + data[1]); // ignore data[2] Size size = new Size(data[3].ToInt(), data[4].ToInt()); int map = data[5].ToInt(); GuardlineEntry guardline = new GuardlineEntry(loc, size, map); Guardlines.Add(guardline); } } } else { new FileInfo(Path.Combine(_definitionsPath.FullName, _ignored[0])).Create().Close(); } ParseUOAM(); }
/// <summary> /// Loads the houses and shops. /// </summary> public override void Load() { lock ( locker ) { Houses.Clear(); using (var connection = new MySqlConnection(ConnectionString)) using (var command = QueryCommand(connection, "SELECT * FROM Houses WHERE WorldId = @0", Main.worldID)) using (var reader = command.ExecuteReader()) { while (reader.Read()) { var ownerName = reader.Get <string>("OwnerName"); var name = reader.Get <string>("Name"); var x = reader.Get <int>("X"); var y = reader.Get <int>("Y"); var x2 = reader.Get <int>("X2"); var y2 = reader.Get <int>("Y2"); var debt = (decimal)reader.Get <long>("Debt"); var lastTaxed = DateTime.Parse(reader.Get <string>("LastTaxed")); var forSale = reader.Get <int>("ForSale") == 1; var salePrice = reader.Get <string>("SalePrice"); var house = new House(ownerName, name, x, y, x2, y2) { Debt = debt, LastTaxed = lastTaxed, ForSale = forSale, SalePrice = salePrice }; using (var connection2 = new MySqlConnection(ConnectionString)) using (var command2 = QueryCommand(connection2, "SELECT Username FROM HouseHasUser " + "WHERE OwnerName = @0 AND HouseName = @1 AND WorldId = @2", ownerName, name, Main.worldID)) using (var reader2 = command2.ExecuteReader()) { while (reader2.Read()) { var username = reader2.Get <string>("Username"); house.AllowedUsernames.Add(username); } } Houses.Add(house); } } Shops.Clear(); using (var connection = new MySqlConnection(ConnectionString)) using (var command = QueryCommand(connection, "SELECT * FROM Shops WHERE WorldID = @0", Main.worldID)) using (var reader = command.ExecuteReader()) { while (reader.Read()) { var ownerName = reader.Get <string>("OwnerName"); var name = reader.Get <string>("Name"); var x = reader.Get <int>("X"); var y = reader.Get <int>("Y"); var x2 = reader.Get <int>("X2"); var y2 = reader.Get <int>("X2"); var chestX = reader.Get <int>("ChestX"); var chestY = reader.Get <int>("ChestY"); var isOpen = reader.Get <int>("IsOpen") == 1; var message = reader.Get <string>("Message"); var shop = new Shop(ownerName, name, x, y, x2, y2, chestX, chestY) { IsOpen = isOpen, Message = message }; using (var connection2 = new MySqlConnection(ConnectionString)) using (var command2 = QueryCommand(connection2, "SELECT * FROM ShopHasItem WHERE OwnerName = @0 AND ShopName = @1 AND WorldId = @2", ownerName, name, Main.worldID)) using (var reader2 = command2.ExecuteReader()) { while (reader2.Read()) { var index = reader2.Get <int>("ItemIndex"); var itemId = reader2.Get <int>("ItemId"); var stackSize = reader2.Get <int>("StackSize"); var prefixId = (byte)reader2.Get <int>("PrefixId"); shop.Items.Add(new ShopItem(index, itemId, stackSize, prefixId)); } } using (var connection2 = new MySqlConnection(ConnectionString)) using (var command2 = QueryCommand(connection2, "SELECT * FROM ShopHasPrice WHERE OwnerName = @0 AND ShopName = @1 AND WorldId = @2", ownerName, name, Main.worldID)) using (var reader2 = command2.ExecuteReader()) { while (reader2.Read()) { var itemId = reader2.Get <int>("ItemId"); var unitPriceString = reader2.Get <string>("UnitPrice"); shop.UnitPrices[itemId] = new PriceInfo(unitPriceString); } } Shops.Add(shop); } } //load in tax collectors. TaxCollectors.Clear(); TaxCollectorNames.Clear(); using (var connection = new MySqlConnection(ConnectionString)) using (var command = QueryCommand(connection, "SELECT * FROM TaxCollectors WHERE WorldID = @0", Main.worldID)) using (var reader = command.ExecuteReader()) { while (reader.Read()) { var playerName = reader.Get <string>("PlayerName"); var tc = new TaxCollector(playerName); TaxCollectors.Add(tc); TaxCollectorNames.Add(playerName); } } } }