예제 #1
0
        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;
            }
        }
예제 #2
0
        public void PrintGrid(string grid)
        {
            var g      = new Spots(grid);
            var result = g.Print();

            Assert.AreEqual(grid, result);
        }
        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);
            }
        }
예제 #4
0
    void Start()
    {
        source = GetComponent <AudioSource>();
        player = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
        gm     = GameObject.FindGameObjectWithTag("GM").GetComponent <PlayerHealth>();
        anim   = GetComponent <Animator>();
        spots  = GameObject.FindGameObjectWithTag("Spots").GetComponent <Spots>();
        shake  = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <ScreenShake>();
        if (complete == true)
        {
            ui = GameObject.FindGameObjectWithTag("UI").GetComponent <UI>();
        }

        if (this.gameObject.tag == "Save Spot")
        {
            gm.respawnSpot = this.transform.position;
        }

        if (complete == false)
        {
            for (int i = 0; i < word.Length; i++)
            {
                word[i].SetActive(false);
            }
        }
    }
예제 #5
0
        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();
        }
예제 #6
0
        public async Task <IActionResult> PostSpots([FromBody] Spots spots)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Spots.Add(spots);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (SpotsExists(spots.SpotId))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetSpots", new { id = spots.SpotId }, spots));
        }
예제 #7
0
        public Spots loadSpot()
        {
            Spots dico = new Spots();
            ObservableCollection <Lieu> Ltest  = new ObservableCollection <Lieu>();
            ObservableCollection <Lieu> Ltest2 = new ObservableCollection <Lieu>();

            //Test pour les Regions
            Region Auvergne = new Region("Région situé au centre de la france, elle est connue pour sa chaine de puys.", "Auvergne", "");
            Region Bretagne = new Region("Région très souvent considérée comme le royaume de la pluie, elle saura vous suprendre.", "Bretagne", "");

            //Test d'ajout de plusieurs Lieu à l'OberservableCollection Ltest1
            Ltest.Add(new Lieu("Chateau", "../Image/chateau.jpg", "Vraiment très bien"));
            Ltest.Add(new Lieu("Bateau", "../Image/bateau.jpg", "Vraiment très bien"));
            Ltest.Add(new Lieu("Maison", "../Image/maison.jpg", "Vraiment très bien"));

            //Ajout d'un avis pour le Lieu lieu
            Lieu lieu = new Lieu("champ", "../Image/champTest.png", "Un champ (du latin campus) est un espace défini et ouvert, parcelle de terre cultivée ou terrain réservé à une activité spécifique. Par extension de sens, un champ est une étendue virtuelle dans un domaine donné, par exemple champ d'application ou champ d'action. Champ ou champ’ est aussi une abréviation familière pour « champagne », lui - même signifiant « vin de Champagne » mais aussi pour le mot champignon.");

            Ltest2.Add(lieu);
            lieu.AddAvis(new Avis(7, "Je recommende chaudement ce site. A défault d'être éloigné de toute civilisation, il vous offrira sans aucun doute un moment de détente dont vous vous souviendrez longtemps !", "guillaume"));

            //Test d'ajout de 2 spots, composé de Region et des Lieux
            dico.AddSpots(Auvergne, Ltest);
            dico.AddSpots(Bretagne, Ltest2);

            return(dico);
        }
예제 #8
0
        /// <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();
                }
            }
        }
예제 #9
0
        public async Task <IActionResult> PutSpots([FromRoute] int id, [FromBody] Spots spots)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != spots.SpotId)
            {
                return(BadRequest());
            }

            _context.Entry(spots).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SpotsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #10
0
        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] + " },"));
                    }
                }
            }
        }
예제 #11
0
 public void AfterClone(Program source, bool fullClone = true)
 {
     Parent   = source.Parent;
     UniqueID = Guid.NewGuid();
     Spots.ForEach(spot =>
     {
         spot.AfterClone(source.Spots.First(sourceSpot => sourceSpot.Date == spot.Date), fullClone);
         spot.Parent = this;
     });
 }
예제 #12
0
        public void Dispose()
        {
            Spots.ForEach(s => s.Dispose());
            Spots.Clear();

            Logo?.Dispose();
            Logo = null;

            Parent = null;
        }
