예제 #1
0
 public FormNewBundle(Document document, BundleProperties bundleProperties)
 {
     InitializeComponent();
     // set unit labels
     UnitsManager.AdaptUnitLabels(this);
     // save document reference
     _document = document;
     _bundleProperties = bundleProperties;
     // set caption text
     Text = string.Format(Properties.Resources.ID_EDIT, _bundleProperties.Name);
     // initialize value
     tbName.Text = bundleProperties.Name;
     tbDescription.Text = bundleProperties.Description;
     BundleLength = bundleProperties.Length;
     BundleWidth = bundleProperties.Width;
     UnitThickness = bundleProperties.UnitThickness;
     UnitWeight = bundleProperties.UnitWeight;
     NoFlats = bundleProperties.NoFlats;
     // disable Ok buttons
     UpdateButtonOkStatus();
 }
예제 #2
0
 public void Save(BundleProperties bundleProperties, XmlElement parentElement, XmlDocument xmlDoc)
 {
     // create xmlPalletProperties element
     XmlElement xmlBundleProperties = xmlDoc.CreateElement("BundleProperties");
     parentElement.AppendChild(xmlBundleProperties);
     // Id
     XmlAttribute guidAttribute = xmlDoc.CreateAttribute("Id");
     guidAttribute.Value = bundleProperties.Guid.ToString();
     xmlBundleProperties.Attributes.Append(guidAttribute);
     // name
     XmlAttribute nameAttribute = xmlDoc.CreateAttribute("Name");
     nameAttribute.Value = bundleProperties.Name;
     xmlBundleProperties.Attributes.Append(nameAttribute);
     // description
     XmlAttribute descAttribute = xmlDoc.CreateAttribute("Description");
     descAttribute.Value = bundleProperties.Description;
     xmlBundleProperties.Attributes.Append(descAttribute);
     // length
     XmlAttribute lengthAttribute = xmlDoc.CreateAttribute("Length");
     lengthAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", bundleProperties.Length);
     xmlBundleProperties.Attributes.Append(lengthAttribute);
     // width
     XmlAttribute widthAttribute = xmlDoc.CreateAttribute("Width");
     widthAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", bundleProperties.Width);
     xmlBundleProperties.Attributes.Append(widthAttribute);
     // height
     XmlAttribute heightAttribute = xmlDoc.CreateAttribute("UnitThickness");
     heightAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", bundleProperties.UnitThickness);
     xmlBundleProperties.Attributes.Append(heightAttribute);
     // weight
     XmlAttribute weightAttribute = xmlDoc.CreateAttribute("UnitWeight");
     weightAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", bundleProperties.UnitWeight);
     xmlBundleProperties.Attributes.Append(weightAttribute);
     // color
     XmlAttribute colorAttribute = xmlDoc.CreateAttribute("Color");
     colorAttribute.Value = string.Format("{0}", bundleProperties.Color.ToArgb());
     xmlBundleProperties.Attributes.Append(colorAttribute);
     // numberFlats
     XmlAttribute numberFlatsAttribute = xmlDoc.CreateAttribute("NumberFlats");
     numberFlatsAttribute.Value = string.Format("{0}", bundleProperties.NoFlats);
     xmlBundleProperties.Attributes.Append(numberFlatsAttribute);
 }
예제 #3
0
 public BundleProperties CreateNewBundle(
     string name, string description
     , double length, double width, double thickness
     , double weight
     , Color color
     , int noFlats)
 {
     // instantiate and initialize
     BundleProperties bundle = new BundleProperties(this, name, description, length, width, thickness, weight, noFlats, color);
     // insert in list
     _typeList.Add(bundle);
     // notify listeners
     NotifyOnNewTypeCreated(bundle);
     Modify();
     return bundle;
 }
