/// <summary> /// if you call this every time the application starts, it will send reports on those launches /// (e.g. {1, 10}) that are listed in the launches parameter. It will get version number and name out of the application. /// </summary> public static void DoTrivialUsageReport(string emailAddress, string topMessage, int[] launches) { int launchCount = int.Parse(RegistryAccess.GetStringRegistryValue("launches", "0")); foreach (int launch in launches) { if (launch == launchCount) { // Set the Application label to the name of the app Assembly assembly = Assembly.GetEntryAssembly(); string version = Application.ProductVersion; if (assembly != null) { object[] attributes = assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false); version = (attributes != null && attributes.Length > 0) ? ((AssemblyFileVersionAttribute)attributes[0]).Version : Application.ProductVersion; } using (UsageEmailDialog d = new SIL.Utils.UsageEmailDialog()) { d.TopLineText = topMessage; d.EmailAddress = emailAddress; d.EmailSubject = string.Format("{0} {1} Report {2} Launches", Application.ProductName, version, launchCount); System.Text.StringBuilder bldr = new System.Text.StringBuilder(); bldr.AppendFormat("<report app='{0}' version='{1}'>", Application.ProductName, version); bldr.AppendFormat("<stat type='launches' value='{0}'/>", launchCount); if (launchCount > 1) { int val = RegistryAccess.GetIntRegistryValue("NumberOfSeriousCrashes", 0); bldr.AppendFormat("<stat type='NumberOfSeriousCrashes' value='{0}'/>", val); val = RegistryAccess.GetIntRegistryValue("NumberOfAnnoyingCrashes", 0); bldr.AppendFormat("<stat type='NumberOfAnnoyingCrashes' value='{0}'/>", val); int csec = RegistryAccess.GetIntRegistryValue("TotalAppRuntime", 0); int cmin = csec / 60; string sRuntime = String.Format("{0}:{1:d2}:{2:d2}", cmin / 60, cmin % 60, csec % 60); bldr.AppendFormat("<stat type='TotalAppRuntime' value='{0}'/>", sRuntime); } bldr.AppendFormat("</report>"); d.Body = bldr.ToString(); d.ShowDialog(); } break; } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the directory for the XeLaTeX software for the XeTeX back end. /// </summary> /// /// <returns> /// name or the directory or string.Empty if the directory name isn't in the registry. /// </returns> /// ------------------------------------------------------------------------------------ public static int GetXeLaTexFontCount() { return(RegistryAccess.GetIntRegistryValue("XeLaTexFontCount", 0)); }