Пример #1
0
        public FormNewBase(Document document, ItemBase item)
        {
            InitializeComponent();

            _document = document;
            _item = item;
        }
        public override void OnAttributeModified(ItemBase modifiedAttribute)
        {
            Vector3D outerDim = _caseDefinition.OuterDimensions(_boxProperties, _constraintSet);
            Length = outerDim.X;
            Width = outerDim.Y;
            Height = outerDim.Z;

            Vector3D innerDim = _caseDefinition.InnerDimensions(_boxProperties);
            InsideLength = innerDim.X;
            InsideWidth = innerDim.Y;
            InsideHeight = innerDim.Z;
        }
Пример #3
0
 public static void FillCombo(ItemBase[] items, ComboBox cb, ItemBase item)
 {
     cb.Items.Clear();
     foreach (ItemBase it in items)
         cb.Items.Add(new ItemBaseCB(it));
     if (cb.Items.Count > 0)
     {
         if (null == item)
             cb.SelectedIndex = 0;
         else
         {
             for (int i = 0; i < cb.Items.Count; ++i)
             {
                 ItemBaseCB cbItem = cb.Items[i] as ItemBaseCB;
                 if (cbItem.Item == item)
                 {
                     cb.SelectedIndex = i;
                     break;
                 }
             }
         }
     }
 }
 public void Kill(ItemBase item)
 {
     Close();
     _analysis.RemoveListener(this);
 }
Пример #5
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;
                 }
             }
         }
     }
 }
Пример #7
0
 private void NotifyOnTypeRemoved(ItemBase item)
 {
     foreach (IDocumentListener listener in _listeners)
         listener.OnTypeRemoved(this, item);
 }
Пример #8
0
 public void AddType(ItemBase item)
 {
     // insert in list
     _typeList.Add(item);
     // notify listeners
     NotifyOnNewTypeCreated(item);
     Modify();
 }
Пример #9
0
 public bool IsValidNewTypeName(string name, ItemBase itemToName)
 {
     // make sure is not empty
     if (name.Trim() == string.Empty)
         return false;
     // make sure it is not already used
     return null == _typeList.Find(
         delegate(ItemBase item)
         {
             return (item != itemToName) && string.Equals(item.Name.Trim(), name.Trim(), StringComparison.CurrentCultureIgnoreCase);
         }
         );
 }
Пример #10
0
 public NodeTag(NodeType type, Document document, CylinderPalletAnalysis analysis)
 {
     _type = type;
     _document = document;
     _itemProperties = null;
     _cylinderPalletAnalysis = analysis;
 }
Пример #11
0
 public NodeTag(NodeType type, Document document, CasePalletAnalysis analysis, SelCasePalletSolution selSolution, ECTAnalysis ectAnalysis)
 {
     _type = type;
     _document = document;
     _itemProperties = null;
     _casePalletAnalysis = analysis;
     _selSolution = selSolution;
     _ectAnalysis = ectAnalysis;
 }
Пример #12
0
 public NodeTag(NodeType type, Document document, ItemBase itemProperties)
 {
     _type = type;
     _document = document;
     _itemProperties = itemProperties;
     if (_type == NodeType.NT_CASEPALLETANALYSIS && itemProperties is CasePalletAnalysis)
     {
         _casePalletAnalysis = itemProperties as CasePalletAnalysis;
         _itemProperties = null;
     }
     else if (_type == NodeType.NT_PACKPALLETANALYSIS && itemProperties is PackPalletAnalysis)
     {
         _packPalletAnalysis = itemProperties as PackPalletAnalysis;
         _itemProperties = null;
     }
     else if (_type == NodeType.NT_BOXCASEANALYSIS && itemProperties is BoxCaseAnalysis)
     {
         _boxCaseAnalysis = itemProperties as BoxCaseAnalysis;
         _itemProperties = null;
     }
     else if (_type == NodeType.NT_BOXCASEPALLETANALYSIS && itemProperties is BoxCasePalletAnalysis)
     {
         _boxCasePalletAnalysis = itemProperties as BoxCasePalletAnalysis;
         _itemProperties = null;
     }
     else if (_type == NodeType.NT_CYLINDERPALLETANALYSIS && itemProperties is CylinderPalletAnalysis)
     {
         _cylinderPalletAnalysis = itemProperties as CylinderPalletAnalysis;
         _itemProperties = null;
     }
     else if (_type == NodeType.NT_HCYLINDERPALLETANALYSIS && itemProperties is HCylinderPalletAnalysis)
     {
         _hCylinderPalletAnalysis = itemProperties as HCylinderPalletAnalysis;
         _itemProperties = null;
     }
 }
