Beispiel #1
0
        private void EnumerateInstanceNames(string className)
        {
            baseKeyClassMap = new Dictionary<CimName, CimName>();
            EnumerateInstanceNamesOpSettings ei = new EnumerateInstanceNamesOpSettings(className);
            mainKBSet = new KeyBindingSet();

            //try
            //{
                progress = new ProgressForm();
                progress.Show();
                progress.Refresh();

                CimInstanceNameList list = mainWbemClient.EnumerateInstanceNames(ei);

                progress.Status = ProgressForm.Updating;
                progress.Refresh();

                int count = list.Count;
                int curCount = 0;
                foreach (CimInstanceName curCIN in list)
                {
                    if (!mainKBSet.Contains(curCIN.KeyBindings, FindBaseKeyClass(curCIN.ClassName)))
                    {
                        mainKBSet.Add(curCIN.KeyBindings, FindBaseKeyClass(curCIN.ClassName));
                    }
                    else
                    {
                        // inc the number in this set item.
                        mainKBSet.Find(curCIN.KeyBindings, FindBaseKeyClass(curCIN.ClassName)).NumInstances++;
                    }
                    curCount++;
                    float val = ((float)curCount * 100) / count;
                    progress.UIupdateComplete(Convert.ToInt32(val));
                }

                list.RemoveRange(0, list.Count);

                list = null;
                DisplayList(mainKBSet, count);
                progress.Close();
            //}
            //catch (Exception e)
            //{
            //    MessageBox.Show(e.Message);
            //}
        }
Beispiel #2
0
        public static List<ListViewItem> ToList(KeyBindingSet mainKBSet)
        {
            List<ListViewItem> newList = new List<ListViewItem>();
            for (int i = 0; i < mainKBSet.Set.Count; i++)
            {
                KeyBindingSetItem curItem = mainKBSet.Set[i];

                ListViewItem item = new ListViewItem(new string[] { curItem.BaseKeyClassName, curItem.NumInstances.ToString() }, (int)ImageUtils.ImageIndex.Instance);

                newList.Add(item);
            }
            return newList;
        }
Beispiel #3
0
        private void DisplayList(KeyBindingSet mainKBSet, int count)
        {
            uxLstView_Instances.BeginUpdate();
            uxLstView_Instances.Items.Clear();

            if (mainKBSet != null)
            {
                statusStrip1.Items[0].Text = "Count: " + count;

                List<ListViewItem> newList = ListViewUtils.ToList(mainKBSet);

                uxLstView_Instances.Items.AddRange(newList.ToArray());
            }

            col0.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);

            if (col0.Width < 80)
                col0.Width = 80;

            col1.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);

            uxLstView_Instances.EndUpdate();
            GC.Collect();
        }