private void TransferTreeToDoc(NGTreeNode rootnode, PlotItemCollection picoll)
        {
            picoll.Clear();
            foreach (NGTreeNode node in rootnode.Nodes)
            {
                IGPlotItem item = (IGPlotItem)node.Tag;
                if (item is PlotItemCollection) // if this is a plot item collection
                {
                    TransferTreeToDoc(node, (PlotItemCollection)item);
                }

                picoll.Add(item);
            }
        }
        public bool Apply()
        {
            if (!this.m_bDirty)
            {
                return(true);     // not dirty - so no need to apply something
            }
            _originalDoc.Clear(); // first, clear all Plot items
            TransferTreeToDoc(_plotItemsRootNode, _originalDoc);

            if (_useDocument == UseDocument.Copy)
            {
                _doc = _originalDoc.Clone();
            }
            SetElements(true); // Reload the applied contents to make sure it is synchronized

            return(true);      // all ok
        }
    private void TransferTreeToDoc(NGTreeNode rootnode, PlotItemCollection picoll)
    {
      picoll.Clear();
      foreach (NGTreeNode node in rootnode.Nodes)
      {
        IGPlotItem item = (IGPlotItem)node.Tag;
        if (item is PlotItemCollection) // if this is a plot item collection
          TransferTreeToDoc(node, (PlotItemCollection)item);

        picoll.Add(item);
      }
    }