Пример #13
0
        public void OnAnalysisRemoved(Document doc, ItemBase analysis)
        {
            NodeTag.NodeType nodeType = NodeTag.NodeType.NT_UNKNOWN;
            if (analysis.GetType() == typeof(CasePalletAnalysis)) nodeType = NodeTag.NodeType.NT_CASEPALLETANALYSIS;
            else if (analysis.GetType() == typeof(PackPalletAnalysis)) nodeType = NodeTag.NodeType.NT_PACKPALLETANALYSIS;
            else if (analysis.GetType() == typeof(CylinderPalletAnalysis)) nodeType = NodeTag.NodeType.NT_CYLINDERPALLETANALYSIS;
            else if (analysis.GetType() == typeof(HCylinderPalletAnalysis)) nodeType = NodeTag.NodeType.NT_HCYLINDERPALLETANALYSIS;
            else if (analysis.GetType() == typeof(BoxCaseAnalysis)) nodeType = NodeTag.NodeType.NT_BOXCASEANALYSIS;
            else if (analysis.GetType() == typeof(BoxCasePalletAnalysis)) nodeType = NodeTag.NodeType.NT_BOXCASEPALLETANALYSIS;

            // get node
            TreeNode analysisNode = FindNode(null, new NodeTag(nodeType, doc, analysis));
            // test
            if (null == analysisNode)
            {
                _log.Warn(string.Format("Failed to find a valid tree node for analysis {0}", analysis.Name));
                return;
            }
            // remove node
            Nodes.Remove(analysisNode);
        }
Пример #14
0
 public void OnAnalysisRemoved(Document doc, ItemBase itemBase)
 {
 }
Пример #15
0
 public override void OnEndUpdate(ItemBase updatedAttribute)
 {
     Modify();
     base.OnEndUpdate(updatedAttribute);
 }
Пример #16
0
 public bool IsValidNewAnalysisName(string name, ItemBase analysisToRename)
 {
     string trimmedName = name.Trim();
     return (null == _casePalletAnalyses.Find(
         delegate(CasePalletAnalysis analysis)
         {
             return analysis != analysisToRename
                 && string.Equals(analysis.Name, trimmedName, StringComparison.InvariantCultureIgnoreCase);
         }
         ))
         && (null == _cylinderPalletAnalyses.Find(
         delegate(CylinderPalletAnalysis analysis)
         {
             return analysis != analysisToRename
                 && string.Equals(analysis.Name, trimmedName, StringComparison.InvariantCultureIgnoreCase);
         }
         ))
         && (null == _hCylinderPalletAnalyses.Find(
         delegate(HCylinderPalletAnalysis analysis)
         {
             return analysis != analysisToRename
                 && string.Equals(analysis.Name, trimmedName, StringComparison.InvariantCultureIgnoreCase);
         }
         ))
         && (null == _boxCaseAnalyses.Find(
         delegate(BoxCaseAnalysis analysis)
         {
             return analysis != analysisToRename
                 && string.Equals(analysis.Name, trimmedName, StringComparison.InvariantCultureIgnoreCase);
         }
         ))
         && (null == _boxCasePalletOptimizations.Find(
         delegate(BoxCasePalletAnalysis analysis)
         {
             return analysis != analysisToRename
                 && string.Equals(analysis.Name, trimmedName, StringComparison.InvariantCultureIgnoreCase);
         }
         ))
         && (null == _packPalletAnalyses.Find(
         delegate(PackPalletAnalysis analysis)
         {
             return analysis != analysisToRename
                 && string.Equals(analysis.Name, trimmedName, StringComparison.InvariantCultureIgnoreCase);
         }
         ));
 }
