private void FillGrid() { // fill grid solutions gridSolutions.Rows.Clear(); // border DevAge.Drawing.BorderLine border = new DevAge.Drawing.BorderLine(Color.DarkBlue, 1); DevAge.Drawing.RectangleBorder cellBorder = new DevAge.Drawing.RectangleBorder(border, border); // views CellBackColorAlternate viewNormal = new CellBackColorAlternate(Color.LightBlue, Color.White); viewNormal.Border = cellBorder; // column header view SourceGrid.Cells.Views.ColumnHeader viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader(); DevAge.Drawing.VisualElements.ColumnHeader backHeader = new DevAge.Drawing.VisualElements.ColumnHeader(); backHeader.BackColor = Color.LightGray; backHeader.Border = DevAge.Drawing.RectangleBorder.NoBorder; viewColumnHeader.Background = backHeader; viewColumnHeader.ForeColor = Color.White; viewColumnHeader.Font = new Font("Arial", 10, FontStyle.Bold); viewColumnHeader.ElementSort.SortStyle = DevAge.Drawing.HeaderSortStyle.None; // create the grid gridSolutions.BorderStyle = BorderStyle.FixedSingle; gridSolutions.ColumnsCount = 5; gridSolutions.FixedRows = 1; gridSolutions.Rows.Insert(0); // header SourceGrid.Cells.ColumnHeader columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_INDEX); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 0] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LAYERPATTERN); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 1] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_BUNDLECOUNT); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 2] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_VOLUMEEFFICIENCY); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 3] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_PALLETWEIGHT); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 4] = columnHeader; // data rows int iIndex = 0; foreach (CasePalletSolution sol in _analysis.Solutions) { // build case count string string sBoxCount = string.Empty; sBoxCount = string.Format("{0}\n({1} * {2})", sol.CaseCount, sol.CasePerLayerCount, sol.Count); // insert row gridSolutions.Rows.Insert(++iIndex); // filling columns gridSolutions[iIndex, 0] = new SourceGrid.Cells.Cell(string.Format("{0}", iIndex)); { Graphics2DImage graphics = new Graphics2DImage(new Size(80, 40)); CasePalletSolutionViewer sv = new CasePalletSolutionViewer(sol); sv.Draw(graphics); gridSolutions[iIndex, 1] = new SourceGrid.Cells.Image(graphics.Bitmap); } gridSolutions[iIndex, 2] = new SourceGrid.Cells.Cell(sBoxCount); gridSolutions[iIndex, 3] = new SourceGrid.Cells.Cell(string.Format("{0:F}", sol.VolumeEfficiencyCases)); gridSolutions[iIndex, 4] = new SourceGrid.Cells.Cell(string.Format("{0:F}", sol.PalletWeight)); gridSolutions[iIndex, 0].View = viewNormal; gridSolutions[iIndex, 1].View = viewNormal; gridSolutions[iIndex, 2].View = viewNormal; gridSolutions[iIndex, 3].View = viewNormal; gridSolutions[iIndex, 4].View = viewNormal; } gridSolutions.AutoStretchColumnsToFitWidth = true; gridSolutions.AutoSizeCells(); gridSolutions.Columns.StretchToFit(); // select first solution gridSolutions.Selection.SelectRow(1, true); // redraw graphCtrlSolution.Invalidate(); }
private void AppendSolutionElement(ReportData inputData, XmlElement elemPalletAnalysis, XmlDocument xmlDoc) { string ns = xmlDoc.DocumentElement.NamespaceURI; SelCasePalletSolution selSolution = inputData.SelSolution; CasePalletSolution sol = inputData.CasePalletSolution; // solution XmlElement elemSolution = xmlDoc.CreateElement("palletSolution", ns); elemPalletAnalysis.AppendChild(elemSolution); // title XmlElement elemTitle = xmlDoc.CreateElement("title", ns); elemTitle.InnerText = sol.Title; elemSolution.AppendChild(elemTitle); // homogeneousLayer XmlElement elemHomogeneousLayer = xmlDoc.CreateElement("homogeneousLayer", ns); elemHomogeneousLayer.InnerText = sol.HasHomogeneousLayers.ToString(); elemSolution.AppendChild(elemHomogeneousLayer); // efficiency XmlElement elemEfficiency = xmlDoc.CreateElement("efficiency", ns); elemEfficiency.InnerText = string.Format("{0:F}", sol.VolumeEfficiencyCases); elemSolution.AppendChild(elemEfficiency); AppendElementValue(xmlDoc, elemSolution, "palletWeight", UnitsManager.UnitType.UT_MASS, inputData.ActualPalletWeight); AppendElementValue(xmlDoc, elemSolution, "palletLength", UnitsManager.UnitType.UT_LENGTH, sol.PalletLength); AppendElementValue(xmlDoc, elemSolution, "palletWidth", UnitsManager.UnitType.UT_LENGTH, sol.PalletWidth); AppendElementValue(xmlDoc, elemSolution, "palletHeight", UnitsManager.UnitType.UT_LENGTH, sol.PalletHeight); // caseCount XmlElement elemCaseCount = xmlDoc.CreateElement("caseCount", ns); elemCaseCount.InnerText = string.Format("{0}", sol.CaseCount); elemSolution.AppendChild(elemCaseCount); // if case of boxes, add box count + box efficiency if (sol.Analysis.BProperties is CaseOfBoxesProperties) { CaseOfBoxesProperties caseOfBoxes = sol.Analysis.BProperties as CaseOfBoxesProperties; XmlElement elemBoxCount = xmlDoc.CreateElement("boxCount", ns); elemBoxCount.InnerText = string.Format("{0:F}", caseOfBoxes.NumberOfBoxes); elemSolution.AppendChild(elemBoxCount); XmlElement elemBoxEfficiency = xmlDoc.CreateElement("boxEfficiency", ns); elemBoxEfficiency.InnerText = string.Format("{0:F}", sol.VolumeEfficiencyCases); } // layerCount XmlElement elemLayerCount = xmlDoc.CreateElement("layerCount", ns); elemLayerCount.InnerText = string.Format("{0}", sol.CaseLayersCount); elemSolution.AppendChild(elemLayerCount); // layer1_caseCount / layer2_caseCount XmlElement elemLayer1_caseCount = xmlDoc.CreateElement("layer1_caseCount", ns); elemLayer1_caseCount.InnerText = string.Format("{0}", sol.CaseLayerFirst.BoxCount); elemSolution.AppendChild(elemLayer1_caseCount); if (sol.Count > 1 && (sol.CaseLayerFirst.BoxCount != sol.CaseLayerSecond.BoxCount)) { XmlElement elemLayer2_caseCount = xmlDoc.CreateElement("layer2_caseCount", ns); elemLayer2_caseCount.InnerText = string.Format("{0}", sol.CaseLayerSecond.BoxCount); elemSolution.AppendChild(elemLayer2_caseCount); } // interlayer count if (sol.Analysis.ConstraintSet.HasInterlayer) { XmlElement elemInterlayerCount = xmlDoc.CreateElement("interlayerCount", ns); elemInterlayerCount.InnerText = string.Format("{0}", sol.InterlayerCount); elemSolution.AppendChild(elemInterlayerCount); } // --- layer images for (int i = 0; i < Math.Min(sol.Count, (sol.HasHomogeneousLayers ? 1 : 2)); ++i) { XmlElement elemLayer = xmlDoc.CreateElement("layer", ns); // layerId XmlElement xmlLayerId = xmlDoc.CreateElement("layerId", ns); xmlLayerId.InnerText = string.Format("{0}", i + 1); elemLayer.AppendChild(xmlLayerId); // --- build layer image // instantiate graphics Graphics3DImage graphics = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail)); // set camera position graphics.CameraPosition = Graphics3D.Top; // instantiate solution viewer CasePalletSolutionViewer sv = new CasePalletSolutionViewer(sol); sv.DrawLayers(graphics, true, i /* layer index*/); // --- // layerImage XmlElement elemLayerImage = xmlDoc.CreateElement("layerImage", ns); TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap)); elemLayerImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[]))); XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style"); styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 2, graphics.Bitmap.Height / 2); elemLayerImage.Attributes.Append(styleAttribute); elemLayer.AppendChild(elemLayerImage); // layerCaseCount XmlElement elemLayerBoxCount = xmlDoc.CreateElement("layerCaseCount", ns); elemLayerBoxCount.InnerText = sol[i].BoxCount.ToString(); elemLayer.AppendChild(elemLayerBoxCount); elemSolution.AppendChild(elemLayer); // save image SaveImageAs(graphics.Bitmap, string.Format("layerImage{0}.png", i + 1)); } // --- pallet images for (int i = 0; i < 5; ++i) { // initialize drawing values string viewName = string.Empty; Vector3D cameraPos = Vector3D.Zero; int imageWidth = ImageSizeDetail; bool showDimensions = false; switch (i) { case 0: viewName = "view_palletsolution_front"; cameraPos = Graphics3D.Front; imageWidth = ImageSizeDetail; break; case 1: viewName = "view_palletsolution_left"; cameraPos = Graphics3D.Left; imageWidth = ImageSizeDetail; break; case 2: viewName = "view_palletsolution_right"; cameraPos = Graphics3D.Right; imageWidth = ImageSizeDetail; break; case 3: viewName = "view_palletsolution_back"; cameraPos = Graphics3D.Back; imageWidth = ImageSizeDetail; break; case 4: viewName = "view_palletsolution_iso"; cameraPos = Graphics3D.Corner_180; imageWidth = ImageSizeWide; showDimensions = true; break; default: break; } // instantiate graphics Graphics3DImage graphics = new Graphics3DImage(new Size(imageWidth, imageWidth)); // set camera position graphics.CameraPosition = cameraPos; // instantiate solution viewer CasePalletSolutionViewer sv = new CasePalletSolutionViewer(sol); sv.ShowDimensions = showDimensions; sv.Draw(graphics); graphics.Flush(); SaveImageAs(graphics.Bitmap, viewName + ".png"); // --- XmlElement elemImage = xmlDoc.CreateElement(viewName, ns); TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap)); elemImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[]))); XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style"); styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 3, graphics.Bitmap.Height / 3); elemImage.Attributes.Append(styleAttribute); elemSolution.AppendChild(elemImage); } }
public void Draw(Graphics3DControl ctrl, Graphics3D graphics) { if (ctrl == graphCtrlPallet) { PalletProperties pp = CurrentPallet; Pallet pallet = new Pallet(pp); pallet.Draw(graphics, Transform3D.Identity); DimensionCube dc = new DimensionCube(pp.Length, pp.Width, pp.Height) { FontSize = 6.0f }; graphics.AddDimensions(dc); } else if (ctrl == graphCtrlSolution) { if (null == CurrentSolution) return; CasePalletSolutionViewer sv = new CasePalletSolutionViewer(CurrentSolution); sv.Draw(graphics); } }
public void Draw(Graphics3DControl ctrl, Graphics3D graphics) { try { // instantiate solution viewer CasePalletSolutionViewer sv = new CasePalletSolutionViewer(CurrentSolution); sv.Draw(graphics); } catch (Exception ex) { _log.Error(ex.ToString()); } }
static int Main(string[] args) { ILog log = LogManager.GetLogger(typeof(Program)); XmlConfigurator.Configure(); try { bool useSingleColor = false; // instantiate document Document doc = new Document("Test", "Test", "fga", DateTime.Now, null); // define pallet properties PalletProperties palletProperties = new PalletProperties(doc, "EUR2", 1200, 1000, 150); Console.WriteLine("=== Pallet properties ==="); Console.WriteLine(palletProperties.ToString()); bool testCylinder = false; if (!testCylinder) { // define box properties BoxProperties boxProperties = new BoxProperties(doc, 162, 210, 250); boxProperties.Name = "Box1"; boxProperties.Weight = 3.0; if (!useSingleColor) { boxProperties.SetColor(HalfAxis.HAxis.AXIS_X_N, Color.Red); boxProperties.SetColor(HalfAxis.HAxis.AXIS_X_P, Color.Red); boxProperties.SetColor(HalfAxis.HAxis.AXIS_Y_N, Color.Green); boxProperties.SetColor(HalfAxis.HAxis.AXIS_Y_P, Color.Green); boxProperties.SetColor(HalfAxis.HAxis.AXIS_Z_N, Color.Blue); boxProperties.SetColor(HalfAxis.HAxis.AXIS_Z_P, Color.Blue); } else boxProperties.SetColor(Color.Chocolate); Console.WriteLine(boxProperties.ToString()); InterlayerProperties interlayerProperties = null; // define constraints CasePalletConstraintSet constraintSet = new CasePalletConstraintSet(); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, true); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, true); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, true); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, true); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, true); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, true); constraintSet.SetAllowedPattern("Trilock"); constraintSet.AllowAlignedLayers = true; constraintSet.AllowAlternateLayers = false; constraintSet.MaximumPalletWeight = 2000; constraintSet.MaximumNumberOfItems = 2000; constraintSet.MaximumHeight = 2000.0; constraintSet.UseMaximumHeight = true; constraintSet.UseMaximumPalletWeight = true; constraintSet.UseMaximumWeightOnBox = false; constraintSet.AllowLastLayerOrientationChange = true; Console.WriteLine("=== Constraint set ==="); Console.WriteLine(constraintSet.ToString()); // initialize analysis CasePalletAnalysis analysis = new CasePalletAnalysis( boxProperties, palletProperties, interlayerProperties, null, null, null, null, constraintSet); // initialize solver CasePalletSolver solver = new CasePalletSolver(); solver.ProcessAnalysis(analysis); Console.WriteLine("=== Solutions ==="); int solIndex = 0; foreach (CasePalletSolution sol in analysis.Solutions) { // instantiate graphics Graphics3DImage graphics = new Graphics3DImage(new Size(1000, 1000)); graphics.CameraPosition = new Vector3D(10000.0, 10000.0, 10000.0); graphics.Target = Vector3D.Zero; graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f); // instantiate solution viewer CasePalletSolutionViewer sv = new CasePalletSolutionViewer(sol); sv.Draw(graphics); // save string fileName = string.Format("Pallet_{0}.bmp", solIndex++); string filePath = Path.Combine(Path.GetTempPath(), fileName); Console.WriteLine("Saving file " + filePath + "..."); graphics.SaveAs(filePath); } } else { // cylinder Console.WriteLine("=== Cylinder properties ==="); CylinderProperties cylProperties = new CylinderProperties(doc, "Cylinder", "Default cylinder", 90, 45.0, 100, 1.5, Color.Gray, Color.SkyBlue, Color.SkyBlue); Console.WriteLine(cylProperties.ToString()); // constraint set Console.WriteLine("=== Constraint set ==="); CylinderPalletConstraintSet constraintSet = new CylinderPalletConstraintSet(); constraintSet.UseMaximumPalletHeight = true; constraintSet.MaximumPalletHeight = 1200.0; constraintSet.UseMaximumPalletWeight = true; constraintSet.MaximumPalletWeight = 2000; constraintSet.UseMaximumNumberOfItems = true; constraintSet.MaximumNumberOfItems = 2000; Console.WriteLine(constraintSet.ToString()); // cylinder analysis CylinderPalletAnalysis analysis = new CylinderPalletAnalysis(cylProperties, palletProperties, null, null, constraintSet); // initialize solver CylinderSolver solver = new CylinderSolver(); solver.ProcessAnalysis(analysis); Console.WriteLine("=== Solutions ==="); int solIndex = 0; foreach (CylinderPalletSolution sol in analysis.Solutions) { // instantiate graphics Graphics3DImage graphics = new Graphics3DImage(new Size(512, 512)); graphics.CameraPosition = new Vector3D(10000.0, 10000.0, 10000.0); graphics.Target = Vector3D.Zero; graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f); // instantiate solution viewer CylinderPalletSolutionViewer sv = new CylinderPalletSolutionViewer(sol); sv.Draw(graphics); string fileName = string.Format("Pallet_{0}.jpg", solIndex++); string filePath = Path.Combine(Path.GetTempPath(), fileName); Console.WriteLine("Saving file " + filePath + "..."); graphics.SaveAs(filePath); } } } catch (Exception ex) { log.Error(ex.ToString()); } return 0; }
private void ProcessViewSolution(viewSolution vSol) { // instantiate graphics Graphics3DImage graphics = InitializeImageFromViewParameters(vSol.viewParameters); // load analysis CasePalletAnalysis analysis = LoadPalletAnalysis(null, vSol.solutionRef.analysisId); // compute solutions TreeDim.StackBuilder.Engine.CasePalletSolver solver = new TreeDim.StackBuilder.Engine.CasePalletSolver(); solver.ProcessAnalysis(analysis); // retrieve wanted solution List<Basics.CasePalletSolution> solutions = analysis.Solutions; if (vSol.solutionRef.index >= solutions.Count) throw new Exception(string.Format("Analysis {0} has no solution with index {1}", analysis.Name, vSol.solutionRef.index)); Basics.CasePalletSolution sol = solutions[(int)vSol.solutionRef.index]; // display solution CasePalletSolutionViewer solViewer = new CasePalletSolutionViewer(sol); solViewer.Draw(graphics); FinalizeImageFromViewParameters(vSol.viewParameters, graphics); }
public void Draw(Graphics3DControl ctrl, Graphics3D graphics) { if (graphCtrlCaseSolution == ctrl) { // instantiate solution viewer BoxCasePalletSolutionViewer sv = new BoxCasePalletSolutionViewer(GetCurrentSolution()); sv.Draw(graphics); } else if (graphCtrlPalletSolution == ctrl) { CasePalletSolution sol = GetCurrentSolution().PalletSolutionDesc.LoadPalletSolution(); // instantial solution viewer CasePalletSolutionViewer svPallet = new CasePalletSolutionViewer(sol); svPallet.Draw(graphics); } }
private void Draw() { try { // get current descriptor PalletSolutionDesc desc = CurrentSolutionDesc; // sanity check if (null == desc || pictureBoxCase.Size.Width < 1 || pictureBoxCase.Size.Height < 1 || pictureBoxSolution.Size.Width < 1 || pictureBoxSolution.Size.Height < 1) return; // load document Document document = new Document(desc.FullFilePath, null); if (document.Analyses.Count == 0) return; // get analysis and solution CasePalletAnalysis analysis = document.Analyses[0]; { Graphics3DImage graphics = new Graphics3DImage(pictureBoxCase.Size); graphics.CameraPosition = Graphics3D.Corner_0; graphics.Target = Vector3D.Zero; Box box = new Box(0, analysis.BProperties); graphics.AddBox(box); graphics.AddDimensions(new DimensionCube(box.Length, box.Width, box.Height)); graphics.Flush(); pictureBoxCase.Image = graphics.Bitmap; } { // instantiate graphics Graphics3DImage graphics = new Graphics3DImage(pictureBoxSolution.Size); // set camera position graphics.CameraPosition = Graphics3D.Corner_0; graphics.Target = Vector3D.Zero; // instantiate solution viewer CasePalletSolutionViewer sv = new CasePalletSolutionViewer(analysis.Solutions[0]); sv.Draw(graphics); // show generated bitmap on picture box control pictureBoxSolution.Image = graphics.Bitmap; } } catch (Exception ex) { _log.Error(ex.ToString()); } }
public void Draw(Graphics3DControl ctrl, Graphics3D graphics) { // instantiate solution viewer CasePalletSolutionViewer sv = new CasePalletSolutionViewer(GetCurrentSolution()); sv.Draw(graphics); }
private void FillGrid() { // fill grid solution gridSolutions.Rows.Clear(); // border DevAge.Drawing.BorderLine border = new DevAge.Drawing.BorderLine(Color.DarkBlue, 1); DevAge.Drawing.RectangleBorder cellBorder = new DevAge.Drawing.RectangleBorder(border, border); // views CellBackColorAlternate viewNormal = new CellBackColorAlternate(Color.LightBlue, Color.White); viewNormal.Border = cellBorder; CheckboxBackColorAlternate viewNormalCheck = new CheckboxBackColorAlternate(Color.LightBlue, Color.White); viewNormalCheck.Border = cellBorder; // column header view SourceGrid.Cells.Views.ColumnHeader viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader(); DevAge.Drawing.VisualElements.ColumnHeader backHeader = new DevAge.Drawing.VisualElements.ColumnHeader(); backHeader.BackColor = Color.LightGray; backHeader.Border = DevAge.Drawing.RectangleBorder.NoBorder; viewColumnHeader.Background = backHeader; viewColumnHeader.ForeColor = Color.White; viewColumnHeader.Font = new Font("Arial", 8, FontStyle.Regular); viewColumnHeader.ElementSort.SortStyle = DevAge.Drawing.HeaderSortStyle.None; // create the grid gridSolutions.BorderStyle = BorderStyle.FixedSingle; gridSolutions.ColumnsCount = 9; gridSolutions.FixedRows = 1; gridSolutions.Rows.Insert(0); // header SourceGrid.Cells.ColumnHeader columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LAYERPATTERN); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 0] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_CASECOUNT); columnHeader.AutomaticSortEnabled = true; columnHeader.View = viewColumnHeader; columnHeader.SortComparer = new SourceGrid.MultiColumnsComparer(); gridSolutions[0, 1] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_CASEPERLAYERCOUNT); columnHeader.AutomaticSortEnabled = true; columnHeader.View = viewColumnHeader; columnHeader.SortComparer = new SourceGrid.MultiColumnsComparer(); gridSolutions[0, 2] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LAYERCOUNT); columnHeader.AutomaticSortEnabled = true; columnHeader.View = viewColumnHeader; columnHeader.SortComparer = new SourceGrid.MultiColumnsComparer(); gridSolutions[0, 3] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_VOLUMEEFFICIENCY); columnHeader.AutomaticSortEnabled = true; columnHeader.View = viewColumnHeader; columnHeader.SortComparer = new SourceGrid.MultiColumnsComparer(); gridSolutions[0, 4] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(string.Format(Resources.ID_PALLETWEIGHT, UnitsManager.MassUnitString)); columnHeader.AutomaticSortEnabled = true; columnHeader.View = viewColumnHeader; columnHeader.SortComparer = new SourceGrid.MultiColumnsComparer(); gridSolutions[0, 5] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(string.Format(Resources.ID_PALLETHEIGHT, UnitsManager.LengthUnitString)); columnHeader.AutomaticSortEnabled = true; columnHeader.View = viewColumnHeader; columnHeader.SortComparer = new SourceGrid.MultiColumnsComparer(); gridSolutions[0, 6] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_PALLETLIMIT); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 7] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_SELECTED); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 8] = columnHeader; // handling check box click SourceGrid.Cells.Controllers.CustomEvents solCheckboxClickEvent = new SourceGrid.Cells.Controllers.CustomEvents(); solCheckboxClickEvent.Click += new EventHandler(clickEvent_Click); // data rows int iIndex = 0; foreach (CasePalletSolution sol in _analysis.Solutions) { // build case count string string sCaseCount = string.Empty; if (sol.HasSameCountLayers && sol.LimitReached == CasePalletSolution.Limit.LIMIT_MAXHEIGHTREACHED) sCaseCount = string.Format("{0}\n({1} * {2})", sol.CaseCount, sol.CasePerLayerCount, sol.CaseLayersCount); else sCaseCount = string.Format("{0}", sol.CaseCount); // insert row gridSolutions.Rows.Insert(++iIndex); gridSolutions.Rows[iIndex].Tag = sol; // filling columns { Graphics2DImage graphics = new Graphics2DImage(new Size(100, 50)); CasePalletSolutionViewer sv = new CasePalletSolutionViewer(sol); sv.Draw(graphics); gridSolutions[iIndex, 0] = new SourceGrid.Cells.Image(graphics.Bitmap); } gridSolutions[iIndex, 1] = new SourceGrid.Cells.Cell(sol.CaseCount); gridSolutions[iIndex, 2] = new SourceGrid.Cells.Cell(sol.CasePerLayerCount); gridSolutions[iIndex, 3] = new SourceGrid.Cells.Cell(sol.CaseLayersCount); gridSolutions[iIndex, 4] = new SourceGrid.Cells.Cell(Math.Round(sol.VolumeEfficiencyCases, 1)); gridSolutions[iIndex, 5] = new SourceGrid.Cells.Cell(Math.Round(sol.PalletWeight, 3)); gridSolutions[iIndex, 6] = new SourceGrid.Cells.Cell(Math.Round(sol.PalletHeight, 1)); gridSolutions[iIndex, 7] = new SourceGrid.Cells.Cell(PalletSolutionLimitToString(sol.LimitReached)); gridSolutions[iIndex, 8] = new SourceGrid.Cells.CheckBox(null, _analysis.HasSolutionSelected(iIndex-1)); gridSolutions[iIndex, 0].View = viewNormal; gridSolutions[iIndex, 1].View = viewNormal; gridSolutions[iIndex, 2].View = viewNormal; gridSolutions[iIndex, 3].View = viewNormal; gridSolutions[iIndex, 4].View = viewNormal; gridSolutions[iIndex, 5].View = viewNormal; gridSolutions[iIndex, 6].View = viewNormal; gridSolutions[iIndex, 7].View = viewNormal; gridSolutions[iIndex, 8].View = viewNormalCheck; gridSolutions[iIndex, 8].AddController(solCheckboxClickEvent); } gridSolutions.AutoStretchColumnsToFitWidth = true; gridSolutions.AutoSizeCells(); gridSolutions.Columns.StretchToFit(); // select first solution gridSolutions.Selection.SelectRow(1, true); graphCtrlSolution.Invalidate(); }
public void Draw(Graphics3DControl ctrl, Graphics3D graphics) { if (ctrl == graphCtrlPallet) { // instantiate solution viewer CasePalletSolutionViewer sv = new CasePalletSolutionViewer(GetCurrentSolution()); sv.Draw(graphics); } else if (ctrl == graphCtrlCase) { // get case of boxes CaseOfBoxesProperties caseOfBoxes = _analysis.BProperties as CaseOfBoxesProperties; // draw CaseDefinitionViewer cdv = new CaseDefinitionViewer(caseOfBoxes.CaseDefinition, caseOfBoxes.InsideBoxProperties, caseOfBoxes.CaseOptimConstraintSet); cdv.CaseProperties = caseOfBoxes; cdv.Orientation = GetCurrentSolution().FirstCaseOrientation; cdv.Draw(graphics); } }
private void FillGrid() { // fill grid solution gridSolutions.Rows.Clear(); // border DevAge.Drawing.BorderLine border = new DevAge.Drawing.BorderLine(Color.DarkBlue, 1); DevAge.Drawing.RectangleBorder cellBorder = new DevAge.Drawing.RectangleBorder(border, border); // views CellBackColorAlternate viewNormal = new CellBackColorAlternate(Color.LightBlue, Color.White); viewNormal.Border = cellBorder; CheckboxBackColorAlternate viewNormalCheck = new CheckboxBackColorAlternate(Color.LightBlue, Color.White); viewNormalCheck.Border = cellBorder; // column header view SourceGrid.Cells.Views.ColumnHeader viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader(); DevAge.Drawing.VisualElements.ColumnHeader backHeader = new DevAge.Drawing.VisualElements.ColumnHeader(); backHeader.BackColor = Color.LightGray; backHeader.Border = DevAge.Drawing.RectangleBorder.NoBorder; viewColumnHeader.Background = backHeader; viewColumnHeader.ForeColor = Color.White; viewColumnHeader.Font = new Font("Arial", 10, FontStyle.Bold); viewColumnHeader.ElementSort.SortStyle = DevAge.Drawing.HeaderSortStyle.None; // create the grid gridSolutions.BorderStyle = BorderStyle.FixedSingle; gridSolutions.ColumnsCount = 7; gridSolutions.FixedRows = 1; gridSolutions.Rows.Insert(0); // header SourceGrid.Cells.ColumnHeader columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_INDEX); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 0] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LAYERPATTERN); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 1] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_CASECOUNT); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 2] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_VOLUMEEFFICIENCY); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 3] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(string.Format(Resources.ID_PALLETWEIGHT, UnitsManager.MassUnitString)); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 4] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(string.Format(Resources.ID_PALLETHEIGHT, UnitsManager.LengthUnitString)); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 5] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_SELECTED); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 6] = columnHeader; // handling check box click SourceGrid.Cells.Controllers.CustomEvents solCheckboxClickEvent = new SourceGrid.Cells.Controllers.CustomEvents(); solCheckboxClickEvent.Click += new EventHandler(clickEvent_Click); // data rows int iIndex = 0; foreach (CasePalletSolution sol in _analysis.Solutions) { ++iIndex; gridSolutions.Rows.Insert(iIndex); gridSolutions[iIndex, 0] = new SourceGrid.Cells.Cell(string.Format("{0}", iIndex)); { Graphics2DImage graphics = new Graphics2DImage(new Size(100, 50)); CasePalletSolutionViewer sv = new CasePalletSolutionViewer(sol); sv.Draw(graphics); gridSolutions[iIndex, 1] = new SourceGrid.Cells.Image(graphics.Bitmap); } gridSolutions[iIndex, 2] = new SourceGrid.Cells.Cell(string.Format("{0}", sol.CaseCount)); gridSolutions[iIndex, 3] = new SourceGrid.Cells.Cell(string.Format("{0:F}", sol.VolumeEfficiencyCases)); gridSolutions[iIndex, 4] = new SourceGrid.Cells.Cell(string.Format("{0:F}", sol.PalletWeight)); gridSolutions[iIndex, 5] = new SourceGrid.Cells.Cell(string.Format("{0:F}", sol.PalletHeight)); gridSolutions[iIndex, 6] = new SourceGrid.Cells.CheckBox(null, _analysis.HasSolutionSelected(iIndex - 1)); gridSolutions[iIndex, 0].View = viewNormal; gridSolutions[iIndex, 1].View = viewNormal; gridSolutions[iIndex, 2].View = viewNormal; gridSolutions[iIndex, 3].View = viewNormal; gridSolutions[iIndex, 4].View = viewNormal; gridSolutions[iIndex, 5].View = viewNormal; gridSolutions[iIndex, 6].View = viewNormalCheck; gridSolutions[iIndex, 6].AddController(solCheckboxClickEvent); } gridSolutions.AutoStretchColumnsToFitWidth = true; gridSolutions.AutoSizeCells(); gridSolutions.Columns.StretchToFit(); // select first solution gridSolutions.Selection.SelectRow(1, true); graphCtrlCase.Invalidate(); graphCtrlPallet.Invalidate(); }