Пример #1
0
        private void Node_ComBox_Changed_Graph_2(object sender, SelectionChangedEventArgs e)
        {
            List <string> Tech = this.nirPlotData.AsEnumerable().Where(row => (string)row[1] == (string)siteListBox_2.SelectedItem).Select(col => (string)col[3]).Distinct().ToList <string>();

            techListBox_2.ItemsSource  = Tech;
            techListBox_2.SelectedItem = Tech[Tech.Count - 1];

            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]).Distinct();

            List <SectorListItem> sectors = new List <SectorListItem>();

            foreach (var cell in cells2Plot)
            {
                sectors.Add(new SectorListItem()
                {
                    Enabled = true, Sector = TECH_NUM.GetSectorFromLNCEL(cell)
                });
            }
            this.Sectors = sectors;

            Binding codeBinding = new Binding("Sectors");

            codeBinding.Source = this;
            sectorListBox.SetBinding(ListBox.ItemsSourceProperty, codeBinding);
            UpdateGraph_2();
        }
Пример #2
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);
        }
Пример #3
0
        //tras acabar el procesado en segundo plano se actualiza la interfaz con ellos
        private void BackGround_Completed(object sender, RunWorkerCompletedEventArgs e)
        {
            // Progress_Bar.Value = 100;
            if (e.Error == null)
            {
                //Paramos de girar el cursor
                Cursor = Cursors.Arrow;

                plotNodo.Visibility   = Visibility;
                plotceldas.Visibility = Visibility;


                bgwBlnOffResult output = (bgwBlnOffResult)e.Result;
                Copiaoutput = output;
                if (output.colindancias != null)
                {
                    colinGrid.WorkingData = output.colindancias;
                    WPFForms.FindParent <TabItem>(colinGrid).Visibility = Visibility.Visible;
                    tabColindancias.IsSelected = true;



                    //fc = new formColindancias(output.colindancias);

                    //fc.Show();
                }

                if (output.siteCoordErrors != "" && (bool)Is_BlnOFF_Enabled.IsChecked)
                {
                    WPFForms.ShowError("Faltan las coordenadas de los siguientes emplazamientos", output.siteCoordErrors);
                }

                if (output.candBl != null)
                {
                    candBLGrid.WorkingData = output.candBl;
                    WPFForms.FindParent <TabItem>(candBLGrid).Visibility = Visibility.Visible;
                }
                if (output.candOff != null)
                {
                    candOFFGrid.WorkingData = output.candOff;
                    WPFForms.FindParent <TabItem>(candOFFGrid).Visibility = Visibility.Visible;
                }
                if (output.error != null)
                {   //se genera la tabla de analis previo
                    errGrid.WorkingData = output.error;
                    WPFForms.FindParent <TabItem>(errGrid).Visibility = Visibility.Visible;

                    //se genera la gárafica por nodos
                    this.erroresAMejorar = output.error;

                    List <string> sites = erroresAMejorar.AsEnumerable().Select(col => (string)col[1]).Distinct().ToList();
                    siteListBox_1.ItemsSource  = sites;
                    siteListBox_1.SelectedItem = sites[0];

                    List <string> Tech = this.erroresAMejorar.AsEnumerable().Where(row => (string)row[1] == (string)siteListBox_1.SelectedItem).Select(col => (string)col[2]).Distinct().ToList <string>();
                    techListBox_1.ItemsSource  = Tech;
                    techListBox_1.SelectedItem = Tech[0];

                    UpdateGraph_1();
                }
                if (output.nirPlotData != null)
                {
                    this.nirPlotData = output.nirPlotData;

                    List <string> sites = erroresAMejorar.AsEnumerable().Select(col => (string)col[1]).Distinct().ToList();
                    siteListBox_2.ItemsSource  = sites;
                    siteListBox_2.SelectedItem = sites[0];

                    List <string> tech = this.nirPlotData.AsEnumerable().Where(row => (string)row[1] == (string)siteListBox_2.SelectedItem).Select(col => (string)col[3]).Distinct().ToList <string>();
                    techListBox_2.ItemsSource  = tech;
                    techListBox_2.SelectedItem = tech[0];

                    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]).Distinct().Where(item => !item.Contains("="));

                    List <SectorListItem> sectors = new List <SectorListItem>();
                    foreach (var cell in cells2Plot)
                    {
                        sectors.Add(new SectorListItem()
                        {
                            Enabled = true, Sector = TECH_NUM.GetSectorFromLNCEL(cell)
                        });
                    }
                    this.Sectors = sectors;

                    Binding codeBinding = new Binding("Sectors");
                    codeBinding.Source = this;
                    sectorListBox.SetBinding(ListBox.ItemsSourceProperty, codeBinding);

                    UpdateGraph_2();
                }
            }
            else
            {
                //Paramos de girar el cursor
                Cursor = Cursors.Arrow;

                //control de errores en BackGround
                switch (e.Error.GetType().Name)
                {
                case "FileNotFoundException":
                    WPFForms.ShowError("Falta un archivo", e.Error.Message);
                    break;

                case "InvalidOperationException":
                    WPFForms.ShowError("Error critico", e.Error.Message);
                    break;

                case "ArgumentException":
                    WPFForms.ShowError("Error en los datos", e.Error.Message);
                    break;

                default:
                    WPFForms.ShowError("No controlado", e.Error.Message);
                    break;
                }
            }
        }