private void filldataexpandedCAT20(int index) //crea la tabla pequeña de CAT20 (solo con los items que existan)
        {
            DataTable expanded = new DataTable();
            CAT20     cat20exp = f.getCAT20(index);

            expanded.Columns.Add(new DataColumn());
            expanded.Columns.Add(new DataColumn());

            expanded.Rows.Add("Package #", index + 1);
            try { expanded.Rows.Add("Data Source ID", "SAC: " + cat20exp.SAC + " SIC: " + cat20exp.SIC); } catch { }
            try { expanded.Rows.Add("Target ID", cat20exp.TargetID[1]); } catch { }
            try { expanded.Rows.Add("Track Number", cat20exp.TrackNum); } catch { }
            try { expanded.Rows.Add("Time of Day (UTC)", cat20exp.TOD); } catch { }
            try { expanded.Rows.Add("Position in WSG-84", "[" + cat20exp.LatWSG.ToString() + "," + cat20exp.LonWSG.ToString() + "]"); } catch { }
            try { expanded.Rows.Add("Position (X, Y)", "[" + cat20exp.X.ToString() + "," + cat20exp.Y.ToString() + "] m"); } catch { }
            try { expanded.Rows.Add("Track Velocity (Vx, Vy)", "[" + cat20exp.Vy.ToString() + "," + cat20exp.Vy.ToString() + "] m/s"); } catch { }
            try { expanded.Rows.Add("Flight Level", "FL" + cat20exp.FL[2]); } catch { }
            try { expanded.Rows.Add("Target Report", cat20exp.getTargetReportDescriptortoString()); } catch { }
            try { expanded.Rows.Add("Track Status", cat20exp.getTrackStatusToString()); } catch { }
            try { expanded.Rows.Add("Mode-3/A Code", cat20exp.Mode3A.ToString()); } catch { }
            try { expanded.Rows.Add("Mode-C Code", cat20exp.ModeC.ToString()); } catch { }
            try { expanded.Rows.Add("Target Address", cat20exp.TargetAddress.ToString()); } catch { }
            try { expanded.Rows.Add("Measured Height", cat20exp.MeasuredHeight.ToString()); } catch { }
            try { expanded.Rows.Add("Geometric Height", cat20exp.geoHeight.ToString()); } catch { }
            try { expanded.Rows.Add("Calculated Accel", cat20exp.calcAccel.ToString()); } catch { }
            try { expanded.Rows.Add("Vehicle Fleet ID", cat20exp.VehicleFleetID.ToString()); } catch { }
            try { expanded.Rows.Add("Pre-Programmed Message", cat20exp.PPMsg.ToString()); } catch { }
            try { expanded.Rows.Add("Position Accuracy:", cat20exp.getPositionAccuracyToString()); } catch { }
            try { expanded.Rows.Add("Receivers", cat20exp.Receivers.ToString()); } catch { }
            try { expanded.Rows.Add("Mode S MB Data", cat20exp.ModeSData.ToString()); } catch { }

            dataexpanded.ItemsSource = expanded.DefaultView;
            dataexpanded.Items.Refresh();
        }
        void ClikDataGrid(object sender, RoutedEventArgs e) //al clicar en una celda de la tabla
        {
            //cogemos la celda
            DataGridCell cell = (DataGridCell)sender;
            int          c    = cell.Column.DisplayIndex; //número de columna
            DataGridRow  r2   = DataGridRow.GetRowContainingElement(cell);
            int          fil  = r2.GetIndex();            //número de fila

            if (this.cat == 10)
            {
                //cojo el paquete
                CAT10 paquete = f.getCAT10(fil);

                //expandimos información:
                if (c == 7 && paquete.DataCharacteristics != null) // Target Report - Data Characteristics
                {
                    MessageBox.Show(paquete.DataCharacteristics, "Data Characteristics");
                }
                if (c == 14 && paquete.TrackStatus != null) // Track Status
                {
                    MessageBox.Show(paquete.TrackStatus, "Track Status");
                }
                if (c == 27 && paquete.Presence != null) // Presence
                {
                    MessageBox.Show(paquete.Presence, "Presence");
                }
                if (c == 17 && paquete.ModeS != null) // Mode S MB Data
                {
                    MessageBox.Show(paquete.ModeS, "Mode S MB Data");
                }
                if (c == 23 && paquete.SystemStatus != null) // System Status
                {
                    MessageBox.Show(paquete.SystemStatus, "System Status");
                }

                //mostramos las características de ese paquete a parte:
                filldataexpandedCAT10(fil);
            }
            if (this.cat == 20)
            {
                CAT20 paquete = f.getCAT20(fil);

                //expandimos información:
                if (c == 6 && paquete.getTargetReportDescriptortoString() != null)
                {
                    MessageBox.Show(paquete.getTargetReportDescriptortoString(), "Target Report Descriptor");
                }
                if (c == 10 && paquete.getTrackStatusToString() != null) //Track status
                {
                    MessageBox.Show(paquete.getTrackStatusToString(), "Track Status");
                }
                if (c == 21 && paquete.getPositionAccuracyToString() != null) //Pos Accuracy
                {
                    MessageBox.Show(paquete.getPositionAccuracyToString(), "Position Accuracy");
                }

                //mostramos las características de ese paquete a parte:
                filldataexpandedCAT20(fil);
            }
            if (this.cat == 21)
            {
                CAT21 paquete = f.getCAT21(fil);

                //expandimos información:
                if (c == 5 && paquete.TargetReport != null) //Target Report Descriptor
                {
                    MessageBox.Show(paquete.TargetReport, "Target Report Descriptor");
                }
                if (c == 11 && paquete.OperationalStatus != null) //Operational Status
                {
                    MessageBox.Show(paquete.OperationalStatus, "Operational Status");
                }
                if (c == 48 && paquete.FigureOfMerit != null) //Figure Of Merit
                {
                    MessageBox.Show(paquete.FigureOfMerit, "Figure of Merit");
                }
                if (c == 49 && paquete.ages != null) //Data ages
                {
                    MessageBox.Show(paquete.ages, "Data Ages");
                }
                if (c == 41 && paquete.TrajectoryIntentData != null) //Trajectory Intent Data
                {
                    MessageBox.Show(paquete.TrajectoryIntentData, "Trajectory Intent Data");
                }
                if (c == 32 && paquete.LinkTech != null) //Link Technology
                {
                    MessageBox.Show(paquete.LinkTech, "Link Technology");
                }
                if (c == 26 && paquete.TargetStatus != null) //Target Status
                {
                    MessageBox.Show(paquete.TargetStatus, "Target Status");
                }
                if (c == 21 && paquete.MetReport != null) //Met Report
                {
                    MessageBox.Show(paquete.MetReport, "Met Report");
                }
                if (c == 30 && paquete.QualityIndicators != null) //Quality Indicators
                {
                    MessageBox.Show(paquete.QualityIndicators, "Quality Indicators");
                }
                if (c == 28 && paquete.ModeS != null) //Mode S
                {
                    MessageBox.Show(paquete.ModeS, "Mode S");
                }
                if (c == 18 && paquete.MOPS != null) //MOPS version
                {
                    MessageBox.Show(paquete.MOPS, "MOPS Version");
                }

                //mostramos las características de ese paquete a parte:
                filldataexpandedCAT21(fil);
            }
        }