예제 #13
0
 public void Distribute()
 {
     while (Creatures.Any() && Spots.Any(x => x.Available()))
     {
         var creature = Creatures.First();
         var spot     = GetRandomSpot();
         spot.Creatures.Add(creature);
         Creatures.Remove(creature);
     }
 }
        public PageAjoutAvis(Spots dico, Connexion connexion, Region region, Lieu lieu)
        {
            InitializeComponent();
            DicoAjourAvis      = dico;
            RegionAjoutAvis    = region;
            LieuAjoutAvis      = lieu;
            ConnexionAjoutAvis = connexion;

            groot.DataContext = this;
        }
예제 #15
0
        private double computePayOff()
        {
            var dic = new Dictionary <string, decimal>();

            for (var shareId = 0; shareId < Option.UnderlyingShareIds.Length; shareId++)
            {
                dic.Add(Option.UnderlyingShareIds[shareId], (decimal)Spots.Last()[shareId]);
            }
            return(Option.GetPayoff(dic));
        }
예제 #16
0
        public Recommendation Spot(string externalSpotRef)
        {
            if (Spots.Exists(s => String.Equals(s.ExternalSpotRef, externalSpotRef)))
            {
                return(Spots
                       .Find(s => String.Equals(s.ExternalSpotRef, externalSpotRef))
                       .Recommendation);
            }

            return(null);
        }
예제 #17
0
        public async Task <IHttpActionResult> GetSpots(string id)
        {
            Spots spots = await db.Spots.FindAsync(id);

            if (spots == null)
            {
                return(NotFound());
            }

            return(Ok(spots));
        }
예제 #18
0
 public static void AffichageCommentaire(Spots dico)
 {
     foreach (ObservableCollection <Lieu> l in dico.Endroits.Values)
     {
         foreach (Lieu lieu in l)
         {
             for (int i = 0; i < lieu.ListeAvis.Count(); i++)
             {
                 Console.WriteLine($"Lieu : {lieu.Nom}, { lieu.ListeAvis[i]}");
             }
         }
     }
 }
예제 #19
0
        public void SpotCheck(int row, int col, Spot expectedSpot)
        {
            var grid   = @"#######
#.G...#
#...EG#
#.#.#G#
#..G#E#
#.....#
#######";
            var myGrid = new Spots(grid);

            Assert.AreEqual(expectedSpot, myGrid.GetSpot(row, col));
        }
예제 #20
0
 public void paradox()
 {
     currRec = new Iteration();
     character.transform.position      = Spots.startLocator(Level, iterNum);
     character.transform.localRotation = Quaternion.Euler(0, 0, 0);
     mouseLook.y = mouseLook.x = 0;
     showText    = true;
     timer       = 0;
     foreach (Iteration itor in allRec.iterations)
     {
         itor.avatar.GetComponent <PastCharacter>().paradox();
     }
 }
예제 #21
0
 private void button1_Click(object sender, EventArgs e)
 {
     parks.Clear();
     spotsSpecificParkPerData.Clear();
     spotsPerData.Clear();
     listSpotsBelongingPark.Clear();
     freeSpotsSpecificPark.Clear();
     parkInfoSpecificPark = null;
     listSpotsNeedReplace.Clear();
     listSpotsNeedReplaceSpecificPark.Clear();
     allSpots.Clear();
     occupancyRate    = null;
     infoSpecificSpot = null;
 }
예제 #22
0
 public static void AfficherSpots(Spots dico)
 {
     //foreach (Region r in dico.Endroits.Keys)
     //{
     //Console.WriteLine(r);
     foreach (ObservableCollection <Lieu> l in dico.Endroits.Values)
     {
         foreach (Lieu lieu in l)
         {
             Console.WriteLine(lieu);
         }
     }
     //}
 }
