private void UpdateRightPanel(MaterialSummary selectedMaterial) { var materialEditor = this.newGUIContentSplitContainerBase1.RightPanel.Controls[0] as MaterialValueEditor; materialEditor.Supplier = selectedMaterial.Supplier; materialEditor.Material = selectedMaterial.Material; }
public void LoadMaterials(Material selectedMaterial = null) { this.newGUIContentSplitContainerBase1.RightPanel.Controls.Clear(); this.newGUIContentSplitContainerBase1.LeftPanel.Controls.Clear(); var materialValueEditor = new MaterialValueEditor(); materialValueEditor.Dock = DockStyle.Fill; materialValueEditor.onTextChanged += MaterialValueEditor_onTextChanged; this.newGUIContentSplitContainerBase1.RightPanel.Controls.Add(materialValueEditor); var summaryHeight = 0; var firstMaterial = true; MaterialSummary selectedMaterialSummary = null; var selectedPrinter = PrintJobManager.SelectedPrinter; var orderedBindingList = new List <MaterialsBySupplier>(); foreach (var materialSupplier in MaterialManager.Catalog) { foreach (var material in materialSupplier.GetMaterialsByResolution(selectedPrinter)) { orderedBindingList.Add(material); } } var orderedList = orderedBindingList.OrderBy(s => s.Materials[0].DisplayName).ToList(); foreach (var material in orderedList) { MaterialSummary materialSummary = PushMaterialInControl(summaryHeight, material.Supplier, material.Materials[0]); materialSummary.Width = this.newGUIContentSplitContainerBase1.splitContainer1.SplitterDistance; if (selectedMaterial != null && selectedMaterial.Id == material.Materials[0].Id) { selectedMaterialSummary = materialSummary; } if (firstMaterial) { materialSummary.Selected = true; firstMaterial = false; this.UpdateRightPanel(materialSummary); } summaryHeight += defaultSummaryHeight; } if (selectedMaterial != null) { this.MaterialSummary_onSelected(selectedMaterialSummary, null); } }
private MaterialSummary PushMaterialInControl(int summaryHeight, string supplier, Material material) { if (material.Id == null || material.Id == Guid.Empty) { material.Id = Guid.NewGuid(); } var materialSummary = new MaterialSummary(); materialSummary.Id = material.Id; materialSummary.onSelected += MaterialSummary_onSelected; materialSummary.Material = material; materialSummary.Supplier = supplier; materialSummary.Left = 0; materialSummary.Top = summaryHeight; materialSummary.UpdateControl(); this.newGUIContentSplitContainerBase1.LeftPanel.Controls.Add(materialSummary); return(materialSummary); }