Move Windows driver enumeration/list from SettingsProfile to WizardPage
This commit is contained in:
parent
c143df3f21
commit
463305c96c
4 changed files with 73 additions and 78 deletions
|
|
@ -94,7 +94,7 @@ namespace MatterHackers.MatterControl
|
|||
AddHandlers();
|
||||
SetVisibleControls();
|
||||
|
||||
if (!pluginsQueuedToAdd && ActiveSliceSettings.Instance.ShowFirmwareUpdater())
|
||||
if (!pluginsQueuedToAdd && ActiveSliceSettings.Instance.ActiveValue("include_firmware_updater") == "Simple Arduino")
|
||||
{
|
||||
UiThread.RunOnIdle(AddPlugins);
|
||||
pluginsQueuedToAdd = true;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using MatterHackers.Agg.PlatformAbstract;
|
|||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.DataStorage;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -13,6 +14,8 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
{
|
||||
public class SetupStepInstallDriver : ConnectionWizardPage
|
||||
{
|
||||
private static List<string> printerDrivers = null;
|
||||
|
||||
private FlowLayoutWidget printerDriverContainer;
|
||||
private TextWidget printerDriverMessage;
|
||||
|
||||
|
|
@ -156,13 +159,80 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
}
|
||||
}
|
||||
|
||||
public static List<string> PrinterDrivers()
|
||||
{
|
||||
if (printerDrivers == null)
|
||||
{
|
||||
printerDrivers = GetPrintDrivers();
|
||||
}
|
||||
|
||||
return printerDrivers;
|
||||
}
|
||||
|
||||
private static List<string> GetPrintDrivers()
|
||||
{
|
||||
var drivers = new List<string>();
|
||||
|
||||
//Determine what if any drivers are needed
|
||||
string infFileNames = ActiveSliceSettings.Instance.ActiveValue("windows_driver");
|
||||
if (!string.IsNullOrEmpty(infFileNames))
|
||||
{
|
||||
string[] fileNames = infFileNames.Split(',');
|
||||
foreach (string fileName in fileNames)
|
||||
{
|
||||
switch (OsInformation.OperatingSystem)
|
||||
{
|
||||
case OSType.Windows:
|
||||
|
||||
string pathForInf = Path.GetFileNameWithoutExtension(fileName);
|
||||
|
||||
// TODO: It's really unexpected that the driver gets copied to the temp folder every time a printer is setup. I'd think this only needs
|
||||
// to happen when the infinstaller is run (More specifically - move this to *after* the user clicks Install Driver)
|
||||
|
||||
string infPath = Path.Combine("Drivers", pathForInf);
|
||||
string infPathAndFileToInstall = Path.Combine(infPath, fileName);
|
||||
|
||||
if (StaticData.Instance.FileExists(infPathAndFileToInstall))
|
||||
{
|
||||
// Ensure the output directory exists
|
||||
string destTempPath = Path.GetFullPath(Path.Combine(ApplicationDataStorage.ApplicationUserDataPath, "data", "temp", "inf", pathForInf));
|
||||
if (!Directory.Exists(destTempPath))
|
||||
{
|
||||
Directory.CreateDirectory(destTempPath);
|
||||
}
|
||||
|
||||
string destTempInf = Path.GetFullPath(Path.Combine(destTempPath, fileName));
|
||||
|
||||
// Sync each file from StaticData to the location on disk for serial drivers
|
||||
foreach (string file in StaticData.Instance.GetFiles(infPath))
|
||||
{
|
||||
using (Stream outstream = File.OpenWrite(Path.Combine(destTempPath, Path.GetFileName(file))))
|
||||
using (Stream instream = StaticData.Instance.OpenSteam(file))
|
||||
{
|
||||
instream.CopyTo(outstream);
|
||||
}
|
||||
}
|
||||
|
||||
drivers.Add(destTempInf);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return drivers;
|
||||
}
|
||||
|
||||
private bool InstallDriver()
|
||||
{
|
||||
try
|
||||
{
|
||||
printerDriverMessage.Text = "Installing".Localize() + "...";
|
||||
|
||||
foreach (string driverPath in ActiveSliceSettings.Instance.PrinterDrivers())
|
||||
foreach (string driverPath in PrinterDrivers())
|
||||
{
|
||||
InstallDriver(driverPath);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue