// 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); }