public DataDef(string name, Type type, UnitsManager.UnitType unitType, bool sortable)
 {
     Name = name;
     Type = type;
     Sortable = sortable;
     UnitType = unitType;
 }
        public void Save()
        {
            XmlDocument xmlDoc = new XmlDocument();
            // solutions
            // let's add the XML declaration section
            XmlNode xmlnode = xmlDoc.CreateNode(XmlNodeType.XmlDeclaration, "", "");

            xmlDoc.AppendChild(xmlnode);
            // create Document (root) element
            XmlElement xmlRootElement = xmlDoc.CreateElement("Solutions");

            xmlDoc.AppendChild(xmlRootElement);
            foreach (PalletSolutionDesc desc in _palletSolutionList)
            {
                // solution element
                XmlElement solutionElt = xmlDoc.CreateElement("Solution");
                xmlRootElement.AppendChild(solutionElt);
                // pallet dimensions
                XmlAttribute palletDimensions = xmlDoc.CreateAttribute("PalletDimensions");
                palletDimensions.Value = desc.Key.PalletDimensions;
                solutionElt.Attributes.Append(palletDimensions);
                // overhang
                XmlAttribute overhang = xmlDoc.CreateAttribute("Overhang");
                overhang.Value = desc.Key.Overhang;
                solutionElt.Attributes.Append(overhang);
                // case dimensions
                XmlAttribute caseDimensions = xmlDoc.CreateAttribute("CaseDimensions");
                caseDimensions.Value = desc.CaseDimensionsString;
                solutionElt.Attributes.Append(caseDimensions);
                // inside dimensions
                XmlAttribute caseInsideDimensions = xmlDoc.CreateAttribute("CaseInsideDimensions");
                caseInsideDimensions.Value = desc.CaseInsideDimensionsString;
                solutionElt.Attributes.Append(caseInsideDimensions);
                // case weight
                XmlAttribute caseWeightAttribute = xmlDoc.CreateAttribute("CaseWeight");
                caseWeightAttribute.Value = UnitsManager.ConvertMassTo(desc.CaseWeight, UnitsManager.UnitSystem.UNIT_METRIC1).ToString(CultureInfo.InvariantCulture);
                solutionElt.Attributes.Append(caseWeightAttribute);
                // palletWeight
                XmlAttribute palletWeightAttribute = xmlDoc.CreateAttribute("PalletWeight");
                palletWeightAttribute.Value = UnitsManager.ConvertMassTo(desc.PalletWeight, UnitsManager.UnitSystem.UNIT_METRIC1).ToString(CultureInfo.InvariantCulture);
                solutionElt.Attributes.Append(palletWeightAttribute);
                // case count
                XmlAttribute caseCount = xmlDoc.CreateAttribute("CaseCount");
                caseCount.Value = string.Format("{0}", desc.CaseCount);
                solutionElt.Attributes.Append(caseCount);
                // friendly name
                XmlAttribute friendlyName = xmlDoc.CreateAttribute("FriendlyName");
                friendlyName.Value = string.Format("{0}", desc.FriendlyName);
                solutionElt.Attributes.Append(friendlyName);
                // guid
                XmlAttribute guid = xmlDoc.CreateAttribute("Guid");
                guid.Value = string.Format("{0}", desc.Guid);
                solutionElt.Attributes.Append(guid);
            }

            xmlDoc.Save(IndexPath);
        }
 private static IUnit<SurfaceDensity> SurfaceMassUnitFromUnitSystem(UnitsManager.UnitSystem unitSystem)
 {
     switch (unitSystem)
     {
         case UnitsManager.UnitSystem.UNIT_METRIC1: return Cureos.Measures.Quantities.SurfaceDensity.KiloGramPerSquareMeter;
         case UnitsManager.UnitSystem.UNIT_METRIC2: return Cureos.Measures.Quantities.SurfaceDensity.KiloGramPerSquareMeter;
         case UnitsManager.UnitSystem.UNIT_IMPERIAL: return Cureos.Measures.Quantities.SurfaceDensity.PoundPerSquareInch;
         case UnitsManager.UnitSystem.UNIT_US: return Cureos.Measures.Quantities.SurfaceDensity.PoundPerSquareInch;
         default: throw new Exception("Invalid unit system!");
     }
 }
 private static IUnit<Mass> MassUnitFromUnitSystem(UnitsManager.UnitSystem unitSystem)
 {
     switch (unitSystem)
     {
         case UnitsManager.UnitSystem.UNIT_METRIC1: return Cureos.Measures.Quantities.Mass.KiloGram;
         case UnitsManager.UnitSystem.UNIT_METRIC2: return Cureos.Measures.Quantities.Mass.KiloGram;
         case UnitsManager.UnitSystem.UNIT_IMPERIAL: return Cureos.Measures.Quantities.Mass.Pound;
         case UnitsManager.UnitSystem.UNIT_US: return Cureos.Measures.Quantities.Mass.Pound;
         default: throw new Exception("Invalid unit system!");
     }
 }
 private static IUnit<Length> LengthUnitFromUnitSystem(UnitsManager.UnitSystem unitSystem)
 {
     switch (unitSystem)
     {
         case UnitsManager.UnitSystem.UNIT_METRIC1: return Cureos.Measures.Quantities.Length.MilliMeter;
         case UnitsManager.UnitSystem.UNIT_METRIC2: return Cureos.Measures.Quantities.Length.CentiMeter;
         case UnitsManager.UnitSystem.UNIT_IMPERIAL: return Cureos.Measures.Quantities.Length.Inch;
         case UnitsManager.UnitSystem.UNIT_US: return Cureos.Measures.Quantities.Length.Inch;
         default: throw new Exception("Invalid unit system!");
     }
 }
 public static double ConvertSurfaceMassFrom(double value, UnitsManager.UnitSystem unitSystem)
 {
     if (unitSystem == CurrentUnitSystem)
         return value;
     else
     {
         StandardMeasure<SurfaceDensity> measure = new StandardMeasure<SurfaceDensity>(value, SurfaceMassUnitFromUnitSystem(unitSystem));
         return measure.GetAmount(SurfaceMassUnitFromUnitSystem(CurrentUnitSystem));
     }
 }
 public static double ConvertMassTo(double value, UnitsManager.UnitSystem unitSystem)
 {
     if (unitSystem == CurrentUnitSystem)
         return value;
     else
     {
         StandardMeasure<Mass> measure = new StandardMeasure<Mass>(value, MassUnitFromUnitSystem(CurrentUnitSystem));
         return measure.GetAmount(MassUnitFromUnitSystem(unitSystem));
     }
 }
 public static double ConvertLengthTo(double value, UnitsManager.UnitSystem unitSystem)
 {
     if (unitSystem == CurrentUnitSystem)
         return value;
     else
     {
         StandardMeasure<Length> measure = new StandardMeasure<Length>(value, LengthUnitFromUnitSystem(CurrentUnitSystem));
         return measure.GetAmount(LengthUnitFromUnitSystem(unitSystem));
     }
 }
 public static Vector3D ConvertLengthFrom(Vector3D value, UnitsManager.UnitSystem unitSystem)
 {
     if (unitSystem == CurrentUnitSystem)
         return value;
     else
     {
         StandardMeasure<Length> measureX = new StandardMeasure<Length>(value.X, LengthUnitFromUnitSystem(unitSystem));
         StandardMeasure<Length> measureY = new StandardMeasure<Length>(value.Y, LengthUnitFromUnitSystem(unitSystem));
         StandardMeasure<Length> measureZ = new StandardMeasure<Length>(value.Z, LengthUnitFromUnitSystem(unitSystem));
         return new Vector3D(
             measureX.GetAmount(LengthUnitFromUnitSystem(CurrentUnitSystem))
             , measureY.GetAmount(LengthUnitFromUnitSystem(CurrentUnitSystem))
             , measureZ.GetAmount(LengthUnitFromUnitSystem(CurrentUnitSystem))
             );
     }
 }