예제 #23
0
    public List <Spot> FindPath(Spot startSpot, Spot endSpot)
    {
        List <Spot>    openSet   = new List <Spot>();
        HashSet <Spot> closedSet = new HashSet <Spot>();

        openSet.Add(startSpot);

        while (openSet.Count > 0)
        {
            Spot currentSpot = openSet[0];
            for (int i = 1; i < openSet.Count; i++)
            {
                if (openSet[i].GetFCost() < currentSpot.GetFCost() || (openSet[i].GetFCost() == currentSpot.GetFCost() && openSet[i].hCost < currentSpot.hCost))
                {
                    currentSpot = openSet[i];
                }
            }

            openSet.Remove(currentSpot);
            closedSet.Add(currentSpot);

            if (currentSpot == endSpot)
            {
                return(RetracePath(startSpot, endSpot));
            }

            foreach (Spot neighborSpot in currentSpot.GetNeighbors())
            {
                if (closedSet.Contains(neighborSpot))
                {
                    continue;
                }

                float newMovementCostToNeighbor = currentSpot.gCost + Spots.GetDistance(currentSpot, neighborSpot);
                if (newMovementCostToNeighbor < neighborSpot.gCost || !openSet.Contains(neighborSpot))
                {
                    neighborSpot.gCost      = newMovementCostToNeighbor;
                    neighborSpot.hCost      = Spots.GetDistance(neighborSpot, endSpot);
                    neighborSpot.parentSpot = currentSpot;

                    if (!openSet.Contains(neighborSpot))
                    {
                        openSet.Add(neighborSpot);
                    }
                }
            }
        }

        return(null);
    }
