Ejemplo n.º 1
0
 public static bool CheckForUpdate()
 {
     try
     {
         List <GitHubCommit> gits    = GitAccess.GetHeaderCommit();
         List <string>       gitshas = new List <string>();
         foreach (GitHubCommit git in gits)
         {
             gitshas.Add(git.Sha);
         }
         gitshas.Sort();
         List <string> shas = LocalData.LoadFileToList("SHAs");
         if (shas == null)
         {
             LocalData.SaveFile(gitshas, "SHAs");
             shas = LocalData.LoadFileToList("SHas");
         }
         shas?.Sort();
         if (!shas.SequenceEqual(gitshas))
         {
             LocalData.SaveFile(gitshas, "SHAs");
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         MessageBox.Show("Can't check for new updates!\n" + e.ToString());
     }
     return(false);
 }
Ejemplo n.º 2
0
        private void YgoProPatcher_Load(object sender, EventArgs e)
        {
            List <string> settings  = LocalData.LoadFileToList("AutoStartSettings");
            bool          minimized = false;

            if (settings != null)
            {
                try
                {
                    minimized = Convert.ToBoolean(settings[0]);
                    StartMinimizedCheckbox.Checked = minimized;
                    UpdateCheckerTimeNumeric.Value = Convert.ToDecimal(settings[1]);
                }
                catch
                {
                }
            }
            if (minimized)
            {
                MinimizeButton_Click(sender, e);
                if (ButtonNotAvailableTimer.Enabled)
                {
                    ButtonNotAvailableTimer.Elapsed += (sender1, e1) => {
                        UpdateCheckerButton.Invoke(new Action(() =>
                        {
                            UpdateCheckerButton_Click(sender1, e1);
                        }));
                    };
                }
                else
                {
                    UpdateCheckerButton_Click(sender, e);
                }
            }
        }
Ejemplo n.º 3
0
        public YgoProPatcher()
        {
            InitializeComponent();
            ServicePointManager.DefaultConnectionLimit = throttleValue + 2;
            List <string> paths = LocalData.LoadFileToList("paths.txt");

            YgoProLinksPath.Text = paths?[0];
            YgoPro2Path.Text     = paths?[1];
            UpdateCheckerCooldownCheck();
            _pool = new Semaphore(0, throttleValue);
            _pool.Release(throttleValue);
            toolTip1.SetToolTip(ReinstallCheckbox, "This will download the newest version of the YGOPro2 Client and install it.\nTHIS OPTION WILL OVERWRITE YOUR SETTINGS AND CUSTOM TEXTURES!");
            toolTip1.SetToolTip(OverwriteCheckbox, "This will redownload all of the pictures in your picture folder.");
            toolTip1.SetToolTip(gitHubDownloadCheckbox, "RECOMMENDED OPTION!\nThis will update your YGOPro2 with the newest cards, pictures.");
            toolTip1.SetToolTip(YgoPro2Path, "Please select your YGOPro2 directory which contains all the YGOPro2 files.");
            toolTip1.SetToolTip(YGOPRO2PathButton, "Please select your YGOPro2 directory which contains all the YGOPro2 files.");
            toolTip1.SetToolTip(YgoProLinksPath, "Please select your YGOPro Percy directory which contains all the YGOPro Percy files.");
            toolTip1.SetToolTip(YGOPRO1PathButton, "Please select your YGOPro Percy directory which contains all the YGOPro Percy files.");
            toolTip1.SetToolTip(UpdateButton, "Start updating with the selected options.");
            toolTip1.SetToolTip(UpdateCheckerButton, "This allows you to get notified via sound and message popup\nabout new updates while this app is running!");
            toolTip1.SetToolTip(UpdateCheckerTimeNumeric, "Select the interval between update checks!");
            toolTip1.SetToolTip(UpdateWhenLabel, "This label tells you if/when the next check will occur or if it's on cooldown!");
            toolTip1.SetToolTip(MimimizeButton, "This button makes the application minimize to taskbar!\nUseful if you want to check for updates without this window taking space!");
            toolTip1.SetToolTip(StartMinimizedCheckbox, "This lets you make YgoProPatcher start in background,\nchecking for new updates in background!");
            toolTip1.SetToolTip(submitFaceButton, "This button will open a webpage where you can submit a custom face icon\nthat others will be able to see if they also update using the patcher.");
            string version = Data.version;

            footerLabel.Text += version;
            CheckForNewVersionOfPatcher(version);
        }
Ejemplo n.º 4
0
 private void UpdateCheckerTimer_Tick(object sender, EventArgs e)
 {
     if (UpdateChecker.CheckForUpdate())
     {
         if (this.WindowState == FormWindowState.Normal)
         {
             SystemSounds.Hand.Play();
             MessageBox.Show("New updates available!");
         }
         else if (this.WindowState == FormWindowState.Minimized && notifyIcon1.Visible)
         {
             SystemSounds.Hand.Play();
             notifyIcon1.ShowBalloonTip(6000, "New update for YGOPro2 available!", "Click this to update!", ToolTipIcon.Info);
             notifyIcon1.BalloonTipClicked += UpdateButton_Click;
         }
     }
     LocalData.SaveFile(new List <string>()
     {
         DateTime.Now.ToLocalTime().ToString(), updateCheckerTimer.Interval.ToString()
     }, "donotdeletethis");
     nextUpdateTimer.Stop();
     nextUpdateTimer.Interval = updateCheckerTimer.Interval / 10;
     nextUpdateTimer.Start();
 }
Ejemplo n.º 5
0
        private void YgoProPatcher_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (threadRunning)
            {
                threadRunning = false;
                while (downloads > 1 - throttleValue && (gitHubDownloadCheckbox.Checked || internetCheckbox.Checked))
                {
                    Status.Invoke(new Action(() => { Status.Text = "Canceling the download, please wait!"; Status.Update(); }));
                }
            }
            try
            {
                LocalData.SaveFile(new List <string> {
                    StartMinimizedCheckbox.Checked.ToString(), UpdateCheckerTimeNumeric.Value.ToString()
                }, "AutoStartSettings");

                LocalData.SaveFile(new List <string> {
                    YgoProLinksPath.Text, YgoPro2Path.Text
                }, "paths.txt");
            }
            catch
            {
            }
        }
Ejemplo n.º 6
0
        private void UpdateCheckerCooldownCheck()
        {
            List <string> timerList = LocalData.LoadFileToList("donotdeletethis");

            if (timerList != null)
            {
                DateTime dateNow = DateTime.Now;
                DateTime result  = Convert.ToDateTime(timerList[0]);
                result = result.AddMilliseconds(Double.Parse(timerList[1]));


                if (result.CompareTo(dateNow) > 0)
                {
                    UpdateCheckerButton.Enabled = false;
                    TimeSpan timer = result.Subtract(dateNow);
                    UpdateWhenLabel.Text = String.Format("Update checking is on cooldown until {0}!", result.ToShortTimeString());


                    ButtonNotAvailableTimer.Interval = (int)timer.TotalMilliseconds;
                    ButtonNotAvailableTimer.Elapsed += ButtonNotAvailableTimer_Tick;
                    ButtonNotAvailableTimer.Start();
                }
            }
        }