public void LoadSlicePresets(string make, string model, string tag) { foreach (string filePath in GetSlicePresets(make, model, tag)) { Dictionary <string, string> settingsDict = LoadSliceSettingsFromFile(filePath); if (settingsDict.Count > 0) { SliceSettingsCollection collection = new SliceSettingsCollection(); collection.Name = Path.GetFileNameWithoutExtension(filePath); collection.PrinterId = ActivePrinter.Id; collection.Tag = tag; collection.Commit(); if (tag == "material" && defaultMaterialPreset != null && collection.Name == defaultMaterialPreset) { ActivePrinter.MaterialCollectionIds = collection.Id.ToString(); ActivePrinter.Commit(); } else if (tag == "quality" && defaultQualityPreset != null && collection.Name == defaultQualityPreset) { ActivePrinter.QualityCollectionId = collection.Id; ActivePrinter.Commit(); } CommitSliceSettings(settingsDict, collection.Id); } } }
private void onPresetLoad(OpenFileDialogParams openParams) { if (openParams.FileNames != null) { SliceSettingsCollection settingsCollection; try { if (File.Exists(openParams.FileName)) { //Create collection to hold preset settings settingsCollection = new SliceSettingsCollection(); settingsCollection.Tag = windowController.filterTag; settingsCollection.PrinterId = ActivePrinterProfile.Instance.ActivePrinter.Id; settingsCollection.Name = System.IO.Path.GetFileNameWithoutExtension(openParams.FileName); settingsCollection.Commit(); string[] lines = System.IO.File.ReadAllLines(openParams.FileName); foreach (string line in lines) { //Ignore commented lines if (!line.StartsWith("#")) { string[] settingLine = line.Split('='); string keyName = settingLine[0].Trim(); string settingDefaultValue = settingLine[1].Trim(); //To do - validate imported settings as valid (KP) SliceSetting sliceSetting = new SliceSetting(); sliceSetting.Name = keyName; sliceSetting.Value = settingDefaultValue; sliceSetting.SettingsCollectionId = settingsCollection.Id; sliceSetting.Commit(); } } windowController.ChangeToSlicePresetList(); } } catch (Exception) { // Error loading configuration } } }
public static PrinterSettingsLayer LoadOemLayer(Printer printer) { SliceSettingsCollection collection; if (printer.DefaultSettingsCollectionId != 0) { int activePrinterSettingsID = printer.DefaultSettingsCollectionId; collection = Datastore.Instance.dbSQLite.Table <SliceSettingsCollection>().Where(v => v.Id == activePrinterSettingsID).Take(1).FirstOrDefault(); } else { collection = new SliceSettingsCollection(); collection.Name = printer.Name; collection.Commit(); printer.DefaultSettingsCollectionId = collection.Id; } return(new PrinterSettingsLayer(LoadSettings(collection))); }
/// <summary> /// Loads a SliceSettingsCollection from StaticData PrinterSettings /// </summary> /// <param name="make">The make to load</param> /// <param name="model">The model to load</param> public SliceSettingsCollection LoadSettingsFromConfigFile(string make, string model) { Dictionary <string, string> settingsDict = LoadSliceSettingsFromFile(Path.Combine("PrinterSettings", make, model, "config.ini")); if (settingsDict.Count > 0) { SliceSettingsCollection collection = new SliceSettingsCollection(); collection.Name = this.ActivePrinter.Name; collection.Commit(); this.ActivePrinter.DefaultSettingsCollectionId = collection.Id; CommitSliceSettings(settingsDict, collection.Id); return(collection); } // Return null if the loaded settings dictionary was empty return(null); }
public void LoadPrinterConfigurationSettings() { if (ActivePrinterProfile.Instance.ActivePrinter != null) { SliceSettingsCollection collection; if (ActivePrinterProfile.Instance.ActivePrinter.DefaultSettingsCollectionId != 0) { int activePrinterSettingsID = ActivePrinterProfile.Instance.ActivePrinter.DefaultSettingsCollectionId; collection = Datastore.Instance.dbSQLite.Table <SliceSettingsCollection>().Where(v => v.Id == activePrinterSettingsID).Take(1).FirstOrDefault(); } else { collection = new SliceSettingsCollection(); collection.Name = ActivePrinterProfile.Instance.ActivePrinter.Name; collection.Commit(); ActivePrinterProfile.Instance.ActivePrinter.DefaultSettingsCollectionId = collection.Id; ActivePrinterProfile.Instance.ActivePrinter.Commit(); } SettingsLayer printerSettingsLayer = LoadConfigurationSettingsFromDatastore(collection); this.activeSettingsLayers.Add(printerSettingsLayer); } }