Пример #17
0
 public NodeTag(NodeType type, Document document, CylinderPalletAnalysis analysis, SelCylinderPalletSolution selSolution)
 {
     _type = type;
     _document = document;
     _itemProperties = null;
     _cylinderPalletAnalysis = analysis;
     _selCylinderPalletSolution = selSolution;
 }
Пример #18
0
        public void RemoveItem(ItemBase item)
        {
            // sanity check
            if (null == item)
            {
                Debug.Assert(false);
                return;
            }
            // dispose item first as it may remove dependancies itself
            _log.Debug(string.Format("Disposing {0}...", item.Name));
            item.Dispose();

            // notify listeners / remove
            if (item.GetType() == typeof(BoxProperties)
                || item.GetType() == typeof(BundleProperties)
                || item.GetType() == typeof(CaseOfBoxesProperties)
                || item.GetType() == typeof(PackProperties)
                || item.GetType() == typeof(PalletProperties)
                || item.GetType() == typeof(InterlayerProperties)
                || item.GetType() == typeof(PalletCornerProperties)
                || item.GetType() == typeof(PalletCapProperties)
                || item.GetType() == typeof(PalletFilmProperties)
                || item.GetType() == typeof(TruckProperties)
                || item.GetType() == typeof(CylinderProperties))
            {
                NotifyOnTypeRemoved(item);
                if (!_typeList.Remove(item))
                    _log.Warn(string.Format("Failed to properly remove item {0}", item.Name));
            }
            else if (item.GetType() == typeof(CasePalletAnalysis))
            {
                NotifyOnAnalysisRemoved(item as CasePalletAnalysis);
                if (!_casePalletAnalyses.Remove(item as CasePalletAnalysis))
                    _log.Warn(string.Format("Failed to properly remove analysis {0}", item.Name));
            }
            else if (item.GetType() == typeof(PackPalletAnalysis))
            {
                NotifyOnAnalysisRemoved(item as PackPalletAnalysis);
                if (!_packPalletAnalyses.Remove(item as PackPalletAnalysis))
                    _log.Warn(string.Format("Failed to properly remove analysis {0}", item.Name));
            }
            else if (item.GetType() == typeof(BoxCaseAnalysis))
            {
                NotifyOnAnalysisRemoved(item as BoxCaseAnalysis);
                if (!_boxCaseAnalyses.Remove(item as BoxCaseAnalysis))
                    _log.Warn(string.Format("Failed to properly remove analysis {0}", item.Name));
            }
            else if (item.GetType() == typeof(CylinderPalletAnalysis))
            {
                NotifyOnAnalysisRemoved(item as CylinderPalletAnalysis);
                if (!_cylinderPalletAnalyses.Remove(item as CylinderPalletAnalysis))
                    _log.Warn(string.Format("Failed to properly remove analysis {0}", item.Name));
            }
            else if (item.GetType() == typeof(HCylinderPalletAnalysis))
            {
                NotifyOnAnalysisRemoved(item as HCylinderPalletAnalysis);
                if (!_hCylinderPalletAnalyses.Remove(item as HCylinderPalletAnalysis))
                    _log.Warn(string.Format("Failed to properly remove analysis {0}", item.Name));
            }
            else if (item.GetType() == typeof(TruckAnalysis))
            {
                TruckAnalysis truckAnalysis = item as TruckAnalysis;
                NotifyOnTruckAnalysisRemoved(truckAnalysis.ParentSelSolution, truckAnalysis);
            }
            else if (item.GetType() == typeof(BoxCasePalletAnalysis))
            {
                BoxCasePalletAnalysis caseAnalysis = item as BoxCasePalletAnalysis;
                NotifyOnAnalysisRemoved(caseAnalysis);
                if (!_boxCasePalletOptimizations.Remove(caseAnalysis))
                    _log.Warn(string.Format("Failed to properly remove analysis {0}", item.Name));
            }
            else if (item.GetType() == typeof(ECTAnalysis))
            {
                ECTAnalysis ectAnalysis = item as ECTAnalysis;
                NotifyOnECTAnalysisRemoved(ectAnalysis.ParentSelSolution, ectAnalysis);
            }
            else if (item.GetType() == typeof(SelCasePalletSolution)) { }
            else if (item.GetType() == typeof(SelBoxCasePalletSolution)) { }
            else if (item.GetType() == typeof(SelBoxCaseSolution)) { }
            else if (item.GetType() == typeof(SelCylinderPalletSolution)) { }
            else if (item.GetType() == typeof(SelHCylinderPalletSolution)) { }
            else if (item.GetType() == typeof(SelPackPalletSolution)) { }
            else
                Debug.Assert(false);
            Modify();
        }
