示例#1
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);
            }
        }
        public LayerDropDownItem(Layer2D layer, Packable packable, bool selected)
        {
            // save layer
            _layer = layer;

            // build image
            Graphics2DImage     graphics  = new Graphics2DImage(new Size(_imgSize, _imgSize));
            SolutionViewerLayer solViewer = new SolutionViewerLayer(_layer);

            solViewer.Draw(graphics, packable, 0.0, selected);
            _img = graphics.Bitmap;
        }