/// <summary>
 ///
 /// </summary>
 /// <param name="selectedItems"></param>
 /// <param name="parent"></param>
 /// <param name="deviceAddress">Complete Device Address, ex. 01-02-03 for a level 3 node</param>
 public DeviceNodeViewModel(
     TreeViewViewModel <TreeViewItemViewModel> tree,
     ICollectionModel <Device> dataModel,
     //ObservableCollection<TreeViewItemViewModel> selectedItems,
     DeviceNodeViewModel parent,
     string deviceAddress,
     int maxDeviceAddressLength)
     : base(tree, /*selectedItems, */ parent, (deviceAddress == null) || (deviceAddress.Trim().Length < maxDeviceAddressLength))
 {
     this._tree                   = tree;
     this._dataModel              = dataModel;
     this._deviceAddress          = deviceAddress;
     this._maxDeviceAddressLength = maxDeviceAddressLength;
 }
예제 #2
0
        IEnumerable <DeviceNodeViewModel> FindDeviceNode(string deviceAddress, DeviceNodeViewModel node)
        {
            if (node != null)
            {
                //DebugLog.TraceMessage(node.DeviceAddress);
                if (node.DeviceAddress == deviceAddress)    // 如果就是這個節點
                {
                    yield return(node);
                }

                // 如果是在這節點下的子節點
                if (node.Children != null && deviceAddress.StartsWith(node.DeviceAddress))
                {
                    foreach (var child in node.Children)
                    {
                        foreach (var selected in this.FindDeviceNode(deviceAddress, child as DeviceNodeViewModel))
                        {
                            yield return(selected);
                        }
                    }
                }
            }
        }