/// <summary> /// Constructor /// </summary> /// <param name="title"></param> /// <param name="caseAnalysis">Parent case analysis reference</param> public BoxCasePalletSolution(BoxCasePalletAnalysis caseAnalysis, string title, PalletSolutionDesc palletSolutionDesc, bool hasHomogeneousLayers) { _title = title; _parentCaseAnalysis = caseAnalysis; _palletSolutionDesc = palletSolutionDesc; _hasHomogeneousLayers = hasHomogeneousLayers; }
/// <summary> /// Remove guid /// </summary> /// <param name="guid"></param> public void RemoveByGuid(Guid guid) { // find item PalletSolutionDesc desc = _palletSolutionList.Find(delegate(PalletSolutionDesc solutionDesc) { return(solutionDesc.Guid == guid); }); try { File.Delete(desc.FullFilePath); } catch (Exception ex) { _log.Error(ex.ToString()); } _palletSolutionList.Remove(desc); // trigger event if (null != SolutionDeleted) { SolutionDeleted(this, new PalletSolutionEventArgs(desc)); } Save(); }
/// <summary> /// Check validity of a friendly name. /// A friendly name should only be used if not already used by an other solution. /// </summary> /// <param name="name">name to check </param> /// <param name="thisDesc">this descriptor</param> /// <returns>true if name can be used</returns> public bool IsValidFriendlyName(string name, PalletSolutionDesc thisDesc) { foreach (PalletSolutionDesc desc in _palletSolutionList) { if (thisDesc == desc) { continue; } if (string.Compare(desc.FriendlyName.Trim(), name.Trim(), true) == 0) { return(false); } } return(true); }
private void RemoveByKeyAndCaseDimensions(PalletSolutionDesc descNew) { // remove .stb files foreach (PalletSolutionDesc desc in _palletSolutionList) { if (desc.MatchesKeyAndCaseDimensions(descNew)) { try { File.Delete(desc.FullFilePath); } catch (Exception ex) { _log.Error(ex.ToString()); } // trigger event if (null != SolutionDeleted) { SolutionDeleted(this, new PalletSolutionEventArgs(desc)); } } } // remove descriptors from list _palletSolutionList.RemoveAll(delegate(PalletSolutionDesc desc) { return(desc.MatchesKeyAndCaseDimensions(descNew)); }); Save(); }
/// <summary> /// Append new solution descriptor /// </summary> /// <param name="desc"></param> public void Append(SelCasePalletSolution selSolution, string name, bool keepSimilarSolutions) { Document document = selSolution.Analysis.ParentDocument; CasePalletSolution sol = selSolution.Solution; CasePalletAnalysis analysis = sol.Analysis; // instantiate new descriptor PalletSolutionDesc desc = new PalletSolutionDesc(this, sol, name); // remove similar solutions if (!keepSimilarSolutions) { RemoveByKeyAndCaseDimensions(desc); } // save solution as stb file document.WriteSolution(selSolution, desc.FullFilePath); _palletSolutionList.Add(desc); _palletSolutionList.Sort(); if (null != SolutionAppended) { SolutionAppended(this, new PalletSolutionEventArgs(desc)); } Save(); }
/// <summary> /// Constructor /// </summary> /// <param name="desc">Pallet solution descriptor of solution saved/removed</param> /// <param name="added"></param> public PalletSolutionEventArgs(PalletSolutionDesc desc) { _desc = desc; }