Esempio n. 1
0
        private void Update_PlotTrack_Data()
        {
            if (this.checkEnableDisplay.Checked == true)
            {

                // First clear all the data from the previous cycle.
                if (DinamicOverlay.Markers.Count > 0)
                    DinamicOverlay.Markers.Clear();

                if (PredictionOverlay.Markers.Count > 0)
                    PredictionOverlay.Markers.Clear();

                // Now get the data since the last cycle and display it on the map
                DynamicDisplayBuilder DP = new DynamicDisplayBuilder();
                System.Collections.Generic.List<DynamicDisplayBuilder.TargetType> TargetList = new System.Collections.Generic.List<DynamicDisplayBuilder.TargetType>();

                // Here handle display od live data
                if (SharedData.bool_Listen_for_Data == true)
                {
                    DynamicDisplayBuilder.GetDisplayData(false, out TargetList);

                    if (FirstCycleDisplayEnabled)
                    {
                        FirstCycleDisplayEnabled = false;
                        TargetList.Clear();
                    }

                    this.lblNumberofTargets.Text = TargetList.Count.ToString();

                    bool Build_Local_Display = comboBoxLiveDisplayMode.Text != "Google Earth";
                    bool Provide_To_Google_Earth = comboBoxLiveDisplayMode.Text != "Local";
                    bool ProvideWebData = comboBoxLiveDisplayMode.Text == "Local & Web" || comboBoxLiveDisplayMode.Text == "Web";
                    Asterix_To_KML_Provider ASTX_TO_KML = new Asterix_To_KML_Provider();
                    WBTD WebBasedDisplayProvider = new WBTD();
                    PredictionBuilder Prediction_B = new PredictionBuilder();

                    try
                    {
                        foreach (DynamicDisplayBuilder.TargetType Target in TargetList)
                        {
                            if (Passes_Check_For_Flight_Level_Filter(Target.ModeC))
                            {
                                // If SSR code filtering is to be applied
                                if (this.checkBoxFilterBySSR.Checked == true && (this.textBoxSSRCode.Text.Length == 4))
                                {
                                    if (Target.ModeA == this.textBoxSSRCode.Text)
                                    {
                                        Target.MyMarker.ToolTipMode = MarkerTooltipMode.Never;
                                        Target.MyMarker.Position = new PointLatLng(Target.Lat, Target.Lon);
                                        BuildDynamicLabelText(Target, ref Target.MyMarker);
                                        SetLabelAttributes(ref Target.MyMarker);

                                        if (Build_Local_Display)
                                        {
                                            DinamicOverlay.Markers.Add(Target.MyMarker);

                                            if (SharedData.Prediction1_Enabled)
                                                Prediction_B.Build_Prediction_Marker(Target.MyMarker.Position, Target.MyMarker.CALLSIGN_STRING, MySqlProvider.PredictionTableNumberType.One, ref PredictionOverlay);

                                            if (SharedData.Prediction2_Enabled)
                                                Prediction_B.Build_Prediction_Marker(Target.MyMarker.Position, Target.MyMarker.CALLSIGN_STRING, MySqlProvider.PredictionTableNumberType.Two, ref PredictionOverlay);

                                            if (SharedData.Prediction3_Enabled)
                                                Prediction_B.Build_Prediction_Marker(Target.MyMarker.Position, Target.MyMarker.CALLSIGN_STRING, MySqlProvider.PredictionTableNumberType.Three, ref PredictionOverlay);

                                        }

                                        if (Provide_To_Google_Earth)
                                            ASTX_TO_KML.AddNewTarget(Target);

                                        if (ProvideWebData)
                                            WebBasedDisplayProvider.SetTargetData(Target.Lat.ToString(), Target.Lon.ToString(), Target.ACID_Mode_S,
                                                Target.ModeA, Target.ModeC);
                                    }
                                }
                                else // No SSR filter so just display all of them
                                {
                                    Target.MyMarker.ToolTipMode = MarkerTooltipMode.Never;
                                    Target.MyMarker.Position = new PointLatLng(Target.Lat, Target.Lon);
                                    BuildDynamicLabelText(Target, ref Target.MyMarker);
                                    SetLabelAttributes(ref Target.MyMarker);

                                    if (Build_Local_Display)
                                    {
                                        DinamicOverlay.Markers.Add(Target.MyMarker);

                                        if (SharedData.Prediction1_Enabled)
                                            Prediction_B.Build_Prediction_Marker(Target.MyMarker.Position, Target.MyMarker.CALLSIGN_STRING, MySqlProvider.PredictionTableNumberType.One, ref PredictionOverlay);

                                        if (SharedData.Prediction2_Enabled)
                                            Prediction_B.Build_Prediction_Marker(Target.MyMarker.Position, Target.MyMarker.CALLSIGN_STRING, MySqlProvider.PredictionTableNumberType.Two, ref PredictionOverlay);

                                        if (SharedData.Prediction3_Enabled)
                                            Prediction_B.Build_Prediction_Marker(Target.MyMarker.Position, Target.MyMarker.CALLSIGN_STRING, MySqlProvider.PredictionTableNumberType.Three, ref PredictionOverlay);
                                    }

                                    if (Provide_To_Google_Earth)
                                        ASTX_TO_KML.AddNewTarget(Target);

                                    if (ProvideWebData)
                                        WebBasedDisplayProvider.SetTargetData(Target.Lat.ToString(), Target.Lon.ToString(), Target.ACID_Mode_S,
                                           Target.ModeA, Target.ModeC);
                                }
                            }
                        }
                    }
                    catch
                    {

                    }

                    Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y);
                    Cursor.Position = new Point(Cursor.Position.X - 1, Cursor.Position.Y);

                    // Check if there were any items, if so then tell KML to build the file
                    if (Provide_To_Google_Earth)
                        ASTX_TO_KML.BuildKML();

                    if (ProvideWebData)
                        WebBasedDisplayProvider.WriteTrackData();

                }
                else // Here handle display of passive display (buffered data)
                {
                    DynamicDisplayBuilder.GetDisplayData(true, out TargetList);

                    this.lblNumberofTargets.Text = TargetList.Count.ToString();

                    foreach (DynamicDisplayBuilder.TargetType Target in TargetList)
                    {
                        if (Passes_Check_For_Flight_Level_Filter(Target.ModeC))
                        {
                            // If SSR code filtering is to be applied
                            if (this.checkBoxFilterBySSR.Checked == true && (this.comboBoxSSRFilterBox.Items.Count > 0))
                            {
                                if (Target.ModeA == this.comboBoxSSRFilterBox.Items[SSR_Filter_Last_Index].ToString())
                                {
                                    GMap.NET.WindowsForms.Markers.GMapMarkerCross MyMarker = new GMap.NET.WindowsForms.Markers.GMapMarkerCross(new PointLatLng(Target.Lat, Target.Lon));
                                    MyMarker.ToolTipMode = MarkerTooltipMode.Always;
                                    MyMarker.ToolTipText = BuildPassiveLabelText(Target);
                                    SetLabelAttributes(ref MyMarker);
                                    DinamicOverlay.Markers.Add(MyMarker);
                                }
                            }
                            else // No filter so just display all of them
                            {
                                GMap.NET.WindowsForms.Markers.GMapMarkerCross MyMarker = new GMap.NET.WindowsForms.Markers.GMapMarkerCross(new PointLatLng(Target.Lat, Target.Lon));
                                MyMarker.ToolTipMode = MarkerTooltipMode.Always;
                                MyMarker.ToolTipText = BuildPassiveLabelText(Target);
                                SetLabelAttributes(ref MyMarker);
                                DinamicOverlay.Markers.Add(MyMarker);
                            }
                        }
                    }
                }
            }
        }