// <summary>
        //    Returns a copy of this node's encapsulated data.  Does not
        //    copy TreeNode fields.
        // </summary>
        public Object Clone()
        {
            DeviceFilterNode newNode = new DeviceFilterNode(
                _webConfig
                );

            newNode.Name = this.Name;
            newNode.Mode = this.Mode;
            if (this.Mode == DeviceFilterMode.Compare)
            {
                newNode.Compare  = this.Compare;
                newNode.Argument = this.Argument;
            }
            else
            {
                newNode.Type   = this.Type;
                newNode.Method = this.Method;
            }
            return((Object)newNode);
        }
        internal ArrayList ReadDeviceFilters()
        {
            EnsureWebConfigIsPresent();

            // Reload the document everytime we read filters
            LoadDocument();

            XmlNode   filters          = FindFilterSection(Document, false);
            ArrayList DeviceFilterList = new ArrayList();

            if (filters != null)
            {
                Hashtable filterTable = new Hashtable();

                foreach (XmlNode childNode in filters.ChildNodes)
                {
                    if (childNode.Name != null && childNode.Name.Equals("filter"))
                    {
                        // Ignore the empty filter.
                        if (childNode.Attributes["name"] == null ||
                            childNode.Attributes["name"].Value == null ||
                            childNode.Attributes["name"].Value.Length == 0)
                        {
                            continue;
                        }

                        String filterName = childNode.Attributes["name"].Value;
                        if (filterTable[filterName] != null)
                        {
                            throw new Exception(SR.GetString(SR.DeviceFilterEditorDialog_DuplicateNames));
                        }

                        DeviceFilterNode node = new DeviceFilterNode(this, childNode);
                        DeviceFilterList.Add(node);
                        filterTable[filterName] = true;
                    }
                }
            }

            return(DeviceFilterList);
        }
 internal bool FilterExistsInComboBox(DeviceFilterNode filter)
 {
     foreach(DeviceFilterNode availableFilter in _cachedComboBox)
     {
         if(availableFilter.Name == filter.Name)
         {
             return true;
         }
     }
     return false;
 }
 internal DeviceFilterTreeNode(DeviceFilterNode node)
 {
     DeviceFilter = node;
     base.Text = node.Name;
 }
 internal DeviceFilterTreeNode(WebConfigManager webConfig) : base()
 {
     DeviceFilter = new DeviceFilterNode(webConfig);
     base.Text = DeviceFilter.Name;
 }
 private bool FilterIsLegal(DeviceFilterNode filter)
 {
     Object[] legalCombinations = {
         new RequirementFlag[] {
             RequirementFlag.Required,         // compare mode
             RequirementFlag.Required,         // compare
             RequirementFlag.Optional,         // argument
             RequirementFlag.Optional,         // method
             RequirementFlag.Optional          // type
         },
         new RequirementFlag[] {
             RequirementFlag.NotAllowed,       // compare mode
             RequirementFlag.Optional,         // compare
             RequirementFlag.Optional,         // argument
             RequirementFlag.Required,         // method
             RequirementFlag.Required          // type
         }
     };
     
     bool[] filterCombination = {
         (filter.Mode == DeviceFilterMode.Compare),
         ((filter.Compare != null) && (filter.Compare.Length > 0)),
         ((filter.Argument != null) && (filter.Argument.Length > 0)),
         ((filter.Type != null) && (filter.Type.Length > 0)),
         ((filter.Method != null) && (filter.Method.Length > 0)),
     };
     
     foreach(RequirementFlag[] legalCombination in legalCombinations)
     {
         if(FilterIsLegal_CheckRow(legalCombination, filterCombination))
         {
             return true;
         }
     }
     return false;
 }
 internal bool ChoiceExistsInTreeView(DeviceFilterNode filter)
 {
     foreach(ChoiceTreeNode appliedFilter in _cachedTreeView)
     {
         if(appliedFilter.Name == filter.Name)
         {
             return true;
         }
     }
     return false;
 }
 private void SelectNextAvailableFilter(DeviceFilterNode currentFilter)
 {
     // if an externally defined filter is selected, let
     // SelectFirstAvailableFitler handle this.
     if(currentFilter == null)
     {
         SelectFirstAvailableFilter();
         return;
     }
     
     int index = _cbAvailableFilters.Items.IndexOf(currentFilter);
     if((index + 1) < _cbAvailableFilters.Items.Count)
     {
         _cbAvailableFilters.SelectedItem =
             _cbAvailableFilters.Items[index + 1];
     }
     else if(index > 0)
     {
         _cbAvailableFilters.SelectedItem =
             _cbAvailableFilters.Items[index - 1];
     }
     else
     {
         _cbAvailableFilters.SelectedItem = null;
         _cbAvailableFilters.Text = String.Empty;
     }
 }
 private void RemoveAvailableFilter(DeviceFilterNode filter)
 {
     SelectNextAvailableFilter(filter);
     _cbAvailableFilters.Items.Remove(filter);
     UpdateUI();
 }
 private DeviceFilterNode CreateExternalFilter(String name)
 {
     DeviceFilterNode externalFilter;
     externalFilter = new DeviceFilterNode(_webConfig);
     externalFilter.Name = name;
     return externalFilter;
 }
 internal ChoiceTreeNode(
     DeviceFilterNode filter,
     DeviceSpecificChoice runtimeChoice,
     IDeviceSpecificDesigner designer
 ) : base()
 {
     _designer = designer;
     _runtimeChoice = runtimeChoice;
     Name = _runtimeChoice.Filter;
     Argument = _runtimeChoice.Argument;
 }
        internal ChoiceTreeNode(
            DeviceFilterNode filter,
            IDeviceSpecificDesigner designer
        ) : base() 
        {
            Name = filter.Name;
            _designer = designer;
            _runtimeChoice = new DeviceSpecificChoice();
            _runtimeChoice.Filter = filter.Name;

            if(
                // This looks like circular reasoning, but the designer is a
                // IDeviceSpecificDesigner and we are interested in the
                // type of the designer's parent control.
                Adapters.DesignerAdapterUtil.ControlDesigner(designer.UnderlyingControl)
                is MobileTemplatedControlDesigner
            ) 
            {
                _runtimeChoice.Xmlns = SR.GetString(SR.MarkupSchema_HTML32);
            }
        }
 // <summary>
 //    Returns a copy of this node's encapsulated data.  Does not
 //    copy TreeNode fields.
 // </summary>
 public Object Clone()
 {
     DeviceFilterNode newNode = new DeviceFilterNode(
         _webConfig
     );
     newNode.Name = this.Name;
     newNode.Mode = this.Mode;
     if(this.Mode == DeviceFilterMode.Compare)
     {
         newNode.Compare = this.Compare;
         newNode.Argument = this.Argument;
     }
     else
     {
         newNode.Type = this.Type;
         newNode.Method = this.Method;
     }
     return (Object) newNode;
 }
        internal ArrayList ReadDeviceFilters()
        {
            EnsureWebConfigIsPresent();

            // Reload the document everytime we read filters
            LoadDocument();

            XmlNode filters = FindFilterSection(Document, false);
            ArrayList DeviceFilterList = new ArrayList();

            if (filters != null)
            {
                Hashtable filterTable = new Hashtable();

                foreach(XmlNode childNode in filters.ChildNodes)
                {
                    if (childNode.Name != null && childNode.Name.Equals("filter"))
                    {
                        // Ignore the empty filter.
                        if (childNode.Attributes["name"] == null ||
                            childNode.Attributes["name"].Value == null ||
                            childNode.Attributes["name"].Value.Length == 0)
                        {
                            continue;
                        }

                        String filterName = childNode.Attributes["name"].Value;
                        if (filterTable[filterName] != null)
                        {
                            throw new Exception(SR.GetString(SR.DeviceFilterEditorDialog_DuplicateNames));
                        }

                        DeviceFilterNode node = new DeviceFilterNode(this, childNode);
                        DeviceFilterList.Add(node);
                        filterTable[filterName] = true;
                    }
                }
            }

            return DeviceFilterList;
        }