public static List <QuickMonTemplate> GetAllTemplates() { List <QuickMonTemplate> list = new List <QuickMonTemplate>(); string fileContents = System.IO.File.ReadAllText(MonitorPack.GetQuickMonUserDataTemplatesFile()); if (fileContents.Contains("<quickMonTemplate>") && fileContents.Contains("</quickMonTemplate>")) { try { XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml(fileContents); XmlElement root = xdoc.DocumentElement; foreach (XmlNode templateNode in root.SelectNodes("template")) { try { QuickMonTemplate newTemplate = new QuickMonTemplate(); newTemplate.Name = templateNode.ReadXmlElementAttr("name", ""); newTemplate.TemplateType = TemplateTypeConverter.FromText(templateNode.ReadXmlElementAttr("type", "MonitorPack")); newTemplate.ForClass = templateNode.ReadXmlElementAttr("class", ""); newTemplate.Description = templateNode.ReadXmlElementAttr("description", ""); newTemplate.Config = templateNode.InnerXml; list.Add(newTemplate); } catch { } } } catch (Exception ex) { LastError = ex.Message; } } return(list); }
static void Main(string[] args) { Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; if (Properties.Settings.Default.NewVersion) { Properties.Settings.Default.Upgrade(); Properties.Settings.Default.NewVersion = false; Properties.Settings.Default.Save(); } if (Properties.Settings.Default.ApplicationMasterKey == null || Properties.Settings.Default.ApplicationMasterKey == "") { Properties.Settings.Default.ApplicationMasterKey = "QuickMon-" + System.Net.Dns.GetHostName(); } if (Properties.Settings.Default.ApplicationUserNameCacheFilePath == null || Properties.Settings.Default.ApplicationUserNameCacheFilePath == "") { Properties.Settings.Default.ApplicationUserNameCacheFilePath = System.IO.Path.Combine(MonitorPack.GetQuickMonUserDataDirectory(), "QM5MasterKeys.qmmxml"); } if (Properties.Settings.Default.ApplicationUserNameCache == null) { Properties.Settings.Default.ApplicationUserNameCache = new System.Collections.Specialized.StringCollection(); } if (Properties.Settings.Default.RecentQMConfigFiles == null) { Properties.Settings.Default.RecentQMConfigFiles = new System.Collections.Specialized.StringCollection(); } if (Properties.Settings.Default.KnownRemoteHosts == null) { Properties.Settings.Default.KnownRemoteHosts = new System.Collections.Specialized.StringCollection(); } try { if (HenIT.Security.AdminModeTools.IsInAdminMode()) { if (Properties.Settings.Default.DisableAutoAdminMode) { HenIT.Security.AdminModeTools.DeleteAdminLaunchTask(AppGlobals.AppTaskId); } else { HenIT.Security.AdminModeTools.CreateAdminLaunchTask(AppGlobals.AppTaskId); } } } catch { } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (args.Length > 0 && args[0].ToLower().Contains(".qmp")) { string qmpFile = args[0]; if (System.IO.File.Exists(qmpFile)) { Properties.Settings.Default.LastMonitorPack = qmpFile; } } try { if (!System.IO.File.Exists(MonitorPack.GetQuickMonUserDataTemplatesFile())) { try { QuickMonTemplate.ResetTemplates(); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.ToString()); } } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message, "Templates", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (!System.IO.Directory.Exists(Properties.Settings.Default.ScriptRepositoryDirectory)) { try { System.IO.Directory.CreateDirectory(Properties.Settings.Default.ScriptRepositoryDirectory); } catch { } } MainForm mainForm = new MainForm(); Application.Run(mainForm); }