Add SID mapping system

This commit is contained in:
John Lewin 2018-10-12 15:11:47 -07:00
parent b54a366f70
commit 98da7c10f0
3 changed files with 152 additions and 8 deletions

View file

@ -75,7 +75,6 @@ namespace MatterHackers.MatterControl.Library.Widgets.HardwarePage
};
headingRow.AddChild(openButton);
this.AddChild(headingRow);
}
@ -84,10 +83,20 @@ namespace MatterHackers.MatterControl.Library.Widgets.HardwarePage
if (File.Exists(printerInfo.ProfilePath))
{
// load up the printer profile so we can get the MatterHackers Skew-ID out of it
var profile = PrinterSettings.LoadFile(printerInfo.ProfilePath);
var printerSettings = PrinterSettings.LoadFile(printerInfo.ProfilePath);
// Get the printer sid from settings
var storeID = printerSettings.GetValue(SettingsKey.matterhackers_sid);
// If empty, fall back to the make-model mapping table
if (string.IsNullOrEmpty(storeID))
{
if (OemSettings.Instance.OemPrinters.TryGetValue($"{printerInfo.Make}-{ printerInfo.Model}", out StorePrinterID storePrinterID))
{
storeID = storePrinterID?.SID;
}
}
// if there is a SID than get the data from that url and display it
var storeID = profile.GetValue(SettingsKey.matterhackers_sid);
if (!string.IsNullOrWhiteSpace(storeID))
{
var product = (await LoadProductData(storeID)).ProductSku;
@ -151,18 +160,55 @@ namespace MatterHackers.MatterControl.Library.Widgets.HardwarePage
var icon = new ImageBuffer(80, 0);
ApplicationController.Instance.DownloadToImageAsync(icon, item.FeaturedImage.ImageUrl, scaleToImageX: true);
var link = new LinkLabel("More Info", theme, pointSize: theme.DefaultFontSize)
var addOnRow = new AddOnRow(item.AddOnTitle, theme, null, icon)
{
VAnchor = VAnchor.Center
HAnchor = HAnchor.Stretch,
Cursor = Cursors.Hand
};
link.Click += (s, e) =>
foreach(var child in addOnRow.Children)
{
child.Selectable = false;
}
addOnRow.Click += (s, e) =>
{
ApplicationController.Instance.LaunchBrowser($"https://www.matterhackers.com/store/l/{item.AddOnListingReference}/sk/{item.AddOnSkuReference}");
};
addonsColumn.AddChild(new AddOnRow(item.AddOnTitle, theme, link, icon)
addonsColumn.AddChild(addOnRow);
}
if (false)
{
var settingsPanel = new GuiWidget()
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Stretch,
MinimumSize = new VectorMath.Vector2(20, 20),
DebugShowBounds = true
};
settingsPanel.Load += (s, e) =>
{
var printer = new PrinterConfig(printerSettings);
var settingsContext = new SettingsContext(
printer,
null,
NamedSettingsLayers.All);
settingsPanel.AddChild(
new ConfigurePrinterWidget(settingsContext, printer, theme)
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Stretch,
});
};
this.AddChild(new SectionWidget("Settings", settingsPanel, theme, expanded: false, setContentVAnchor: false)
{
VAnchor = VAnchor.Stretch
});
}
}

View file

