Example #1
0
 public void setTrackInfo(TrackData track)
 {
     this.track = track;
     if (track != null)
     {
         txtNumber.Text       = track.Number.ToString("000");
         txtCallSign.Text     = track.CallSign;
         cmbStatus.Text       = track.Status.ToString();
         txtPosition.Text     = PositionConverter.ParsePointToString(track.Position, cmbPosition.Text);
         txtSpeed.Text        = ScaleConverter.ConvertSpeed(track.Speed, "knots", cmbSpeed.Text).ToString();
         txtBearing.Text      = ScaleConverter.ConvertBearing(track.Bearing, "degree", cmbBearing.Text).ToString();
         txtCallSign.ReadOnly = false;
         txtPosition.ReadOnly = txtSpeed.ReadOnly = txtBearing.ReadOnly = txtHeight.ReadOnly = !track.Faker;
         if (track.Height.HasValue)
         {
             txtHeight.Text = ScaleConverter.ConvertHeight(track.Height.Value, "ft", cmbHeight.Text).ToString();
         }
         else
         {
             txtHeight.Text     = "Unknown";
             txtHeight.ReadOnly = true;
         }
     }
     else
     {
         clearFields();
     }
 }
Example #2
0
 private void cmbSpeed_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (track != null)
     {
         lbSpeed.Text = ScaleConverter.ConvertSpeed(track.Speed, "knots", cmbSpeed.Text).ToString("#,##0.####");
     }
 }
        private void btnCreate_Click(object sender, EventArgs e)
        {
            PointLatLng point = PositionConverter.ParsePointFromString(txtPosition.Text);
            int         number;
            double      speed, bearing, height;
            bool        server = rdbServer.Checked;

            if (point.IsEmpty)
            {
            }
            else if (!int.TryParse(txtNumber.Text, out number))
            {
            }
            else if (!double.TryParse(txtSpeed.Text, out speed))
            {
            }
            else if (!double.TryParse(txtBearing.Text, out bearing))
            {
            }
            else if (!double.TryParse(txtHeight.Text, out height))
            {
            }
            else
            {
                TrackData faker = new TrackData
                {
                    Source      = RadarClient.Connected ? DataSource.Self : null,
                    Number      = number,
                    Position    = point,
                    Speed       = ScaleConverter.ConvertSpeed(speed, speedScale, "knots"),
                    Bearing     = ScaleConverter.ConvertBearing(bearing, bearingScale, "degree"),
                    Height      = ScaleConverter.ConvertHeight(height, heightScale, "ft"),
                    LastUpdated = DateTime.Now
                };
                if (server && !RadarClient.Connected)
                {
                }
                else
                {
                    faker.Faker = server && RadarClient.Connected ? TrackFakerType.Server : TrackFakerType.Client;
                    TrackCommandResponse response = main.trackHandler.CreateTrack(faker);
                    if (response.Code == TrackCommandResponseCode.Success)
                    {
                        txtNumber.Text   = "";
                        txtPosition.Text = "";
                        txtSpeed.Text    = "";
                        txtBearing.Text  = "";
                        txtHeight.Text   = "";
                    }
                    else
                    {
                        MessageBox.Show(response.Message);
                    }
                }
            }
        }
Example #4
0
        private void cmbSpeed_SelectedIndexChanged(object sender, EventArgs e)
        {
            var    newScale = cmbSpeed.SelectedItem.ToString();
            double speed;

            if (double.TryParse(txtSpeed.Text, out speed))
            {
                double newvalue = ScaleConverter.ConvertSpeed(speed, speedScale, newScale);
                txtSpeed.Text = newvalue.ToString();
            }
            speedScale = newScale;
        }
Example #5
0
 public void setTrackInfo(TrackData track)
 {
     this.track = track;
     if (track != null)
     {
         foreach (Control control in Controls)
         {
             control.Visible = true;
         }
         lbNumber.Text   = track.Number.ToString("000");
         lbCallsign.Text = track.CallSign ?? "";
         if (track.Status == TrackStatus.OverridePending)
         {
             lbStatus.Text = TrackStatus.Pending.ToString();
         }
         else
         {
             lbStatus.Text = track.Status.ToString();
         }
         lbPosition.Text = PositionConverter.ParsePointToString(track.Position, cmbPosition.Text);
         lbSpeed.Text    = ScaleConverter.ConvertSpeed(track.Speed, "knots", cmbSpeed.Text).ToString("#,##0.####");
         lbBearing.Text  = ScaleConverter.ConvertBearing(track.Bearing, "degree", cmbBearing.Text).ToString("#,##0.####");
         if (track.Height.HasValue)
         {
             lbHeight.Text = ScaleConverter.ConvertHeight(track.Height.Value, "ft", cmbHeight.Text).ToString("#,##0.####");
         }
         else
         {
             lbHeight.Text = "Unknown";
         }
     }
     else
     {
         foreach (Control control in Controls)
         {
             control.Visible = false;
         }
         lbNumber.Text   = "";
         lbCallsign.Text = "";
         lbStatus.Text   = "";
         lbPosition.Text = "";
         lbSpeed.Text    = "";
         lbBearing.Text  = "";
         lbHeight.Text   = "";
     }
 }