예제 #24
0
        public IEnumerable <Spots> GetSpotByParkAndGivenTime(string nameOfPark, DateTime pubdate)
        {
            SqlConnection conn  = new SqlConnection(connectionString);;
            List <Spots>  spots = new List <Spots>();

            //2018-12-12T16:11:14
            //api/spots/campus_2_A_Park1/date/2018-12-12T16:11:14
            //alterar algum valor nessa data já nao encontra
            //era suposto dar com estes tbm
            //Wed, 12 Dec 2018
            //12 / 12 / 2018 16:11:14
            try
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("Select s.id, s.name, s.type, hs.value, s.batterystatus, hs.timestamp, s.geoLatitude, s.geoLongitude From Spots s Join History_Spots hs ON (s.name = hs.idSpot) Where s.id=@parksName And hs.timestamp = @date", conn);
                //DbFunctions.TruncateTime(hs.timestamp) = DbFunctions.TruncateTime(@date)
                //SqlCommand cmd = new SqlCommand("Select * from History_Spots Where timestamp = @date", conn);

                cmd.Parameters.AddWithValue("@parksName", nameOfPark);
                cmd.Parameters.AddWithValue("@date", pubdate);

                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Spots s = new Spots
                    {
                        Id            = (string)reader["Id"],
                        Name          = (string)reader["Name"],
                        BatteryStatus = (int)reader["BatteryStatus"],
                        Type          = (string)reader["Type"],
                        Value         = (string)reader["Value"],
                        Timestamp     = (DateTime)reader["Timestamp"],
                        Latitude      = (string)reader["GeoLatitude"],
                        Longitude     = (string)reader["GeoLongitude"]
                    };
                    spots.Add(s);
                }
                reader.Close();
                conn.Close();
            }
            catch (Exception e)
            {
                if (conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(spots);
        }
예제 #25
0
 public LayerView(IonControlPoint starticp, double beamMU, double MU_weight_ratio)
 {
     this.MU_weight_ratio = MU_weight_ratio;
     this.Energy          = starticp.NominalBeamEnergy;
     this.SpotNo          = starticp.FinalSpotList.Count();
     this.TotalMU         = starticp.FinalSpotList.Sum(s => s.Weight) * MU_weight_ratio;
     this.MaxMU           = starticp.FinalSpotList.Max(s => s.Weight) * MU_weight_ratio;
     this.MinMU           = starticp.FinalSpotList.Min(s => s.Weight) * MU_weight_ratio;
     this.MUpercent       = this.TotalMU / beamMU * 100;
     this.Spots           = starticp.FinalSpotList;
     this.xmax            = Spots.Max(s => s.Position.x);
     this.xmin            = Spots.Min(s => s.Position.x);
     this.ymax            = Spots.Max(s => s.Position.y);
     this.ymin            = Spots.Min(s => s.Position.y);
 }
예제 #26
0
        public void CheckForClears(List <int> rowsToCheck, List <int> colsToCheck)
        {
            int score = 0, count = 0;

            List <int> rowsToRemove = new List <int>(), colsToRemove = new List <int>();

            foreach (int i in rowsToCheck)
            {
                int numSpots = Spots.Where(x => x[0] == i).Count() - Obstacles.Where(x => x[0] == i).Count();

                IEnumerable <Bit> matches = Bits.Where(x => x.Coordinates.X == i);

                if (numSpots == matches.Count())
                {
                    rowsToRemove.Add(i);

                    score += matches.Count();
                    count++;
                }
            }

            foreach (int i in colsToCheck)
            {
                int numSpots = Spots.Where(x => x[1] == i).Count() - Obstacles.Where(x => x[1] == i).Count();

                IEnumerable <Bit> matches = Bits.Where(x => x.Coordinates.Y == i);

                if (numSpots == matches.Count())
                {
                    colsToRemove.Add(i);

                    score += matches.Count();
                    count++;
                }
            }

            foreach (int i in rowsToRemove)
            {
                Bits.RemoveAll(x => x.Coordinates.X == i);
            }

            foreach (int i in colsToRemove)
            {
                Bits.RemoveAll(x => x.Coordinates.Y == i);
            }

            Score += score * count;
        }
예제 #27
0
        private string ShowSpot(Spots s)
        {
            string batteryStatus = "";

            if (s.BatteryStatus == 1)
            {
                batteryStatus = "Needs Replacement";
            }
            else
            {
                batteryStatus = "Is fine";
            }
            return(string.Format("Id: {0} \n\tName: {1} \n\tType: {2} \n\tLatitude: {3} " +
                                 "\n\tLongitude: {4} \n\tValue: {5} \n\tDate Time: {6} \n\tBattery Status: {7} \n\n",
                                 s.Id, s.Name, s.Type, s.Latitude, s.Longitude, s.Value, s.Timestamp, batteryStatus));
        }
예제 #28
0
        public void RebuildSpots(bool keepExistedData = false)
        {
            if (!Parent.ParentScheduleSettings.FlightDateStart.HasValue || !Parent.ParentScheduleSettings.FlightDateEnd.HasValue)
            {
                return;
            }

            var startDate = Parent.ParentScheduleSettings.FlightDateStart.Value;
            var endDate   = Parent.ParentScheduleSettings.FlightDateEnd.Value;
            var spotDate  = startDate;

            var newSpots = new List <Spot>();

            while (spotDate < endDate)
            {
                var spot = new Spot(this)
                {
                    Date = spotDate
                };
                spotDate = Parent.SpotType == SpotType.Week ? spotDate.AddDays(7) : new DateTime(spotDate.AddMonths(1).Year, spotDate.AddMonths(1).Month, 1);
                newSpots.Add(spot);
            }

            if (!(Spots.Any() && Spots.First().Date == startDate && Spots.Count == newSpots.Count))
            {
                if (keepExistedData)
                {
                    if (Spots.Count >= newSpots.Count)
                    {
                        for (int i = 0; i < newSpots.Count; i++)
                        {
                            newSpots[i].Count = Spots[i].Count;
                        }
                    }
                    else
                    {
                        for (int i = 0; i < Spots.Count; i++)
                        {
                            newSpots[i].Count = Spots[i].Count;
                        }
                    }
                }

                Spots.Clear();
                Spots.AddRange(newSpots);
            }
        }
예제 #29
0
 public static void ListeAvis(Spots dico, string region, string lieuChoisi, int noteDonne, string commentDonne)
 {
     foreach (Region r in dico.Endroits.Keys)
     {
         if (r.Nom == region)
         {
             foreach (ObservableCollection <Lieu> l in dico.Endroits.Values)
             {
                 foreach (Lieu lieu in l)
                 {
                     if (lieu.Nom == lieuChoisi)
                     {
                         lieu.AddAvis(new Avis(noteDonne, commentDonne, "fabien"));
                     }
                 }
             }
         }
     }
 }
예제 #30
0
        public long SolveA(string input)
        {
            var spots  = new Spots(input);
            int rowNum = -1;

            foreach (var row in spots.Rows)
            {
                rowNum++;
                int colNum = -1;
                foreach (var spot in row)
                {
                    colNum++;
                    switch (spot)
                    {
                    case Spot.Wall:
                        continue;

                    case Spot.Space:
                        continue;

                    case Spot.Goblin:
                        // Choose the closest spot that's reachable, empty, and adjacent to an Elf.
                        // Move one spot towards that spot.
                        spots.MoveTowardsEnemy(new Coords(rowNum, colNum));

                        // Attack the weakest adjacent Elf.
                        //spots.Attack(new Coords(rowNum, colNum));

                        break;

                    case Spot.Elf:
                        // Move one spot towards a reachable, empty spot adjacent to a Goblin.

                        // Attack the weakest Goblin.
                        break;
                    }
                }
            }


            return(0);
        }