static private SliceEngineInfo getSliceEngineInfoByType(ActivePrinterProfile.SlicingEngineTypes engineType) { foreach (SliceEngineInfo info in AvailableSliceEngines) { if (info.GetSliceEngineType() == engineType) { return(info); } } return(null); }
public SliceEngineSelector(string label) : base(label) { HAnchor = HAnchor.ParentLeftRight; //Add Each SliceEngineInfo Objects to DropMenu foreach (SliceEngineInfo engineMenuItem in SlicingQueue.AvailableSliceEngines) { bool engineAllowed = true; if (ActiveSliceSettings.Instance.ExtruderCount > 1 && engineMenuItem.Name != "MatterSlice") { engineAllowed = false; } if (engineAllowed) { MenuItem item = AddItem(engineMenuItem.Name); ActivePrinterProfile.SlicingEngineTypes itemEngineType = engineMenuItem.GetSliceEngineType(); item.Selected += (sender, e) => { if (ActivePrinterProfile.Instance.ActiveSliceEngineType != itemEngineType) { ActivePrinterProfile.Instance.ActiveSliceEngineType = itemEngineType; ApplicationController.Instance.ReloadAdvancedControlsPanel(); } }; //Set item as selected if it matches the active slice engine if (engineMenuItem.GetSliceEngineType() == ActivePrinterProfile.Instance.ActiveSliceEngineType) { SelectedLabel = engineMenuItem.Name; } } } //If nothing is selected (ie selected engine is not available) set to if (SelectedLabel == "") { try { SelectedLabel = MatterSliceInfo.DisplayName; } catch (Exception e) { Debug.Print(e.Message); GuiWidget.BreakInDebugger(); throw new Exception("MatterSlice is not available, for some strange reason"); } } MinimumSize = new Vector2(LocalBounds.Width, LocalBounds.Height); }
AnchoredDropDownList CreateSliceEngineDropdown() { AnchoredDropDownList engineMenuDropList = new AnchoredDropDownList("Engine "); engineMenuDropList.Margin = new BorderDouble(0, 3); { //Add Each SliceEngineInfo Objects to DropMenu foreach (SliceEngineInfo engineMenuItem in SlicingQueue.AvailableSliceEngines) { MenuItem item = engineMenuDropList.AddItem(engineMenuItem.Name); ActivePrinterProfile.SlicingEngineTypes itemEngineType = engineMenuItem.GetSliceEngineType(); item.Selected += (sender, e) => { ActivePrinterProfile.Instance.ActiveSliceEngineType = itemEngineType; ApplicationController.Instance.ReloadAdvancedControlsPanel(); }; //Set item as selected if it matches the active slice engine if (engineMenuItem.GetSliceEngineType() == ActivePrinterProfile.Instance.ActiveSliceEngineType) { engineMenuDropList.SelectedLabel = engineMenuItem.Name; } } //If nothing is selected (ie selected engine is not available) set to if (engineMenuDropList.SelectedLabel == "") { try { engineMenuDropList.SelectedLabel = MatterSliceInfo.DisplayName; } catch { throw new Exception("MatterSlice is not available, for some strange reason"); } } } engineMenuDropList.MinimumSize = new Vector2(engineMenuDropList.LocalBounds.Width, engineMenuDropList.LocalBounds.Height); return(engineMenuDropList); }