示例#10
0
 private OptDouble LoadOptDouble(XmlElement xmlElement, string attribute, UnitsManager.UnitType unitType)
 {
     if (!xmlElement.HasAttribute(attribute))
         return new OptDouble(false, 0.0);
     else
     {
         OptDouble optD = OptDouble.Parse(xmlElement.Attributes[attribute].Value);
         switch (unitType)
         {
             case UnitsManager.UnitType.UT_LENGTH:
                 optD.Value = UnitsManager.ConvertLengthFrom(optD.Value, _unitSystem);
                 break;
             case UnitsManager.UnitType.UT_MASS:
                 optD.Value = UnitsManager.ConvertMassFrom(optD.Value, _unitSystem);
                 break;
             default:
                 Debug.Assert(false);
                 break;
         }
         return optD;
     }
 }
示例#11
0
 private static void AppendElementValue(XmlDocument xmlDoc, XmlElement parent, string eltName, UnitsManager.UnitType unitType, double eltValue)
 {
     // eltName
     XmlElement createdElement = xmlDoc.CreateElement(eltName, xmlDoc.DocumentElement.NamespaceURI);
     parent.AppendChild(createdElement);
     // unit
     XmlElement unitElement = xmlDoc.CreateElement("unit", xmlDoc.DocumentElement.NamespaceURI);
     unitElement.InnerText = UnitsManager.UnitString(unitType);
     createdElement.AppendChild(unitElement);
     // value
     XmlElement valueElement = xmlDoc.CreateElement("value", xmlDoc.DocumentElement.NamespaceURI);
     valueElement.InnerText = string.Format(UnitsManager.UnitFormat(unitType), eltValue);
     createdElement.AppendChild(valueElement);
 }