Skip to content

Commit

Permalink
Provide Navaids to GetExportText of FileExport
Browse files Browse the repository at this point in the history
  • Loading branch information
rklomp committed Aug 24, 2019
1 parent 9b80226 commit f0a3bf9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/QSP/RouteFinding/FileExport/FileExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using QSP.Common.Options;
using QSP.LibraryExtension;
using QSP.RouteFinding.Airports;
using QSP.RouteFinding.Navaids;
using QSP.RouteFinding.Routes;
using QSP.Utilities;
using System;
Expand All @@ -17,16 +18,19 @@ public class FileExporter
{
private readonly Route route;
private readonly AirportManager airports;
private readonly MultiMap<string, Navaid> navaids;
private readonly IEnumerable<ExportCommand> commands;
private readonly Func<AppOptions> options;

public FileExporter(
Route route,
MultiMap<string, Navaid> navaids,
AirportManager airports,
IEnumerable<ExportCommand> commands,
Func<AppOptions> options)
{
this.route = route;
this.navaids = navaids;
this.airports = airports;
this.commands = commands;
this.options = options;
Expand Down Expand Up @@ -73,7 +77,7 @@ private Status Export(string nameBase, ExportCommand c, int i)
: fileName;

File.WriteAllText(newName,
Providers.Types.GetExportText(c.ProviderType, route, airports));
Providers.Types.GetExportText(c.ProviderType, route, navaids, airports));
return new Status(newName, true, "", false);
}
catch (Exception ex)
Expand Down
4 changes: 3 additions & 1 deletion src/QSP/RouteFinding/FileExport/Providers/Types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using QSP.LibraryExtension;
using QSP.LibraryExtension.Sets;
using QSP.RouteFinding.Airports;
using QSP.RouteFinding.Navaids;
using QSP.RouteFinding.Routes;
using QSP.Utilities;
using System;
Expand Down Expand Up @@ -201,11 +202,12 @@ public static string GetSimulatorPath(SimulatorType t)
public static string GetExtension(ProviderType type) => Lookup[type].FileExtension;

public static string GetExportText(ProviderType type, Route route,
AirportManager airports)
MultiMap<string, Navaid> navaids, AirportManager airports)
{
var input = new ExportInput()
{
Route = route,
Navaids = navaids,
Airports = airports
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
using System.Windows.Forms;
using static QSP.UI.Views.Factories.FormFactory;
using System;
using QSP.LibraryExtension;
using QSP.RouteFinding.Navaids;

namespace QSP.UI.Presenters.FuelPlan.Routes
{
Expand All @@ -33,6 +35,7 @@ public static void ShowMap(this ISupportActionContextMenu view, RouteGroup route
IMessageDisplay view,
RouteGroup Route,
IEnumerable<ExportCommand> cmds,
MultiMap<string, Navaid> Navaids,
AirportManager airportList,
ExportMenu menu)
{
Expand All @@ -46,6 +49,7 @@ public static void ShowMap(this ISupportActionContextMenu view, RouteGroup route
{
menu.Location = new Point(0, 0);
menu.Route = Route;
menu.Navaids = Navaids;
menu.AirportList = airportList;

frm.AutoSizeMode = AutoSizeMode.GrowAndShrink;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public void ExportRouteFiles()
view,
Route,
AppOptions.ExportCommands,
airwayNetwork.Navaids,
AirportList,
exportMenu);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,10 @@ public void ExportRouteFiles()
Debug.Assert(view.IsAirportToAirport());

var o = model.FuelPlanningModel.AppOption.Instance;
var navaids = model.FuelPlanningModel.AirwayNetwork.Navaids;
var airportList = model.FuelPlanningModel.AirwayNetwork.AirportList;
var cmds = o.ExportCommands;
ActionContextMenuHelper.ExportRouteFiles(view, Route, cmds, airportList, exportMenu);
ActionContextMenuHelper.ExportRouteFiles(view, Route, cmds, navaids, airportList, exportMenu);
}

public void AnalyzeRoute()
Expand Down
6 changes: 4 additions & 2 deletions src/QSP/UI/UserControls/ExportMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using QSP.LibraryExtension;
using QSP.RouteFinding.Airports;
using QSP.RouteFinding.FileExport;
using QSP.RouteFinding.Navaids;
using QSP.RouteFinding.Routes;
using QSP.UI.Util;
using QSP.UI.Views;
Expand All @@ -19,9 +20,10 @@ public partial class ExportMenu : UserControl, IMessageDisplay
private Locator<AppOptions> appOption;
private Action showOptions;

// These two properties are required for exporting the route.
// These three properties are required for exporting the route.
public RouteGroup Route { get; set; }
public AirportManager AirportList { get; set; }
public MultiMap<string, Navaid> Navaids { get; set; }

public ExportMenu()
{
Expand Down Expand Up @@ -57,7 +59,7 @@ private void ExportFiles(object sender, EventArgs e)
var o = UpdatedOption();
UpdateOption(o);

var writer = new FileExporter(Route.Expanded, AirportList, o.ExportCommands,
var writer = new FileExporter(Route.Expanded, Navaids, AirportList, o.ExportCommands,
() => appOption.Instance);
IEnumerable<FileExporter.Status> reports = null;

Expand Down

0 comments on commit f0a3bf9

Please sign in to comment.