Esempio n. 1
0
        public Tower ActivateRandom(string activator = "XANA")
        {
            Random random          = new Random();
            var    possibleSectors = Sectors.Where(sector => sector.Towers.Any())
                                     .Where(sector => sector.Towers.Any(tower => !tower.Activated)).ToList();

            if (!possibleSectors.Any())
            {
                return(null);
            }

            int number       = random.Next(possibleSectors.Count);
            var chosenSector = Sectors.ToList()[number];

            return(chosenSector.ActivateRandom(activator));
        }
Esempio n. 2
0
        public void CreateSectors(List <Track> tracks, List <Entities.Sector> sectors)
        {
            UnitOfWork worker = new UnitOfWork();

            TrackObject = tracks.FirstOrDefault(t => t.ID == TrackNumber);

            if (TrackObject == null)
            {
                Console.WriteLine("Track with ID " + TrackNumber + " Does not exist in the database.");
                return;
            }

            TrackObject.Sectors = sectors.Where(s => s.TrackID == TrackNumber).OrderBy(s => s.ID).ToList();


            // Remove initial controls.
            foreach (Sector c in Sectors.Where(x => x != sectorOne))
            {
                Controls.Remove(c);
            }


            // If no sectors, return.
            if (TrackObject.Sectors.Count < 1)
            {
                return;
            }

            sectorOne.SectorObject  = TrackObject.Sectors[0];
            sectorOne.ClickHandler += OnSectorClick;

            for (int i = 1; i < TrackObject.Sectors.Count; i++)
            {
                Sector newSector = new Sector
                {
                    Location     = new Point(sectorOne.Location.X, sectorOne.Location.Y + sectorOne.Height + (sectorOne.Height * (i - 1))),
                    SectorObject = TrackObject.Sectors[i],
                };

                newSector.ClickHandler += OnSectorClick;

                Controls.Add(newSector);
            }
        }
Esempio n. 3
0
        private void UpdateGraph_2()
        {
            var xAxis = nirPlotData.AsEnumerable()
                        .Where(row => (string)row[1] == (string)siteListBox_2.SelectedItem && (string)row[3] == (string)techListBox_2.SelectedItem)
                        .Select(col => (string)col[0]).Distinct();



            InsertEmpty();

            List <string> xAxis2 = xAxis.ToList();

            xAxis2 = sort_fechas(xAxis2);


            var cells2Plot = nirPlotData.AsEnumerable()
                             .Where(row => (string)row[1] == (string)siteListBox_2.SelectedItem && (string)row[3] == (string)techListBox_2.SelectedItem)
                             .Select(col => (string)col[2]);



            SeriesCollection data = new SeriesCollection();

            var plotSectors = Sectors.Where(item => item.Enabled).ToList();



            if ((bool)checkInter.IsChecked)
            {
                for (int i = 0; i < plotSectors.Count; i++)         // Intentos
                {
                    try
                    {
                        data.Add(new StackedColumnSeries
                        {
                            Values = new ChartValues <int>(nirPlotData.AsEnumerable().Where(row => TECH_NUM.GetSectorFromLNCEL((string)row["LNCEL name"]) == (byte)plotSectors[i].Sector && (string)row[1] == (string)siteListBox_2.SelectedItem &&
                                                                                            (string)row[3] == (string)techListBox_2.SelectedItem).Select(col => (int)col[4]).ToList <int>()),
                            StackMode  = StackMode.Values,
                            DataLabels = true,
                            Fill       = (SolidColorBrush)(new BrushConverter().ConvertFrom("#AA" + interColorsLines[i])),
                            ScalesYAt  = 0,
                            Title      = "Intentos HO Inter s" + plotSectors[i].Sector
                        });
                    }

                    catch (InvalidCastException ice)
                    {
                        Console.WriteLine("HAY VALORES VACIOS " + ice.StackTrace);
                    }
                }
            }
            if ((bool)checkIntra.IsChecked)
            {
                for (int i = 0; i < plotSectors.Count; i++)         // Intentos
                {
                    try
                    {
                        data.Add(new StackedColumnSeries
                        {
                            Values = new ChartValues <int>(nirPlotData.AsEnumerable().Where(row => TECH_NUM.GetSectorFromLNCEL((string)row["LNCEL name"]) == (byte)plotSectors[i].Sector && (string)row[1] == (string)siteListBox_2.SelectedItem &&
                                                                                            (string)row[3] == (string)techListBox_2.SelectedItem).Select(col => (int)col[8]).ToList <int>()),
                            StackMode  = StackMode.Values,
                            DataLabels = true,
                            Fill       = (SolidColorBrush)(new BrushConverter().ConvertFrom("#AA" + intraColorsLines[i])),
                            ScalesYAt  = 0,

                            Title = "Intentos HO Intra s" + plotSectors[i].Sector
                        });
                    }
                    catch (InvalidCastException ice)
                    {
                        Console.WriteLine("HAY VALORES VACIOS " + ice.StackTrace);
                    }
                }
            }
            if ((bool)checkInter.IsChecked)
            {
                for (int i = 0; i < plotSectors.Count; i++)         //Tasa de Exito
                {
                    try
                    {
                        data.Add(new LineSeries
                        {
                            Values = new ChartValues <double>(nirPlotData.AsEnumerable().Where(row => TECH_NUM.GetSectorFromLNCEL((string)row["LNCEL name"]) == (byte)plotSectors[i].Sector && (string)row[1] == (string)siteListBox_2.SelectedItem &&
                                                                                               (string)row[3] == (string)techListBox_2.SelectedItem).Select(col => (double)col[5]).ToList <double>()),
                            ScalesYAt       = 1,
                            StrokeThickness = 2.5,
                            Stroke          = (SolidColorBrush)(new BrushConverter().ConvertFrom("#" + interColorsLines[i])),
                            Fill            = Brushes.Transparent,
                            Title           = " % Exitos HO Inter s" + plotSectors[i].Sector
                        });
                    }
                    catch (InvalidCastException ice)
                    {
                        Console.WriteLine("HAY VALORES VACIOS " + ice.StackTrace);
                    }
                }
            }
            if ((bool)checkIntra.IsChecked)
            {
                for (int i = 0; i < plotSectors.Count; i++)         //Tasa de Exito
                {
                    try
                    {
                        data.Add(new LineSeries
                        {
                            Values = new ChartValues <double>(nirPlotData.AsEnumerable().Where(row => TECH_NUM.GetSectorFromLNCEL((string)row["LNCEL name"]) == (byte)plotSectors[i].Sector && (string)row[1] == (string)siteListBox_2.SelectedItem &&
                                                                                               (string)row[3] == (string)techListBox_2.SelectedItem).Select(col => (double)col[9]).ToList <double>()),
                            ScalesYAt       = 1,
                            StrokeThickness = 2.5,
                            Stroke          = (SolidColorBrush)(new BrushConverter().ConvertFrom("#" + intraColorsLines[i])),
                            Fill            = Brushes.Transparent,
                            Title           = " % Exitos HO Intra s" + plotSectors[i].Sector,
                        });
                    }
                    catch (InvalidCastException ice)
                    {
                        Console.WriteLine("HAY VALORES VACIOS " + ice.StackTrace);
                    }
                }
            }

            //arreglar lo de los ejes, te puedes inspirar en UpdateGraph_1(), y la ordenacion de las fechas, buena suerte, y pregunta cosas a la gente
            graphObject_2.DrawGraph(data, 50000, xAxis2);
        }
Esempio n. 4
0
        public Sector GetSector(string name)
        {
            var sectors = Sectors.Where(sector => sector.Name == name);

            return(sectors.FirstOrDefault());
        }