internal DeviceFilterNode(WebConfigManager webConfig) : base()
        {
            _webConfig = webConfig;
            _xmlNode   = webConfig.Document.CreateElement("filter");

            Name = SR.GetString(SR.DeviceFilterNode_DefaultFilterName);
            Mode = DeviceFilterMode.Compare;
        }
        internal DeviceFilterNode(
            WebConfigManager webConfig,
            XmlNode xmlNode
            )
        {
            _webConfig = webConfig;
            _xmlNode   = xmlNode;

            Debug.Assert(_xmlNode.Attributes != null);

            if (_xmlNode.Attributes["type"] != null)
            {
                Mode = DeviceFilterMode.Delegate;
                Debug.Assert(
                    _xmlNode.Attributes["argument"] == null && _xmlNode.Attributes["compare"] == null,
                    "Managementobject contains both Compare and Delegate mode properties."
                    );
            }
            else
            {
                Mode = DeviceFilterMode.Compare;
                // we already know type is null, but it nevers hurts...
                Debug.Assert(
                    _xmlNode.Attributes["type"] == null && _xmlNode.Attributes["method"] == null,
                    "Managementobject contains both Compare and Delegate mode properties."
                    );
            }

            _name = _xmlNode.Attributes["name"] == null?
                    null : _xmlNode.Attributes["name"].Value;

            _compare = _xmlNode.Attributes["compare"] == null?
                       null : _xmlNode.Attributes["compare"].Value;

            _argument = _xmlNode.Attributes["argument"] == null?
                        null : _xmlNode.Attributes["argument"].Value;

            _type = _xmlNode.Attributes["type"] == null?
                    null : _xmlNode.Attributes["type"].Value;

            _method = _xmlNode.Attributes["method"] == null?
                      null : _xmlNode.Attributes["method"].Value;
        }
        // NOTE: A FileLoadException is thrown if an error occurs while reading
        //       web.config.
        internal DeviceFilterEditorDialog(ISite site, WebConfigManager webConfig) : base(site)
        {
            InitializeComponent();

            _lblArgument.Text = SR.GetString(SR.DeviceFilterEditorDialog_Argument);
            _glAttributes.Text = SR.GetString(SR.DeviceFilterEditorDialog_Attributes);
            _lblMethod.Text = SR.GetString(SR.DeviceFilterEditorDialog_Method);
            _glType.Text = SR.GetString(SR.DeviceFilterEditorDialog_TypeGl);
            _rbCompare.Text = SR.GetString(SR.DeviceFilterEditorDialog_Equality);
            _lblCompare.Text = SR.GetString(SR.DeviceFilterEditorDialog_Compare);
            _rbDelegate.Text = SR.GetString(SR.DeviceFilterEditorDialog_Evaluator);
            _lblType.Text = SR.GetString(SR.DeviceFilterEditorDialog_TypeTxt);
            _lblHeader.Text = SR.GetString(SR.DeviceFilterEditorDialog_Header);
            this.Text = SR.GetString(SR.DeviceFilterEditorDialog_Title);

            int tabOffset = 0;
            this._pnlMain.TabIndex = tabOffset++;
            this._filterList.TabIndex = tabOffset++;
            this._pnlRight.TabIndex = tabOffset++;
            this._glType.TabIndex = tabOffset++;
            this._rbCompare.TabIndex = tabOffset++;
            this._rbDelegate.TabIndex = tabOffset++;
            this._glAttributes.TabIndex = tabOffset++;
            this._pnlCompare.TabIndex = tabOffset++;
            this._pnlDelegate.TabIndex = tabOffset++;
            this._lblCompare.TabIndex = tabOffset++;
            this._cbCompare.TabIndex = tabOffset++;
            this._lblType.TabIndex = tabOffset++;
            this._txtType.TabIndex = tabOffset++;
            this._lblArgument.TabIndex = tabOffset++;
            this._txtArgument.TabIndex = tabOffset++;
            this._lblMethod.TabIndex = tabOffset++;
            this._txtMethod.TabIndex = tabOffset++;
            this._dialogButtons.TabIndex = tabOffset++;
            
            _webConfig = webConfig;
            this._site = site;
            GenericUI.InitDialog(this, site);

            _filterList.LblTitle.Text = SR.GetString(SR.DeviceFilterEditorDialog_DeviceFilters);
            _filterList.BtnAdd.Text = SR.GetString(SR.DeviceFilterEditorDialog_NewDeviceFilter);

            // Attempt to load Device Filters
            ArrayList filters = null;
            try 
            {
                filters = _webConfig.ReadDeviceFilters();
            }
            catch (FileNotFoundException e)
            {
                GenericUI.ShowWarningMessage(
                    SR.GetString(SR.DeviceFilterEditorDialog_Title),
                    SR.GetString(SR.DeviceFilterEditorDialog_WebConfigMissingOnOpen)
                );
                throw new FileLoadException(
                    SR.GetString(SR.WebConfig_FileLoadException, e)
                );
            }
            catch (Exception e)
            {
                if (e.Message.Equals(SR.GetString(SR.DeviceFilterEditorDialog_DuplicateNames)))
                {
                    GenericUI.ShowWarningMessage(
                        SR.GetString(SR.DeviceFilterEditorDialog_Title),
                        SR.GetString(SR.DeviceFilterEditorDialog_DuplicateNames)
                    );
                }
                else
                {
                    GenericUI.ShowWarningMessage(
                        SR.GetString(SR.DeviceFilterEditorDialog_Title),
                        SR.GetString(
                            SR.DeviceFilterEditorDialog_WebConfigParsingError,
                            e.Message
                        )
                    );
                }
                throw new FileLoadException(
                    SR.GetString(SR.WebConfig_FileLoadException, e)
                );
            }

            // Make sure web.config is checked out before we make changes.
            _webConfig.EnsureWebConfigCheckedOut();

            // Insert the Device Filters into the List UI
            foreach(DeviceFilterNode filter in filters)
            {
                DeviceFilterTreeNode node = new DeviceFilterTreeNode(filter);
                _filterList.TvList.Nodes.Add(node);
            }

            // Make sure all filters have a name...
            // NOTE: Do not combine with the above loop or GetUniqueLabel()
            //       will not necessarily be unique.  It could be done if
            //       we wrote another implementation of GetUniqueLabel()
            //       that compared against filters [ArrayList returned
            //       from ReadDeviceFilters()].
            foreach(DeviceFilterTreeNode node in _filterList.TvList.Nodes)
            {
                if(String.IsNullOrEmpty(node.Text))
                {
                    node.Text = _filterList.GetUniqueLabel(
                        SR.GetString(SR.DeviceFilterNode_DefaultFilterName)
                    );
                }
            }
                
            // Initialize the UI
            _rbCompare.Click += new EventHandler(OnClickCompareRadioButton);
            _rbDelegate.Click += new EventHandler(OnClickDelegateRadioButton);
            _cbCompare.TextChanged += new EventHandler(OnTextChanged);
            _cbCompare.SelectedIndexChanged += new EventHandler(OnTextChanged);
            _txtArgument.TextChanged += new EventHandler(OnTextChanged);
            _txtType.TextChanged += new EventHandler(OnTextChanged);
            _txtMethod.TextChanged += new EventHandler(OnTextChanged);
            _filterList.TvList.AfterLabelEdit += new NodeLabelEditEventHandler(OnAfterLabelEdit);
            _filterList.TvList.AfterSelect += new TreeViewEventHandler(OnFilterSelected);
            _filterList.BtnAdd.Click += new EventHandler(OnClickAddButton);
            _filterList.BtnRemove.Click += new EventHandler(OnClickRemoveButton);
            _filterList.TvList.SelectedNode = null;

            LoadAvailableCapabilities();
            UpdateButtonsEnabling();

            _dialogButtons.CmdOK.Click += new EventHandler(OnClickOK);
            _dialogButtons.CmdCancel.Click += new EventHandler(OnClickCancel);
        }
 internal DeviceFilterTreeNode(WebConfigManager webConfig) : base()
 {
     DeviceFilter = new DeviceFilterNode(webConfig);
     base.Text = DeviceFilter.Name;
 }
        internal AppliedDeviceFiltersDialog(
            IDeviceSpecificDesigner designer, 
            int mergingContext) : base (designer.UnderlyingControl.Site)
        {
            _designer = designer;
            _designer.SetDeviceSpecificEditor(this);

            // Required for Win Form Designer support
            InitializeComponent();

            _lblAvailableFilters.Text =
                SR.GetString(SR.AppliedDeviceFiltersDialog_AvailableDeviceFilters);
            _appliedFiltersList.LblTitle.Text =
                SR.GetString(SR.AppliedDeviceFiltersDialog_AppliedDeviceFilters);
            _btnEditFilters.Text = SR.GetString(SR.GenericDialog_Edit);
            _btnApplyFilter.Text =
                SR.GetString(SR.AppliedDeviceFiltersDialog_ApplyDeviceFilter);
            _lblArgument.Text =
                SR.GetString(SR.AppliedDeviceFiltersDialog_Argument);
            _cmdOK.Text = SR.GetString(SR.GenericDialog_OKBtnCaption);
            _cmdCancel.Text = SR.GetString(SR.GenericDialog_CancelBtnCaption);

            int tabOffset = GenericUI.InitDialog(
                this,
                _designer,
                mergingContext
            );
            
            this.Text = _designer.UnderlyingControl.ID
                + " - " + SR.GetString(SR.AppliedDeviceFiltersDialog_Title);
            SetTabIndexes(tabOffset);
            _webConfig = new WebConfigManager(_designer.UnderlyingControl.Site);
            LoadAvailableFilters();

            // Note that the following can cause an
            // IDeviceSpecificDesigner.Refresh() to occur as a side-effect.
            _designer.RefreshHeader(mergingContext);

            _currentDeviceSpecificID = _designer.CurrentDeviceSpecificID;
            if(_currentDeviceSpecificID != null)
            {
                DeviceSpecific ds;
                _designer.GetDeviceSpecific(_currentDeviceSpecificID, out ds);
                LoadChoices(ds);
            }

            // Register Event Handlers
            _cbAvailableFilters.SelectedIndexChanged += new EventHandler(
                OnAvailableFilterSelected
            );
            _cbAvailableFilters.TextChanged += new EventHandler(
                OnAvailableFilterSelected
            );
            _btnApplyFilter.Click += new EventHandler(OnApplyFilter);
            _btnEditFilters.Click += new EventHandler(OnEditFilters);
            _appliedFiltersList.TvList.AfterSelect += new TreeViewEventHandler(OnAppliedFilterSelected);
            _appliedFiltersList.TvList.AfterLabelEdit += new NodeLabelEditEventHandler(OnAfterLabelEdit);
            _appliedFiltersList.BtnUp.Click += new EventHandler(OnAppliedFiltersReordered);
            _appliedFiltersList.BtnDown.Click += new EventHandler(OnAppliedFiltersReordered);
            _appliedFiltersList.BtnRemove.Click -= _appliedFiltersList.RemoveHandler;
            _appliedFiltersList.BtnRemove.Click += new EventHandler(OnRemove);
            _tbArgument.TextChanged += new EventHandler(OnArgumentChanged);
            _cmdOK.Click += new EventHandler(OnOK);
            _cmdCancel.Click += new EventHandler(OnCancel);

            UpdateUI();
        }
        internal DeviceFilterNode(
            WebConfigManager webConfig,
            XmlNode xmlNode
        ) {
            _webConfig = webConfig;
            _xmlNode = xmlNode;

            Debug.Assert(_xmlNode.Attributes != null);

            if (_xmlNode.Attributes["type"] != null)
            {
                Mode = DeviceFilterMode.Delegate;
                Debug.Assert(
                    _xmlNode.Attributes["argument"] == null && _xmlNode.Attributes["compare"] == null,
                    "Managementobject contains both Compare and Delegate mode properties."
                );
            }
            else
            {
                Mode = DeviceFilterMode.Compare;
                // we already know type is null, but it nevers hurts...
                Debug.Assert(
                    _xmlNode.Attributes["type"] == null && _xmlNode.Attributes["method"] == null,
                    "Managementobject contains both Compare and Delegate mode properties."
                );
            }

            _name = _xmlNode.Attributes["name"] == null? 
                null : _xmlNode.Attributes["name"].Value;

            _compare = _xmlNode.Attributes["compare"] == null?
                null : _xmlNode.Attributes["compare"].Value;

            _argument = _xmlNode.Attributes["argument"] == null?
                null : _xmlNode.Attributes["argument"].Value;

            _type = _xmlNode.Attributes["type"] == null?
                null : _xmlNode.Attributes["type"].Value;

            _method = _xmlNode.Attributes["method"] == null?
                null : _xmlNode.Attributes["method"].Value;
        }
        internal DeviceFilterNode(WebConfigManager webConfig) : base()
        {
            _webConfig = webConfig;
            _xmlNode = webConfig.Document.CreateElement("filter");

            Name = SR.GetString(SR.DeviceFilterNode_DefaultFilterName);
            Mode = DeviceFilterMode.Compare;
        }