/// <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(); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // font size GridFontSize = 8; // fill combo boxes cbBoxes.Initialize(_doc, this, null); // initialize orientation uCtrlCaseOrient.AllowedOrientations = new bool[] { Settings.Default.AllowVerticalX, Settings.Default.AllowVerticalY, Settings.Default.AllowVerticalZ }; // initialize grid gridSolutions.Selection.SelectionChanged += new SourceGrid.RangeRegionChangedEventHandler(onSelChangeGrid); // load cases DCSBCase[] sbCases = WCFClientSingleton.Instance.Client.GetAllCases(); foreach (DCSBCase sbCase in sbCases) { try { // get values from database if (!sbCase.HasInnerDims) { continue; } UnitsManager.UnitSystem us = (UnitsManager.UnitSystem)sbCase.UnitSystem; double boxLength = UnitsManager.ConvertLengthFrom(sbCase.DimensionsOuter.M0, us); double boxWidth = UnitsManager.ConvertLengthFrom(sbCase.DimensionsOuter.M1, us); double boxHeight = UnitsManager.ConvertLengthFrom(sbCase.DimensionsOuter.M2, us); double innerLength = UnitsManager.ConvertLengthFrom(sbCase.DimensionsInner.M0, us); double innerWidth = UnitsManager.ConvertLengthFrom(sbCase.DimensionsInner.M1, us); double innerHeight = UnitsManager.ConvertLengthFrom(sbCase.DimensionsInner.M2, us); double weight = UnitsManager.ConvertMassFrom(sbCase.Weight, us); Color[] colors = new Color[6]; for (int i = 0; i < 6; ++i) { colors[i] = Color.FromArgb(sbCase.Colors[i]); } // instantiate box properties BoxProperties bProperties = new BoxProperties(null , boxLength, boxWidth, boxHeight , innerLength, innerWidth, innerHeight); bProperties.ID.SetNameDesc(sbCase.Name, sbCase.Description); bProperties.SetWeight(weight); bProperties.TapeWidth = new OptDouble(sbCase.ShowTape, sbCase.TapeWidth); bProperties.TapeColor = Color.FromArgb(sbCase.TapeColor); bProperties.SetAllColors(colors); // insert in listbox control chklbCases.Items.Add(new ItemBaseCB(bProperties), true); } catch (Exception ex) { _log.Error(ex.Message); } } // update graph control graphCtrl.DrawingContainer = this; }
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); }
private void FillGridPallets(WCFClient wcfClient) { // initialize grid List <string> captions = new List <string> { string.Format(Properties.Resources.ID_DIMENSIONS, UnitsManager.UnitString(UnitsManager.UnitType.UT_LENGTH)), string.Format(Properties.Resources.ID_WEIGHT_WU, UnitsManager.UnitString(UnitsManager.UnitType.UT_MASS)) }; GridInitialize(gridPallets, captions); // handling delete event SourceGrid.Cells.Controllers.CustomEvents buttonDelete = new SourceGrid.Cells.Controllers.CustomEvents(); buttonDelete.Click += new EventHandler(OnDeleteItem); _pallets = wcfClient.Client.GetAllPalletsSearch(SearchString, SearchDescription, RangeIndex, ref _numberOfItems, false); int iIndex = 0; foreach (DCSBPallet p in _pallets) { UnitsManager.UnitSystem us = (UnitsManager.UnitSystem)p.UnitSystem; gridPallets.Rows.Insert(++iIndex); int iCol = 0; gridPallets[iIndex, iCol++] = new SourceGrid.Cells.Cell(p.Name); gridPallets[iIndex, iCol++] = new SourceGrid.Cells.Cell(p.Description); gridPallets[iIndex, iCol++] = new SourceGrid.Cells.Cell( string.Format("{0:0.##} x {1:0.##} x {2:0.##}", UnitsManager.ConvertLengthFrom(p.Dimensions.M0, us), UnitsManager.ConvertLengthFrom(p.Dimensions.M1, us), UnitsManager.ConvertLengthFrom(p.Dimensions.M2, us)) ); gridPallets[iIndex, iCol++] = new SourceGrid.Cells.Cell( string.Format("{0:0.###}", UnitsManager.ConvertMassFrom(p.Weight, us)) ); gridPallets[iIndex, iCol] = new SourceGrid.Cells.Button("") { Image = Properties.Resources.Delete }; gridPallets[iIndex, iCol++].AddController(buttonDelete); } GridFinalize(gridPallets); }
/// <summary> /// Constructor (new truck properties) /// </summary> /// <param name="document">Document to which the new item will belong</param> public FormNewTruck(Document document) { InitializeComponent(); // set unit labels UnitsManager.AdaptUnitLabels(this); // save document reference _document = document; // initialize data tbName.Text = _document.GetValidNewTypeName(Resources.ID_TRUCK); TruckLength = UnitsManager.ConvertLengthFrom(13600, UnitsManager.UnitSystem.UNIT_METRIC1); TruckWidth = UnitsManager.ConvertLengthFrom(2450, UnitsManager.UnitSystem.UNIT_METRIC1); TruckHeight = UnitsManager.ConvertLengthFrom(2700, UnitsManager.UnitSystem.UNIT_METRIC1); TruckAdmissibleLoadWeight = UnitsManager.ConvertMassFrom(38000, UnitsManager.UnitSystem.UNIT_METRIC1); TruckColor = Color.LightBlue; // description tbDescription.Text = tbName.Text; // disable Ok button UpdateButtonOkStatus(); }
private void onPalletTypeChanged(object sender, EventArgs e) { PalletData palletData = PalletData.GetByName(PalletTypeName); if (null == palletData) { return; } // set name / description / length / width / height / weight PalletName = palletData.Name; Description = palletData.Description; PalletLength = UnitsManager.ConvertLengthFrom(palletData.Length, UnitsManager.UnitSystem.UNIT_METRIC1); PalletWidth = UnitsManager.ConvertLengthFrom(palletData.Width, UnitsManager.UnitSystem.UNIT_METRIC1); PalletHeight = UnitsManager.ConvertLengthFrom(palletData.Height, UnitsManager.UnitSystem.UNIT_METRIC1); Weight = UnitsManager.ConvertMassFrom(palletData.Weight, UnitsManager.UnitSystem.UNIT_METRIC1); PalletColor = palletData.Color; graphCtrl.Invalidate(); }
public FormNewCylinder(Document document) { InitializeComponent(); // set unit labels UnitsManager.AdaptUnitLabels(this); // save document reference _document = document; // name / description tbName.Text = _document.GetValidNewTypeName(Resources.ID_CYLINDER); tbDescription.Text = tbName.Text; // properties nudDiameterOuter.Value = (decimal)UnitsManager.ConvertLengthFrom(2.0 * 75.0, UnitsManager.UnitSystem.UNIT_METRIC1); nudDiameterInner.Value = (decimal)UnitsManager.ConvertLengthFrom(0.0, UnitsManager.UnitSystem.UNIT_METRIC1); nudHeight.Value = (decimal)UnitsManager.ConvertLengthFrom(150.0, UnitsManager.UnitSystem.UNIT_METRIC1); nudWeight.Value = (decimal)UnitsManager.ConvertMassFrom(1.0, UnitsManager.UnitSystem.UNIT_METRIC1); cbColorWallOuter.Color = System.Drawing.Color.LightSkyBlue; cbColorWallInner.Color = System.Drawing.Color.Chocolate; cbColorTop.Color = System.Drawing.Color.Gray; // disable Ok button UpdateButtonOkStatus(); }
static public void InsertDefaultItems(DocumentSB docSB) { if (null == docSB) { return; } try { using (WCFClient wcfClient = new WCFClient()) { // pallets int rangeIndex = 0, numberOfItems = 0; do { DCSBPallet[] pallets = wcfClient.Client.GetAllPalletsAuto(rangeIndex++, ref numberOfItems, true); foreach (var dcsbPallet in pallets) { UnitsManager.UnitSystem us = (UnitsManager.UnitSystem)dcsbPallet.UnitSystem; PalletProperties palletProperties = docSB.CreateNewPallet( dcsbPallet.Name, dcsbPallet.Description, dcsbPallet.PalletType, UnitsManager.ConvertLengthFrom(dcsbPallet.Dimensions.M0, us), UnitsManager.ConvertLengthFrom(dcsbPallet.Dimensions.M1, us), UnitsManager.ConvertLengthFrom(dcsbPallet.Dimensions.M2, us), UnitsManager.ConvertMassFrom(dcsbPallet.Weight, us), Color.FromArgb(dcsbPallet.Color)); if (null != dcsbPallet.AdmissibleLoad) { palletProperties.AdmissibleLoadWeight = UnitsManager.ConvertMassFrom(dcsbPallet.AdmissibleLoad.Value, us); } } }while ((rangeIndex + 1) * 20 < numberOfItems); // cases rangeIndex = 0; numberOfItems = 0; do { DCSBCase[] cases = wcfClient.Client.GetAllCasesAuto(rangeIndex++, ref numberOfItems, true); foreach (var dcsbCase in cases) { UnitsManager.UnitSystem us = (UnitsManager.UnitSystem)dcsbCase.UnitSystem; var colors = new Color[6]; for (int i = 0; i < 6; ++i) { colors[i] = Color.FromArgb(dcsbCase.Colors[i]); } BoxProperties bProperties = null; if (dcsbCase.IsCase) { bProperties = docSB.CreateNewCase(dcsbCase.Name, dcsbCase.Description, UnitsManager.ConvertLengthFrom(dcsbCase.DimensionsOuter.M0, us), UnitsManager.ConvertLengthFrom(dcsbCase.DimensionsOuter.M1, us), UnitsManager.ConvertLengthFrom(dcsbCase.DimensionsOuter.M2, us), UnitsManager.ConvertLengthFrom(dcsbCase.DimensionsInner.M0, us), UnitsManager.ConvertLengthFrom(dcsbCase.DimensionsInner.M1, us), UnitsManager.ConvertLengthFrom(dcsbCase.DimensionsInner.M2, us), UnitsManager.ConvertMassFrom(dcsbCase.Weight, us), colors); } else { bProperties = docSB.CreateNewBox( dcsbCase.Name, dcsbCase.Description, UnitsManager.ConvertLengthFrom(dcsbCase.DimensionsOuter.M0, us), UnitsManager.ConvertLengthFrom(dcsbCase.DimensionsOuter.M1, us), UnitsManager.ConvertLengthFrom(dcsbCase.DimensionsOuter.M2, us), UnitsManager.ConvertMassFrom(dcsbCase.Weight, us), colors); } bProperties.TapeWidth = new OptDouble(dcsbCase.IsCase && dcsbCase.ShowTape, UnitsManager.ConvertLengthFrom(dcsbCase.TapeWidth, us)); bProperties.TapeColor = Color.FromArgb(dcsbCase.TapeColor); bProperties.SetNetWeight( new OptDouble(!dcsbCase.HasInnerDims && dcsbCase.NetWeight.HasValue , dcsbCase.NetWeight ?? 0.0)); List <Pair <HalfAxis.HAxis, Texture> > textures = new List <Pair <HalfAxis.HAxis, Texture> >(); bProperties.TextureList = textures; } }while ((rangeIndex + 1) * 20 < numberOfItems); // bundles rangeIndex = 0; numberOfItems = 0; do { DCSBBundle[] bundles = wcfClient.Client.GetAllBundlesAuto(rangeIndex++, ref numberOfItems, true); foreach (var dcsbBundle in bundles) { UnitsManager.UnitSystem us = (UnitsManager.UnitSystem)dcsbBundle.UnitSystem; docSB.CreateNewBundle(dcsbBundle.Name, dcsbBundle.Description, UnitsManager.ConvertLengthFrom(dcsbBundle.DimensionsUnit.M0, us), UnitsManager.ConvertLengthFrom(dcsbBundle.DimensionsUnit.M1, us), UnitsManager.ConvertLengthFrom(dcsbBundle.DimensionsUnit.M2, us), UnitsManager.ConvertMassFrom(dcsbBundle.UnitWeight, us), Color.FromArgb(dcsbBundle.Color), dcsbBundle.Number); } }while ((rangeIndex + 1) * 20 < numberOfItems); // interlayers rangeIndex = 0; numberOfItems = 0; do { DCSBInterlayer[] interlayers = wcfClient.Client.GetAllInterlayersAuto(rangeIndex++, ref numberOfItems, true); foreach (var dcsbInterlayer in interlayers) { UnitsManager.UnitSystem us = (UnitsManager.UnitSystem)dcsbInterlayer.UnitSystem; docSB.CreateNewInterlayer(dcsbInterlayer.Name, dcsbInterlayer.Description, UnitsManager.ConvertLengthFrom(dcsbInterlayer.Dimensions.M0, us), UnitsManager.ConvertLengthFrom(dcsbInterlayer.Dimensions.M1, us), UnitsManager.ConvertLengthFrom(dcsbInterlayer.Dimensions.M2, us), UnitsManager.ConvertMassFrom(dcsbInterlayer.Weight, us), Color.FromArgb(dcsbInterlayer.Color) ); } }while ((rangeIndex + 1) * 20 < numberOfItems); // trucks rangeIndex = 0; numberOfItems = 0; do { DCSBTruck[] trucks = wcfClient.Client.GetAllTrucksAuto(rangeIndex++, ref numberOfItems, true); foreach (var dcsbTruck in trucks) { UnitsManager.UnitSystem us = (UnitsManager.UnitSystem)dcsbTruck.UnitSystem; docSB.CreateNewTruck(dcsbTruck.Name, dcsbTruck.Description, UnitsManager.ConvertLengthFrom(dcsbTruck.DimensionsInner.M0, us), UnitsManager.ConvertLengthFrom(dcsbTruck.DimensionsInner.M1, us), UnitsManager.ConvertLengthFrom(dcsbTruck.DimensionsInner.M2, us), UnitsManager.ConvertMassFrom(dcsbTruck.AdmissibleLoad, us), Color.FromArgb(dcsbTruck.Color) ); } }while ((rangeIndex + 1) * 20 < numberOfItems); // cylinders rangeIndex = 0; numberOfItems = 0; do { DCSBCylinder[] cylinders = wcfClient.Client.GetAllCylindersAuto(rangeIndex++, ref numberOfItems, true); foreach (var dcsbCylinder in cylinders) { UnitsManager.UnitSystem us = (UnitsManager.UnitSystem)dcsbCylinder.UnitSystem; docSB.CreateNewCylinder( dcsbCylinder.Name, dcsbCylinder.Description, UnitsManager.ConvertLengthFrom(dcsbCylinder.RadiusOuter, us), UnitsManager.ConvertLengthFrom(dcsbCylinder.RadiusInner, us), UnitsManager.ConvertLengthFrom(dcsbCylinder.Height, us), UnitsManager.ConvertMassFrom(dcsbCylinder.Weight, us), Color.FromArgb(dcsbCylinder.ColorTop), Color.FromArgb(dcsbCylinder.ColorOuter), Color.FromArgb(dcsbCylinder.ColorInner) ); } }while ((rangeIndex + 1) * 20 < numberOfItems); // pallet corners rangeIndex = 0; numberOfItems = 0; do { DCSBPalletCorner[] palletCorners = wcfClient.Client.GetAllPalletCornersAuto(rangeIndex++, ref numberOfItems, true); foreach (var dcsbPalletCorner in palletCorners) { UnitsManager.UnitSystem us = (UnitsManager.UnitSystem)dcsbPalletCorner.UnitSystem; docSB.CreateNewPalletCorners( dcsbPalletCorner.Name, dcsbPalletCorner.Description, UnitsManager.ConvertLengthFrom(dcsbPalletCorner.Length, us), UnitsManager.ConvertLengthFrom(dcsbPalletCorner.Width, us), UnitsManager.ConvertLengthFrom(dcsbPalletCorner.Thickness, us), UnitsManager.ConvertMassFrom(dcsbPalletCorner.Weight, us), Color.FromArgb(dcsbPalletCorner.Color) ); } }while ((rangeIndex + 1) * 20 < numberOfItems); // pallet caps rangeIndex = 0; numberOfItems = 0; do { DCSBPalletCap[] palletCaps = wcfClient.Client.GetAllPalletCapsAuto(rangeIndex++, ref numberOfItems, true); foreach (var dcsbCap in palletCaps) { UnitsManager.UnitSystem us = (UnitsManager.UnitSystem)dcsbCap.UnitSystem; docSB.CreateNewPalletCap( dcsbCap.Name, dcsbCap.Description, UnitsManager.ConvertLengthFrom(dcsbCap.DimensionsOuter.M0, us), UnitsManager.ConvertLengthFrom(dcsbCap.DimensionsOuter.M1, us), UnitsManager.ConvertLengthFrom(dcsbCap.DimensionsOuter.M2, us), UnitsManager.ConvertLengthFrom(dcsbCap.DimensionsInner.M0, us), UnitsManager.ConvertLengthFrom(dcsbCap.DimensionsInner.M1, us), UnitsManager.ConvertLengthFrom(dcsbCap.DimensionsInner.M2, us), UnitsManager.ConvertMassFrom(dcsbCap.Weight, us), Color.FromArgb(dcsbCap.Color) ); } }while ((rangeIndex + 1) * 20 < numberOfItems); // pallet films rangeIndex = 0; numberOfItems = 0; do { DCSBPalletFilm[] palletFilms = wcfClient.Client.GetAllPalletFilmsAuto(rangeIndex++, ref numberOfItems, true); foreach (var dcsbPalletFilm in palletFilms) { UnitsManager.UnitSystem us = (UnitsManager.UnitSystem)dcsbPalletFilm.UnitSystem; docSB.CreateNewPalletFilm(dcsbPalletFilm.Name, dcsbPalletFilm.Description, dcsbPalletFilm.UseTransparency, dcsbPalletFilm.UseHatching, dcsbPalletFilm.HatchingSpace, dcsbPalletFilm.HatchingAngle, Color.FromArgb(dcsbPalletFilm.Color)); } }while ((rangeIndex + 1) * 20 < numberOfItems); } // using } catch (Exception ex) { _log.Error(ex.ToString()); } }
private void OnFillListCases(object sender, EventArgs e) { // sanity check if (null == ListCases || ListCases.Count < 1) { return; } // clear check list chklbCases.Items.Clear(); // fill list of cases foreach (DCSBCase sbCase in ListCases) { try { // get values from database if (!sbCase.HasInnerDims) { continue; } UnitsManager.UnitSystem us = (UnitsManager.UnitSystem)sbCase.UnitSystem; double boxLength = UnitsManager.ConvertLengthFrom(sbCase.DimensionsOuter.M0, us); double boxWidth = UnitsManager.ConvertLengthFrom(sbCase.DimensionsOuter.M1, us); double boxHeight = UnitsManager.ConvertLengthFrom(sbCase.DimensionsOuter.M2, us); double innerLength = UnitsManager.ConvertLengthFrom(sbCase.DimensionsInner.M0, us); double innerWidth = UnitsManager.ConvertLengthFrom(sbCase.DimensionsInner.M1, us); double innerHeight = UnitsManager.ConvertLengthFrom(sbCase.DimensionsInner.M2, us); if (uCtrlCaseDimensionsMin.Checked && (innerLength < uCtrlCaseDimensionsMin.X || innerWidth < uCtrlCaseDimensionsMin.Y || innerHeight < uCtrlCaseDimensionsMin.Z)) { continue; } if (uCtrlCaseDimensionsMax.Checked && (innerLength > uCtrlCaseDimensionsMax.X || innerWidth > uCtrlCaseDimensionsMax.Y || innerHeight > uCtrlCaseDimensionsMax.Z)) { continue; } double weight = UnitsManager.ConvertMassFrom(sbCase.Weight, us); Color[] colors = new Color[6]; for (int i = 0; i < 6; ++i) { colors[i] = Color.FromArgb(sbCase.Colors[i]); } // instantiate box properties BoxProperties bProperties = new BoxProperties(null , boxLength, boxWidth, boxHeight , innerLength, innerWidth, innerHeight); bProperties.TapeWidth = new OptDouble(sbCase.ShowTape, sbCase.TapeWidth); bProperties.TapeColor = Color.FromArgb(sbCase.TapeColor); bProperties.ID.SetNameDesc(sbCase.Name, sbCase.Description); bProperties.SetWeight(weight); bProperties.SetAllColors(colors); // insert in listbox control chklbCases.Items.Add(new ItemBaseCB(bProperties), true); } catch (Exception ex) { _log.Error(ex.Message); } } OnCaseChecked(this, null); }
/// <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) : base(document, null) { InitializeComponent(); if (!DesignMode) { // 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); uCtrlDimensionsOuter.ValueX = UnitsManager.ConvertLengthFrom(400.0, UnitsManager.UnitSystem.UNIT_METRIC1); uCtrlDimensionsOuter.ValueY = UnitsManager.ConvertLengthFrom(300.0, UnitsManager.UnitSystem.UNIT_METRIC1); uCtrlDimensionsOuter.ValueZ = UnitsManager.ConvertLengthFrom(200.0, UnitsManager.UnitSystem.UNIT_METRIC1); uCtrlDimensionsInner.Value = new Vector3D( uCtrlDimensionsOuter.ValueX - UnitsManager.ConvertLengthFrom(6.0, UnitsManager.UnitSystem.UNIT_METRIC1), uCtrlDimensionsOuter.ValueY - UnitsManager.ConvertLengthFrom(6.0, UnitsManager.UnitSystem.UNIT_METRIC1), uCtrlDimensionsOuter.ValueZ - UnitsManager.ConvertLengthFrom(6.0, UnitsManager.UnitSystem.UNIT_METRIC1)); uCtrlDimensionsInner.Checked = false; uCtrlTapeWidth.Value = new OptDouble(true, UnitsManager.ConvertLengthFrom(50, UnitsManager.UnitSystem.UNIT_METRIC1)); cbTapeColor.Color = Color.Beige; break; case Mode.MODE_BOX: tbName.Text = _document.GetValidNewTypeName(Resources.ID_BOX); uCtrlDimensionsOuter.ValueX = UnitsManager.ConvertLengthFrom(120.0, UnitsManager.UnitSystem.UNIT_METRIC1); uCtrlDimensionsOuter.ValueY = UnitsManager.ConvertLengthFrom(60.0, UnitsManager.UnitSystem.UNIT_METRIC1); uCtrlDimensionsOuter.ValueZ = UnitsManager.ConvertLengthFrom(30.0, UnitsManager.UnitSystem.UNIT_METRIC1); uCtrlDimensionsInner.Value = new Vector3D( uCtrlDimensionsOuter.ValueX - UnitsManager.ConvertLengthFrom(6.0, UnitsManager.UnitSystem.UNIT_METRIC1), uCtrlDimensionsOuter.ValueY - UnitsManager.ConvertLengthFrom(6.0, UnitsManager.UnitSystem.UNIT_METRIC1), uCtrlDimensionsOuter.ValueZ - UnitsManager.ConvertLengthFrom(6.0, UnitsManager.UnitSystem.UNIT_METRIC1)); uCtrlDimensionsInner.Checked = false; break; default: break; } // description (same as name) tbDescription.Text = tbName.Text; // color : all faces set together / face by face chkAllFaces.Checked = false; OnAllFacesColorCheckedChanged(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; // weight Weight = UnitsManager.ConvertMassFrom(1.0, UnitsManager.UnitSystem.UNIT_METRIC1); // net weight NetWeight = new OptDouble(false, UnitsManager.ConvertMassFrom(0.0, UnitsManager.UnitSystem.UNIT_METRIC1)); ctrlStrapperSet.StrapperSet = _strapperSet; // disable Ok button UpdateStatus(string.Empty); } }
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()); } }
public bool onFileNew(ref string fileName) { // INTEX data are in cms UnitsManager.CurrentUnitSystem = UnitsManager.UnitSystem.UNIT_METRIC2; string dbPath = Properties.Settings.Default.DatabasePathINTEX; if (string.IsNullOrWhiteSpace(dbPath) || !File.Exists(dbPath)) { OpenFileDialog fd = new OpenFileDialog(); fd.DefaultExt = "xls"; fd.AddExtension = false; fd.Filter = "Microsoft Excel File (*.xls)|*.xls|All files (*.*)|*.*"; fd.FilterIndex = 0; fd.RestoreDirectory = true; fd.CheckFileExists = true; if (DialogResult.OK != fd.ShowDialog()) { return(false); } dbPath = fd.FileName; Properties.Settings.Default.DatabasePathINTEX = dbPath; Properties.Settings.Default.Save(); } // load INTEX excel file List <DataItemINTEX> listItems = null; List <DataPalletINTEX> listPallets = null; List <DataCaseINTEX> listCases = null; try { // Set cursor as hourglass Cursor.Current = Cursors.WaitCursor; // load excel file if (!ExcelDataReader.ExcelDataReader.LoadIntexFile(dbPath, ref listItems, ref listPallets, ref listCases)) { Cursor.Current = Cursors.Default; string message = string.Empty; if (null == listItems || listItems.Count < 1) { message = string.Format(Properties.Resources.ID_ERROR_NOITEMFOUND, "article", "Articles"); } else if (null == listPallets || listPallets.Count < 1) { message = string.Format(Properties.Resources.ID_ERROR_NOITEMFOUND, "palette", "Palettes"); } else { message = string.Format(Properties.Resources.ID_ERROR_INVALIDFILE, dbPath); } if (!string.IsNullOrEmpty(message)) { MessageBox.Show(message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } return(false); } } catch (Exception ex) { MessageBox.Show( ex.Message , Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); _log.Error(ex.Message); } finally { Cursor.Current = Cursors.Default; } // do we have a valid list if (null == listItems || 0 == listItems.Count) { return(false); } // proceed : buid project file try { FormNewINTEX form = new FormNewINTEX(); form._listItems = listItems; form._listPallets = listPallets; form._listCases = listCases; if (DialogResult.OK != form.ShowDialog()) { return(false); } // create document DataItemINTEX item = form._currentItem; Document document = new Document(item._ref, item._description, "INTEX", DateTime.Now, null); // create box properties Color[] colorsCase = new Color[6]; for (int i = 0; i < 6; ++i) { colorsCase[i] = Color.Chocolate; } BoxProperties itemProperties = null; if (!form.UseIntermediatePacking) { itemProperties = document.CreateNewCase( item._ref , string.Format("{0};EAN14 : {1};UPC : {2};PCB : {3}", item._description, item._gencode, item._UPC, item._PCB) , UnitsManager.ConvertLengthFrom(item._length, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(item._width, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(item._height, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(item._length - 0.6, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(item._width - 0.6, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(item._height - 0.6, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertMassFrom(item._weight, UnitsManager.UnitSystem.UNIT_METRIC2) , colorsCase); } else { itemProperties = document.CreateNewBox( item._ref , string.Format("{0};EAN14 : {1};UPC : {2};PCB : {3}", item._description, item._gencode, item._UPC, item._PCB) , UnitsManager.ConvertLengthFrom(item._length, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(item._width, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(item._height, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertMassFrom(item._weight, UnitsManager.UnitSystem.UNIT_METRIC2) , colorsCase); } itemProperties.ShowTape = true; itemProperties.TapeColor = Color.Beige; itemProperties.TapeWidth = 5.0; InsertPictogram(ref itemProperties); BoxProperties currentCase = null; if (form.UseIntermediatePacking) { // create cases foreach (DataCaseINTEX dataCase in listCases) { double lengthInt = dataCase._lengthInt > 0 ? dataCase._lengthInt : dataCase._lengthExt - 2 * form.DefaultCaseThickness; double widthInt = dataCase._widthInt > 0 ? dataCase._widthInt : dataCase._widthExt - 2 * form.DefaultCaseThickness; double heightInt = dataCase._heightInt > 0 ? dataCase._heightInt : dataCase._heightExt - 2 * form.DefaultCaseThickness; BoxProperties intercaseProperties = document.CreateNewCase( dataCase._ref , string.Format("{0:0.0}*{1:0.0}*{2:0.0}", dataCase._lengthExt, dataCase._widthExt, dataCase._heightExt) , UnitsManager.ConvertLengthFrom(dataCase._lengthExt, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(dataCase._widthExt, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(dataCase._heightExt, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(lengthInt, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(widthInt, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(heightInt, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertMassFrom(dataCase._weight, UnitsManager.UnitSystem.UNIT_METRIC2) , colorsCase); intercaseProperties.ShowTape = true; intercaseProperties.TapeColor = Color.Beige; intercaseProperties.TapeWidth = 5.0; if (string.Equals(form._currentCase._ref, intercaseProperties.Name)) { currentCase = intercaseProperties; } } } if (form.UseIntermediatePacking) { // Case constraint set BoxCaseConstraintSet boxCaseConstraintSet = new BoxCaseConstraintSet(); boxCaseConstraintSet.SetAllowedOrthoAxisAll(); if (boxCaseConstraintSet.IsValid) { // create case analysis BoxCaseAnalysis analysis = document.CreateNewBoxCaseAnalysis( string.Format(Properties.Resources.ID_PACKING, item._ref) , item._description , itemProperties , currentCase , boxCaseConstraintSet , new BoxCaseSolver()); } } // create pallets PalletProperties currentPallet = null; foreach (DataPalletINTEX pallet in listPallets) { PalletProperties palletProperties = document.CreateNewPallet( pallet._type, pallet._type, "EUR" , UnitsManager.ConvertLengthFrom(pallet._length, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(pallet._width, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(pallet._height, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertMassFrom(pallet._weight, UnitsManager.UnitSystem.UNIT_METRIC2)); if (string.Equals(form._currentPallet._type, pallet._type)) { currentPallet = palletProperties; } } // *** pallet analysis *** // constraint set CasePalletConstraintSet constraintSet = new CasePalletConstraintSet(); constraintSet.UseMaximumHeight = true; constraintSet.MaximumHeight = UnitsManager.ConvertLengthFrom(form.PalletHeight, UnitsManager.UnitSystem.UNIT_METRIC2); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, true); constraintSet.AllowAlignedLayers = true; constraintSet.AllowAlternateLayers = true; constraintSet.SetAllowedPattern("Column"); constraintSet.SetAllowedPattern("Diagonale"); constraintSet.SetAllowedPattern("Interlocked"); constraintSet.SetAllowedPattern("Trilock"); constraintSet.SetAllowedPattern("Spirale"); constraintSet.SetAllowedPattern("Enlarged spirale"); if (constraintSet.IsValid) { // create analysis CasePalletSolver solver = new CasePalletSolver(); CasePalletAnalysis palletAnalysis = document.CreateNewCasePalletAnalysis( item._ref, item.ToString() , form.UseIntermediatePacking ? currentCase : itemProperties , currentPallet, null, null, null, null, null, constraintSet, solver); } // save document fileName = form.FilePath; document.Write(form.FilePath); // return true to let application open return(File.Exists(fileName)); } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } }
private void FormNewAnalysisHCylinder_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; } } } } // 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; MaximumNumberOfItems = 500; MaximumPalletHeight = UnitsManager.ConvertLengthFrom(Settings.Default.MaximumPalletHeight, UnitsManager.UnitSystem.UNIT_METRIC1); MaximumPalletWeight = UnitsManager.ConvertMassFrom(Settings.Default.MaximumPalletWeight, UnitsManager.UnitSystem.UNIT_METRIC1); AllowPatternDefault = true; AllowPatternStaggered = false; AllowPatternColumn = false; } else { UseMaximumNumberOfItems = _analysis.ConstraintSet.UseMaximumNumberOfItems; UseMaximumPalletHeight = _analysis.ConstraintSet.UseMaximumPalletHeight; UseMaximumPalletWeight = _analysis.ConstraintSet.UseMaximumPalletWeight; MaximumNumberOfItems = _analysis.ConstraintSet.MaximumNumberOfItems; MaximumPalletHeight = _analysis.ConstraintSet.MaximumPalletHeight; MaximumPalletWeight = _analysis.ConstraintSet.MaximumPalletWeight; // patterns AllowPatternDefault = _analysis.ConstraintSet.AllowPattern("Default"); AllowPatternColumn = _analysis.ConstraintSet.AllowPattern("Column"); AllowPatternStaggered = _analysis.ConstraintSet.AllowPattern("Staggered"); } chkPatternColumnized_CheckedChanged(this, null); UpdateButtonOkStatus(); } catch (Exception ex) { _log.Error(ex.ToString()); } }
private void FormNewAnalysis_Load(object sender, EventArgs e) { try { // name / description if (null != _analysis) { tbName.Text = _analysis.Name; tbDescription.Text = _analysis.Description; } // fill boxes combo foreach (BProperties box in _cases) { cbBox.Items.Add(new BoxItem(box)); } if (cbBox.Items.Count > 0) { if (null == _analysis) { cbBox.SelectedIndex = 0; } else { for (int i = 0; i < cbBox.Items.Count; ++i) { BoxItem boxItem = cbBox.Items[i] as BoxItem; if (boxItem.Item == _analysis.BProperties) { cbBox.SelectedIndex = i; break; } } } } // fill pallet combo foreach (PalletProperties pallet in _palletProperties) { cbPallet.Items.Add(new PalletItem(pallet)); } if (cbPallet.Items.Count > 0) { if (null == _analysis) { cbPallet.SelectedIndex = 0; } else { for (int i = 0; i < cbPallet.Items.Count; ++i) { PalletItem palletItem = cbPallet.Items[i] as PalletItem; if (palletItem.Item == _analysis.PalletProperties) { cbPallet.SelectedIndex = i; break; } } } } // fill other combo FillCombo(checkBoxInterlayer, cbInterlayer, _interlayerProperties, (null == _analysis) ? null : _analysis.InterlayerProperties); FillCombo(checkBoxAntiSlipInterlayer, cbInterlayerAntiSlip, _interlayerProperties, (null == _analysis) ? null : _analysis.InterlayerPropertiesAntiSlip); FillCombo(chkbPalletCorners, cbPalletCorners, _palletCornerProperties, (null == _analysis) ? null : _analysis.PalletCornerProperties); FillCombo(chkbPalletCap, cbPalletCap, _palletCapProperties, (null == _analysis) ? null : _analysis.PalletCapProperties); FillCombo(chkbPalletFilm, cbPalletFilm, _palletFilmProperties, (null == _analysis) ? null : _analysis.PalletFilmProperties); // overhang if (null == _analysis) { OverhangX = Settings.Default.OverhangX; OverhangY = Settings.Default.OverhangY; } else { OverhangX = _analysis.ConstraintSet.OverhangX; OverhangY = _analysis.ConstraintSet.OverhangY; } // allowed position box + allowed patterns if (null == _analysis) { AllowVerticalX = Settings.Default.AllowVerticalX; AllowVerticalY = Settings.Default.AllowVerticalY; AllowVerticalZ = Settings.Default.AllowVerticalZ; AllowedPatternsString = Settings.Default.AllowedPatterns; AllowTwoLayerOrientations = Settings.Default.AllowLayerOrientChange; AllowLastLayerOrientationChange = Settings.Default.AllowLayerOrientChangeLastOnly; } else { PalletConstraintSet constraintSet = _analysis.ConstraintSet; InterlayerPeriod = Math.Max(constraintSet.InterlayerPeriod, 1); AllowVerticalX = constraintSet.AllowOrthoAxis(HalfAxis.HAxis.AXIS_X_N) || constraintSet.AllowOrthoAxis(HalfAxis.HAxis.AXIS_X_P); AllowVerticalY = constraintSet.AllowOrthoAxis(HalfAxis.HAxis.AXIS_Y_N) || constraintSet.AllowOrthoAxis(HalfAxis.HAxis.AXIS_Y_P); AllowVerticalZ = constraintSet.AllowOrthoAxis(HalfAxis.HAxis.AXIS_Z_N) || constraintSet.AllowOrthoAxis(HalfAxis.HAxis.AXIS_Z_P); AllowTwoLayerOrientations = constraintSet.AllowTwoLayerOrientations; AllowLastLayerOrientationChange = constraintSet.AllowLastLayerOrientationChange; AllowedPatternsString = constraintSet.AllowedPatternString; } // alternate / aligned layers + stop stacking criterion if (null == _analysis) { AllowAlignedLayers = Settings.Default.AllowAlignedLayer; AllowAlternateLayers = Settings.Default.AllowAlternateLayer; UseMaximumNumberOfBoxes = false; UseMaximumPalletHeight = true; UseMaximumPalletWeight = true; UseMaximumLoadOnBox = false; MaximumNumberOfBoxes = 500; MaximumPalletHeight = UnitsManager.ConvertLengthFrom(Properties.Settings.Default.MaximumPalletHeight, UnitsManager.UnitSystem.UNIT_METRIC1); MaximumPalletWeight = UnitsManager.ConvertMassFrom(Properties.Settings.Default.MaximumPalletWeight, UnitsManager.UnitSystem.UNIT_METRIC1); MaximumLoadOnBox = 100.0; } else { AllowAlignedLayers = _analysis.ConstraintSet.AllowAlignedLayers; AllowAlternateLayers = _analysis.ConstraintSet.AllowAlternateLayers; UseMaximumNumberOfBoxes = _analysis.ConstraintSet.UseMaximumNumberOfCases; UseMaximumPalletHeight = _analysis.ConstraintSet.UseMaximumHeight; UseMaximumPalletWeight = _analysis.ConstraintSet.UseMaximumPalletWeight; UseMaximumLoadOnBox = _analysis.ConstraintSet.UseMaximumWeightOnBox; MaximumNumberOfBoxes = _analysis.ConstraintSet.MaximumNumberOfItems; MaximumPalletHeight = _analysis.ConstraintSet.MaximumHeight; MaximumPalletWeight = _analysis.ConstraintSet.MaximumPalletWeight; MaximumLoadOnBox = _analysis.ConstraintSet.MaximumWeightOnBox; } if (null != _analysis) { PalletFilmTurns = _analysis.ConstraintSet.PalletFilmTurns; } UpdateCriterionFields(); UpdateButtonOkStatus(); // windows settings if (null != Settings.Default.FormNewAnalysisPosition) { Settings.Default.FormNewAnalysisPosition.Restore(this); } } catch (Exception ex) { _log.Error(ex.ToString()); } }
private void FormNewAnalysisBundle_Load(object sender, EventArgs e) { try { // name / description if (null != _analysis) { ItemName = _analysis.Name; ItemDescription = _analysis.Description; } else { ItemName = _document.GetValidNewAnalysisName(Resources.ID_ANALYSIS); ItemDescription = ItemName; } // fill boxes combo foreach (BProperties bundle in _bundles) { cbBox.Items.Add(new BoxItem(bundle)); } if (cbBox.Items.Count > 0) { if (null == _analysis) { cbBox.SelectedIndex = 0; } else { for (int i = 0; i < cbBox.Items.Count; ++i) { BoxItem boxItem = cbBox.Items[i] as BoxItem; if (boxItem.Item == _analysis.BProperties) { cbBox.SelectedIndex = i; break; } } } } // fill pallet combo foreach (PalletProperties pallet in _palletProperties) { cbPallet.Items.Add(new PalletItem(pallet)); } if (cbPallet.Items.Count > 0) { if (null == _analysis) { cbPallet.SelectedIndex = 0; } else { for (int i = 0; i < cbPallet.Items.Count; ++i) { PalletItem palletItem = cbPallet.Items[i] as PalletItem; if (palletItem.Item == _analysis.PalletProperties) { cbPallet.SelectedIndex = i; break; } } } } // overhang if (null == _analysis) { OverhangX = Settings.Default.OverhangX; OverhangY = Settings.Default.OverhangY; } else { OverhangX = _analysis.ConstraintSet.OverhangX; OverhangY = _analysis.ConstraintSet.OverhangY; } // alternate / aligned layers if (null == _analysis) { AllowAlignedLayers = Settings.Default.AllowAlignedLayer; AllowAlternateLayers = Settings.Default.AllowAlternateLayer; UseMaximumNumberOfBoxes = false; UseMaximumPalletHeight = true; UseMaximumPalletWeight = true; MaximumNumberOfBoxes = 1000; MaximumPalletHeight = UnitsManager.ConvertLengthFrom(1200.0, UnitsManager.UnitSystem.UNIT_METRIC1); MaximumPalletWeight = UnitsManager.ConvertMassFrom(1000.0, UnitsManager.UnitSystem.UNIT_METRIC1); } else { AllowAlignedLayers = _analysis.ConstraintSet.AllowAlignedLayers;; AllowAlternateLayers = _analysis.ConstraintSet.AllowAlternateLayers; UseMaximumNumberOfBoxes = _analysis.ConstraintSet.UseMaximumNumberOfCases; UseMaximumPalletHeight = _analysis.ConstraintSet.UseMaximumHeight; UseMaximumPalletWeight = _analysis.ConstraintSet.UseMaximumPalletWeight; // stop stacking criterion MaximumNumberOfBoxes = _analysis.ConstraintSet.MaximumNumberOfItems; MaximumPalletHeight = _analysis.ConstraintSet.MaximumHeight; MaximumPalletWeight = _analysis.ConstraintSet.MaximumPalletWeight; } if (null == _analysis) { AllowedPatternsString = Settings.Default.AllowedPatterns; } else { AllowedPatternsString = _analysis.ConstraintSet.AllowedPatternString; } UpdateCriterionFields(); UpdateStatus(string.Empty); // windows settings if (null != Settings.Default.FormNewAnalysisPosition) { Settings.Default.FormNewAnalysisPosition.Restore(this); } } catch (Exception ex) { _log.Error(ex.ToString()); } }
public bool OnFileNew(ref string fileName) { // INTEX data are in cms UnitsManager.CurrentUnitSystem = UnitsManager.UnitSystem.UNIT_METRIC2; string dbPath = Properties.Settings.Default.DatabasePathINTEX; if (string.IsNullOrWhiteSpace(dbPath) || !File.Exists(dbPath)) { OpenFileDialog fd = new OpenFileDialog(); fd.DefaultExt = "xls"; fd.AddExtension = false; fd.Filter = "Microsoft Excel File (*.xls)|*.xls|All files (*.*)|*.*"; fd.FilterIndex = 0; fd.RestoreDirectory = true; fd.CheckFileExists = true; if (DialogResult.OK != fd.ShowDialog()) { return(false); } dbPath = fd.FileName; Properties.Settings.Default.DatabasePathINTEX = dbPath; Properties.Settings.Default.Save(); } // load INTEX excel file List <DataItemINTEX> listItems = null; List <DataPalletINTEX> listPallets = null; List <DataCaseINTEX> listCases = null; try { // Set cursor as hourglass Cursor.Current = Cursors.WaitCursor; // load excel file if (!ExcelDataReader.ExcelDataReader.LoadIntexFile(dbPath, ref listItems, ref listPallets, ref listCases)) { Cursor.Current = Cursors.Default; string message = string.Empty; if (null == listItems || listItems.Count < 1) { message = string.Format(Properties.Resources.ID_ERROR_NOITEMFOUND, "article", "Articles"); } else if (null == listPallets || listPallets.Count < 1) { message = string.Format(Properties.Resources.ID_ERROR_NOITEMFOUND, "palette", "Palettes"); } else { message = string.Format(Properties.Resources.ID_ERROR_INVALIDFILE, dbPath); } if (!string.IsNullOrEmpty(message)) { MessageBox.Show(message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } return(false); } } catch (Exception ex) { MessageBox.Show( ex.Message , Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); _log.Error(ex.Message); } finally { Cursor.Current = Cursors.Default; } // do we have a valid list if (null == listItems || 0 == listItems.Count) { return(false); } // proceed : buid project file try { FormNewINTEX form = new FormNewINTEX() { ListItems = listItems, ListPallets = listPallets, ListCases = listCases }; if (DialogResult.OK != form.ShowDialog()) { return(false); } // create document DataItemINTEX item = form._currentItem; Document document = new Document(item._ref, item._description, "INTEX", DateTime.Now, null); // create box properties Color[] colorsCase = new Color[6]; for (int i = 0; i < 6; ++i) { colorsCase[i] = Color.Chocolate; } BoxProperties itemProperties = null; if (!form.UseIntermediatePacking) { itemProperties = document.CreateNewCase( item._ref , $"{item._description};EAN14 : {item._gencode};UPC : {item._UPC};PCB : {item._PCB}" , UnitsManager.ConvertLengthFrom(item._length, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(item._width, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(item._height, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertMassFrom(item._weight, UnitsManager.UnitSystem.UNIT_METRIC2) , colorsCase); } else { itemProperties = document.CreateNewBox( item._ref , string.Format("{0};EAN14 : {1};UPC : {2};PCB : {3}", item._description, item._gencode, item._UPC, item._PCB) , UnitsManager.ConvertLengthFrom(item._length, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(item._width, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(item._height, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertMassFrom(item._weight, UnitsManager.UnitSystem.UNIT_METRIC2) , colorsCase); } itemProperties.TapeColor = Color.Beige; itemProperties.TapeWidth = new OptDouble(true, 5.0); InsertPictogram(ref itemProperties); BoxProperties currentCase = null; if (form.UseIntermediatePacking) { // create cases foreach (DataCaseINTEX dataCase in listCases) { double lengthInt = dataCase._lengthInt > 0 ? dataCase._lengthInt : dataCase._lengthExt - 2 * form.DefaultCaseThickness; double widthInt = dataCase._widthInt > 0 ? dataCase._widthInt : dataCase._widthExt - 2 * form.DefaultCaseThickness; double heightInt = dataCase._heightInt > 0 ? dataCase._heightInt : dataCase._heightExt - 2 * form.DefaultCaseThickness; BoxProperties intercaseProperties = document.CreateNewCase( dataCase._ref , string.Format("{0:0.0}*{1:0.0}*{2:0.0}", dataCase._lengthExt, dataCase._widthExt, dataCase._heightExt) , UnitsManager.ConvertLengthFrom(dataCase._lengthExt, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(dataCase._widthExt, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(dataCase._heightExt, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(lengthInt, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(widthInt, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(heightInt, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertMassFrom(dataCase._weight, UnitsManager.UnitSystem.UNIT_METRIC2) , colorsCase); intercaseProperties.TapeColor = Color.Beige; intercaseProperties.TapeWidth = new OptDouble(true, 5.0); if (string.Equals(form._currentCase._ref, intercaseProperties.Name)) { currentCase = intercaseProperties; } } } // initialize Layer solver SolutionLayered.SetSolver(new LayerSolver()); if (form.UseIntermediatePacking) { // Case constraint set ConstraintSetBoxCase constraintSetBoxCase = new ConstraintSetBoxCase(currentCase); constraintSetBoxCase.AllowedOrientationsString = "1,1,1"; if (constraintSetBoxCase.Valid) { SolverBoxCase solver = new SolverBoxCase(itemProperties, currentCase); Layer2DBrickImp layer = solver.BuildBestLayer(constraintSetBoxCase); List <LayerDesc> layerDescs = new List <LayerDesc>(); if (null != layer) { layerDescs.Add(layer.LayerDescriptor); } // create case analysis AnalysisLayered analysis = document.CreateNewAnalysisBoxCase( string.Format(Properties.Resources.ID_PACKING, item._ref) , item._description , itemProperties , currentCase , null , constraintSetBoxCase , layerDescs); } } // create pallets PalletProperties currentPallet = null; foreach (DataPalletINTEX pallet in listPallets) { PalletProperties palletProperties = document.CreateNewPallet( pallet._type, pallet._type, "EUR" , UnitsManager.ConvertLengthFrom(pallet._length, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(pallet._width, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(pallet._height, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertMassFrom(pallet._weight, UnitsManager.UnitSystem.UNIT_METRIC2) , Color.Gold); if (string.Equals(form._currentPallet._type, pallet._type)) { currentPallet = palletProperties; } } // *** pallet analysis *** // constraint set ConstraintSetCasePallet constraintSet = new ConstraintSetCasePallet(); constraintSet.SetMaxHeight(new OptDouble(true, UnitsManager.ConvertLengthFrom(form.PalletHeight, UnitsManager.UnitSystem.UNIT_METRIC2))); constraintSet.SetAllowedOrientations(new bool[] { false, false, true }); if (constraintSet.Valid) { SolverCasePallet solver = new SolverCasePallet(form.UseIntermediatePacking ? currentCase : itemProperties, currentPallet); Layer2DBrickImp layer = solver.BuildBestLayer(constraintSet); List <LayerDesc> layerDescs = new List <LayerDesc>(); if (null != layer) { layerDescs.Add(layer.LayerDescriptor); } // create analysis AnalysisLayered palletAnalysis = document.CreateNewAnalysisCasePallet( item._ref, item.ToString() , form.UseIntermediatePacking ? currentCase : itemProperties , currentPallet, null, null, null, null, constraintSet, layerDescs); } // save document fileName = form.FilePath; document.Write(form.FilePath); if (null != OpenFile) { OpenFile(fileName); } // return true to let application open return(File.Exists(fileName)); } catch (Exception ex) { _log.Error(ex.Message); return(false); } }