@ -169,6 +169,7 @@ namespace MatterHackers.MatterControl.SettingsManagement
public OemProfileDictionary OemProfiles { get; set; }
public Dictionary<string, string> OemUrls { get; }
public Dictionary<string, StorePrinterID> OemPrinters { get; }
[OnDeserialized]
private void Deserialized(StreamingContext context)
@ -256,9 +257,16 @@ namespace MatterHackers.MatterControl.SettingsManagement
{
this.ManufacturerNameMappings = new List<ManufacturerNameMapping>();
this.OemUrls = JsonConvert.DeserializeObject<Dictionary<string, string>>(AggContext.StaticData.ReadAllText(Path.Combine("OEMSettings", "OEMUrls.json")));
this.OemPrinters = JsonConvert.DeserializeObject<Dictionary<string, StorePrinterID>>(AggContext.StaticData.ReadAllText(Path.Combine("OEMSettings", "Printers.json")));
}
}
public class StorePrinterID
{
public string SID { get; set; }
public string AltInfoUrl { get; set; }
}
public class ManufacturerNameMapping
{
public string NameOnDisk { get; set; }

View file

@ -0,0 +1,90 @@
{
"BCN-Sigma": { "SID": "MCN1YNVE"},
"BCN3D-Sigma": { "SID": "MCN1YNVE"},
"Creality-CR-10 300": { "AltInfoUrl": "https://www.matterhackers.com/store/c/creality-3d-printers"},
"Creality-CR-10 400": { "AltInfoUrl": "https://www.matterhackers.com/store/c/creality-3d-printers"},
"Creality-CR-10 500": { "AltInfoUrl": "https://www.matterhackers.com/store/c/creality-3d-printers"},
"Creality-CR-20": { "SID": "MN6SPN76"},
"FlashForge-Creator Dual": { "AltInfoUrl": "https://www.matterhackers.com/s/store?q=FlashForge"},
"FlashForge-Creator Pro Dual": { "SID": "MW7Z2YD3"},
"FlashForge-Creator X Dual": { "AltInfoUrl": "https://www.matterhackers.com/s/store?q=FlashForge"},
"FlashForge-Creator": { "AltInfoUrl": "https://www.matterhackers.com/s/store?q=FlashForge"},
"FlashForge-Finder": { "AltInfoUrl": "https://www.matterhackers.com/s/store?q=FlashForge"},
"JumpStart-V1": { "SID": "MAGGENLY"},
"Lulzbot-Mini": { "SID": "M0HR99H8"},
"Lulzbot-TAZ 4": { "AltInfoUrl": "https://www.matterhackers.com/store/c/Lulzbot"},
"Lulzbot-TAZ 5": { "AltInfoUrl": "https://www.matterhackers.com/store/c/Lulzbot"},
"Lulzbot-TAZ 6 Software Leveling": { "SID": "MY1N33MZ"},
"Lulzbot-TAZ 6": { "SID": "MY1N33MZ"},
"Lulzbot-TAZ": { "AltInfoUrl": "https://www.matterhackers.com/store/c/Lulzbot"},
"MAKEiT-Pro": { "AltInfoUrl": "https://www.matterhackers.com/store/c/MAKEiT"},
"MAKEiT-Pro-L": { "SID": "MGQVTSSG"},
"MAKEiT-Pro-M": { "SID": "MZXLLQJ9"},
"MakerGear-M2": { "AltInfoUrl": "https://www.matterhackers.com/store/c/makergear-"},
"MakerGear-M3": { "SID": "MXUD1KES"},
"Peopoly-Moai": { "SID": "M2513KLL"},
"Pulse-A-024": { "SID": "MUY6R1P5"},
"Pulse-A-025": { "SID": "MUY6R1P5"},
"Pulse-A-026": { "SID": "MUY6R1P5"},
"Pulse-A-034": { "SID": "MUY6R1P5"},
"Pulse-A-035": { "SID": "MUY6R1P5"},
"Pulse-A-124": { "SID": "MUY6R1P5"},
"Pulse-A-125": { "SID": "MUY6R1P5"},
"Pulse-A-134": { "SID": "MUY6R1P5"},
"Pulse-A-135": { "SID": "MUY6R1P5"},
"Pulse-A-136": { "SID": "MUY6R1P5"},
"Pulse-A-226": { "SID": "MUY6R1P5"},
"Pulse-A-324": { "SID": "MUY6R1P5"},
"Pulse-A-325": { "SID": "MUY6R1P5"},
"Pulse-A-335": { "SID": "MUY6R1P5"},
"Pulse-A-336": { "SID": "MUY6R1P5"},
"Pulse-A-424": { "SID": "MUY6R1P5"},
"Pulse-A-434": { "SID": "MUY6R1P5"},
"Pulse-A-435": { "SID": "MUY6R1P5"},
"Pulse-A-524": { "SID": "MUY6R1P5"},
"Pulse-A-525": { "SID": "MUY6R1P5"},
"Pulse-A-534": { "SID": "MUY6R1P5"},
"Pulse-A-535": { "SID": "MUY6R1P5"},
"Pulse-A-724": { "SID": "MUY6R1P5"},
"Pulse-A-725": { "SID": "MUY6R1P5"},
"Pulse-A-734": { "SID": "MUY6R1P5"},
"Pulse-A-735": { "SID": "MUY6R1P5"},
"Pulse-A-736": { "SID": "MUY6R1P5"},
"Pulse-A-745": { "SID": "MUY6R1P5"},
"Pulse-B-111": { "SID": "MUY6R1P5"},
"Pulse-B-112": { "SID": "MUY6R1P5"},
"Pulse-B-121": { "SID": "MUY6R1P5"},
"Pulse-B-122": { "SID": "MUY6R1P5"},
"Pulse-B-123": { "SID": "MUY6R1P5"},
"Pulse-C-111": { "SID": "MUY6R1P5"},
"Pulse-C-112": { "SID": "MUY6R1P5"},
"Pulse-C-113": { "SID": "MUY6R1P5"},
"Pulse-C-121": { "SID": "MUY6R1P5"},
"Pulse-C-122": { "SID": "MUY6R1P5"},
"Pulse-C-123": { "SID": "MUY6R1P5"},
"Pulse-C-131": { "SID": "MUY6R1P5"},
"Pulse-C-132": { "SID": "MUY6R1P5"},
"Pulse-C-133": { "SID": "MUY6R1P5"},
"Pulse-C-221": { "SID": "MUY6R1P5"},
"Pulse-C-222": { "SID": "MUY6R1P5"},
"Pulse-C-231": { "SID": "MUY6R1P5"},
"Pulse-C-232 (XE)": { "SID": "MFG0HF92"},
"Pulse-C-232": { "SID": "MUY6R1P5"},
"Pulse-C-233": { "SID": "MUY6R1P5"},
"Pulse-D-132": { "SID": "MUY6R1P5"},
"Pulse-D-232": { "SID": "MUY6R1P5"},
"ROBO 3D-R1 & R1 +Plus": { "SID": "MJ112NE5"},
"SeeMeCNC-Artemis": { "SID": "MRGNCQVK"},
"SeeMeCNC-Eris": { "SID": "MHR7VPJU"},
"SeeMeCNC-H2": { "AltInfoUrl": "https://www.matterhackers.com/store/c/SeeMeCNC"},
"SeeMeCNC-Orion": { "SID": "MWD4YGWM"},
"SeeMeCNC-Rostock MAX v2": { "AltInfoUrl": "https://www.matterhackers.com/store/c/SeeMeCNC"},
"SeeMeCNC-Rostock MAX v3": { "SID": "MGFTLKAA"},
"SeeMeCNC-Rostock MAX": { "AltInfoUrl": "https://www.matterhackers.com/store/c/SeeMeCNC"},
"Ultimaker-2 Extended+": { "SID": "M0T2WS4H"},
"Ultimaker-2 Extended": { "SID": "M0T2WS4H"},
"Ultimaker-2+": { "SID": "ME7R89S4"},
"Ultimaker-2": { "SID": "ME7R89S4"},
"Ultimaker-Original+": { "SID": "MZZKP1YY"}
}