private List <TruckSolution> GenerateSolutions(TruckAnalysis truckAnalysis) { List <TruckSolution> solutions = new List <TruckSolution>(); HalfAxis.HAxis[] axis = { HalfAxis.HAxis.AXIS_Z_N, HalfAxis.HAxis.AXIS_Z_P }; // build layer using truck length / width foreach (LayerPattern pattern in LayerPattern.All) { for (int swapPos = 0; swapPos < (pattern.CanBeSwapped ? 2 : 1); ++swapPos) { for (int orientation = 0; orientation < 2; ++orientation) { try { Layer2D layer = BuildLayer(truckAnalysis.ParentSolution, truckAnalysis.TruckProperties, truckAnalysis.ConstraintSet , axis[orientation], swapPos == 1); double actualLength = 0.0, actualWidth = 0.0; if (!pattern.GetLayerDimensionsChecked(layer, out actualLength, out actualWidth)) { continue; } pattern.GenerateLayer(layer, actualLength, actualWidth); TruckSolution sol = new TruckSolution("sol", truckAnalysis); BoxLayer boxLayer = new BoxLayer(0.0, 0); foreach (LayerPosition layerPos in layer) { boxLayer.AddPosition(layerPos.Position, layerPos.LengthAxis, layerPos.WidthAxis); } sol.Layer = boxLayer; // insert solution if (sol.PalletCount > 0) { solutions.Add(sol); } } catch (Exception ex) { _log.Error(string.Format("Exception caught: {0}", ex.ToString())); } } } } // sort solutions solutions.Sort(); return(solutions); }
public void Update(ItemBase item) { // update grid FillGrid(); // select first solution if (gridSolutions.RowsCount > 0) { gridSolutions.Selection.SelectRow(1, true); } if (_truckAnalysis.Solutions.Count > 0) { _sol = _truckAnalysis.Solutions[0]; } // draw graphCtrlSolution.Invalidate(); }
// selection changed private void onGridSolutionSelectionChanged(object sender, SourceGrid.RangeRegionChangedEventArgs e) { SourceGrid.RangeRegion region = gridSolutions.Selection.GetSelectionRegion(); int[] indexes = region.GetRowsIndex(); // no selection -> exit if (indexes.Length == 0) { return; } // get selected solution _sol = _truckAnalysis.Solutions[indexes[0] - 1]; // update select/unselect button text UpdateSelectButtonText(); // redraw graphCtrlSolution.Invalidate(); }
public TruckSolutionViewer(TruckSolution truckSolution) { _truckSolution = truckSolution; }
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; 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 = 8; 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_LAYOUT); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 1] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_PALLETCOUNT); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 2] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_CASECOUNT); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 3] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_VOLUMEEFFICIENCY); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 4] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LOADWEIGHT); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 5] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LOADHEIGHT); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 6] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_SELECTED); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 7] = 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 (TruckSolution sol in _truckAnalysis.Solutions) { ++iIndex; gridSolutions.Rows.Insert(iIndex); // index gridSolutions[iIndex, 0] = new SourceGrid.Cells.Cell(string.Format("{0}", iIndex)); // Layout { Graphics2DImage graphics = new Graphics2DImage(new Size(300, 30)); TruckSolutionViewer sv = new TruckSolutionViewer(sol); sv.Draw(graphics); gridSolutions[iIndex, 1] = new SourceGrid.Cells.Image(graphics.Bitmap); } // Pallet count gridSolutions[iIndex, 2] = new SourceGrid.Cells.Cell(string.Format("{0}", sol.PalletCount)); // Case count gridSolutions[iIndex, 3] = new SourceGrid.Cells.Cell(string.Format("{0}", sol.BoxCount)); // Efficiency gridSolutions[iIndex, 4] = new SourceGrid.Cells.Cell(string.Format("{0:F}", sol.Efficiency)); // Load gridSolutions[iIndex, 5] = new SourceGrid.Cells.Cell(string.Format("{0:F}", sol.LoadWeight)); // Load height gridSolutions[iIndex, 6] = new SourceGrid.Cells.Cell(string.Format("{0:F}", sol.LoadHeight)); // Selected gridSolutions[iIndex, 7] = new SourceGrid.Cells.CheckBox(null, _truckAnalysis.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 = viewNormalCheck; gridSolutions[iIndex, 7].AddController(solCheckboxClickEvent); } gridSolutions.AutoStretchColumnsToFitWidth = true; gridSolutions.AutoSizeCells(); gridSolutions.Columns.StretchToFit(); // select first solution gridSolutions.Selection.SelectRow(1, true); if (_truckAnalysis.Solutions.Count > 0) { _sol = _truckAnalysis.Solutions[0]; } graphCtrlSolution.Invalidate(); }