void SolutionSelectionChanged(BoxCasePalletAnalysis analysis, SelBoxCasePalletSolution selSolution) { UpdateSelectButtonText(); UpdateGridCheckBoxes(); }
public void SelectSolutionByIndex(int index) { if (index < 0 || index >= _caseSolutions.Count) return; if (HasSolutionSelected(index)) return; // instantiate new SelCaseSolution SelBoxCasePalletSolution selCaseSolution = new SelBoxCasePalletSolution(ParentDocument, this, _caseSolutions[index]); // insert in list _selectedSolutions.Add(selCaseSolution); // fire event if (null != SolutionSelected) SolutionSelected(this, selCaseSolution); // set document modified ParentDocument.Modify(); }
public void UnSelectSolution(SelBoxCasePalletSolution selSolution) { if (null == selSolution) return; // this solution not selected // remove from list _selectedSolutions.Remove(selSolution); ParentDocument.RemoveItem(selSolution); // fire event if (null != SolutionSelectionRemoved) SolutionSelectionRemoved(this, selSolution); // set document modified (not analysis, otherwise selected solutions are erased) ParentDocument.Modify(); }
private void onCaseAnalysisSolutionSelectionRemoved(BoxCasePalletAnalysis caseAnalysis, SelBoxCasePalletSolution selSolution) { // retrieve parent document Document doc = caseAnalysis.ParentDocument; // get node TreeNode caseAnalysisNode = FindNode(null, new NodeTag(NodeTag.NodeType.NT_BOXCASEPALLETANALYSIS, doc, caseAnalysis)); // test if (null == caseAnalysisNode) { _log.Warn(string.Format("Failed to find a valid tree node for caseAnalysis {0}", caseAnalysis.Name)); return; } // remove node Nodes.Remove(caseAnalysisNode); }
private void SaveCaseSolution(BoxCasePalletSolution sol, SelBoxCasePalletSolution selSolution, XmlElement parentElement, XmlDocument xmlDoc) { // create case solution element XmlElement solutionElt = xmlDoc.CreateElement("CaseSolution"); parentElement.AppendChild(solutionElt); // title XmlAttribute titleAttribute = xmlDoc.CreateAttribute("Title"); titleAttribute.Value = sol.Title; solutionElt.Attributes.Append(titleAttribute); // homogeneousLayers ? XmlAttribute homogeneousLayersAttribute = xmlDoc.CreateAttribute("HomogeneousLayers"); homogeneousLayersAttribute.Value = sol.HasHomogeneousLayers ? "true" : "false"; solutionElt.Attributes.Append(homogeneousLayersAttribute); // pallet solution id XmlAttribute palletSolutionAttribute = xmlDoc.CreateAttribute("PalletSolutionId"); palletSolutionAttribute.Value = sol.PalletSolutionDesc.Guid.ToString(); solutionElt.Attributes.Append(palletSolutionAttribute); // layers XmlElement layersElt = xmlDoc.CreateElement("Layers"); solutionElt.AppendChild(layersElt); foreach (ILayer layer in sol) { BoxLayer boxLayer = layer as BoxLayer; if (null != boxLayer) Save(boxLayer, layersElt, xmlDoc); InterlayerPos interlayerPos = layer as InterlayerPos; if (null != interlayerPos) { // Interlayer XmlElement interlayerElt = xmlDoc.CreateElement("Interlayer"); layersElt.AppendChild(interlayerElt); // ZLow XmlAttribute zlowAttribute = xmlDoc.CreateAttribute("ZLow"); zlowAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", interlayerPos.ZLow); interlayerElt.Attributes.Append(zlowAttribute); } } // Is selected ? if (null != selSolution) { // selected attribute XmlAttribute selAttribute = xmlDoc.CreateAttribute("Selected"); selAttribute.Value = "true"; solutionElt.Attributes.Append(selAttribute); } }
public NodeTag(NodeType type, Document document, BoxCasePalletAnalysis caseAnalysis, SelBoxCasePalletSolution selBoxCasePalletSolution) { _type = type; _document = document; _boxCasePalletAnalysis = caseAnalysis; _selBoxCasePalletSolution = selBoxCasePalletSolution; }
private void onCaseAnalysisSolutionSelected(BoxCasePalletAnalysis caseAnalysis, SelBoxCasePalletSolution selSolution) { // retrieve document Document doc = caseAnalysis.ParentDocument; // get parent node TreeNode parentNode = FindNode(null, new NodeTag(NodeTag.NodeType.NT_BOXCASEPALLETANALYSIS, doc, caseAnalysis)); if (null == parentNode) throw new Exception("Failed to locate Analysis (NT_BOXCASEPALLETANALYSIS) node..."); // insert selected solution node TreeNode nodeSelSolution = new TreeNode(selSolution.Name, 15, 15); nodeSelSolution.Tag = new NodeTag(NodeTag.NodeType.NT_CASESOLUTION, doc, caseAnalysis, selSolution); parentNode.Nodes.Add(nodeSelSolution); // expand tree node parentNode.Expand(); }
/// <summary> /// handles case solution unselected : actually removed selected solution node from case analysis node /// </summary> public void OnCaseAnalysisSolutionRemoved(Document doc, BoxCasePalletAnalysis caseAnalysis, SelBoxCasePalletSolution selSolution) { // get node TreeNode selSolutionNode = FindNode(null, new NodeTag(NodeTag.NodeType.NT_CASESOLUTION, doc, caseAnalysis, selSolution)); // test if (null == selSolutionNode) { _log.Error(string.Format("Failed to find a valid tree node for selSolution {0}", selSolution.Name)); return; } // remove node Nodes.Remove(selSolutionNode); }
public ReportData( CasePalletAnalysis palletAnalysis, SelCasePalletSolution selSolution , CylinderPalletAnalysis cylinderPalletAnalysis, SelCylinderPalletSolution selCylinderPalletSolution , HCylinderPalletAnalysis hCylinderPalletAnalysis, SelHCylinderPalletSolution selHCylinderPalletSolution , BoxCaseAnalysis boxCaseAnalysis, SelBoxCaseSolution selBoxCaseSolution , BoxCasePalletAnalysis caseAnalysis, SelBoxCasePalletSolution selCaseSolution , PackPalletAnalysis packPalletAnalysis, SelPackPalletSolution selPackPalletSolution ) { // case/pallet analysis _palletAnalysis = palletAnalysis; _selSolution = selSolution; // box/case/pallet analysis _caseAnalysis = caseAnalysis; _selCaseSolution = selCaseSolution; // Cylinder analysis _cylinderPalletAnalysis = cylinderPalletAnalysis; _selCylinderPalletSolution = selCylinderPalletSolution; // HCylinder analysis _hCylinderPalletAnalysis = hCylinderPalletAnalysis; _selHCylinderPalletSolution = selHCylinderPalletSolution; // Box case analysis _boxCaseAnalysis = boxCaseAnalysis; _selBoxCaseSolution = selBoxCaseSolution; // Pack pallet analysis _packPalletAnalysis = packPalletAnalysis; _selPackPalletSolution = selPackPalletSolution; }
public ReportData(BoxCasePalletAnalysis caseAnalysis, SelBoxCasePalletSolution selCaseSolution) { _caseAnalysis = caseAnalysis; _selCaseSolution = selCaseSolution; }
private void AppendCaseSolutionElement(SelBoxCasePalletSolution selSolution, XmlElement elemCaseAnalysis, XmlDocument xmlDoc) { string ns = xmlDoc.DocumentElement.NamespaceURI; BoxCasePalletSolution caseSolution = selSolution.Solution; // caseSolution element XmlElement elemCaseSolution = CreateElement("boxCasePalletSolution", null, elemCaseAnalysis, xmlDoc, ns); // title CreateElement("title", caseSolution.Title, elemCaseSolution, xmlDoc, ns); // homogeneousLayer CreateElement("homogeneousLayer", caseSolution.HasHomogeneousLayers ? "Y" : "N", elemCaseSolution, xmlDoc, ns); // casePerPalletCount CreateElement("casePerPalletCount", caseSolution.CasePerPalletCount, elemCaseSolution, xmlDoc, ns); // boxPerCaseCount CreateElement("boxPerCaseCount", caseSolution.BoxPerCaseCount, elemCaseSolution, xmlDoc, ns); // boxPerPalletCount CreateElement("boxPerPalletCount", caseSolution.BoxPerPalletCount, elemCaseSolution, xmlDoc, ns); // caseEfficiency CreateElement("caseEfficiency", caseSolution.CaseEfficiency, elemCaseSolution, xmlDoc, ns); // palletEfficiency CreateElement("palletEfficiency", caseSolution.PalletEfficiency, elemCaseSolution, xmlDoc, ns); AppendElementValue(xmlDoc, elemCaseSolution, "caseWeight", UnitsManager.UnitType.UT_MASS, caseSolution.CaseWeight); AppendElementValue(xmlDoc, elemCaseSolution, "palletWeight", UnitsManager.UnitType.UT_MASS, caseSolution.PalletWeight); // --- build image Graphics3DImage graphics = new Graphics3DImage(new Size(512, 512)); graphics.CameraPosition = Graphics3D.Corner_0; graphics.Target = Vector3D.Zero; // instantiate solution viewer BoxCasePalletSolutionViewer sv = new BoxCasePalletSolutionViewer(caseSolution); sv.Draw(graphics); graphics.Flush(); SaveImageAs(graphics.Bitmap, "view_caseSolution_iso.png"); // --- // view_caseSolution_iso XmlElement elemImage = xmlDoc.CreateElement("view_caseSolution_iso", ns); TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap)); elemImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[]))); XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style"); styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 4, graphics.Bitmap.Height / 4); elemImage.Attributes.Append(styleAttribute); elemCaseSolution.AppendChild(elemImage); }
private void AppendCaseElement(SelBoxCasePalletSolution caseSolution, XmlElement elemCaseAnalysis, XmlDocument xmlDoc) { string ns = xmlDoc.DocumentElement.NamespaceURI; BoxProperties boxProp = caseSolution.Solution.AttachedPalletSolution.Analysis.BProperties as BoxProperties; // case element XmlElement elemCase = CreateElement("caseWithInnerDims", null, elemCaseAnalysis, xmlDoc, ns); // name CreateElement("name", boxProp.Name, elemCase, xmlDoc, ns); // description CreateElement("description", boxProp.Description, elemCase, xmlDoc, ns); AppendElementValue(xmlDoc, elemCase, "length", UnitsManager.UnitType.UT_LENGTH, boxProp.Length); AppendElementValue(xmlDoc, elemCase, "width", UnitsManager.UnitType.UT_LENGTH, boxProp.Width); AppendElementValue(xmlDoc, elemCase, "height", UnitsManager.UnitType.UT_LENGTH, boxProp.Height); AppendElementValue(xmlDoc, elemCase, "innerLength", UnitsManager.UnitType.UT_LENGTH, boxProp.InsideLength); AppendElementValue(xmlDoc, elemCase, "innerWidth", UnitsManager.UnitType.UT_LENGTH, boxProp.InsideWidth); AppendElementValue(xmlDoc, elemCase, "innerHeight", UnitsManager.UnitType.UT_LENGTH, boxProp.InsideHeight); AppendElementValue(xmlDoc, elemCase, "weight", UnitsManager.UnitType.UT_MASS, boxProp.Height); // --- build image Graphics3DImage graphics = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail)); graphics.CameraPosition = Graphics3D.Corner_0; graphics.Target = Vector3D.Zero; Box box = new Box(0, boxProp); graphics.AddBox(box); graphics.AddDimensions(new DimensionCube(box.Length, box.Width, box.Height)); graphics.Flush(); // --- // view_case_iso XmlElement elemImage = xmlDoc.CreateElement("view_case_iso", ns); TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap)); elemImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[]))); XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style"); styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 4, graphics.Bitmap.Height / 4); elemImage.Attributes.Append(styleAttribute); elemCase.AppendChild(elemImage); // save image SaveImageAs(graphics.Bitmap, "view_case_iso.png"); }