public void Draw(Graphics3DControl ctrl, Graphics3D graphics) { if (CornerLength > 0 && CornerWidth > 0 && CornerThickness > 0 && CornerThickness < CornerWidth) { // draw PalletCornerProperties palletCornerProperties = new PalletCornerProperties( null, ItemName, ItemDescription, CornerLength, CornerWidth, CornerThickness, CornerWeight, CornerColor); Corner palletCap = new Corner(0, palletCornerProperties); palletCap.Draw(graphics); graphics.AddDimensions(new DimensionCube(CornerWidth, CornerWidth, CornerLength)); } }
private void AppendPalletCornerElement(PalletCornerProperties palletCornerProp, XmlElement elemPalletAnalysis, XmlDocument xmlDoc) { // sanity check if (null == palletCornerProp) return; // namespace string ns = xmlDoc.DocumentElement.NamespaceURI; // interlayer XmlElement elemPalletCorner = xmlDoc.CreateElement("palletCorner", ns); elemPalletAnalysis.AppendChild(elemPalletCorner); // name XmlElement elemName = xmlDoc.CreateElement("name", ns); elemName.InnerText = palletCornerProp.Name; elemPalletCorner.AppendChild(elemName); // description XmlElement elemDescription = xmlDoc.CreateElement("description", ns); elemDescription.InnerText = palletCornerProp.Description; elemPalletCorner.AppendChild(elemDescription); AppendElementValue(xmlDoc, elemPalletCorner, "length", UnitsManager.UnitType.UT_LENGTH, palletCornerProp.Length); AppendElementValue(xmlDoc, elemPalletCorner, "width", UnitsManager.UnitType.UT_LENGTH, palletCornerProp.Width); AppendElementValue(xmlDoc, elemPalletCorner, "thickness", UnitsManager.UnitType.UT_LENGTH, palletCornerProp.Thickness); AppendElementValue(xmlDoc, elemPalletCorner, "weight", UnitsManager.UnitType.UT_LENGTH, palletCornerProp.Weight); // --- // view_palletCorner_iso // build image Graphics3DImage graphics = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail)); graphics.CameraPosition = Graphics3D.Corner_0; Corner corner = new Corner(0, palletCornerProp); corner.Draw(graphics); graphics.Flush(); // save image ? SaveImageAs(graphics.Bitmap, "view_palletCorner_iso.png"); // --- // view_palletCorner_iso XmlElement elemImage = xmlDoc.CreateElement("view_palletCorner_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); elemPalletCorner.AppendChild(elemImage); }