Пример #1
0
        /// <summary>
        /// Method to check for updates to AutoLegalityMod
        /// </summary>
        public void CheckALMUpdate()
        {
            L_UpdateAvailable.Click += (sender, e) => Process.Start("https://github.com/architdate/PKHeX-Auto-Legality-Mod/releases/latest");
            try
            {
                new Task(() =>
                {
                    string data = AutomaticLegality.GetPage("https://api.github.com/repos/architdate/pkhex-auto-legality-mod/releases/latest");
                    if (data.StartsWith("Error"))
                    {
                        return;
                    }
                    int latestVersion = AutomaticLegality.ParseTagAsVersion(data.Split(new string[] { "\"tag_name\":\"" }, System.StringSplitOptions.None)[1].Split('"')[0]);
                    if (data == null || latestVersion == -1)
                    {
                        return;
                    }
                    if (int.TryParse(CurrentProgramVersion.ToString(), out var cur) && latestVersion <= cur)
                    {
                        return;
                    }

                    Invoke((MethodInvoker)(() =>
                    {
                        L_UpdateAvailable.Visible = true;
                        L_UpdateAvailable.Text = $"New Auto Legality Mod update available! {latestVersion:d}";
                    }));
                }).Start();
            }
            catch { }
        }
        public System.Windows.Forms.ToolStripMenuItem EnableMenu(System.ComponentModel.ComponentResourceManager resources)
        {
            var Settings = Properties.Settings.Default;

            int.TryParse(Settings.Version, out int lastrev);
            int.TryParse(CurrentProgramVersion.ToString(), out int currrev);
            if (lastrev < currrev)
            {
                WinFormsUtil.Alert($"Changelog: {currrev}", PKHeX.WinForms.AutoLegality.ConstData.changelog, "Keyboard Shortcuts:", PKHeX.WinForms.AutoLegality.ConstData.keyboardshortcuts, "Discord Link:", PKHeX.WinForms.AutoLegality.ConstData.discord);
            }
            this.Menu_AutoLegality       = new System.Windows.Forms.ToolStripMenuItem();
            this.Menu_AutoLegality.Image = ((System.Drawing.Image)AutoLegality.AutoLegalityMod.menuautolegality);
            this.Menu_AutoLegality.Name  = "Menu_AutoLegality";
            this.Menu_AutoLegality.Size  = new System.Drawing.Size(133, 22);
            this.Menu_AutoLegality.Text  = "Auto Legality Mod";
            return(this.Menu_AutoLegality);
        }