private void FillGrid() { try { // 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 = 12; gridSolutions.FixedRows = 1; gridSolutions.Rows.Insert(0); // header SourceGrid.Cells.ColumnHeader columnHeader; // 0 columnHeader = new SourceGrid.Cells.ColumnHeader("#"); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 0] = columnHeader; // 1 columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_A1); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 1] = columnHeader; // 2 columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_A2); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 2] = columnHeader; // 3 columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_A3); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 3] = columnHeader; // 4 columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LENGTH); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 4] = columnHeader; // 5 columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_WIDTH); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 5] = columnHeader; // 6 columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_HEIGHT); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 6] = columnHeader; // 7 columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_AREA); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 7] = columnHeader; // 8 columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_CASESLAYER); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 8] = columnHeader; // 9 columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LAYERS); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 9] = columnHeader; // 10 columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_CASESPALLET); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 10] = columnHeader; // 11 columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_VOLUMEEFFICIENCY); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 11] = columnHeader; // column width gridSolutions.Columns[0].Width = 30; gridSolutions.Columns[1].Width = 30; gridSolutions.Columns[2].Width = 30; gridSolutions.Columns[3].Width = 30; gridSolutions.Columns[4].Width = 50; gridSolutions.Columns[5].Width = 50; gridSolutions.Columns[6].Width = 50; gridSolutions.Columns[7].Width = 50; gridSolutions.Columns[8].Width = 80; gridSolutions.Columns[9].Width = 50; gridSolutions.Columns[10].Width = 80; gridSolutions.Columns[11].Width = 100; // get BoxProperties BoxProperties boxProperties = SelectedBox; PalletProperties palletProperties = SelectedPallet; CaseOptimConstraintSet caseOptimConstraintSet = BuildCaseOptimConstraintSet(); PalletConstraintSet palletConstraintSet = new CasePalletConstraintSet(); palletConstraintSet.MaximumHeight = (double)nudPalletHeight.Value; // data int iIndex = 0; foreach (CaseOptimSolution sol in _solutions) { // insert new row gridSolutions.Rows.Insert(++iIndex); // # (index) gridSolutions[iIndex, 0] = new SourceGrid.Cells.Cell(string.Format("{0}", iIndex)); // A1 gridSolutions[iIndex, 1] = new SourceGrid.Cells.Cell(string.Format("{0}", sol.CaseDefinition.Arrangement._iLength)); // A2 gridSolutions[iIndex, 2] = new SourceGrid.Cells.Cell(string.Format("{0}", sol.CaseDefinition.Arrangement._iWidth)); // A3 gridSolutions[iIndex, 3] = new SourceGrid.Cells.Cell(string.Format("{0}", sol.CaseDefinition.Arrangement._iHeight)); // Case inner dimensions Vector3D innerDim = sol.CaseDefinition.InnerDimensions(boxProperties); // LENGTH gridSolutions[iIndex, 4] = new SourceGrid.Cells.Cell(string.Format("{0:0.#}", innerDim.X)); // WIDTH gridSolutions[iIndex, 5] = new SourceGrid.Cells.Cell(string.Format("{0:0.#}", innerDim.Y)); // HEIGHT gridSolutions[iIndex, 6] = new SourceGrid.Cells.Cell(string.Format("{0:0.#}", innerDim.Z)); // AREA gridSolutions[iIndex, 7] = new SourceGrid.Cells.Cell(string.Format("{0:0.00}", sol.CaseDefinition.Area(boxProperties, caseOptimConstraintSet) * 1.0E-06)); // CASES PER LAYER gridSolutions[iIndex, 8] = new SourceGrid.Cells.Cell(string.Format("{0}", sol.PalletSolution[0].BoxCount)); // LAYERS gridSolutions[iIndex, 9] = new SourceGrid.Cells.Cell(string.Format("{0}", sol.PalletSolution.Count)); // CASES PER PALLET gridSolutions[iIndex, 10] = new SourceGrid.Cells.Cell(string.Format("{0}", sol.CaseCount)); // EFFICIENCY double efficiency = sol.CaseCount * sol.CaseDefinition.InnerVolume(boxProperties) / ((palletProperties.Length - palletConstraintSet.OverhangX) * (palletProperties.Width - palletConstraintSet.OverhangY) * (palletConstraintSet.MaximumHeight - palletProperties.Height) ); gridSolutions[iIndex, 11] = new SourceGrid.Cells.Cell(string.Format("{0:0.00}", efficiency)); } // select first solution if (_solutions.Count > 0) { gridSolutions.Selection.EnableMultiSelection = false; gridSolutions.Selection.SelectRow(1, true); } } catch (Exception ex) { _log.Error(ex.ToString()); } graphCtrlBoxesLayout.Invalidate(); graphCtrlPalletLayout.Invalidate(); UpdateToolbarButtons(); }
/// <summary> /// Fill SourceGrid control with analysis solutions /// </summary> 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, "kg")); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 4] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(string.Format(Resources.ID_PALLETHEIGHT, "mm")); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 5] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_PALLETLIMIT); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 6] = columnHeader; // 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); // 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(sCaseCount); 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.Cell(PalletSolutionLimitToString(sol.LimitReached)); 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.AutoStretchColumnsToFitWidth = true; gridSolutions.AutoSizeCells(); gridSolutions.Columns.StretchToFit(); // select first solution gridSolutions.Selection.SelectRow(1, true); graphCtrlSolution.Invalidate(); }
/// <summary> /// Fill SourceGrid control with analysis solutions /// </summary> 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, "kg")); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 4] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(string.Format(Resources.ID_PALLETHEIGHT, "mm")); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 5] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_PALLETLIMIT); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 6] = columnHeader; // 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); // 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(sCaseCount); 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.Cell(PalletSolutionLimitToString(sol.LimitReached)); 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.AutoStretchColumnsToFitWidth = true; gridSolutions.AutoSizeCells(); gridSolutions.Columns.StretchToFit(); // select first solution gridSolutions.Selection.SelectRow(1, true); graphCtrlSolution.Invalidate(); }