private void eventSourceCombo_SelectedItemsChanged(object sender, EventArgs e)
        {
            var provs = Array.ConvertAll <DropDownCheckListItem, string>(eventSourceCombo.SelectedItems, i => (string)i.Value);

            if (!internalSet)
            {
                ql.Query.Providers = new List <string>(provs);
                if (eventLogCombo.CheckedItems.Count == 0)
                {
                    var logs = SystemEventEnumerator.GetLogsForProviders(null, provs);
                    foreach (var log in logs)
                    {
                        eventLogCombo.CheckValue(log);
                    }
                    EnableControls();
                }
            }
            var tasks = SystemEventEnumerator.GetEventTasks(null, provs);

            if (tasks.Count == 0)
            {
                categoryCombo.Enabled = false;
            }
            else
            {
                categoryCombo.Enabled = true;
                categoryCombo.BeginUpdate();
                categoryCombo.Items.Clear();
                categoryCombo.Items.Add(new DropDownCheckListItem(categoryCombo.CheckAllText));
                categoryCombo.Items.AddRange(tasks.ConvertAll <DropDownCheckListItem>(kv => new DropDownCheckListItem(kv.Value, kv.Key)).ToArray());
                categoryCombo.EndUpdate();
            }
        }
 private static void UpdateProviderList(CheckedListBox.ObjectCollection items, string targetServer = null)
 {
     if (Providers == null)
     {
         Providers = new System.Collections.Generic.List <string>(SystemEventEnumerator.GetEventProviders(targetServer, null, true));
     }
     items.Clear();
     items.AddRange(Providers.ConvertAll <DropDownCheckListItem>(s => { var p = s.Split('|'); return(new DropDownCheckListItem(p[1], p[0])); }).ToArray());
 }
 private static void UpdateLogList(TreeNodeCollection nodes, string targetServer = null)
 {
     if (Logs == null)
     {
         Logs = new StringNode(null);
         // Add standard nodes
         StringNode std     = new StringNode(EditorProperties.Resources.EventLogParentStandard);
         string[]   stdLogs = new string[] { "Application", "Security", "Setup", "System", "ForwardedEvents" };
         foreach (string s in stdLogs)
         {
             std.Nodes.Add(new StringNode(s, s));
         }
         std.LastChild.Text = "Forwarded Events";
         Logs.Nodes.Add(std);
         // Get all event logs and remove standard ones
         var list = new List <string>(SystemEventEnumerator.GetEventLogs(targetServer));
         list.Sort();
         foreach (string s in stdLogs)
         {
             list.Remove(s);
         }
         // Add app nodes
         StringNode lastParent = null, curCompare = null, appNode = new StringNode(EditorProperties.Resources.EventLogParentApps);
         Logs.Nodes.Add(appNode);
         int max = 0;
         var partList = list.ConvertAll <string[]>(delegate(string s) { var a = s.Split('-', '/', '\\'); max = Math.Max(max, a.Length); return(a); });
         for (int i = 0; i < partList.Count; i++)
         {
             lastParent = appNode;
             for (int j = 0; j < partList[i].Length; j++)
             {
                 if (curCompare != null && string.Compare(curCompare, partList[i][j], true) == 0)
                 {
                     lastParent = curCompare;
                     curCompare = curCompare.LastChild;
                 }
                 else
                 {
                     var sn = new StringNode(partList[i][j]);
                     if (j == partList[i].Length - 1)
                     {
                         sn.Path = list[i];
                     }
                     lastParent.Nodes.Add(sn);
                     lastParent = sn;
                 }
             }
             curCompare = appNode.LastChild;
         }
     }
     Logs.UpdateTreeView(nodes);
 }