private void UpdateWMIClassCollection(string status)
        {
            IEnumerable <WMIClass> result = from q in WMIClasses
                                            select q;

            result = result
                     .Where(x => x.Name == WMIClassName);

            WMIClass record = result
                              .SingleOrDefault();

            record.Status = status;
        }
Example #2
0
        private void propertiesListView_ItemActivate(object sender, EventArgs e)
        {
            if (propertiesListView.SelectedItems.Count == 0)
            {
                return;
            }

            string propertyName = propertiesListView.SelectedItems[0].Text;
            string newValue     = Interaction.InputBox("Please enter the new value that you want for this property.", propertyName, propertiesListView.SelectedItems[0].SubItems[1].Text);

            if (newValue.Length > 0)
            {
                ListViewItem currentItem = classesListView.SelectedItems[0];

                if (currentItem == null)
                {
                    return;
                }

                WMIClass currentWmiClass = currentItem.Tag as WMIClass;
                addNewItem(currentWmiClass.DisplayName, propertyName, newValue);
            }
        }
Example #3
0
        private void classesListView_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (classesListView.SelectedItems.Count == 0)
            {
                return;
            }

            ListViewItem currentItem = classesListView.SelectedItems[0];

            if (currentItem == null)
            {
                return;
            }

            WMIClass currentWmiClass = currentItem.Tag as WMIClass;

            propertiesListView.Clear();
            propertiesListView.Columns.Add("Property Name", -2, HorizontalAlignment.Left);
            propertiesListView.Columns.Add("Current Value (First instance)", -2, HorizontalAlignment.Left);
            propertiesListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            propertiesListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            propertiesListView.BeginUpdate();

            LoadingForm loadingWindow = new LoadingForm();

            loadingWindow.Show(this);

            ManagementObjectCollection instances = currentWmiClass.Class.GetInstances();

            foreach (PropertyData property in currentWmiClass.Class.Properties)
            {
                if (property.Type == CimType.String)
                {
                    string        propName   = property.Name;
                    string        propDesc   = String.Empty;
                    List <string> propValues = new List <string>();

                    try
                    {
                        foreach (ManagementObject c in instances)
                        {
                            object value = c.Properties[property.Name.ToString()].Value;

                            if (value != null)
                            {
                                propValues.Add(value.ToString());
                            }

                            break;
                        }
                    }
                    catch
                    {
                    }

                    foreach (QualifierData qualifier in property.Qualifiers)
                    {
                        if (qualifier.Name.Equals("Description", StringComparison.CurrentCultureIgnoreCase))
                        {
                            propDesc = qualifier.Value.ToString();
                        }
                    }

                    ListViewItem listItem = new ListViewItem
                    {
                        Name        = propName,
                        Text        = propName,
                        ToolTipText = propDesc,
                        Tag         = property
                    };

                    listItem.SubItems.Add(string.Join(" | ", propValues));
                    propertiesListView.Items.Add(listItem);
                }
            }

            loadingWindow.Close();
            propertiesListView.Sorting = SortOrder.Ascending;
            propertiesListView.Sort();
            propertiesListView.EndUpdate();
        }