Пример #19
0
 public NodeTag(NodeType type, Document document, HCylinderPalletAnalysis analysis, ItemBase itemProperties)
 {
     _type = type;
     _document = document;
     _itemProperties = itemProperties;
     _hCylinderPalletAnalysis = analysis;
 }
Пример #20
0
 private void NotifyOnAnalysisRemoved(ItemBase analysis)
 {
     foreach (IDocumentListener listener in _listeners)
         listener.OnAnalysisRemoved(this, analysis);
 }
Пример #21
0
 public NodeTag(NodeType type, Document document, HCylinderPalletAnalysis analysis, SelHCylinderPalletSolution selSolution, TruckAnalysis truckAnalysis)
 {
     _type = type;
     _document = document;
     _itemProperties = null;
     _hCylinderPalletAnalysis = analysis;
     _selHCylinderPalletSolution = selSolution;
     _truckAnalysis = truckAnalysis;
 }
 public override void OnEndUpdate(ItemBase updatedAttribute)
 {
     if (null != Modified)
         Modified(this);
     // clear selected solutions
     while (_selectedSolutions.Count > 0)
         UnSelectSolution(_selectedSolutions[0]);
     // clear solutions
     _solutions.Clear();
     // get default analysis solver
     if (null != _solver)
         _solver.ProcessAnalysis(this);
     else
         _log.Error("_solver == null : solver was not set");
     if (_solutions.Count == 0)
         _log.Debug("Recomputed analysis has no solutions");
     // set modified / propagate modifications
     Modify();
 }
Пример #23
0
 public NodeTag(NodeType type, Document doc, BoxCasePalletAnalysis caseAnalysis, ItemBase itemProperties)
 {
     _type = type;
     _document = doc;
     _boxCasePalletAnalysis = caseAnalysis;
     _itemProperties = itemProperties;
     _selSolution = null;
 }
 public void Update(ItemBase item)
 {
 }
