/// <summary> /// INIT LICENSING FOR FORM - CALL THIS /// Inserts about tab on menu strip /// </summary> /// <param name="baseform">The baseform.</param> /// <param name="existingMenuStrip">The existing menu strip.</param> /// <param name="helpString"></param> /// <param name="otherText"></param> public static void LicensingForm(Form baseform, MenuStrip existingMenuStrip, string helpString, string otherText) { var a = AssemblyExtras.GetEntryAssemblyInfo(); _sd = new SolutionDetails( GitHubLicensing.GetGitHubReleaseDetails, helpString, a.AppName, a.RepoName, a.CurrentVersion, otherText); baseform.Text = _sd.AppName + " Version:" + _sd.Ld.CurrentVersion; var existed = false; const string help = "&Help"; var helpToolStripItem = GetItem(existingMenuStrip); if (helpToolStripItem != null) existed = true; else //if it doesnt, create { existingMenuStrip.Items.Add(new ToolStripMenuItem(help)); //should always be set now helpToolStripItem = GetItem(existingMenuStrip); } //add the help window if (!string.IsNullOrEmpty(_sd.HelpText)) { AddHelpOption(helpToolStripItem); } //check for updates button var updateitem = new ToolStripMenuItem("&Check For Updates"); updateitem.Click += async (a1, b1) => { await UpdateEvent(a1, b1); }; helpToolStripItem.DropDownItems.Add(updateitem); //about item var aboutitem = new ToolStripMenuItem("&About"); aboutitem.Click += Aboutbox; helpToolStripItem.DropDownItems.Add(aboutitem); //add all the items to the menu if help didnt exist if (existed == false) { existingMenuStrip.Items.Add(helpToolStripItem); } }
/// <summary> /// update process via console. if true, terminate console app in 1 second so update process can overwrite exe /// </summary> /// <returns></returns> public static async Task<bool> IsUpdateConsoleRequired(string helpString, string otherText) { var a = AssemblyExtras.GetEntryAssemblyInfo(); _sd = new SolutionDetails( GitHubLicensing.GetGitHubReleaseDetails, helpString, a.AppName, a.RepoName, a.CurrentVersion, otherText); Console.WriteLine("--------------\r\nUPDATE PROCESS\r\n--------------"); Console.WriteLine("This app will now connect to the internet to find the newest version.\nDo you wish to continue? y/[n]"); var ok = Console.ReadKey().Key.ToString(); if (ok.ToLower() != "y") { return false; } var det = await GetUpdateDetails(); Console.WriteLine("\r\n>>" + det.ResponseMessage); if (det.Response != LicensingDetails.LicenseResponse.NewVersion) return false; Console.WriteLine( det.OnlineVersion + "\n\nDo you wish to update to this version? y/[n] \n(Be aware that this program will restart; please save your data beforehand)"); ok = Console.ReadKey().Key.ToString(); if (ok.ToLower() != "y") { return false; } UpdateApplication(det); return true; }