internal static void ImportFromExisting(string settingsFilePath) { if (string.IsNullOrEmpty(settingsFilePath) || !File.Exists(settingsFilePath)) { return; } var printerIdentifier = new PrinterInfo { Name = Path.GetFileNameWithoutExtension(settingsFilePath), Id = Guid.NewGuid().ToString() }; string importType = Path.GetExtension(settingsFilePath).ToLower(); switch (importType) { case ".printer": var profile = LoadProfileFromDisk(settingsFilePath); profile.ID = Guid.NewGuid().ToString(); break; case ".ini": var settingsToImport = SettingsLayer.LoadFromIni(settingsFilePath); var oemProfile = new OemProfile(settingsToImport); SettingsLayer baseConfig = SliceSettingsOrganizer.Instance.GetDefaultSettings(); var layeredProfile = new LayeredProfile(oemProfile, baseConfig) { ID = printerIdentifier.Id, DocumentPath = Path.Combine(profilesPath, printerIdentifier.Id + ".json") }; // TODO: Resolve name conflicts layeredProfile.UserLayer["MatterControl.PrinterName"] = printerIdentifier.Name; layeredProfile.Save(); break; } ProfileData.Profiles.Add(printerIdentifier); UserSettings.Instance.set("ActiveProfileID", printerIdentifier.Id); Instance = LoadProfile(printerIdentifier.Id); }
internal static void AcquireNewProfile(string make, string model, string printerName) { string guid = Guid.NewGuid().ToString(); OemProfile oemProfile = LoadHttpOemProfile(make, model); var layeredProfile = new PrinterSettings() { ID = guid, // TODO: This should really be set by the system that generates the source documents DocumentVersion = PrinterSettings.LatestVersion, OemLayer = oemProfile.OemLayer }; layeredProfile.UserLayer[SettingsKey.printer_name.ToString()] = printerName; // Import named macros as defined in the following printers: (Airwolf Axiom, HD, HD-R, HD2x, HDL, HDx, Me3D Me2, Robo R1[+]) var classicDefaultMacros = layeredProfile.GetValue("default_macros"); if (!string.IsNullOrEmpty(classicDefaultMacros)) { var namedMacros = new Dictionary <string, string>(); namedMacros["Lights On"] = "M42 P6 S255"; namedMacros["Lights Off"] = "M42 P6 S0"; namedMacros["Offset 0.8"] = "M565 Z0.8;\nM500"; namedMacros["Offset 0.9"] = "M565 Z0.9;\nM500"; namedMacros["Offset 1"] = "M565 Z1;\nM500"; namedMacros["Offset 1.1"] = "M565 Z1.1;\nM500"; namedMacros["Offset 1.2"] = "M565 Z1.2;\nM500"; namedMacros["Z Offset"] = "G1 Z10;\nG28;\nG29;\nG1 Z10;\nG1 X5 Y5 F4000;\nM117;"; foreach (string namedMacro in classicDefaultMacros.Split(',')) { string gcode; if (namedMacros.TryGetValue(namedMacro.Trim(), out gcode)) { layeredProfile.Macros.Add(new GCodeMacro() { Name = namedMacro.Trim(), GCode = gcode }); } } } // Copy OemProfile presets into user layers foreach (var materialPreset in oemProfile.MaterialLayers) { layeredProfile.MaterialLayers.Add(materialPreset); } foreach (var qualityPreset in oemProfile.QualityLayers) { layeredProfile.QualityLayers.Add(qualityPreset); } layeredProfile.Save(); Instance.Profiles.Add(new PrinterInfo { Name = printerName, ID = guid }); UserSettings.Instance.set("ActiveProfileID", guid); ActiveSliceSettings.Instance = new SettingsProfile(layeredProfile); }
internal static void AcquireNewProfile(string make, string model, string printerName) { string guid = Guid.NewGuid().ToString(); OemProfile printerProfile = LoadHttpOemProfile(make, model); SettingsLayer baseConfig = SliceSettingsOrganizer.Instance.GetDefaultSettings(); var layeredProfile = new LayeredProfile(printerProfile, baseConfig) { ID = guid, DocumentPath = Path.Combine(profilesPath, guid + ".json") }; layeredProfile.UserLayer["MatterControl.PrinterName"] = printerName; // Import named macros as defined in the following printers: (Airwolf Axiom, HD, HD-R, HD2x, HDL, HDx, Me3D Me2, Robo R1[+]) var classicDefaultMacros = layeredProfile.GetValue("default_macros"); if (!string.IsNullOrEmpty(classicDefaultMacros)) { var namedMacros = new Dictionary <string, string>(); namedMacros["Lights On"] = "M42 P6 S255"; namedMacros["Lights Off"] = "M42 P6 S0"; namedMacros["Offset 0.8"] = "M565 Z0.8;\nM500"; namedMacros["Offset 0.9"] = "M565 Z0.9;\nM500"; namedMacros["Offset 1"] = "M565 Z1;\nM500"; namedMacros["Offset 1.1"] = "M565 Z1.1;\nM500"; namedMacros["Offset 1.2"] = "M565 Z1.2;\nM500"; namedMacros["Z Offset"] = "G1 Z10;\nG28;\nG29;\nG1 Z10;\nG1 X5 Y5 F4000;\nM117;"; foreach (string namedMacro in classicDefaultMacros.Split(',')) { string gcode; if (namedMacros.TryGetValue(namedMacro.Trim(), out gcode)) { layeredProfile.Macros.Add(new GCodeMacro() { Name = namedMacro.Trim(), GCode = gcode }); } } } // Copy OemProfile presets into user layers layeredProfile.MaterialLayers.AddRange(layeredProfile.OemProfile.MaterialLayers); layeredProfile.QualityLayers.AddRange(layeredProfile.OemProfile.QualityLayers); layeredProfile.OemProfile.MaterialLayers.Clear(); layeredProfile.OemProfile.QualityLayers.Clear(); layeredProfile.Save(); ProfileData.Profiles.Add(new PrinterInfo { Name = printerName, Id = guid }); UserSettings.Instance.set("ActiveProfileID", guid); Instance = new SettingsProfile(layeredProfile); }
public LayeredProfile(OemProfile printerProfile, SettingsLayer baseConfig) { this.OemProfile = printerProfile; this.BaseLayer = baseConfig; }