Пример #25
0
 /// <summary>
 /// handles new type creation
 /// </summary>
 /// <param name="doc"></param>
 /// <param name="itemProperties"></param>
 public void OnNewTypeCreated(Document doc, ItemBase itemProperties)
 {
     int iconIndex = 0;
     NodeTag.NodeType nodeType = NodeTag.NodeType.NT_BOX;
     NodeTag.NodeType parentNodeType = NodeTag.NodeType.NT_LISTBOX;
     if (itemProperties.GetType() == typeof(CaseOfBoxesProperties))
     {
         iconIndex = 17;
         nodeType = NodeTag.NodeType.NT_CASEOFBOXES;
         parentNodeType = NodeTag.NodeType.NT_LISTCASE;
     }
     else if (itemProperties.GetType() == typeof(BoxProperties))
     {
         BoxProperties boxProperties = itemProperties as BoxProperties;
         if (boxProperties.HasInsideDimensions)
         {
             iconIndex = 4;
             nodeType = NodeTag.NodeType.NT_CASE;
             parentNodeType = NodeTag.NodeType.NT_LISTCASE;
         }
         else
         {
             iconIndex = 3;
             nodeType = NodeTag.NodeType.NT_BOX;
             parentNodeType = NodeTag.NodeType.NT_LISTBOX;
         }
     }
     else if (itemProperties.GetType() == typeof(BundleProperties))
     {
         iconIndex = 5;
         nodeType = NodeTag.NodeType.NT_BUNDLE;
         parentNodeType = NodeTag.NodeType.NT_LISTBUNDLE;
     }
     else if (itemProperties.GetType() == typeof(CylinderProperties))
     {
         iconIndex = 6;
         nodeType = NodeTag.NodeType.NT_CYLINDER;
         parentNodeType = NodeTag.NodeType.NT_LISTCYLINDER;
     }
     else if (itemProperties.GetType() == typeof(PalletProperties))
     {
         iconIndex = 7;
         nodeType = NodeTag.NodeType.NT_PALLET;
         parentNodeType = NodeTag.NodeType.NT_LISTPALLET;
     }
     else if (itemProperties.GetType() == typeof(InterlayerProperties))
     {
         iconIndex = 8;
         nodeType = NodeTag.NodeType.NT_INTERLAYER;
         parentNodeType = NodeTag.NodeType.NT_LISTINTERLAYER;
     }
     else if (itemProperties.GetType() == typeof(TruckProperties))
     {
         iconIndex = 9;
         nodeType = NodeTag.NodeType.NT_TRUCK;
         parentNodeType = NodeTag.NodeType.NT_LISTTRUCK;
     }
     else if (itemProperties.GetType() == typeof(PalletCornerProperties))
     {
         iconIndex = 10;
         nodeType = NodeTag.NodeType.NT_PALLETCORNERS;
         parentNodeType = NodeTag.NodeType.NT_LISTPALLETCORNERS;
     }
     else if (itemProperties.GetType() == typeof(PalletCapProperties))
     {
         iconIndex = 11;
         nodeType = NodeTag.NodeType.NT_PALLETCAP;
         parentNodeType = NodeTag.NodeType.NT_LISTPALLETCAP;
     }
     else if (itemProperties.GetType() == typeof(PalletFilmProperties))
     {
         iconIndex = 12;
         nodeType = NodeTag.NodeType.NT_PALLETFILM;
         parentNodeType = NodeTag.NodeType.NT_LISTPALLETFILM;
     }
     else if (itemProperties.GetType() == typeof(PackProperties))
     {
         iconIndex = 22;
         nodeType = NodeTag.NodeType.NT_PACK;
         parentNodeType = NodeTag.NodeType.NT_LISTPACK;
     }
     else
     {
         Debug.Assert(false);
         _log.Error("AnalysisTreeView.OnNewTypeCreated() -> unknown type!");
         return;
     }
     // get parent node
     TreeNode parentNode = FindNode(null, new NodeTag(parentNodeType, doc));
     if (null == parentNode)
     {
         _log.Error(string.Format("Failed to load parentNode for {0}", itemProperties.Name));
         return;
     }
     // instantiate node
     TreeNode nodeItem = new TreeNode(itemProperties.Name, iconIndex, iconIndex);
     // set node tag
     nodeItem.Tag = new NodeTag(nodeType, doc, itemProperties);
     // insert
     parentNode.Nodes.Add(nodeItem);
     parentNode.Expand();
     // if item is CaseOfBoxesProperties
     if (itemProperties is CaseOfBoxesProperties)
     {
         // insert sub node
         CaseOfBoxesProperties caseOfBoxesProperties = itemProperties as CaseOfBoxesProperties;
         TreeNode subNode = new TreeNode(caseOfBoxesProperties.InsideBoxProperties.Name, 3, 3);
         subNode.Tag = new NodeTag(NodeTag.NodeType.NT_BOX, doc, caseOfBoxesProperties.InsideBoxProperties);
         nodeItem.Nodes.Add(subNode);
     }
 }
