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(); }
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(); }