private bool FiltersAreValid() { #if DEBUG Debug.Assert( !Debug_DuplicateFiltersExist(_filterList.TvList.Nodes), "UI failed to prevent duplicate filters from being created." ); #endif ArrayList filtersInErrorList = new ArrayList(); foreach (DeviceFilterTreeNode filterNode in _filterList.TvList.Nodes) { DeviceFilterNode filter = filterNode.DeviceFilter; if (!FilterIsLegal(filter)) { filtersInErrorList.Add(filter.Name); } } if (filtersInErrorList.Count != 0) { GenericUI.ShowWarningMessage( SR.GetString(SR.DeviceFilterEditorDialog_Title), SR.GetString( SR.DeviceFilterEditorDialog_InvalidFilter, GenericUI.BuildCommaDelimitedList( filtersInErrorList ) ) ); return(false); } return(true); }
private void OnTextChanged(Object sender, EventArgs e) { if (null != _filterList.SelectedNode) { DeviceFilterNode node = ((DeviceFilterTreeNode)_filterList.SelectedNode).DeviceFilter; if (sender == _cbCompare) { node.Compare = _cbCompare.Text; } else if (sender == _txtArgument) { node.Argument = _txtArgument.Text; } else if (sender == _txtType) { node.Type = _txtType.Text; } else if (sender == _txtMethod) { node.Method = _txtMethod.Text; } else { Debug.Fail("Unknown sender."); } } }
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 = ""; } }
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 bool FilterExistsInComboBox(DeviceFilterNode filter) { foreach (DeviceFilterNode availableFilter in _cachedComboBox) { if (availableFilter.Name == filter.Name) { 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 SelectFirstAvailableFilter() { if (_cbAvailableFilters.Items.Count > 0) { DeviceFilterNode filter = (DeviceFilterNode)_cbAvailableFilters.Items[0]; _cbAvailableFilters.SelectedItem = filter; } else { _cbAvailableFilters.Text = ""; } }
private void LoadChoice(DeviceSpecificChoice runtimeChoice) { DeviceFilterNode filterUsed = FindAvailableFilter(runtimeChoice.Filter); ChoiceTreeNode choice = new ChoiceTreeNode( filterUsed, runtimeChoice, _designer ); _appliedFiltersList.TvList.Nodes.Add(choice); }
private void EnsureDefaultFilterAvailableXorApplied() { if (DefaultFilterIsApplied) { DeviceFilterNode filter = FindAvailableFilter(""); if (filter != null) { RemoveAvailableFilter(filter); } } else if (!DefaultFilterIsAvailable) { _cbAvailableFilters.Items.Add(CreateExternalFilter("")); } }
private bool Debug_DuplicateFiltersExist(ICollection filters) { // Filter names are case-sensitive. IDictionary namesEncountered = new Hashtable(); foreach (DeviceFilterTreeNode node in filters) { DeviceFilterNode filter = node.DeviceFilter; if (namesEncountered[filter.Name] != null) { return(true); } namesEncountered[filter.Name] = true; } return(false); }
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); } }
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); }
private void RemoveAvailableFilter(DeviceFilterNode filter) { SelectNextAvailableFilter(filter); _cbAvailableFilters.Items.Remove(filter); UpdateUI(); }
internal DeviceFilterTreeNode(DeviceFilterNode node) { DeviceFilter = node; base.Text = node.Name; }
internal DeviceFilterTreeNode(WebConfigManager webConfig) : base() { DeviceFilter = new DeviceFilterNode(webConfig); base.Text = DeviceFilter.Name; }
private void OnApplyFilter(Object sender, EventArgs e) { DeviceFilterNode filter = (DeviceFilterNode)_cbAvailableFilters.SelectedItem; if (filter == null) { String name = _cbAvailableFilters.Text; Debug.Assert( ((name != null) && (name.Length > 0)), "Should not be trying to apply a filter with none selected. " + "Missed a call to UpdateUI()?" ); // If the user typed the name of a filter which exists in their // web.config, we need to find the original rather than create // a new external filter. filter = FindAvailableFilter(name); if (filter == null) { /* Removed for DCR 4240 * if (!DesignerUtility.IsValidName(name)) * { * GenericUI.ShowWarningMessage( * SR.GetString(SR.AppliedDeviceFiltersDialog_Title), * SR.GetString( * SR.AppliedDeviceFiltersDialog_InvalidFilterName, * _cbAvailableFilters.Text * ) * ); * return; * } */ filter = CreateExternalFilter(_cbAvailableFilters.Text); } } ChoiceTreeNode choice = new ChoiceTreeNode( filter, _designer ); if (IsDefaultFilter(filter.Name)) { if (DefaultFilterIsApplied) { // Do not allow user to apply default filter if already // been applied. GenericUI.ShowWarningMessage( SR.GetString(SR.AppliedDeviceFiltersDialog_Title), SR.GetString(SR.AppliedDeviceFiltersDialog_DefaultFilterAlreadyApplied) ); } else { // Add the default filter to the end of the list and // remove it from list of available filters. _appliedFiltersList.TvList.Nodes.Add(choice); RemoveAvailableFilter(filter); } } else { // All other filters are added to the beginning _appliedFiltersList.TvList.Nodes.Insert(0, choice); } SetDirty(true); UpdateUI(); }