public string ExtruderTemperature(int extruderIndex) { if (extruderIndex >= layeredProfile.MaterialSettingsKeys.Count) { // MaterialSettingsKeys is empty or lacks a value for the given extruder index // // If extruder index zero was requested, return the layer cascade temperature value, otherwise null return((extruderIndex == 0) ? layeredProfile.GetValue("temperature") : null); } string materialKey = layeredProfile.MaterialSettingsKeys[extruderIndex]; if (extruderIndex == 0 && (string.IsNullOrEmpty(materialKey) || layeredProfile.UserLayer.ContainsKey("temperature"))) { // In the case where a user override exists or MaterialSettingsKeys is populated with multiple extruder // positions but position 0 is empty and thus unassigned, use layer cascade to resolve temp return(layeredProfile.GetValue("temperature")); } // Otherwise, use the SettingsLayers that is bound to this extruder SettingsLayer layer = layeredProfile.GetMaterialLayer(materialKey); string result = "0"; layer?.TryGetValue("temperature", out result); return(result); }
public void SaveValue(string keyName, string keyValue, int layerIndex = 1) { SettingsLayer layer = this.activeSettingsLayers[layerIndex]; if (layer.settingsDictionary.ContainsKey(keyName) && layer.settingsDictionary[keyName].Value != keyValue) { layer.settingsDictionary[keyName].Value = keyValue; OnSettingsChanged(); HasUncommittedChanges = true; } else { DataStorage.SliceSetting sliceSetting = new DataStorage.SliceSetting(); sliceSetting.Name = keyName; sliceSetting.Value = keyValue; sliceSetting.SettingsCollectionId = layer.settingsCollectionData.Id; layer.settingsDictionary[keyName] = sliceSetting; OnSettingsChanged(); HasUncommittedChanges = true; } }
private void LoadDefaultConfigrationSettings() { DataStorage.SliceSettingsCollection defaultCollection = new DataStorage.SliceSettingsCollection(); defaultCollection.Name = "__default__"; SettingsLayer defaultSettingsLayer = LoadConfigurationSettingsFromFile(Path.Combine("PrinterSettings", "config.ini"), defaultCollection); this.activeSettingsLayers.Add(defaultSettingsLayer); }
public void CommitLayerChanges(int layerIndex) { SettingsLayer layer = this.activeSettingsLayers[layerIndex]; foreach (KeyValuePair <String, DataStorage.SliceSetting> item in layer.settingsDictionary) { item.Value.Commit(); } }
internal void ClearValue(string sliceSetting, SettingsLayer layer) { if (layer.ContainsKey(sliceSetting)) { layer.Remove(sliceSetting); } // TODO: Reconsider this frequency Save(); }
private void LoadDefaultConfigrationSettings() { string slic3rDefaultConfigurationPathAndFile = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "PrinterSettings", "config.ini"); DataStorage.SliceSettingsCollection defaultCollection = new DataStorage.SliceSettingsCollection(); defaultCollection.Name = "__default__"; SettingsLayer defaultSettingsLayer = LoadConfigurationSettingsFromFile(slic3rDefaultConfigurationPathAndFile, defaultCollection); this.activeSettingsLayers.Add(defaultSettingsLayer); }
internal SettingsLayer GetQualityLayer(string key) { // Find the first matching layer in either the user or the OEM layers SettingsLayer layer = null; if (key != null && !QualityLayers.TryGetValue(key, out layer)) { OemProfile.QualityLayers.TryGetValue(key, out layer); } return(layer); }
public void ChangeToSlicePresetDetail(SliceSettingsCollection collection = null) { if (collection != null) { Dictionary <string, DataStorage.SliceSetting> settingsDictionary = new Dictionary <string, DataStorage.SliceSetting>(); IEnumerable <DataStorage.SliceSetting> settingsList = GetCollectionSettings(collection.Id); foreach (DataStorage.SliceSetting s in settingsList) { settingsDictionary[s.Name] = s; } this.ActivePresetLayer = new SettingsLayer(collection, settingsDictionary); } UiThread.RunOnIdle(DoChangeToSlicePresetDetail); }
public void ChangeToSlicePresetDetail(SliceSettingsCollection collection = null) { if (collection != null) { Dictionary <string, SliceSetting> settingsDictionary = new Dictionary <string, SliceSetting>(); foreach (SliceSetting s in GetCollectionSettings(collection.Id)) { settingsDictionary[s.Name] = s; } this.ActivePresetLayer = new SettingsLayer(collection, settingsDictionary); } UiThread.RunOnIdle(DoChangeToSlicePresetDetail); }
private SettingsLayer LoadConfigurationSettingsFromDatastore(DataStorage.SliceSettingsCollection collection) { Dictionary <string, DataStorage.SliceSetting> settingsDictionary = new Dictionary <string, DataStorage.SliceSetting>(); IEnumerable <DataStorage.SliceSetting> settingsList = GetCollectionSettings(collection.Id); foreach (DataStorage.SliceSetting s in settingsList) { settingsDictionary[s.Name] = s; } SettingsLayer settingsLayer = new SettingsLayer(collection, settingsDictionary); return(settingsLayer); }
private GuiWidget CreateSliceSettingsWidget(SettingsLayer persistenceLayer) { var layerCascade = new List <SettingsLayer> { persistenceLayer, ActiveSliceSettings.Instance.OemLayer, ActiveSliceSettings.Instance.BaseLayer }; var settingsWidget = new SliceSettingsWidget(layerCascade, presetsContext.LayerType); settingsWidget.settingsControlBar.Visible = false; return(settingsWidget); }
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 SettingsLayer GetMaterialLayer(string key) { if (string.IsNullOrEmpty(key)) { return(null); } // Find the first matching layer in either the user or the OEM layers SettingsLayer layer = null; if (!MaterialLayers.TryGetValue(key, out layer)) { OemProfile.MaterialLayers.TryGetValue(key, out layer); } return(layer); }
public static SettingsLayer LoadFromIni(TextReader reader) { var layer = new SettingsLayer(); string line; while ((line = reader.ReadLine()) != null) { var segments = line.Split('='); if (!line.StartsWith("#") && !string.IsNullOrEmpty(line)) { string key = segments[0].Trim(); layer[key] = segments[1].Trim(); } } return(layer); }
public void LoadSettingsForMaterial(int extruderNumber1Based) { if (ActivePrinterProfile.Instance.ActivePrinter != null) { SettingsLayer printerSettingsLayer; SliceSettingsCollection collection; if (ActivePrinterProfile.Instance.GetMaterialSetting(extruderNumber1Based) != 0) { int materialOneSettingsID = ActivePrinterProfile.Instance.GetMaterialSetting(extruderNumber1Based); collection = Datastore.Instance.dbSQLite.Table <SliceSettingsCollection>().Where(v => v.Id == materialOneSettingsID).Take(1).FirstOrDefault(); printerSettingsLayer = LoadConfigurationSettingsFromDatastore(collection); } else { printerSettingsLayer = new SettingsLayer(new SliceSettingsCollection(), new Dictionary <string, SliceSetting>()); } this.activeSettingsLayers.Add(printerSettingsLayer); } }
public void LoadSettingsForQuality() { if (ActivePrinterProfile.Instance.ActivePrinter != null) { SettingsLayer printerSettingsLayer; DataStorage.SliceSettingsCollection collection; if (ActivePrinterProfile.Instance.ActiveQualitySettingsID != 0) { int materialOneSettingsID = ActivePrinterProfile.Instance.ActiveQualitySettingsID; collection = DataStorage.Datastore.Instance.dbSQLite.Table <DataStorage.SliceSettingsCollection>().Where(v => v.Id == materialOneSettingsID).Take(1).FirstOrDefault(); printerSettingsLayer = LoadConfigurationSettingsFromDatastore(collection); } else { printerSettingsLayer = new SettingsLayer(new SliceSettingsCollection(), new Dictionary <string, SliceSetting>()); } this.activeSettingsLayers.Add(printerSettingsLayer); } }
public static SettingsLayer LoadFromIni(string filePath) { var settings = from line in File.ReadAllLines(filePath) let segments = line.Split('=') where !line.StartsWith("#") && !string.IsNullOrEmpty(line) select new { Key = segments[0].Trim(), Value = segments[1].Trim() }; var layer = new SettingsLayer(); foreach (var setting in settings) { layer[setting.Key] = setting.Value; } return(layer); }
void duplicatePresets_Click(object sender, MouseEventArgs mouseEvent) { UiThread.RunOnIdle((state) => { DataStorage.SliceSettingsCollection duplicateCollection = new SliceSettingsCollection(); duplicateCollection.Name = string.Format("{0} (copy)".FormatWith(windowController.ActivePresetLayer.settingsCollectionData.Name)); duplicateCollection.Tag = windowController.ActivePresetLayer.settingsCollectionData.Tag; duplicateCollection.PrinterId = windowController.ActivePresetLayer.settingsCollectionData.PrinterId; Dictionary <string, DataStorage.SliceSetting> settingsDictionary = new Dictionary <string, DataStorage.SliceSetting>(); IEnumerable <DataStorage.SliceSetting> settingsList = this.windowController.GetCollectionSettings(windowController.ActivePresetLayer.settingsCollectionData.Id); foreach (DataStorage.SliceSetting s in settingsList) { settingsDictionary[s.Name] = s; } SettingsLayer duplicateLayer = new SettingsLayer(duplicateCollection, settingsDictionary); windowController.ActivePresetLayer = duplicateLayer; windowController.ChangeToSlicePresetDetail(); }); }
private static SettingsLayer LoadMatterHackersBaseLayer() { string baseConfigPath = Path.Combine(profilesPath, "config.json"); if (!File.Exists(baseConfigPath)) { string configIniPath = Path.Combine("PrinterSettings", "config.ini"); SettingsLayer baseLayer; using (var sourceStream = StaticData.Instance.OpenSteam(configIniPath)) using (var reader = new StreamReader(sourceStream)) { baseLayer = SettingsLayer.LoadFromIni(reader); } File.WriteAllText(baseConfigPath, JsonConvert.SerializeObject(baseLayer)); return(baseLayer); } return(JsonConvert.DeserializeObject <SettingsLayer>(File.ReadAllText(baseConfigPath))); }
public SettingsLayer LoadConfigurationSettingsFromFile(string pathAndFileName, DataStorage.SliceSettingsCollection collection) { Dictionary <string, DataStorage.SliceSetting> settingsDictionary = new Dictionary <string, DataStorage.SliceSetting>(); SettingsLayer activeCollection; try { if (StaticData.Instance.FileExists(pathAndFileName)) { foreach (string line in StaticData.Instance.ReadAllLines(pathAndFileName)) { //Ignore commented lines if (!line.StartsWith("#")) { string[] settingLine = line.Split('='); string keyName = settingLine[0].Trim(); string settingDefaultValue = settingLine[1].Trim(); DataStorage.SliceSetting sliceSetting = new DataStorage.SliceSetting(); sliceSetting.Name = keyName; sliceSetting.Value = settingDefaultValue; settingsDictionary.Add(keyName, sliceSetting); } } activeCollection = new SettingsLayer(collection, settingsDictionary); return(activeCollection); } return(null); } catch (Exception e) { Debug.Print(e.Message); GuiWidget.BreakInDebugger(); Debug.WriteLine(string.Format("Error loading configuration: {0}", e)); return(null); } }
public void LoadPrinterConfigurationSettings() { if (ActivePrinterProfile.Instance.ActivePrinter != null) { DataStorage.SliceSettingsCollection collection; if (ActivePrinterProfile.Instance.ActivePrinter.DefaultSettingsCollectionId != 0) { int activePrinterSettingsID = ActivePrinterProfile.Instance.ActivePrinter.DefaultSettingsCollectionId; collection = DataStorage.Datastore.Instance.dbSQLite.Table <DataStorage.SliceSettingsCollection>().Where(v => v.Id == activePrinterSettingsID).Take(1).FirstOrDefault(); } else { collection = new DataStorage.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); } }
public string GetMaterialValue(string sliceSetting, int extruderNumber1Based) { int numberOfActiveLayers = activeSettingsLayers.Count; string settingValue = null; if (ActivePrinterProfile.Instance.GetMaterialSetting(extruderNumber1Based) != 0) { int materialOneSettingsID = ActivePrinterProfile.Instance.GetMaterialSetting(extruderNumber1Based); DataStorage.SliceSettingsCollection collection = DataStorage.Datastore.Instance.dbSQLite.Table <DataStorage.SliceSettingsCollection>().Where(v => v.Id == materialOneSettingsID).Take(1).FirstOrDefault(); SettingsLayer printerSettingsLayer = LoadConfigurationSettingsFromDatastore(collection); if (printerSettingsLayer.settingsDictionary.ContainsKey(sliceSetting)) { settingValue = printerSettingsLayer.settingsDictionary[sliceSetting].Value; } } if (settingValue == null) { //Go through settings layers one-by-one, starting with quality (index = 2), in reverse order, until we find a layer that contains the value int startingLayer = Math.Min(numberOfActiveLayers - 1, 2); for (int i = startingLayer; i >= 0; i--) { if (activeSettingsLayers[i].settingsDictionary.ContainsKey(sliceSetting)) { settingValue = activeSettingsLayers[i].settingsDictionary[sliceSetting].Value; return(settingValue); } } } if (settingValue == null) { settingValue = "Unknown"; } return(settingValue); }
public void SetComPort(string port, SettingsLayer layer) { layeredProfile.SetActiveValue(string.Format("MatterControl.{0}.ComPort", Environment.MachineName), port, layer); }
public void ClearValue(string sliceSetting, SettingsLayer persistenceLayer) { layeredProfile.ClearValue(sliceSetting, persistenceLayer); }
public void LoadSettingsForQuality() { if (ActivePrinterProfile.Instance.ActivePrinter != null) { SettingsLayer printerSettingsLayer; DataStorage.SliceSettingsCollection collection; if (ActivePrinterProfile.Instance.ActiveQualitySettingsID != 0) { int materialOneSettingsID = ActivePrinterProfile.Instance.ActiveQualitySettingsID; collection = DataStorage.Datastore.Instance.dbSQLite.Table<DataStorage.SliceSettingsCollection>().Where(v => v.Id == materialOneSettingsID).Take(1).FirstOrDefault(); printerSettingsLayer = LoadConfigurationSettingsFromDatastore(collection); } else { printerSettingsLayer = new SettingsLayer(new SliceSettingsCollection(), new Dictionary<string, SliceSetting>()); } this.activeSettingsLayers.Add(printerSettingsLayer); } }
public void ChangeToSlicePresetDetail(SliceSettingsCollection collection = null) { if (collection != null) { Dictionary<string, DataStorage.SliceSetting> settingsDictionary = new Dictionary<string, DataStorage.SliceSetting>(); IEnumerable<DataStorage.SliceSetting> settingsList = GetCollectionSettings(collection.Id); foreach (DataStorage.SliceSetting s in settingsList) { settingsDictionary[s.Name] = s; } this.ActivePresetLayer = new SettingsLayer(collection, settingsDictionary); } UiThread.RunOnIdle(DoChangeToSlicePresetDetail); }
public SliceSettingsWidget(List<SettingsLayer> layerFilters = null, NamedSettingsLayers viewFilter = NamedSettingsLayers.All) { this.layerFilters = layerFilters; this.viewFilter = viewFilter; // The last layer of the layerFilters is the target persistence layer persistenceLayer = layerFilters?.Last() ?? ActiveSliceSettings.Instance.UserLayer; textImageButtonFactory = new TextImageButtonFactory(); textImageButtonFactory.normalFillColor = RGBA_Bytes.Transparent; textImageButtonFactory.FixedHeight = 15 * TextWidget.GlobalPointSizeScaleRatio; textImageButtonFactory.fontSize = 8; textImageButtonFactory.borderWidth = 1; textImageButtonFactory.normalBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200); textImageButtonFactory.hoverBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200); this.textImageButtonFactory.disabledTextColor = RGBA_Bytes.Gray; this.textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; this.textImageButtonFactory.normalTextColor = ActiveTheme.Instance.SecondaryTextColor; this.textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor; int minSettingNameWidth = (int)(180 * TextWidget.GlobalPointSizeScaleRatio + .5); buttonFactory.FixedHeight = 20 * TextWidget.GlobalPointSizeScaleRatio; buttonFactory.fontSize = 10; buttonFactory.normalFillColor = RGBA_Bytes.White; buttonFactory.normalTextColor = RGBA_Bytes.DarkGray; FlowLayoutWidget pageTopToBottomLayout = new FlowLayoutWidget(FlowDirection.TopToBottom, vAnchor: Agg.UI.VAnchor.ParentTop); pageTopToBottomLayout.AnchorAll(); pageTopToBottomLayout.Padding = new BorderDouble(3, 0); this.AddChild(pageTopToBottomLayout); settingsControlBar = new SettingsControlBar() { HAnchor = HAnchor.ParentLeftRight, BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay, Padding = new BorderDouble(8, 12, 8, 8) }; pageTopToBottomLayout.AddChild(settingsControlBar); noConnectionMessageContainer = new AltGroupBox(new TextWidget("No Printer Selected".Localize(), pointSize: 18, textColor: ActiveTheme.Instance.SecondaryAccentColor)); noConnectionMessageContainer.Margin = new BorderDouble(top: 10); noConnectionMessageContainer.BorderColor = ActiveTheme.Instance.PrimaryTextColor; noConnectionMessageContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; noConnectionMessageContainer.Height = 90; string noConnectionString = "No printer is currently selected. Please select a printer to edit slice settings.".Localize(); noConnectionString += "\n\n" + "NOTE: You need to select a printer, but do not need to connect to it.".Localize(); TextWidget noConnectionMessage = new TextWidget(noConnectionString, pointSize: 10); noConnectionMessage.Margin = new BorderDouble(5); noConnectionMessage.TextColor = ActiveTheme.Instance.PrimaryTextColor; noConnectionMessage.VAnchor = VAnchor.ParentCenter; noConnectionMessageContainer.AddChild(noConnectionMessage); pageTopToBottomLayout.AddChild(noConnectionMessageContainer); categoryTabs = new TabControl(); categoryTabs.TabBar.BorderColor = ActiveTheme.Instance.PrimaryTextColor; categoryTabs.Margin = new BorderDouble(top: 8); categoryTabs.AnchorAll(); sliceSettingsDetailControl = new SliceSettingsDetailControl(); List<TabBar> sideTabBarsListForLayout = new List<TabBar>(); for (int categoryIndex = 0; categoryIndex < SliceSettingsOrganizer.Instance.UserLevels[UserLevel].CategoriesList.Count; categoryIndex++) { OrganizerCategory category = SliceSettingsOrganizer.Instance.UserLevels[UserLevel].CategoriesList[categoryIndex]; string categoryPageLabel = category.Name.Localize(); TabPage categoryPage = new TabPage(categoryPageLabel); SimpleTextTabWidget textTabWidget = new SimpleTextTabWidget(categoryPage, category.Name + " Tab", 16, ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes()); categoryPage.AnchorAll(); categoryTabs.AddTab(textTabWidget); TabControl sideTabs = CreateSideTabsAndPages(minSettingNameWidth, category); sideTabBarsListForLayout.Add(sideTabs.TabBar); categoryPage.AddChild(sideTabs); } categoryTabs.TabBar.AddChild(new HorizontalSpacer()); categoryTabs.TabBar.AddChild(sliceSettingsDetailControl); if (sliceSettingsDetailControl.SelectedValue == "Advanced" && ActiveSliceSettings.Instance.ActiveSliceEngineType == SlicingEngineTypes.Slic3r) { TabPage extraSettingsPage = new TabPage("Other"); SimpleTextTabWidget extraSettingsTextTabWidget = new SimpleTextTabWidget(extraSettingsPage, "Other Tab", 16, ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes()); extraSettingsPage.AnchorAll(); int count; TabControl extraSettingsSideTabs = CreateExtraSettingsSideTabsAndPages(minSettingNameWidth, categoryTabs, out count); if (count > 0) { categoryTabs.AddTab(extraSettingsTextTabWidget); sideTabBarsListForLayout.Add(extraSettingsSideTabs.TabBar); extraSettingsPage.AddChild(extraSettingsSideTabs); } } double sideTabBarsMinimumWidth = 0; foreach (TabBar tabBar in sideTabBarsListForLayout) { sideTabBarsMinimumWidth = Math.Max(sideTabBarsMinimumWidth, tabBar.Width); } foreach (TabBar tabBar in sideTabBarsListForLayout) { tabBar.MinimumSize = new Vector2(sideTabBarsMinimumWidth, tabBar.MinimumSize.y); } if (sideTabBarsListForLayout.Count == 1) { sideTabBarsListForLayout[0].MinimumSize = new Vector2(0, 0); sideTabBarsListForLayout[0].Width = 0; } pageTopToBottomLayout.AddChild(categoryTabs); AddHandlers(); SetVisibleControls(); // Make sure we are on the right tab when we create this view { string settingsName = "SliceSettingsWidget_CurrentTab"; string selectedTab = UserSettings.Instance.get(settingsName); categoryTabs.SelectTab(selectedTab); categoryTabs.TabBar.TabIndexChanged += (object sender, EventArgs e) => { UserSettings.Instance.set(settingsName, categoryTabs.TabBar.SelectedTabName); }; } this.AnchorAll(); }
internal void ClearValue(string sliceSetting, SettingsLayer layer) { if(layer.ContainsKey(sliceSetting)) { layer.Remove(sliceSetting); } // TODO: Reconsider this frequency Save(); }
private void duplicatePresets_Click(object sender, EventArgs mouseEvent) { UiThread.RunOnIdle(() => { DataStorage.SliceSettingsCollection duplicateCollection = new SliceSettingsCollection(); duplicateCollection.Name = string.Format("{0} (copy)".FormatWith(windowController.ActivePresetLayer.settingsCollectionData.Name)); duplicateCollection.Tag = windowController.ActivePresetLayer.settingsCollectionData.Tag; duplicateCollection.PrinterId = windowController.ActivePresetLayer.settingsCollectionData.PrinterId; Dictionary<string, DataStorage.SliceSetting> settingsDictionary = new Dictionary<string, DataStorage.SliceSetting>(); IEnumerable<DataStorage.SliceSetting> settingsList = this.windowController.GetCollectionSettings(windowController.ActivePresetLayer.settingsCollectionData.Id); foreach (DataStorage.SliceSetting s in settingsList) { DataStorage.SliceSetting newSetting = new DataStorage.SliceSetting(); newSetting.Name = s.Name; newSetting.Value = s.Value; settingsDictionary.Add(s.Name, newSetting); } SettingsLayer duplicateLayer = new SettingsLayer(duplicateCollection, settingsDictionary); windowController.ActivePresetLayer = duplicateLayer; windowController.ChangeToSlicePresetDetail(); }); }
public void SetActiveValue(string sliceSetting, string sliceValue, SettingsLayer persistenceLayer) { layeredProfile.SetActiveValue(sliceSetting, sliceValue, persistenceLayer); }
public SettingsLayer LoadConfigurationSettingsFromFile(string pathAndFileName, DataStorage.SliceSettingsCollection collection) { Dictionary<string, DataStorage.SliceSetting> settingsDictionary = new Dictionary<string, DataStorage.SliceSetting>(); SettingsLayer activeCollection; try { if (StaticData.Instance.FileExists(pathAndFileName)) { foreach (string line in StaticData.Instance.ReadAllLines(pathAndFileName)) { //Ignore commented lines if (!line.StartsWith("#")) { string[] settingLine = line.Split('='); string keyName = settingLine[0].Trim(); string settingDefaultValue = settingLine[1].Trim(); DataStorage.SliceSetting sliceSetting = new DataStorage.SliceSetting(); sliceSetting.Name = keyName; sliceSetting.Value = settingDefaultValue; settingsDictionary.Add(keyName, sliceSetting); } } activeCollection = new SettingsLayer(collection, settingsDictionary); return activeCollection; } return null; } catch (Exception e) { Debug.WriteLine(string.Format("Error loading configuration: {0}", e)); return null; } }
private SettingsLayer LoadConfigurationSettingsFromDatastore(DataStorage.SliceSettingsCollection collection) { Dictionary<string, DataStorage.SliceSetting> settingsDictionary = new Dictionary<string, DataStorage.SliceSetting>(); IEnumerable<DataStorage.SliceSetting> settingsList = GetCollectionSettings(collection.Id); foreach (DataStorage.SliceSetting s in settingsList) { settingsDictionary[s.Name] = s; } SettingsLayer settingsLayer = new SettingsLayer(collection, settingsDictionary); return settingsLayer; }
public LayeredProfile(OemProfile printerProfile, SettingsLayer baseConfig) { this.OemProfile = printerProfile; this.BaseLayer = baseConfig; }
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 OemProfile(Dictionary <string, string> settingsDictionary) { OemLayer = new SettingsLayer(settingsDictionary); }
public OemProfile(Dictionary<string, string> settingsDictionary) { OemLayer = new SettingsLayer(settingsDictionary); }
internal void SetActiveValue(string sliceSetting, string sliceValue, SettingsLayer layer) { layer[sliceSetting] = sliceValue; Save(); }
internal void OnDeserializedMethod(StreamingContext context) { QualityLayer = GetQualityLayer(ActiveQualityKey); MaterialLayer = GetMaterialLayer(ActiveMaterialKey); ; }
public void ChangeToSlicePresetList() { this.ActivePresetLayer = null; UiThread.RunOnIdle(DoChangeToSlicePresetList); }
private StyledDropDownList CreateDropdown() { var dropDownList = new StyledDropDownList("- default -", maxHeight: 300, useLeftIcons: true) { HAnchor = HAnchor.ParentLeftRight, MenuItemsPadding = new BorderDouble(10, 4, 10, 6), }; dropDownList.Margin = new BorderDouble(0, 3); dropDownList.MinimumSize = new Vector2(dropDownList.LocalBounds.Width, dropDownList.LocalBounds.Height); MenuItem defaultMenuItem = dropDownList.AddItem("- default -", ""); defaultMenuItem.Selected += MenuItem_Selected; var listSource = (layerType == NamedSettingsLayers.Material) ? ActiveSliceSettings.Instance.MaterialLayers : ActiveSliceSettings.Instance.QualityLayers; foreach (var layer in listSource) { if (string.IsNullOrEmpty(layer.Value.Name)) { layer.Value.Name = layer.Key; } MenuItem menuItem = dropDownList.AddItem(layer.Value.Name, layer.Value.ID); menuItem.Selected += MenuItem_Selected; } MenuItem addNewPreset = dropDownList.AddItem(StaticData.Instance.LoadIcon("icon_plus.png", 32, 32), "Add New Setting...", "new"); addNewPreset.Selected += (s, e) => { var newLayer = new SettingsLayer(); if (layerType == NamedSettingsLayers.Quality) { newLayer.Name = "Quality" + ActiveSliceSettings.Instance.QualityLayers.Count; ActiveSliceSettings.Instance.QualityLayers[newLayer.Name] = newLayer; ActiveSliceSettings.Instance.ActiveQualityKey = newLayer.ID; } else { newLayer.Name = "Material" + ActiveSliceSettings.Instance.MaterialLayers.Count; ActiveSliceSettings.Instance.MaterialLayers[newLayer.Name] = newLayer; ActiveSliceSettings.Instance.ActiveMaterialKey = newLayer.ID; ActiveSliceSettings.Instance.SetMaterialPreset(this.extruderIndex, newLayer.Name); } // TODO: Consider adding a .Replace(existingWidget, newWidget) to GuiWidget // Replace existing list with updated list var parent = this.dropDownList.Parent; parent.RemoveChild(this.dropDownList); this.dropDownList.Close(); this.dropDownList = CreateDropdown(); parent.AddChild(this.dropDownList); editButton.ClickButton(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); }; try { string settingsKey; if (layerType == NamedSettingsLayers.Material) { settingsKey = ActiveSliceSettings.Instance.MaterialPresetKey(extruderIndex); } else { settingsKey = ActiveSliceSettings.Instance.ActiveQualityKey; } if (!string.IsNullOrEmpty(settingsKey)) { dropDownList.SelectedValue = settingsKey; } } catch (Exception ex) { GuiWidget.BreakInDebugger(ex.Message); } return(dropDownList); }