Пример #26
0
 public ItemBaseEncapsulator(ItemBase interlayerProperties)
 {
     _itemBase = interlayerProperties;
 }
Пример #27
0
 /// <summary>
 /// handles new type removed
 /// </summary>
 /// <param name="doc"></param>
 /// <param name="itemBase"></param>
 public void OnTypeRemoved(Document doc, ItemBase itemBase)
 {
     NodeTag.NodeType nodeType = NodeTag.NodeType.NT_UNKNOWN;
     if (itemBase.GetType() == typeof(BoxProperties))
     {
         BoxProperties box = itemBase as BoxProperties;
         if (box.HasInsideDimensions)
             nodeType = NodeTag.NodeType.NT_CASE;
         else
             nodeType = NodeTag.NodeType.NT_BOX;
     }
     else if (itemBase.GetType() == typeof(BundleProperties))
         nodeType = NodeTag.NodeType.NT_BUNDLE;
     else if (itemBase.GetType() == typeof(PackProperties))
         nodeType = NodeTag.NodeType.NT_PACK;
     else if (itemBase.GetType() == typeof(CaseOfBoxesProperties))
         nodeType = NodeTag.NodeType.NT_CASEOFBOXES;
     else if (itemBase.GetType() == typeof(InterlayerProperties))
         nodeType = NodeTag.NodeType.NT_INTERLAYER;
     else if (itemBase.GetType() == typeof(PalletCornerProperties))
         nodeType = NodeTag.NodeType.NT_PALLETCORNERS;
     else if (itemBase.GetType() == typeof(PalletCapProperties))
         nodeType = NodeTag.NodeType.NT_PALLETCAP;
     else if (itemBase.GetType() == typeof(PalletFilmProperties))
         nodeType = NodeTag.NodeType.NT_PALLETFILM;
     else if (itemBase.GetType() == typeof(PalletProperties))
         nodeType = NodeTag.NodeType.NT_PALLET;
     else if (itemBase.GetType() == typeof(TruckProperties))
         nodeType = NodeTag.NodeType.NT_TRUCK;
     else if (itemBase.GetType() == typeof(CylinderProperties))
         nodeType = NodeTag.NodeType.NT_CYLINDER;
     Debug.Assert(nodeType != NodeTag.NodeType.NT_UNKNOWN);
     if (nodeType == NodeTag.NodeType.NT_UNKNOWN)
         return; // ->not found exit
     // get node
     TreeNode typeNode = FindNode(null, new NodeTag(nodeType, doc, itemBase));
     // remove node
     if (null != typeNode)
         Nodes.Remove(typeNode);
 }
Пример #28
0
 public ItemBaseCB(ItemBase itemBase)
 {
     _itemBase = itemBase;
 }
 /// <summary>
 /// overrides IItemListener.Update
 /// </summary>
 /// <param name="item"></param>
 public void Update(ItemBase item)
 {
     // update grid
     FillGrid();
     // select first solution
     if (gridSolutions.RowsCount > 0)
         gridSolutions.Selection.SelectRow(1, true);
     // draw
     graphCtrlCaseSolution.Invalidate();
     graphCtrlPalletSolution.Invalidate();
 }
 public void Update(ItemBase item)
 {
     // update grid
     FillGrid();
     // select first solution
     if (gridSolutions.RowsCount > 0)
         gridSolutions.Selection.SelectRow(1, true);
     if (_analysis.Solutions.Count > 0)
         _sol = _analysis.Solutions[0];
     // draw
     graphCtrlSolution.Invalidate();
 }
 public override void OnAttributeModified(ItemBase modifiedAttribute)
 {
     // clear selected solutions
     while (_selectedSolutions.Count > 0)
         UnSelectSolution(_selectedSolutions[0]);
     // clear solutions
     _solutions.Clear();
     // base
     base.OnAttributeModified(modifiedAttribute);
 }