private void cmbProps_SelectedIndexChanged(object sender, EventArgs e) { lsbValues.Items.Clear(); lsbValues.SelectedIndex = -1; btnAdd.Enabled = false; gbConnect.Enabled = false; if (cmbProps.SelectedIndex < 0 || cmbProps.SelectedItem == null || !(cmbProps.SelectedItem is PropertyFilter)) { return; } var selectedItem = PropertyFilter.FirstOrDefault(x => x.PropertyName == (cmbProps.SelectedValue as PropertyFilter).PropertyName); selectedItem.Values.Sort(CompareValues); foreach (var val in selectedItem.Values) { if (val.Value != null) { if (CurrentDevice == null && !lsbValues.Items.Contains(val.Value)) { lsbValues.Items.Add(val.Value); } else if (val.Parent == CurrentDevice && !lsbValues.Items.Contains(val.Value)) { lsbValues.Items.Add(val.Value); } } } gbConnect.Enabled = true; }
private void AddFilterValue(string parent, XElement prop, object parsedValue) { XElement filterMember = prop.Element("FilterMember"); if (parent == null || filterMember == null || filterMember.Value == null || !filterMember.Value.ToBoolean()) { return; } var key = prop.Element("Name").Value.ToString(); var item = PropertyFilter.FirstOrDefault(x => x.PropertyName == key); if (item != null) { var valList = item.Values; var valuePair = new PropertyFilterValue { Value = parsedValue, Parent = parent }; if (!valList.Contains(valuePair)) { valList.Add(valuePair); } } else { var valList = new List <PropertyFilterValue>(); valList.Add(new PropertyFilterValue { Value = parsedValue, Parent = parent }); PropertyFilter.Add(new PropertyFilter { PropertyName = key, Values = valList }); } }