private void lvProviders_ItemChecked(object sender, ItemCheckedEventArgs e) { if (e.Item.Tag != null) { VirtualPropertySet set = new VirtualPropertySet(DefaultProperty.DefaultSet); foreach (ListViewItem item in this.lvProviders.Items) { PropertyProviderInfo tag = (PropertyProviderInfo) item.Tag; if ((item.Checked && (tag != null)) && (tag.Provider != null)) { set.Or(tag.Provider.GetRegisteredProperties()); } } this.lvProperties.BeginUpdate(); try { foreach (ListViewItem item in this.lvProperties.Items) { VirtualProperty property = (VirtualProperty) item.Tag; if (!set[property.PropertyId]) { item.Checked = false; item.ForeColor = SystemColors.GrayText; } else if (property.PropertyId != 0) { item.ForeColor = this.lvProperties.ForeColor; } } } finally { this.lvProperties.EndUpdate(); } } }
public void LoadComponentSettings() { ListViewItem item; VirtualPropertySet set = new VirtualPropertySet(DefaultProperty.DefaultSet); this.lvProviders.BeginUpdate(); try { this.lvProviders.Items.Clear(); foreach (string str in StringHelper.SplitString(Settings.Default.DisabledPropertyProviders, new char[] { ',' })) { this.DisabledProviders.Add(str, 0); } foreach (PropertyProviderInfo info in PropertyProviderManager.GetAllProviders()) { item = new ListViewItem(info.DisplayName) { Tag = info, Checked = !this.DisabledProviders.ContainsKey(info.Key) }; IPropertyProvider component = info.Provider; if (component == null) { item.SubItems.Add(Resources.sNotAvailable); item.ForeColor = SystemColors.GrayText; } else { VersionAttribute attribute = TypeDescriptor.GetAttributes(component).OfType<VersionAttribute>().FirstOrDefault<VersionAttribute>(); if (attribute != null) { item.SubItems.Add(attribute.Version.ToString()); } if (item.Checked) { set.Or(component.GetRegisteredProperties()); } } this.lvProviders.Items.Add(item); } } finally { this.lvProviders.EndUpdate(); } this.lvProperties.BeginUpdate(); try { this.lvProperties.Items.Clear(); Dictionary<int, ListViewGroup> dictionary = new Dictionary<int, ListViewGroup>(); foreach (VirtualProperty property in (IEnumerable<VirtualProperty>) VirtualProperty.All) { ListViewGroup group; if ((property.PropertyOptions & VirtualPropertyOption.Hidden) > 0) { continue; } if (!dictionary.TryGetValue(property.GroupId, out group)) { group = new ListViewGroup(property.LocalizedGroupName); this.lvProperties.Groups.Add(group); dictionary.Add(property.GroupId, group); } item = new ListViewItem(property.LocalizedName) { Group = group, Checked = !property.PropertyVisible ? false : set[property.PropertyId], Tag = property }; if (!((property.PropertyId != 0) && set[property.PropertyId])) { item.ForeColor = SystemColors.GrayText; } switch (System.Type.GetTypeCode(property.PropertyType)) { case TypeCode.Byte: case TypeCode.Int16: case TypeCode.UInt16: case TypeCode.Int32: case TypeCode.UInt32: case TypeCode.Int64: case TypeCode.UInt64: item.ImageIndex = 1; break; case TypeCode.DateTime: item.ImageIndex = 3; break; case TypeCode.String: item.ImageIndex = 2; break; default: if (property.PropertyType == typeof(Version)) { item.ImageIndex = 4; } else { item.ImageIndex = 0; } break; } this.lvProperties.Items.Add(item); } } finally { this.lvProperties.EndUpdate(); } }