Merge pull request #439 from gregory-diaz/master

Master
This commit is contained in:
Lars Brubaker 2015-11-02 18:06:16 -08:00
commit 5b786de08b
12 changed files with 64 additions and 16 deletions

View file

@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project.
using MatterHackers.Agg.PlatformAbstract;
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
using System.Collections.Generic;
using MatterHackers.MatterControl.SettingsManagement;
using System.IO;
using System.Linq;
@ -40,6 +41,7 @@ namespace MatterHackers.MatterControl
{
public StyledDropDownList ManufacturerDropList;
private int countOfMakes = 0;
private string manufacturer;
public int CountOfMakes { get { return countOfMakes; } }
@ -50,6 +52,7 @@ namespace MatterHackers.MatterControl
ManufacturerDropList = new StyledDropDownList(defaultManufacturerLabelFull, maxHeight: 200);
bool addOther = false;
string[] printerWhiteListStrings = OemSettings.Instance.PrinterWhiteList.ToArray();
List<ManufacturerNameMapping> manufacturerNameMappings = OemSettings.Instance.ManufacturerNameMappings;
string pathToManufacturers = "PrinterSettings";
if (StaticData.Instance.DirectoryExists(pathToManufacturers))
{
@ -59,29 +62,37 @@ namespace MatterHackers.MatterControl
{
string folderName = Path.GetFileName(manufacturerDirectory.TrimEnd(new[] { '/', '\\' }));
if (printerWhiteListStrings.Contains(folderName))
foreach(ManufacturerNameMapping nameMapping in manufacturerNameMappings)
{
string manufacturer = Path.GetFileName(manufacturerDirectory);
if (manufacturer == "Other")
if(nameMapping.NameOnDisk == folderName)
{
addOther = true;
this.manufacturer = nameMapping.NameToDisplay;
}
else
{
ManufacturerDropList.AddItem(manufacturer);
if (selectedMake != null)
{
if (manufacturer == selectedMake)
{
preselectIndex = index;
}
}
index++;
this.manufacturer = Path.GetFileName(manufacturerDirectory);
}
countOfMakes += 1;
}
if (this.manufacturer == "Other")
{
addOther = true;
}
else
{
ManufacturerDropList.AddItem(manufacturer);
if (selectedMake != null)
{
if (this.manufacturer == selectedMake)
{
preselectIndex = index;
}
}
index++;
}
countOfMakes += 1;
}
if (addOther)
{
if (selectedMake != null && preselectIndex == -1)

View file

@ -3,6 +3,7 @@ using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.DataStorage;
using System;
using MatterHackers.MatterControl.SettingsManagement;
using System.Collections.Generic;
using System.Linq;
@ -182,6 +183,18 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
//reconstruct model selector
int currentIndex = contentRow.GetChildIndex(printerModelContainer);
contentRow.RemoveChild(printerModelContainer);
List<ManufacturerNameMapping> manufacturerNameMapping = OemSettings.Instance.ManufacturerNameMappings;
foreach(ManufacturerNameMapping mapping in manufacturerNameMapping)
{
if (mapping.NameToDisplay == ActivePrinter.Make)
{
ActivePrinter.Make = mapping.NameOnDisk;
}
}
printerModelContainer = createPrinterModelContainer(ActivePrinter.Make);
contentRow.AddChild(printerModelContainer, currentIndex);

View file

@ -75,11 +75,15 @@ namespace MatterHackers.MatterControl.SettingsManagement
public List<string> PrinterWhiteList { get { return printerWhiteList; } }
public List<ManufacturerNameMapping> ManufacturerNameMappings { get; set; }
// TODO: Is this ever initialized and if so, how, given there's no obvious references and only one use of the property
private List<string> preloadedLibraryFiles = new List<string>();
public List<string> PreloadedLibraryFiles { get { return preloadedLibraryFiles; } }
private OemSettings()
{
#if false // test saving the file
@ -93,4 +97,18 @@ namespace MatterHackers.MatterControl.SettingsManagement
#endif
}
}
}
public class ManufacturerNameMapping
{
public string NameOnDisk
{
get; set;
}
public string NameToDisplay
{
get; set;
}
}
}

View file

@ -33,6 +33,12 @@
"Wanhao USA",
"Velleman",
],
"ManufacturerNameMappings": [
{
"NameOnDisk": "Esagono",
"NameToDisplay": "Esagonò",
}
],
"PreloadedLibraryFiles": [
"Calibration - Box.stl"
]