예제 #1
0
 private void FillCombo(CheckBox chkb, ComboBox cb, ItemBase[] items, ItemBase selectedItem)
 {
     foreach (ItemBase item in items)
     {
         cb.Items.Add(new ItemBaseEncapsulator(item));
     }
     if (cb.Items.Count > 0)
     {
         if (null == selectedItem)
         {
             cb.SelectedIndex = 0;
         }
         else
         {
             for (int i = 0; i < cb.Items.Count; ++i)
             {
                 ItemBaseEncapsulator itemEncapsulator = cb.Items[i] as ItemBaseEncapsulator;
                 if (itemEncapsulator.Item == selectedItem)
                 {
                     cb.SelectedIndex = i;
                     break;
                 }
             }
         }
     }
     chkb.Checked = null != selectedItem;
     chkb.Enabled = (cb.Items.Count > 0);
 }
 private void FillCombo(ComboBox cb, ItemBase[] items, ItemBase selectedItem)
 {
     cb.Items.Clear();
     foreach (ItemBase item in items)
     {
         cb.Items.Add(new ItemBaseEncapsulator(item));
     }
     if (cb.Items.Count > 0)
     {
         if (null == selectedItem)
         {
             cb.SelectedIndex = 0;
         }
         else
         {
             for (int i = 0; i < cb.Items.Count; ++i)
             {
                 ItemBaseEncapsulator itemEncapsulator = cb.Items[i] as ItemBaseEncapsulator;
                 if (itemEncapsulator.Item == selectedItem)
                 {
                     cb.SelectedIndex = i;
                     break;
                 }
             }
         }
     }
 }
