Skip to content

Commit

Permalink
Adds Bearing and Range from reference points separately to unit impor…
Browse files Browse the repository at this point in the history
…ter table
  • Loading branch information
FalcoGer committed Sep 14, 2023
1 parent a87b1d6 commit 187457a
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 75 deletions.
1 change: 1 addition & 0 deletions CoordinateConverter/CoordinateConverter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
</EmbeddedResource>
<EmbeddedResource Include="DCS\Tools\FormUnitImporter.resx">
<DependentUpon>FormUnitImporter.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
Expand Down
2 changes: 1 addition & 1 deletion CoordinateConverter/DCS/Aircraft/AH64.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public int ClearPoints(EPointType pointType, int startIdx, int endIdx)

for (int pointIdx = startIdx - ((pointType == EPointType.ControlMeasure) ? 50 : 0); pointIdx <= endIdx - ((pointType == EPointType.ControlMeasure) ? 50 : 0); pointIdx++)
{
commands.Add(new DCSCommand(deviceId, (int)EKeyCode.RMFD_TSD)); // Reset to TSD after every point, to a void weirdness.
commands.Add(new DCSCommand(deviceId, (int)EKeyCode.RMFD_TSD)); // Reset to TSD after every point, to avoid weirdness.
commands.Add(new DCSCommand(deviceId, (int)EKeyCode.RMFD_B6)); // Point
commands.Add(new DCSCommand(deviceId, (int)EKeyCode.RMFD_L1)); // Point >
commands.AddRange(GetCommandsForKUText(pointType.ToString().First() + pointIdx.ToString() + "\n", true)); // Enter point identifier
Expand Down
152 changes: 85 additions & 67 deletions CoordinateConverter/DCS/Tools/FormUnitImporter.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 22 additions & 7 deletions CoordinateConverter/DCS/Tools/FormUnitImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public partial class FormUnitImporter : Form
/// </value>
public List<CoordinateDataEntry> Coordinates { get; private set; } = null;
private readonly Dictionary<int, CoordinateDataEntry> referencePoints = null;
private const int IMPORT_CHECKBOX_COLUMN_ID = 6;
private const int IMPORT_CHECKBOX_COLUMN_ID = 8;

private void UpdateAllUnitsFromDCS()
{
Expand Down Expand Up @@ -102,9 +102,9 @@ private void Filter()
}
Bullseye be = new Bullseye(refPoint.Coordinate);

ERangeUnit rangeUnit = ComboItem<ERangeUnit>.GetSelectedValue(cb_RadiusUnit);
if (cb_WithRadiusFilter.Checked)
{
ERangeUnit rangeUnit = ComboItem<ERangeUnit>.GetSelectedValue(cb_RadiusUnit);
double rawRangeValue = (double)nud_RadiusValue.Value;
double rangeInM = 0;
switch (rangeUnit)
Expand Down Expand Up @@ -178,11 +178,25 @@ private void Filter()
Format = CoordinateSharp.CoordinateFormatType.Degree_Minutes_Seconds
};

string positionStr = coordinate.ToString(options);
string rangeStr = string.Empty;
if (cb_WithRadiusFilter.Checked)
{

positionStr += " | From Ref: [" + be.GetBRA(coordinate).ToString() + "]";
double rangeInNmi = be.GetBRA(coordinate).Range;
switch (rangeUnit)
{
case ERangeUnit.Feet:
rangeStr = Math.Round(rangeInNmi * 6076.12, 1).ToString() + " ft";
break;
case ERangeUnit.NauticalMile:
rangeStr = Math.Round(rangeInNmi * 1, 1).ToString() + " nmi";
break;
case ERangeUnit.Meter:
rangeStr = Math.Round(rangeInNmi * 1852, 1).ToString() + " m";
break;
case ERangeUnit.KiloMeter:
rangeStr = Math.Round(rangeInNmi * 1.852, 1).ToString() + " km";
break;
}
}

int rowIdx = dgv_Units.Rows.Add(
Expand All @@ -191,7 +205,9 @@ private void Filter()
unit.TypeName,
unit.Type.Level2.ToString() + " / " + unit.Type.Level3.ToString(),
(unit.UnitName ?? string.Empty) + " / " + (unit.GroupName ?? string.Empty),
positionStr,
coordinate.ToString(),
be != null ? Math.Round(be.GetBRA(coordinate).Bearing, 1).ToString() : String.Empty,
rangeStr,
true
);

Expand Down Expand Up @@ -290,7 +306,6 @@ private void Cb_WithRadiusFilter_CheckedChanged(object sender, EventArgs e)
{
nud_RadiusValue.Enabled = cb_WithRadiusFilter.Checked;
cb_RadiusUnit.Enabled = cb_WithRadiusFilter.Checked;
cb_RadiusCenter.Enabled = cb_WithRadiusFilter.Checked;
}

private void Btn_ApplyFilter_Click(object sender, EventArgs e)
Expand Down
6 changes: 6 additions & 0 deletions CoordinateConverter/DCS/Tools/FormUnitImporter.resx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@
<metadata name="dgvColPosition.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dgvColBearing.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dgvColRange.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dgvColImport.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
Expand Down

0 comments on commit 187457a

Please sign in to comment.