예제 #4
0
 private static BundleProperties LoadBundleById(Document doc, List<bundle> listBundles, string sid)
 {
     bundle bundleItem = listBundles.Find(delegate(bundle b) { return b.id == sid; });
     if (null == bundleItem)
         return null;
     else
     {
         double[] bundleDim = bundleItem.flatDimensions.ToArray();
         // instantiate bundle
         BundleProperties bundleProperties = new BundleProperties(
             doc, bundleItem.name, bundleItem.description
             , bundleDim[0], bundleDim[1], bundleDim[2]
             , bundleItem.flatWeight, (int)bundleItem.numberFlats
             , System.Drawing.Color.FromArgb((int)bundleItem.color[0], (int)bundleItem.color[1], (int)bundleItem.color[2]));
         // insert in list
         if (null != doc)
             doc.AddType(bundleProperties);
         return bundleProperties;
     }
 }
예제 #5
0
 public Box(uint pickId, BundleProperties bundleProperties)
 {
     _pickId = pickId;
     _isBundle = true;
     _dim[0] = bundleProperties.Length;
     _dim[1] = bundleProperties.Width;
     _dim[2] = bundleProperties.Height;
     _colors = new Color[6];
     for (int i = 0; i < 6; ++i)
         _colors[i] = bundleProperties.Color;
     _noFlats = bundleProperties.NoFlats;
     // IsBundle ?
     _isBundle = bundleProperties.IsBundle;
 }
예제 #6
0
 public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
 {
     BundleProperties bundleProperties = new BundleProperties(
         null, BundleName, Description
         , BundleLength, BundleWidth, UnitThickness, UnitWeight, NoFlats, Color);
     Box box = new Box(0, bundleProperties);
     graphics.AddBox(box);
     graphics.AddDimensions(new DimensionCube(BundleLength, BundleWidth, UnitThickness * NoFlats));
 }
예제 #7
0
 private void AppendBundleElement(BundleProperties bundleProp, XmlElement elemAnalysis, XmlDocument xmlDoc)
 {
     string ns = xmlDoc.DocumentElement.NamespaceURI;
     if (null == bundleProp) return;
     // bundle
     XmlElement elemBundle = CreateElement("bundle", null, elemAnalysis, xmlDoc, ns);
     elemAnalysis.AppendChild(elemBundle);
     // name
     XmlElement elemName = xmlDoc.CreateElement("name", ns);
     elemName.InnerText = bundleProp.Name;
     elemBundle.AppendChild(elemName);
     // description
     XmlElement elemDescription = xmlDoc.CreateElement("description", ns);
     elemDescription.InnerText = bundleProp.Description;
     elemBundle.AppendChild(elemDescription);
     // length / width / number of flats / unit thickness / unit weight / total thickness / total weight
     AppendElementValue(xmlDoc, elemBundle, "length", UnitsManager.UnitType.UT_LENGTH, bundleProp.Length);
     AppendElementValue(xmlDoc, elemBundle, "width", UnitsManager.UnitType.UT_LENGTH, bundleProp.Width);
     AppendElementValue(xmlDoc, elemBundle, "numberOfFlats", bundleProp.NoFlats);
     AppendElementValue(xmlDoc, elemBundle, "unitThickness", UnitsManager.UnitType.UT_LENGTH, bundleProp.UnitThickness);
     AppendElementValue(xmlDoc, elemBundle, "unitWeight", UnitsManager.UnitType.UT_MASS, bundleProp.UnitWeight);
     AppendElementValue(xmlDoc, elemBundle, "totalThickness", UnitsManager.UnitType.UT_LENGTH, bundleProp.UnitThickness * bundleProp.NoFlats);
     AppendElementValue(xmlDoc, elemBundle, "totalWeight", UnitsManager.UnitType.UT_MASS, bundleProp.UnitWeight * bundleProp.NoFlats);
     // --- build image
     Graphics3DImage graphics = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail));
     graphics.CameraPosition = Graphics3D.Corner_0;
     Box box = new Box(0, bundleProp);
     graphics.AddBox(box);
     DimensionCube dc = new DimensionCube(bundleProp.Length, bundleProp.Width, bundleProp.Height);   dc.FontSize = 6.0f;
     graphics.AddDimensions(dc);
     graphics.Flush();
     // ---
     // view_bundle_iso
     XmlElement elemImage = xmlDoc.CreateElement("view_bundle_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);
     elemBundle.AppendChild(elemImage);
     // save images ?
     SaveImageAs(graphics.Bitmap, "view_bundle_iso.png");
 }