Пример #1
0
        private void CheckUpdate()
        {
            UpdateChecker updateChecker = new UpdateChecker(Links.URL_UPDATE, Application.ProductName, Program.AssemblyVersion,
                                                            ReleaseChannelType.Stable, Uploader.ProxyInfo.GetWebProxy());

            updateChecker.CheckUpdate();

            if (updateChecker.UpdateInfo != null)
            {
                switch (updateChecker.UpdateInfo.Status)
                {
                case UpdateStatus.UpdateRequired:
                    string updateText = string.Format("Would you like to download the update?\r\n\r\n{0} is current version.\r\n{1} is latest version.",
                                                      updateChecker.UpdateInfo.CurrentVersion, updateChecker.UpdateInfo.LatestVersion);

                    if (MessageBox.Show(updateText, "ShareX update is available", MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                    {
                        UpdaterForm downloader = new UpdaterForm(updateChecker.UpdateInfo.URL, updateChecker.Proxy, updateChecker.UpdateInfo.Summary);
                        downloader.ShowDialog();
                        if (downloader.Status == DownloaderFormStatus.InstallStarted)
                        {
                            Application.Exit();
                        }
                    }
                    break;

                case UpdateStatus.UpdateCheckFailed:
                    DebugHelper.WriteLine("Update check failed.");
                    break;
                }
            }
        }
Пример #2
0
 private void navBarItem0705_LinkClicked(object sender, NavBarLinkEventArgs e)
 {
     using (var updaterForm = new UpdaterForm())
     {
         updaterForm.ShowDialog();
     }
 }
Пример #3
0
        private static bool Update()
        {
            var updaterForm = new UpdaterForm();

            updaterForm.WindowState = FormWindowState.Minimized;
            Application.Run(updaterForm);
            return(updaterForm.Updater.UpdateStarted);
        }
 private void llblUpdateAvailable_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (updateChecker != null && updateChecker.UpdateInfo != null && !string.IsNullOrEmpty(updateChecker.UpdateInfo.URL))
     {
         UpdaterForm downloader = new UpdaterForm(updateChecker.UpdateInfo.URL, updateChecker.Proxy, updateChecker.UpdateInfo.Summary);
         downloader.ShowDialog();
         if (downloader.Status == DownloaderFormStatus.InstallStarted)
         {
             Application.Exit();
         }
     }
 }
Пример #5
0
        private void NotifyUpdate(UpdateReleaseDetails details)
        {
            var file = Path.Combine(Path.GetTempPath(), details.FileName);

            using (var dialog = new UpdaterForm(details, file))
            {
                dialog.ShowDialog(this);
                if (dialog.Completed)
                {
                    _updateExecutable = file;
                    Close();
                }
            }
        }
Пример #6
0
        public static async Task UpdateTo(int version, UpdaterForm form = null)
        {
            Logger.Log("Updating to " + version, true);
            string savePath = Path.Combine(Paths.GetExeDir(), $"FlowframesV{version}");

            try
            {
                var client = new WebClient();
                client.DownloadProgressChanged += async(sender, args) =>
                {
                    if (form != null && (args.ProgressPercentage % 5 == 0))
                    {
                        Logger.Log("Downloading update... " + args.ProgressPercentage, true);
                        form.SetProgLabel(args.ProgressPercentage, $"Downloading latest version... {args.ProgressPercentage}%");
                        await Task.Delay(20);
                    }
                };
                client.DownloadFileCompleted += (sender, args) =>
                {
                    form.SetProgLabel(100f, $"Downloading latest version... 100%");
                };
                await client.DownloadFileTaskAsync(new Uri($"https://dl.nmkd.de/flowframes/exe/{version}/Flowframes.exe"), savePath);
            }
            catch (Exception e)
            {
                MessageBox.Show("Error: Failed to download update.\n\n" + e.Message, "Error");
                Logger.Log("Updater Error during download: " + e.Message, true);
                return;
            }
            try
            {
                Logger.Log("Installing v" + version, true);
                string runningExePath = Paths.GetExe();
                string oldExePath     = runningExePath + ".old";
                IOUtils.TryDeleteIfExists(oldExePath);
                File.Move(runningExePath, oldExePath);
                File.Move(savePath, runningExePath);
            }
            catch (Exception e)
            {
                MessageBox.Show("Error: Failed to install update.\n\n" + e.Message, "Error");
                Logger.Log("Updater Error during install: " + e.Message, true);
                return;
            }
            form.SetProgLabel(101f, $"Update downloaded.");
            await Task.Delay(20);

            MessageBox.Show("Update was installed!\nFlowframes will now close. Restart it to use the new version.", "Message");
            Application.Exit();
        }
Пример #7
0
        private static bool Update()
        {
            var updateStarted = false;
            var random        = new Random().Next(10);

            if (random == 0)
            {
                var updaterForm = new UpdaterForm();
                updaterForm.WindowState = FormWindowState.Minimized;
                Application.Run(updaterForm);
                updateStarted = updaterForm.Updater.UpdateStarted;
            }

            return(updateStarted);
        }
Пример #8
0
        private void CheckUpdate()
        {
            UpdateChecker updateChecker = TaskHelpers.CheckUpdate();

            if (updateChecker.UpdateInfo != null && updateChecker.UpdateInfo.Status == UpdateStatus.UpdateAvailable &&
                MessageBox.Show("An update is available for ShareX.\r\nWould you like to download it?", "ShareX",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
            {
                UpdaterForm updaterForm = new UpdaterForm(updateChecker);
                updaterForm.ShowDialog();

                if (updaterForm.Status == DownloaderFormStatus.InstallStarted)
                {
                    Application.Exit();
                }
            }
        }
Пример #9
0
        protected virtual void Dispose(bool disposing)
        {
            MyForm.Close();
            MyForm           = null;
            WorkingManifest  = null;
            WorkingDirectory = null;

            TotalFileProgress        = 0;
            CurrentFileProgress      = 0;
            TotalOverallProgress     = 0;
            ModDownloadRootUrl       = null;
            ConfigDownloadRootUrl    = null;
            ScriptDownloadRootUrl    = null;
            ModDirectory             = null;
            ConfigDirectory          = null;
            ScriptDirectory          = null;
            CurrentMods              = null;
            CurrentConfigFiles       = null;
            CurrentScripts           = null;
            CurrentConfigDirectories = null;

            GC.SuppressFinalize(this);
        }
Пример #10
0
        public void Initialize(Manifest workingManifest, string workingDirectory, bool isPTRUpdate, UpdaterForm form)
        {
            WorkingManifest      = workingManifest;
            WorkingDirectory     = workingDirectory;
            MyForm               = form;
            TotalFileProgress    = 0;
            CurrentFileProgress  = 0;
            TotalOverallProgress = 0;

            if (isPTRUpdate == true)
            {
                ModDownloadRootUrl    = Library.ModPTRDownloadRootUrl;
                ConfigDownloadRootUrl = "/modpack/bin/ptr/configs/";
                ScriptDownloadRootUrl = Library.ScriptPTRDownloadRootUrl;
            }
            else
            {
                ModDownloadRootUrl    = Library.ModDownloadRootUrl;
                ConfigDownloadRootUrl = "/modpack/bin/stable/configs/";
                ScriptDownloadRootUrl = Library.ScriptDownloadRootUrl;
            }

            ModDirectory    = new DirectoryInfo(Path.Combine(WorkingDirectory, "mods\\"));
            ConfigDirectory = new DirectoryInfo(Path.Combine(WorkingDirectory, "config\\"));
            ScriptDirectory = new DirectoryInfo(Path.Combine(WorkingDirectory, "scripts\\"));

            CurrentMods              = new List <FileInfo>();
            CurrentConfigFiles       = new List <FileInfo>();
            CurrentConfigDirectories = new List <DirectoryInfo>();
            CurrentScripts           = new List <FileInfo>();

            if (ModDirectory.GetFiles().Count() > 0)
            {
                foreach (FileInfo file in ModDirectory.GetFiles())
                {
                    CurrentMods.Add(file);
                }
            }
            if (ConfigDirectory.GetFiles().Count() > 0)
            {
                foreach (FileInfo file in ConfigDirectory.GetFiles())
                {
                    CurrentConfigFiles.Add(file);
                }
            }
            if (ConfigDirectory.GetDirectories().Count() > 0)
            {
                foreach (DirectoryInfo directory in ConfigDirectory.GetDirectories())
                {
                    CurrentConfigDirectories.Add(directory);
                }
            }
            if (ScriptDirectory.GetFiles().Count() > 0)
            {
                foreach (FileInfo file in ScriptDirectory.GetFiles())
                {
                    CurrentScripts.Add(file);
                }
            }

            TotalFileProgress = workingManifest.Mods.Count + workingManifest.Scripts.Count;
            MyForm.SetTotalItems(TotalFileProgress);
        }
Пример #11
0
 public Updater(Manifest workingManifest, string workingDirectory, bool isPTRUpdate, UpdaterForm form)
 {
     Initialize(workingManifest, workingDirectory, isPTRUpdate, form);
 }
Пример #12
0
        public MainForm()
        {
            InitializeComponent();

            // Clean the update (deletes temporary files)
            Utilities.CleanUpdate(Application.StartupPath);

            // Check for updates
            uf = new UpdaterForm(true, Config.AppUpdateURL, Config.AssemblyVersion, true, true);
            uf.Show();

            // Check the config version
            if (new Config.C().ConfigVersion > Config.conf.ConfigVersion)
            {
                // Check if the user wants to update their config
                if (MessageBox.Show($"Your config is outdated, would you like to update your config?\nYour config version \"{Config.conf.ConfigVersion}\"\nNew config version \"{new Config.C().ConfigVersion}\"", "Update Config?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    File.Delete(Config.ConfigFile); // Delete the config
                    Application.Restart();          // Restart CaptureThat
                    Environment.Exit(0);            // Exit CaptureThat
                }
            }

            // Check if form styling is enabled
            if (Config.conf.FormStyle.EnableStyling)
            {
                // Get the button color from the config
                Color btnColor = Color.FromName(Config.conf.FormStyle.ButtonColor);

                // Style the buttons
                btnCaptureArea.FlatStyle = FlatStyle.Flat;
                btnCaptureArea.FlatAppearance.BorderColor = btnColor;
                btnCaptureWindow.FlatStyle = FlatStyle.Flat;
                btnCaptureWindow.FlatAppearance.BorderColor = btnColor;
                btnCaptureFull.FlatStyle = FlatStyle.Flat;
                btnCaptureFull.FlatAppearance.BorderColor = btnColor;

                btnSettings.FlatStyle = FlatStyle.Flat;
                btnSettings.FlatAppearance.BorderColor = btnColor;
                btnAbout.FlatStyle = FlatStyle.Flat;
                btnAbout.FlatAppearance.BorderColor = btnColor;

                BackColor = Color.FromName(Config.conf.FormStyle.FormBackgroundColor);

                // Get all of the buttons
                foreach (Control control in Controls)
                {
                    if (control.GetType() == typeof(Button))
                    {
                        // Change the color to the color in the config
                        control.BackColor = Color.FromName(Config.conf.FormStyle.ButtonColor);
                    }
                }
            }

            // Set the title of the form to display the version and if it's portable mode
            Text += " v" + Config.AppVersion + (Config.mode.PortableMode ? " (PORTABLE)" : "");

            // Set notifyIcon to notifyIcon1 to be accessable in the project
            notifyIcon = notifyIcon1;

            // Set notifyIcon1 text
            notifyIcon1.Text = $"CaptureThat v{Config.AppVersion}";

            // Check if the user wants to minimize the form on startup
            if (Config.conf.MinimizeFormOnStartup)
            {
                WindowState   = FormWindowState.Minimized; // Set the WindowState to Minimized
                ShowInTaskbar = false;                     // Disable showing the form in the taskbar
            }

            // Check if the user wants to force icons on the buttons
            if (Config.conf.ForceIconsOnButtons)
            {
                // Remove the text from all buttons
                btnCaptureArea.Text   = "";
                btnCaptureWindow.Text = "";
                btnCaptureFull.Text   = "";
                btnSettings.Text      = "";
                btnAbout.Text         = "";

                // Create the path for the icons
                string p = $@"{Application.StartupPath}\iconpacks\{Config.conf.IconPackName}";

                // Set the background image on the buttons
                btnCaptureArea.BackgroundImage   = File.Exists($@"{p}\area.png") ? System.Drawing.Image.FromFile($@"{p}\area.png") : Properties.Resources.area_icon;
                btnCaptureWindow.BackgroundImage = File.Exists($@"{p}\window.png") ? System.Drawing.Image.FromFile($@"{p}\window.png") : Properties.Resources.window_icon;
                btnCaptureFull.BackgroundImage   = File.Exists($@"{p}\full.png") ? System.Drawing.Image.FromFile($@"{p}\full.png") : Properties.Resources.full_icon;
                btnSettings.BackgroundImage      = File.Exists($@"{p}\settings.png") ? System.Drawing.Image.FromFile($@"{p}\settings.png") : Properties.Resources.settings_icon;
                btnAbout.BackgroundImage         = File.Exists($@"{p}\about.png") ? System.Drawing.Image.FromFile($@"{p}\about.png") : Properties.Resources.about_icon;

                // Set the layout for the background image on the buttons
                btnCaptureArea.BackgroundImageLayout   = ImageLayout.Stretch;
                btnCaptureWindow.BackgroundImageLayout = ImageLayout.Stretch;
                btnCaptureFull.BackgroundImageLayout   = ImageLayout.Stretch;
                btnSettings.BackgroundImageLayout      = ImageLayout.Stretch;
                btnAbout.BackgroundImageLayout         = ImageLayout.Stretch;
            }

            try
            {
                // Check if the user wants CaptureThat to run on Windows startup
                if (Config.conf.RunOnWindowsStartup)
                {
                    // Set the key CaptureThat to the Executable file (so CaptureThat runs on windows startup)
                    key.SetValue("CaptureThat", Application.ExecutablePath);
                }
                else if (!Config.conf.RunOnWindowsStartup)
                {
                    key.SetValue("CaptureThat", ""); // Set the key to null
                    key.DeleteValue("CaptureThat");  // Delete the key
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            // Create the context menu
            ContextMenu cm         = new ContextMenu();
            MenuItem    niOpen     = cm.MenuItems.Add("Open CaptureThat");
            MenuItem    niSettings = cm.MenuItems.Add("CaptureThat Settings");
            MenuItem    niAbout    = cm.MenuItems.Add("About CaptureThat");
            MenuItem    niUpdate   = cm.MenuItems.Add("Check for Updates");
            MenuItem    niSpacer   = cm.MenuItems.Add("-");
            MenuItem    niExit     = cm.MenuItems.Add("Exit CaptureThat");

            // Context menu event handlers
            niOpen.Click     += NiOpen_Click;
            niSettings.Click += NiSettings_Click;
            niAbout.Click    += NiAbout_Click;
            niUpdate.Click   += NiUpdate_Click;
            niExit.Click     += NiExit_Click;

            // Set the context menu to the notifyIcon1
            notifyIcon1.ContextMenu = cm;

            // Check if the AppSettingsPath exists
            if (!Directory.Exists(Config.AppSettingsPath))
            {
                // Create the AppSettingsPath directory
                Directory.CreateDirectory(Config.AppSettingsPath);
            }
        }
Пример #13
0
        private void NiUpdate_Click(object sender, EventArgs e)
        {
            uf = new UpdaterForm(false, Config.AppUpdateURL, Config.AssemblyVersion, true, true);

            uf.Show();
        }
        private void ShowUpdateForm(IAppCast currentItem)
        {
            UpdaterForm updaterForm = new UpdaterForm(currentItem) { TopMost = true };
            DialogResult dialogResult = updaterForm.ShowDialog();

            if (dialogResult.Equals(DialogResult.Yes))
            {
                InitDownloadAndInstallProcess(currentItem);
            }
        }
Пример #15
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            FileConfig.ReadFile();
            try
            {
                try
                {
                    if (FileConfig.config.updateapi != "")
                    {
                        Updater.checkversion();
                        if (Updater.ready.Count() > 0)
                        {
                            DialogResult dlr = MessageBox.Show("Sẵn sàng cho cật nhập", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                            if (dlr == DialogResult.OK)
                            {
                                UpdaterForm upd = new UpdaterForm();
                                upd.ShowDialog();
                                return;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                }

                if (!FileConfig.config.connectsuccess)
                {
                    CommonForm cf = new CommonForm();
                    cf.signal = 0;
                    Application.Run(cf);
                }
                else if (FileConfig.config.connectsuccess)
                {
                    using (var context = new ControllerModel())
                    {
                        if (context.Database.Exists())
                        {
                            if (!UserController.countUser())
                            {
                                CommonForm cf = new CommonForm();
                                cf.signal = 1;
                                Application.Run(cf);
                            }
                        }
                        else
                        {
                            BackupFile buf = new BackupFile();
                            buf.ShowDialog();
                        }
                    }

                    Application.Run(new LoginForm());
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex);
                BackupFile buf = new BackupFile();
                buf.ShowDialog();
            }
        }