public static WinFormsUINotifierBase GetNotifierUIClass(INotifier agent)
        {
            WinFormsUINotifierBase uiClass = null;

            if (agentsCache == null || agentsCache.Count == 0)
            {
                LoadCache();
            }
            WinFormsUIEntry winFormsUIEntry = (from w in agentsCache
                                               where w.AgentClassName == agent.AgentClassName &&
                                               w.UIClassName.ToLower().Contains("notifier")
                                               select w).FirstOrDefault();

            if (winFormsUIEntry != null)
            {
                uiClass = (WinFormsUINotifierBase)winFormsUIEntry.ContainingAssembly.CreateInstance(winFormsUIEntry.UIClassName);
            }
            return(uiClass);
        }
Exemple #2
0
 private void EditAgent()
 {
     //Call local (in this assembly) utility that match editor type for agent class.
     //  This assembly will search through all assemblies in local directory for classes that inherits IWinFormsUI
     //  each IWinFormsUI class must provide the name of the IAgent class it can edit
     //  thus each IAgent class name must be unique...
     //  each IWinFormsUI class must have a method to edit the IAgent class.  EditAgent(xmlConfigString)
     //If no default editor can be found show raw xml editor...
     try
     {
         if (lvwEntries.SelectedItems.Count == 1)
         {
             INotifier agent = (INotifier)lvwEntries.SelectedItems[0].Tag;
             WinFormsUINotifierBase agentEditor = (WinFormsUINotifierBase)RegisteredAgentUIMapper.GetUIClass(agent);
             if (agentEditor != null)
             {
                 IAgentConfigEntryEditWindow detailEditor = agentEditor.DetailEditor;
                 detailEditor.SelectedEntry = agent.AgentConfig;
                 if (detailEditor.ShowEditEntry() == QuickMonDialogResult.Ok)
                 {
                     agent.AgentConfig = detailEditor.SelectedEntry;
                     lvwEntries.SelectedItems[0].Tag = agent;;
                     lvwEntries.SelectedItems[0].SubItems[2].Text = detailEditor.SelectedEntry.ConfigSummary;
                 }
             }
             else
             {
                 MessageBox.Show("There is no registered UI editor for this type of agent yet! Please contact the creator of the agent type.", "Agent type", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     CheckOkEnabled();
 }
        public static bool HasAgentViewer(INotifier agent)
        {
            WinFormsUINotifierBase ui = GetNotifierUIClass(agent);

            return(ui == null ? false : ui.HasDetailView);
        }