/// <summary> /// Load all spot from database and store in Spot list /// </summary> public void loadAllSpot() { //Refresh data //Retrieve data from data base and create new object try { this.Spots.Clear(); conn.Open(); MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "SELECT * FROM `campingspot` ORDER BY `CampingSpotNr` ASC"; MySqlDataReader reader; reader = cmd.ExecuteReader(); Spot spot = null; while (reader.Read()) { spot = new Spot(Convert.ToInt32(reader["CampingSpotNr"]), Convert.ToInt32(reader["numberOfPeople"])); Spots.Add(spot); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } } }
private void OnTestCommand() { var df = Spots; Spot spot = new Spot() { Color = Colors.Red, Height = 26.0, Id = 9088127, IsSelected = true, Price = 1000, RowNum = "1", SeatNum = "28", SectorName = "4 сектор", SideName = "Левая сторона", Width = 26.0, X = 851.0, Y = 445.0 }; if (Spots.Contains(spot, new SpotIdComparer())) { var dfd = Spots.FirstOrDefault(x => x.Id == spot.Id); Spots.Remove(dfd); } else { Spots.Add(spot); } }
private void GetSpots(DateTime beginningTest, IDataFeedProvider simulateMarket) {//Get all the spots of the underlying asset from the debTest date to the maturity date Spots.Clear(); var firstDateMarket = simulateMarket.GetMinDate(); if (beginningTest.Date < firstDateMarket.Date) { throw new Exception("No Market data before the " + firstDateMarket.ToShortDateString()); } if (beginningTest.Date > Option.Maturity.Date) { throw new Exception("No Market data after the Maturity date (" + Option.Maturity.ToShortDateString() + ")"); } var dataFeed = simulateMarket.GetDataFeed(Option, beginningTest); if (dataFeed.Count() == 0) { throw new Exception("No Market data"); } foreach (DataFeed d in dataFeed) { var spotList = new List <double>(); foreach (string shareId in Option.UnderlyingShareIds) { spotList.Add((double)d.PriceList[shareId]); } Spots.Add(spotList.ToArray()); MarketDataDates.Add(d.Date); } PayOff = computePayOff(); }
async Task ExecuteLoadSpotsCommand() { if (IsBusy) { return; } IsBusy = true; try { Spots.Clear(); var spots = await App.Database.GetItemsSortedAsync(); foreach (var spot in spots) { Spots.Add(spot); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } finally { IsBusy = false; } }
public override void Update(GameTime gt) { if ((Mouse.LeftMouseDown || Mouse.RightMouseDown) && Mouse.CanPress) { Point coords = GetCoordinates(Mouse.Position); if (Mouse.LeftMouseDown) { if (SpotExists(coords)) { foreach (int[] pair in Spots) { if (pair[0] == coords.X && pair[1] == coords.Y) { Spots.Remove(pair); break; } } } else { Spots.Add(new int[2] { coords.X, coords.Y }); } Console.WriteLine("\n=========================================\nNew Spots:"); Spots.ForEach(x => Console.WriteLine("\t\t\t\tnew int[] { " + x[0] + ", " + x[1] + " },")); } else { if (SpotExists(coords)) { if (ObstacleExists(coords.X, coords.Y)) { foreach (int[] pair in Obstacles) { if (pair[0] == coords.X && pair[1] == coords.Y) { Obstacles.Remove(pair); break; } } } else { Obstacles.Add(new int[2] { coords.X, coords.Y }); } Console.WriteLine("\n=========================================\nNew Obstacles:"); Obstacles.ForEach(x => Console.WriteLine("\t\t\t\tnew int[] { " + x[0] + ", " + x[1] + " },")); } } } }
public void AddSpot(Spot spot) { Spots.Add(spot); }
public void Deserialize(XmlNode node) { double tempDouble; Guid tempGuid; foreach (XmlAttribute programAttribute in node.Attributes) { switch (programAttribute.Name) { case "Name": _name = programAttribute.Value; break; case "UniqueID": if (Guid.TryParse(programAttribute.Value, out tempGuid)) { UniqueID = tempGuid; } break; case "Station": Station = programAttribute.Value; break; case "Daypart": Daypart = programAttribute.Value; break; case "Day": Day = programAttribute.Value; break; case "Time": Time = programAttribute.Value; break; case "Length": Length = programAttribute.Value; break; case "Rate": if (double.TryParse(programAttribute.Value, out tempDouble)) { Rate = tempDouble; } break; case "Rating": if (double.TryParse(programAttribute.Value, out tempDouble)) { Rating = tempDouble; } break; } } foreach (XmlNode childNode in node.ChildNodes) { switch (childNode.Name) { case "Spots": foreach (XmlNode spotNode in childNode.ChildNodes) { var spot = new Spot(this); spot.Deserialize(spotNode); Spots.Add(spot); } break; case "SummaryItem": SummaryItem.Deserialize(childNode); break; case "Logo": Logo = new ImageSource(); Logo.Deserialize(childNode); break; } } }