示例#1
0
        /// <summary>
        /// FormNewBox constructor used when defining a new BoxProperties item
        /// </summary>
        /// <param name="document">Document in which the BoxProperties item is to be created</param>
        /// <param name="mode">Mode is either Mode.MODE_CASE or Mode.MODE_BOX</param>
        public FormNewBox(Document document, Mode mode)
        {
            InitializeComponent();
            // set unit labels
            UnitsManager.AdaptUnitLabels(this);
            // save document reference
            _document = document;
            // mode
            _mode = mode;

            switch (_mode)
            {
                case Mode.MODE_CASE:
                    tbName.Text = _document.GetValidNewTypeName(Resources.ID_CASE);
                    nudLength.Value = (decimal)UnitsManager.ConvertLengthFrom(400.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                    nudWidth.Value = (decimal)UnitsManager.ConvertLengthFrom(300.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                    nudHeight.Value = (decimal)UnitsManager.ConvertLengthFrom(200.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                    nudInsideLength.Value = nudLength.Value - (decimal)UnitsManager.ConvertLengthFrom(6.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                    nudInsideWidth.Value = nudWidth.Value - (decimal)UnitsManager.ConvertLengthFrom(6.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                    nudInsideHeight.Value = nudHeight.Value - (decimal)UnitsManager.ConvertLengthFrom(6.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                    nudTapeWidth.Value = (decimal)UnitsManager.ConvertLengthFrom(50, UnitsManager.UnitSystem.UNIT_METRIC1);
                    cbTapeColor.Color = Color.Beige;
                    break;
                case Mode.MODE_BOX:
                    tbName.Text = _document.GetValidNewTypeName(Resources.ID_BOX);
                    nudLength.Value = (decimal)UnitsManager.ConvertLengthFrom(120.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                    nudWidth.Value = (decimal)UnitsManager.ConvertLengthFrom(60.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                    nudHeight.Value = (decimal)UnitsManager.ConvertLengthFrom(30.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                    nudInsideLength.Value = nudLength.Value - (decimal)UnitsManager.ConvertLengthFrom(6.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                    nudInsideWidth.Value = nudWidth.Value - (decimal)UnitsManager.ConvertLengthFrom(6.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                    nudInsideHeight.Value = nudHeight.Value - (decimal)UnitsManager.ConvertLengthFrom(6.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                    break;
                default:
                    break;
            }
            // description (same as name)
            tbDescription.Text = tbName.Text;
            // color : all faces set together / face by face
            chkAllFaces.Checked = false;
            chkAllFaces_CheckedChanged(this, null);
            // set colors
            for (int i=0; i<6; ++i)
                _faceColors[i] = _mode == Mode.MODE_BOX ? Color.Turquoise : Color.Chocolate;
            // set textures
            _textures = new List<Pair<HalfAxis.HAxis, Texture>>();
            // set default face
            cbFace.SelectedIndex = 0;
            // net weight
            NetWeight = new OptDouble(false, UnitsManager.ConvertMassFrom(0.0, UnitsManager.UnitSystem.UNIT_METRIC1));
            // disable Ok button
            UpdateButtonOkStatus();
        }
示例#2
0
 private static void AppendElementValue(XmlDocument xmlDoc, XmlElement parent, string eltName, UnitsManager.UnitType unitType, OptDouble optValue)
 {
     if (optValue.Activated)
     {
         // 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), optValue.Value);
         createdElement.AppendChild(valueElement);
     }
 }
示例#3
0
 private void SaveOptDouble(OptDouble optD, XmlDocument xmlDoc, XmlElement xmlElement, string attributeName)
 {
     XmlAttribute att = xmlDoc.CreateAttribute(attributeName);
     att.Value = optD.ToString();
     xmlElement.Attributes.Append(att);
 }
示例#4
0
 public OptDouble(OptDouble optValue)
 {
     _activated = optValue._activated;
     _val = optValue._val;
 }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            ComboBoxHelpers.FillCombo(_packs, cbPack, (null != _analysis) ? _analysis.PackProperties : _packs[0]);
            ComboBoxHelpers.FillCombo(_pallets, cbPallet, (null != _analysis) ? _analysis.PalletProperties : _pallets[0]);
            ComboBoxHelpers.FillCombo(_interlayers, cbInterlayer, (null != _analysis ? _analysis.InterlayerProperties : (_interlayers.Length > 0 ? _interlayers[0] : null)));

            chkbInterlayer.Enabled = cbInterlayer.Items.Count > 0;
            chkbInterlayer.Checked = (null != _analysis) ? _analysis.HasInterlayer : false;

            PackPalletConstraintSet constraintSet = (null != _analysis) ? _analysis.ConstraintSet : null;

            if (null != constraintSet)
            {
                chkbInterlayerFirstLayer.Checked = constraintSet.HasFirstInterlayer;

                OverhangX = constraintSet.OverhangX;
                OverhangY = constraintSet.OverhangY;

                MinimumOverhangX = constraintSet.MinOverhangX;
                MinimumOverhangY = constraintSet.MinOverhangY;

                MaximumSpace = constraintSet.MaximumSpaceAllowed;
                MinimumSpace = constraintSet.MinimumSpace;

                MaximumPalletHeight = constraintSet.MaximumPalletHeight;
                MaximumPalletWeight = constraintSet.MaximumPalletWeight;

                MaximumLayerWeight = constraintSet.MaximumLayerWeight;
            }
            else
            {
                chkbInterlayerFirstLayer.Checked = false;

                OverhangX = Settings.Default.OverhangX;
                OverhangY = Settings.Default.OverhangY;

                MinimumOverhangX = OptDouble.Zero;
                MinimumOverhangY = OptDouble.Zero;

                MaximumSpace = OptDouble.Zero;
                MinimumSpace = OptDouble.Zero;

                MaximumPalletHeight = new OptDouble(true, UnitsManager.ConvertLengthFrom(1200.0, UnitsManager.UnitSystem.UNIT_METRIC1));
                MaximumPalletWeight = new OptDouble(false, UnitsManager.ConvertMassFrom(1000.0, UnitsManager.UnitSystem.UNIT_METRIC1));

                MaximumLayerWeight = new OptDouble(false, UnitsManager.ConvertMassFrom(100.0, UnitsManager.UnitSystem.UNIT_METRIC1));
            }

            onInterlayerChecked(this, null);
            UpdateStatus(string.Empty);
        }
示例#6
0
 /// <summary>
 /// Converts the specified string to its <see cref="OptDouble"/> equivalent.
 /// </summary>
 /// <param name="value">A string representation of a <see cref="OptDouble"/>.</param>
 /// <param name="result">When this method returns, if the conversion succeeded,
 /// contains a <see cref="OptDouble"/> reprensention the OptValue specified by <paramref name="value"/>.
 /// </param>
 /// <returns><see langword="true"/> if value was converted successfully; otherwise, <see langword="false"/>.</returns>
 public static bool TryParse(string value, out OptDouble result)
 {
     Regex r = new Regex(@"\((?<o>),(?<v>.*)\)", RegexOptions.Singleline);
     Match m = r.Match(value);
     if (m.Success)
     {
         result = new OptDouble(
             bool.Parse(m.Result("${o}")),
             double.Parse(m.Result("${v}"), System.Globalization.CultureInfo.InvariantCulture)
             );
         return true;
     }
     result = OptDouble.Zero;
     return false;
 }
示例#7
0
 public static OptDouble Negate(OptDouble optValue)
 {
     return new OptDouble(optValue._activated, -optValue._val);
 }
示例#8
0
 public OptDouble(OptDouble optValue)
 {
     _activated = optValue._activated;
     _val       = optValue._val;
 }
示例#9
0
 public static OptDouble operator -(OptDouble optValue)
 {
     return(OptDouble.Negate(optValue));
 }
示例#10
0
 public static OptDouble Negate(OptDouble optValue)
 {
     return(new OptDouble(optValue._activated, -optValue._val));
 }