Example #6
0
 public void setTrackInfo(TrackData track)
 {
     currentTrack = track;
     if (track != null)
     {
         txtKey.Text          = track.Key;
         txtPosition.Text     = PositionConverter.ParsePointToString(track.Position, cmbPosition.Text);
         txtSpeed.Text        = ScaleConverter.ConvertSpeed(track.Speed, "knots", cmbSpeed.Text).ToString();
         txtBearing.Text      = ScaleConverter.ConvertBearing(track.Bearing, "degree", cmbBearing.Text).ToString();
         txtPosition.ReadOnly = false;
         txtSpeed.ReadOnly    = false;
         txtBearing.ReadOnly  = false;
         if (track.Height.HasValue)
         {
             txtHeight.Text     = ScaleConverter.ConvertHeight(track.Height.Value, "ft", cmbHeight.Text).ToString();
             txtHeight.ReadOnly = false;
         }
         else
         {
             txtHeight.Text     = "Unknown";
             txtHeight.ReadOnly = true;
         }
         lbScope.Text = track.Faker == TrackFakerType.Client ? "Client" : "Server";
     }
     else
     {
         txtPosition.ReadOnly = true;
         txtSpeed.ReadOnly    = true;
         txtBearing.ReadOnly  = true;
         txtKey.Text          = "";
         txtPosition.Text     = "";
         txtSpeed.Text        = "";
         txtBearing.Text      = "";
         txtHeight.Text       = "";
         lbScope.Text         = "";
     }
 }
Example #7
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            PointLatLng point = PositionConverter.ParsePointFromString(txtPosition.Text);
            int         number;
            double      speed, bearing, height;

            if (point.IsEmpty)
            {
            }
            else if (!int.TryParse(txtNumber.Text, out number))
            {
            }
            else if (!double.TryParse(txtSpeed.Text, out speed))
            {
            }
            else if (!double.TryParse(txtBearing.Text, out bearing))
            {
            }
            else if (!double.TryParse(txtHeight.Text, out height) && txtHeight.Text != "Unknown")
            {
            }
            else
            {
                var track = new TrackData
                {
                    CallSign    = txtCallSign.Text.ToUpper(),
                    Status      = (TrackStatus)Enum.Parse(typeof(TrackStatus), cmbStatus.Text),
                    Number      = number,
                    Position    = point,
                    Speed       = ScaleConverter.ConvertSpeed(speed, speedScale, "knots"),
                    Bearing     = ScaleConverter.ConvertBearing(bearing, bearingScale, "degree"),
                    LastUpdated = DateTime.Now
                };
                if (editMode)
                {
                    MessageBox.Show("Passin");
                    if (this.track != null)
                    {
                        track.Faker = this.track.Faker;
                        if (txtHeight.Text != "Unknown")
                        {
                            track.Height = ScaleConverter.ConvertHeight(height, heightScale, "ft");
                        }
                        if (txtCallSign.Text == "")
                        {
                            track.CallSign = null;
                        }
                        if (track.Status == TrackStatus.Pending)
                        {
                            track.Status = TrackStatus.OverridePending;
                        }
                        CommandResponse response = ControlViews.Main.trackHandler.Update(track);
                        if (response.Code == CommandResponseCode.Success)
                        {
                            ControlViews.Track.SetControl(ControlViews.TrackView);
                            ControlViews.TrackView.setTrackInfo(track);
                        }
                        else
                        {
                            MessageBox.Show(response.Message);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Passin2");
                    track.Faker  = true;
                    track.Height = ScaleConverter.ConvertHeight(height, heightScale, "ft");
                    CommandResponse response = ControlViews.Main.trackHandler.Create(track);
                    if (response.Code == CommandResponseCode.Success)
                    {
                        clearFields();
                    }
                    else
                    {
                        MessageBox.Show(response.Message);
                    }
                }
            }
        }