private Bitmap GetBoxBitmapFromDesc(PalletSolutionDesc desc)
        {
            bool showDimensions = false;

            // load document
            Document document = new Document(desc.FullFilePath, null);

            if (document.Analyses.Count != 1)
            {
                throw new Exception("Failed to load analysis.");
            }
            // get analysis and solution
            CasePalletAnalysis analysis = document.Analyses[0];
            Graphics3DImage    graphics = new Graphics3DImage(new Size(50, 50));

            graphics.CameraPosition = Graphics3D.Corner_0;
            graphics.Target         = Vector3D.Zero;
            Box box = new Box(0, analysis.BProperties);

            graphics.AddBox(box);
            if (showDimensions)
            {
                graphics.AddDimensions(new DimensionCube(box.Length, box.Width, box.Height));
            }
            graphics.Flush();
            return(graphics.Bitmap);
        }
Esempio n. 2
0
        private void Draw()
        {
            try
            {
                // get current descriptor
                PalletSolutionDesc desc = CurrentSolutionDesc;
                // sanity check
                if (null == desc ||
                    pictureBoxCase.Size.Width < 1 || pictureBoxCase.Size.Height < 1 ||
                    pictureBoxSolution.Size.Width < 1 || pictureBoxSolution.Size.Height < 1)
                {
                    return;
                }

                // load document
                Document document = new Document(desc.FullFilePath, null);
                if (!document.AnalysesCasePallet.Any())
                {
                    return;
                }
                // get analysis and solution
                CasePalletAnalysis analysis = document.AnalysesCasePallet.First() as CasePalletAnalysis;
                {
                    Graphics3DImage graphics = new Graphics3DImage(pictureBoxCase.Size)
                    {
                        CameraPosition = Graphics3D.Corner_0,
                        Target         = Vector3D.Zero
                    };
                    Box box = new Box(0, analysis.BProperties);
                    graphics.AddBox(box);
                    graphics.AddDimensions(new DimensionCube(box.Length, box.Width, box.Height));
                    graphics.Flush();
                    pictureBoxCase.Image = graphics.Bitmap;
                }

                {
                    // instantiate graphics
                    Graphics3DImage graphics = new Graphics3DImage(pictureBoxSolution.Size)
                    {
                        // set camera position
                        CameraPosition = Graphics3D.Corner_0,
                        Target         = Vector3D.Zero
                    };
                    // instantiate solution viewer
                    CasePalletSolutionViewer sv = new CasePalletSolutionViewer(analysis.Solutions[0]);
                    sv.Draw(graphics);
                    graphics.Flush();
                    // show generated bitmap on picture box control
                    pictureBoxSolution.Image = graphics.Bitmap;
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
Esempio n. 3
0
 void DeleteButton_Click(object sender, EventArgs e)
 {
     SourceGrid.CellContext context = (SourceGrid.CellContext)sender;
     if (context.Position.Row > 0)
     {
         PalletSolutionDesc desc = PalletSolutionDatabase.Instance.QueryPalletSolutions(CurrentKey)[context.Position.Row - 1];
         PalletSolutionDatabase.Instance.RemoveByGuid(desc.Guid);
         if (PalletSolutionDatabase.Instance.HasKey(CurrentKey))
         {
             FillGrid();
         }
         else
         {
             FillKeyCombo();
         }
     }
 }
        private Bitmap GetBoxBitmapFromDesc(PalletSolutionDesc desc)
        {
            bool showDimensions = false;

            // load document
            Document document = new Document(desc.FullFilePath, null);
            if (document.Analyses.Count != 1)
                throw new Exception("Failed to load analysis.");
            // get analysis and solution
            CasePalletAnalysis analysis = document.Analyses[0];
            Graphics3DImage graphics = new Graphics3DImage(new Size(50,50));
            graphics.CameraPosition = Graphics3D.Corner_0;
            graphics.Target = Vector3D.Zero;
            Box box = new Box(0, analysis.BProperties);
            graphics.AddBox(box);
            if (showDimensions)
                graphics.AddDimensions(new DimensionCube(box.Length, box.Width, box.Height));
            graphics.Flush();
            return graphics.Bitmap;
        }
Esempio n. 5
0
 private void SavePalletSolutionDescriptor(PalletSolutionDesc desc, XmlElement parentElement, XmlDocument xmlDoc)
 {
     // pallet solution descriptor element
     XmlElement palletSolutionDescElt = xmlDoc.CreateElement("PalletSolutionDescriptor");
     parentElement.AppendChild(palletSolutionDescElt);
     // pallet dimensions
     XmlAttribute palletDimensionsAttribute = xmlDoc.CreateAttribute("PalletDimensions");
     palletDimensionsAttribute.Value = desc.Key.PalletDimensions;
     palletSolutionDescElt.Attributes.Append(palletDimensionsAttribute);
     // overhang
     XmlAttribute palletOverhangAttribute = xmlDoc.CreateAttribute("PalletOverhang");
     palletOverhangAttribute.Value = desc.Key.Overhang;
     palletSolutionDescElt.Attributes.Append(palletOverhangAttribute);
     // guid
     XmlAttribute idAttribute = xmlDoc.CreateAttribute("Id");
     idAttribute.Value = desc.Guid.ToString();
     palletSolutionDescElt.Attributes.Append(idAttribute);
     // friendly name
     XmlAttribute friendlyNameAttribute = xmlDoc.CreateAttribute("FriendlyName");
     friendlyNameAttribute.Value = desc.FriendlyName;
     palletSolutionDescElt.Attributes.Append(friendlyNameAttribute);
     // case dimensions
     XmlAttribute dimensionsAttribute = xmlDoc.CreateAttribute("CaseDimensions");
     dimensionsAttribute.Value = desc.CaseDimensionsString;
     palletSolutionDescElt.Attributes.Append(dimensionsAttribute);
     // case inside dimensions
     XmlAttribute insideDimensionsAttribute = xmlDoc.CreateAttribute("CaseInsideDimensions");
     insideDimensionsAttribute.Value = desc.CaseInsideDimensionsString;
     palletSolutionDescElt.Attributes.Append(insideDimensionsAttribute);
     // case weight
     XmlAttribute caseWeightAttribute = xmlDoc.CreateAttribute("CaseWeight");
     caseWeightAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", desc.CaseWeight);
     palletSolutionDescElt.Attributes.Append(caseWeightAttribute);
     // pallet weight
     XmlAttribute palletWeightAttribute = xmlDoc.CreateAttribute("PalletWeight");
     palletWeightAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", desc.PalletWeight);
     palletSolutionDescElt.Attributes.Append(palletWeightAttribute);
     // case count
     XmlAttribute caseCountAttribute = xmlDoc.CreateAttribute("CaseCount");
     caseCountAttribute.Value = desc.CaseCount.ToString();
     palletSolutionDescElt.Attributes.Append(caseCountAttribute);
     // case orientation
     XmlAttribute caseOrientationAttribute = xmlDoc.CreateAttribute("CaseOrientation");
     caseOrientationAttribute.Value = desc.CaseOrientation;
     palletSolutionDescElt.Attributes.Append(caseOrientationAttribute);
 }