Exemplo n.º 1
0
 public static Bitmap Draw(Layer2D layer, BProperties bProperties, double height, Size size, bool selected)
 {
     Graphics2DImage graphics = new Graphics2DImage(size);
     using (SolutionViewerLayer solViewer = new SolutionViewerLayer(layer))
     {   solViewer.Draw(graphics, bProperties, height, selected); }
     return graphics.Bitmap;
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {

            bool bestLayersOnly = true;
            Vector3D dimBox = new Vector3D(400.0, 300.0, 150.0);
            Vector2D dimContainer = new Vector2D(1200.0, 1000.0);
            ConstraintSetCasePallet constraintSet = new ConstraintSetCasePallet();
            constraintSet.SetMaxHeight(1200.0); 

            try
            {
                LayerSolver solver = new LayerSolver();
                List<Layer2D> layers = solver.BuildLayers(dimBox, dimContainer, constraintSet, bestLayersOnly);

                int solIndex = 0;
                foreach (Layer2D layer in layers)
                {
                    string fileName = string.Format("{0}_{1}.bmp", layer.Name, solIndex++);
                    string filePath = Path.Combine(Path.GetTempPath(), fileName);
                    Console.WriteLine(string.Format("Generating {0}...", filePath));

                    Graphics2DImage graphics = new Graphics2DImage( new Size(150, 150) );
                    SolutionViewerLayer solViewer = new SolutionViewerLayer(layer);
                    BoxProperties bProperties = new BoxProperties(null, 400.0, 300.0, 150.0);
                    bProperties.SetColor(Color.Brown);
                    solViewer.Draw(graphics, bProperties, 1500.0);
                    graphics.SaveAs(filePath);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 3
0
        public static Bitmap Draw(Layer2D layer, BProperties bProperties, double height, Size size, bool selected)
        {
            Graphics2DImage graphics = new Graphics2DImage(size);

            using (SolutionViewerLayer solViewer = new SolutionViewerLayer(layer))
            { solViewer.Draw(graphics, bProperties, height, selected); }
            return(graphics.Bitmap);
        }
        public Bitmap GeneratePalletImage(PalletProperties palletProperties)
        {
            Graphics2DImage graphics = new Graphics2DImage(ImageSize);

            graphics.SetViewport(PtMin - new Vector2D(0.5f, 0.5f), PtMax + new Vector2D(0.5, 0.5));
            graphics.MarginRatio = 0.0f;

            Pallet pallet = new Pallet(palletProperties);

            pallet.Draw(graphics);

            return(graphics.Bitmap);
        }
        public Bitmap GenerateCaseImage(Packable content, int number, CaseAlignement caseAlignment)
        {
            Graphics2DImage graphics = new Graphics2DImage(ImageSize);

            graphics.SetViewport(PtMin - new Vector2D(0.5f, 0.5f), PtMax + new Vector2D(0.5, 0.5));
            graphics.MarginRatio = 0.0f;

            double length = 0.0, width = 0.0;

            if (content is PackableBrick packable)
            {
                length = packable.Length;
                width  = packable.Width;
            }

            uint pickId = 0;

            for (int i = 0; i < number; ++i)
            {
                Vector3D v = Vector3D.Zero;
                switch (caseAlignment)
                {
                case CaseAlignement.SHARING_LENGTH: v = new Vector3D(0.0, i * width, 0.0); break;

                case CaseAlignement.SHARING_WIDTH: v = new Vector3D(i * length, 0.0, 0.0); break;

                default: break;
                }

                Box b;
                if (content is PackProperties pack)
                {
                    b = new Pack(pickId++, pack, new BoxPosition(v));
                }
                else if (content is PackableBrick brick)
                {
                    b = new Box(pickId++, brick, new BoxPosition(v))
                    {
                        ShowOrientationMark = true
                    }
                }
                ;
                else
                {
                    return(null);
                }
                b.Draw(graphics);
            }
            return(graphics.Bitmap);
        }
Exemplo n.º 6
0
 public static Bitmap Draw(ILayer2D layer, Packable packable, double height, Size size, bool selected, eGraphMode eMode)
 {
     if (eGraphMode.GRAPH_2D == eMode)
     {
         Graphics2DImage graphics = new Graphics2DImage(size);
         using (ViewerILayer2D solViewer = new ViewerILayer2D(layer))
         { solViewer.Draw(graphics, packable, height, selected); }
         return(graphics.Bitmap);
     }
     else
     {
         Graphics3DImage graphics = new Graphics3DImage(size);
         graphics.MarginPercentage = 0.05;
         using (ViewerILayer2D solViewer = new ViewerILayer2D(layer))
         { solViewer.Draw(graphics, packable, height, selected); }
         return(graphics.Bitmap);
     }
 }
Exemplo n.º 7
0
        public Bitmap GetLayerImage(Packable content)
        {
            Graphics2DImage graphics = new Graphics2DImage(SizeImage);

            graphics.SetViewport(PtMin, PtMax);

            uint pickId = 0;

            foreach (var bp in Positions)
            {
                Box b;
                if (content is PackProperties pack)
                {
                    b = new Pack(pickId++, pack, bp);
                }
                else
                {
                    b = new Box(pickId++, content as PackableBrick, bp);
                }
                graphics.DrawBox(b);
            }
            graphics.DrawRectangle(Vector2D.Zero, DimContainer, Color.OrangeRed);

            if (-1 != SelectedIndex)
            {
                var bp = Positions[SelectedIndex];

                Box boxSelected;
                if (content is PackProperties pack)
                {
                    boxSelected = new Pack((uint)SelectedIndex, pack, bp);
                }
                else
                {
                    boxSelected = new Box((uint)SelectedIndex, content as PackableBrick, bp);
                }
                graphics.DrawBoxSelected(boxSelected);

                // draw position
                graphics.DrawText($"({bp.Position.X:0.##}, {bp.Position.Y:0.##}, {bp.Position.Z:0.##}), {HalfAxis.ToString(bp.DirectionLength)}, {HalfAxis.ToString(bp.DirectionWidth)}", FontSize);
            }
            return(graphics.Bitmap);
        }
Exemplo n.º 8
0
 public static Bitmap Draw(IEnumerable <Box> boxes, Vector2D dimensions, Size size, EGraphMode eMode)
 {
     if (EGraphMode.GRAPH_2D == eMode)
     {
         var graphics = new Graphics2DImage(size);
         using (var viewer = new ViewerLayeredBoxes(dimensions))
             viewer.Draw(graphics, boxes, false, true);
         return(graphics.Bitmap);
     }
     else
     {
         var graphics = new Graphics3DImage(size)
         {
             MarginPercentage = 0.05
         };
         using (var viewer = new ViewerLayeredBoxes(dimensions))
             viewer.Draw(graphics, boxes, false, true);
         return(graphics.Bitmap);
     }
 }
        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 = 8;
            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_PACKCOUNT);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View = viewColumnHeader;
            gridSolutions[0, 1] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_CONSUMERSALESUNITS);
            columnHeader.AutomaticSortEnabled = true;
            columnHeader.View = viewColumnHeader;
            columnHeader.SortComparer = new SourceGrid.MultiColumnsComparer();
            gridSolutions[0, 2] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(string.Format(Resources.ID_LAYERWEIGHT, UnitsManager.MassUnitString));
            columnHeader.AutomaticSortEnabled = true;
            columnHeader.View = viewColumnHeader;
            gridSolutions[0, 3] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(string.Format(Resources.ID_PALLETWEIGHT, UnitsManager.MassUnitString));
            columnHeader.AutomaticSortEnabled = true;
            columnHeader.View = viewColumnHeader;
            gridSolutions[0, 4] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(string.Format(Resources.ID_PALLETHEIGHT, UnitsManager.LengthUnitString));
            columnHeader.AutomaticSortEnabled = true;
            columnHeader.View = viewColumnHeader;
            gridSolutions[0, 5] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(string.Format(Resources.ID_MAXIMUMSPACE, UnitsManager.LengthUnitString));
            columnHeader.AutomaticSortEnabled = true;
            columnHeader.View = viewColumnHeader;
            gridSolutions[0, 6] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_SELECTED);
            columnHeader.AutomaticSortEnabled = true;
            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 (PackPalletSolution sol in _analysis.Solutions)
            {
                // build case count string
                string sPackCount = string.Format("{0}\n({1} * {2})", sol.PackCount, sol.PackPerLayer, sol.LayerCount);
                string sCSUCount = string.Format("{0}", sol.CSUCount);
                // insert row
                gridSolutions.Rows.Insert(++iIndex);
                gridSolutions.Rows[iIndex].Tag = sol;

                // filling columns
                {
                    Graphics2DImage graphics = new Graphics2DImage(new Size(100, 50));
                    PackPalletSolutionViewer sv = new PackPalletSolutionViewer(sol);
                    sv.Draw(graphics);
                    gridSolutions[iIndex, 0] = new SourceGrid.Cells.Image(graphics.Bitmap);
                }
                gridSolutions[iIndex, 1] = new SourceGrid.Cells.Cell(sPackCount);
                gridSolutions[iIndex, 2] = new SourceGrid.Cells.Cell(sCSUCount);
                gridSolutions[iIndex, 3] = new SourceGrid.Cells.Cell(Math.Round(sol.LayerWeight, 3));
                gridSolutions[iIndex, 4] = new SourceGrid.Cells.Cell(Math.Round(sol.PalletWeight, 3));
                gridSolutions[iIndex, 5] = new SourceGrid.Cells.Cell(Math.Round(sol.PalletHeight, 1));
                gridSolutions[iIndex, 6] = new SourceGrid.Cells.Cell(Math.Round(sol.MaximumSpace, 1));
                gridSolutions[iIndex, 7] = 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 = viewNormalCheck;

                gridSolutions[iIndex, 7].AddController(solCheckboxClickEvent);
            }
            gridSolutions.AutoStretchColumnsToFitWidth = true;
            gridSolutions.AutoSizeCells();
            gridSolutions.Columns.StretchToFit();

            // select first solution
            gridSolutions.Selection.SelectRow(1, true);
            graphCtrlSolution.Invalidate();
        }
        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 = 7;
            gridSolutions.FixedRows = 1;
            gridSolutions.Rows.Insert(0);
            // header
            SourceGrid.Cells.ColumnHeader columnHeader;
            // index
            columnHeader = new SourceGrid.Cells.ColumnHeader(Properties.Resources.ID_INDEX);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View = viewColumnHeader;
            gridSolutions[0, 0] = columnHeader;
            // layers
            columnHeader = new SourceGrid.Cells.ColumnHeader(Properties.Resources.ID_LAYERPATTERNS);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View = viewColumnHeader;
            gridSolutions[0, 1] = columnHeader;
            // case dimensions
            columnHeader = new SourceGrid.Cells.ColumnHeader(Properties.Resources.ID_CASE);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View = viewColumnHeader;
            gridSolutions[0, 2] = columnHeader;
            // box / case count
            columnHeader = new SourceGrid.Cells.ColumnHeader(Properties.Resources.ID_BOXCASECOUNT);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View = viewColumnHeader;
            gridSolutions[0, 3] = columnHeader;
            // efficiency
            columnHeader = new SourceGrid.Cells.ColumnHeader(Properties.Resources.ID_EFFICIENCYPERCENTAGE);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View = viewColumnHeader;
            gridSolutions[0, 4] = columnHeader;
            // weights
            columnHeader = new SourceGrid.Cells.ColumnHeader(string.Format(Properties.Resources.ID_WEIGHT, UnitsManager.MassUnitString));
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View = viewColumnHeader;
            gridSolutions[0, 5] = columnHeader;
            // selected
            columnHeader = new SourceGrid.Cells.ColumnHeader(Properties.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 (BoxCasePalletSolution sol in _caseAnalysis.Solutions)
            {
                if (null == sol.PalletSolutionDesc.LoadPalletSolution())
                    continue;
                // insert new row
                gridSolutions.Rows.Insert(++iIndex);
                // # (index)
                gridSolutions[iIndex, 0] = new SourceGrid.Cells.Cell(string.Format("{0}", iIndex));
                {
                    Graphics2DImage graphics = new Graphics2DImage(new Size(100, 50));
                    BoxCasePalletSolutionViewer sv = new BoxCasePalletSolutionViewer(sol);
                    sv.Draw(graphics);
                    // layers
                    gridSolutions[iIndex, 1] = new SourceGrid.Cells.Image(graphics.Bitmap);
                }
                // case dimensions
                gridSolutions[iIndex, 2] = new SourceGrid.Cells.Cell(string.Format(CultureInfo.InvariantCulture, "{0}\n({1:0.#}*{2:0.#}*{3:0.#})", sol.PalletSolutionDesc.FriendlyName, sol.CaseLength, sol.CaseWidth, sol.CaseHeight));
                // box / case count
                gridSolutions[iIndex, 3] = new SourceGrid.Cells.Cell(string.Format("Boxes/case: {0}\nCases/pallet: {1}\nBoxes/pallet:{2}", sol.BoxPerCaseCount, sol.CasePerPalletCount, sol.BoxPerPalletCount));
                // efficiency
                gridSolutions[iIndex, 4] = new SourceGrid.Cells.Cell(string.Format(CultureInfo.InvariantCulture, "Case :{0:0.#}\nPallet :{1:0.#}", sol.CaseEfficiency, sol.PalletEfficiency));
                // weights
                gridSolutions[iIndex, 5] = new SourceGrid.Cells.Cell(string.Format(CultureInfo.InvariantCulture, "Case :{0:0.#}\nPallet :{1:0.#}", sol.CaseWeight, sol.PalletWeight));
                // selected
                gridSolutions[iIndex, 6] = new SourceGrid.Cells.CheckBox(null, _caseAnalysis.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);
            }
            try
            {
                gridSolutions.AutoStretchColumnsToFitWidth = true;
                gridSolutions.AutoSizeCells();
                gridSolutions.Columns.StretchToFit();
            }
            catch (Exception /*ex*/)
            { 
            }

            // select first solution
            gridSolutions.Selection.SelectRow(1, true);
            // draw
            graphCtrlCaseSolution.Invalidate();
            graphCtrlPalletSolution.Invalidate();
        }
        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_CASEWEIGHT);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View = viewColumnHeader;
            gridSolutions[0, 4] = columnHeader;

            // data rows
            int iIndex = 0;
            foreach (BoxCaseSolution sol in _analysis.Solutions)
            {
                // build case count string
                string sBoxCount = string.Empty;
                sBoxCount = string.Format("{0}\n({1} * {2})", sol.BoxPerCaseCount, sol.BoxPerLayerCount, 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));
                    BoxCaseSolutionViewer sv = new BoxCaseSolutionViewer(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.VolumeEfficiencyBoxes));
                gridSolutions[iIndex, 4] = new SourceGrid.Cells.Cell(string.Format("{0:F}", sol.CaseWeight));

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