예제 #3
0
        private void FormNewAnalysisCylinder_Load(object sender, EventArgs e)
        {
            try
            {
                // name / description
                if (null != _analysis)
                {
                    tbName.Text        = _analysis.Name;
                    tbDescription.Text = _analysis.Description;
                }
                else
                {
                    tbName.Text        = _document.GetValidNewAnalysisName(Resources.ID_ANALYSIS);
                    tbDescription.Text = tbName.Text;
                }
                // fill cylinders combo
                foreach (CylinderProperties cyl in _cylinderProperties)
                {
                    cbCylinders.Items.Add(new CylinderItem(cyl));
                }
                if (cbCylinders.Items.Count > 0)
                {
                    if (null == _analysis)
                    {
                        cbCylinders.SelectedIndex = 0;
                    }
                    else
                    {
                        for (int i = 0; i < cbCylinders.Items.Count; ++i)
                        {
                            CylinderItem boxItem = cbCylinders.Items[i] as CylinderItem;
                            if (boxItem.Item == _analysis.CylinderProperties)
                            {
                                cbCylinders.SelectedIndex = i;
                                break;
                            }
                        }
                    }
                }
                // fill pallet combo
                foreach (PalletProperties pallet in _palletProperties)
                {
                    cbPallets.Items.Add(new PalletItem(pallet));
                }
                if (cbPallets.Items.Count > 0)
                {
                    if (null == _analysis)
                    {
                        cbPallets.SelectedIndex = 0;
                    }
                    else
                    {
                        for (int i = 0; i < cbPallets.Items.Count; ++i)
                        {
                            PalletItem palletItem = cbPallets.Items[i] as PalletItem;
                            if (palletItem.Item == _analysis.PalletProperties)
                            {
                                cbPallets.SelectedIndex = i;
                                break;
                            }
                        }
                    }
                }

                // fill interlayer combo
                foreach (InterlayerProperties interlayer in _interlayerProperties)
                {
                    cbInterlayers.Items.Add(new ItemBaseEncapsulator(interlayer));
                }
                if (cbInterlayers.Items.Count > 0)
                {
                    cbInterlayers.SelectedIndex = 0;
                    if (null != _analysis)
                    {
                        for (int i = 0; i < cbInterlayers.Items.Count; ++i)
                        {
                            ItemBaseEncapsulator interlayerItem = cbInterlayers.Items[i] as ItemBaseEncapsulator;
                            if (interlayerItem.Item == _analysis.InterlayerProperties)
                            {
                                cbInterlayers.SelectedIndex = i;
                                break;
                            }
                        }

                        checkBoxInterlayer.Checked = _analysis.ConstraintSet.HasInterlayer;
                        checkBoxInterlayer.Enabled = true;
                    }
                }
                else
                {
                    checkBoxInterlayer.Checked = false;
                    checkBoxInterlayer.Enabled = false;
                }

                // fill interlayer combo
                foreach (InterlayerProperties interlayer in _interlayerProperties)
                {
                    cbInterlayersAntiSlip.Items.Add(new ItemBaseEncapsulator(interlayer));
                }
                if (cbInterlayersAntiSlip.Items.Count > 0)
                {
                    cbInterlayersAntiSlip.SelectedIndex = 0;
                    if (null != _analysis)
                    {
                        for (int i = 0; i < cbInterlayersAntiSlip.Items.Count; ++i)
                        {
                            ItemBaseEncapsulator interlayerItem = cbInterlayersAntiSlip.Items[i] as ItemBaseEncapsulator;
                            if (interlayerItem.Item == _analysis.InterlayerPropertiesAntiSlip)
                            {
                                cbInterlayersAntiSlip.SelectedIndex = i;
                                break;
                            }
                        }

                        checkBoxInterlayerAntiSlip.Checked = _analysis.ConstraintSet.HasInterlayerAntiSlip;
                        checkBoxInterlayerAntiSlip.Enabled = true;
                    }
                }
                else
                {
                    checkBoxInterlayer.Checked = false;
                    checkBoxInterlayer.Enabled = false;
                }

                // overhang
                if (null == _analysis)
                {
                    OverhangX = Settings.Default.OverhangX;
                    OverhangY = Settings.Default.OverhangY;
                }
                else
                {
                    OverhangX = _analysis.ConstraintSet.OverhangX;
                    OverhangY = _analysis.ConstraintSet.OverhangY;
                }
                // stop stacking criterions
                if (null == _analysis)
                {
                    UseMaximumNumberOfItems       = false;
                    UseMaximumPalletHeight        = true;
                    UseMaximumPalletWeight        = false;
                    UseMaximumLoadOnLowerCylinder = false;

                    MaximumNumberOfItems       = 500;
                    MaximumPalletHeight        = UnitsManager.ConvertLengthFrom(Settings.Default.MaximumPalletHeight, UnitsManager.UnitSystem.UNIT_METRIC1);
                    MaximumPalletWeight        = UnitsManager.ConvertMassFrom(Settings.Default.MaximumPalletWeight, UnitsManager.UnitSystem.UNIT_METRIC1);
                    MaximumLoadOnLowerCylinder = UnitsManager.ConvertMassFrom(100.0, UnitsManager.UnitSystem.UNIT_METRIC1);
                }
                else
                {
                    UseMaximumNumberOfItems       = _analysis.ConstraintSet.UseMaximumNumberOfItems;
                    UseMaximumPalletHeight        = _analysis.ConstraintSet.UseMaximumPalletHeight;
                    UseMaximumPalletWeight        = _analysis.ConstraintSet.UseMaximumPalletWeight;
                    UseMaximumLoadOnLowerCylinder = _analysis.ConstraintSet.UseMaximumLoadOnLowerCylinder;

                    MaximumNumberOfItems       = _analysis.ConstraintSet.MaximumNumberOfItems;
                    MaximumPalletHeight        = _analysis.ConstraintSet.MaximumPalletHeight;
                    MaximumPalletWeight        = _analysis.ConstraintSet.MaximumPalletWeight;
                    MaximumLoadOnLowerCylinder = _analysis.ConstraintSet.MaximumLoadOnLowerCylinder;
                }
                UpdateButtonOkStatus();
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }