//UPDATE LISTENER STARTUP MODIFIED public void update_listener_startup() { if (currentlyChecking_update == false) { currentlyChecking_update = true; string github_Latest_Release_path = "https://github.com/decemyn/Discord-Launcher/releases/latest"; WebRequest github_request = WebRequest.Create(github_Latest_Release_path); WebResponse github_response = github_request.GetResponse(); string github_response_path = github_response.ResponseUri.ToString(); string healty_response_path = "https://github.com/decemyn/Discord-Launcher/releases/tag/v"; try { if (github_response_path.Substring(0, github_response_path.Length - 7) == healty_response_path) { try { string github_latest_version = github_response_path.Substring(github_response_path.LastIndexOf('/') + 2, 7); if (github_latest_version == currentVersion) { ; } else { DiscordIconTray.ShowBalloonTip(3000, "Discord Launcher", "Updates found!", ToolTipIcon.None); github_global_version = github_latest_version; safe_ui_updater sync_delegate = new safe_ui_updater(sync_button_ui_update); sync_button_ui.Invoke(sync_delegate); } } catch (ArgumentOutOfRangeException) { DiscordIconTray.ShowBalloonTip(3000, "Discord Launcher", "GitHub servers problem. Try again at a later date!", ToolTipIcon.None); } github_response.Close(); } else { DiscordIconTray.ShowBalloonTip(3000, "Discord Launcher", "GitHub servers problem. Try again at a later date!", ToolTipIcon.None); } } catch (ArgumentOutOfRangeException) { DiscordIconTray.ShowBalloonTip(3000, "Discord Launcher", "GitHub servers problem. Try again at a later date!", ToolTipIcon.None); } } if (currentlyChecking_update == true) { currentlyChecking_update = false; } }
//MINIMIZE APP HANDLING private void Main_menu_Move(object sender, EventArgs e) { if (this.WindowState == FormWindowState.Minimized) { this.Hide(); if (DiscordLauncher.Properties.Settings.Default.disable_running_in_background_message == false) { DiscordIconTray.ShowBalloonTip(3000, "Discord Launcher", "Running in background.", ToolTipIcon.None); } if (DiscordLauncher.Properties.Settings.Default.minimize_on_startup == true && DiscordLauncher.Properties.Settings.Default.start_discord_on_load == false && first_start_tooltip == true) { first_start_tooltip = false; DiscordIconTray.ShowBalloonTip(3000, "Discord Launcher", "Running in background.", ToolTipIcon.None); } } }
//START DISCORD STARTUP METHOD private void start_discord_on_load() { Process[] throwaway = Process.GetProcessesByName("discord"); if (throwaway.Length == 0) { if (DiscordLauncher.Properties.Settings.Default.discord_app_path == string.Empty) { string discord_path = registry_pull_discord_path(); if (discord_path != string.Empty) { DiscordLauncher.Properties.Settings.Default.discord_app_path = discord_path; DiscordLauncher.Properties.Settings.Default.Save(); } else { MessageBox.Show("Discord Launcher couldn't detect Discord's application executable! Please select it manually!", "Select path", MessageBoxButtons.OK, MessageBoxIcon.Information); OpenFileDialog discord_executable_selector = new OpenFileDialog(); discord_executable_selector.Title = "Select Discord's executable"; discord_executable_selector.Filter = "|*.exe"; discord_executable_selector.ShowDialog(); if (discord_executable_selector.FileName != string.Empty) { DiscordLauncher.Properties.Settings.Default.discord_app_path = discord_executable_selector.FileName; DiscordLauncher.Properties.Settings.Default.Save(); } } } try { FileInfo discord_file = new FileInfo(DiscordLauncher.Properties.Settings.Default.discord_app_path); if (discord_file.Exists != false) { Process.Start(DiscordLauncher.Properties.Settings.Default.discord_app_path); Process[] snoop_start = Process.GetProcessesByName("discord"); if (snoop_start.Length == 0) { MessageBox.Show("Wrong executable selected! Resetting path to default!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); DiscordLauncher.Properties.Settings.Default.discord_app_path = string.Empty; DiscordLauncher.Properties.Settings.Default.Save(); } } else { MessageBox.Show("Discord Launcher couldn't detect Discord's application executable! Please select it manually!", "Select path", MessageBoxButtons.OK, MessageBoxIcon.Information); OpenFileDialog discord_executable_selector = new OpenFileDialog(); discord_executable_selector.Title = "Select Discord's executable"; discord_executable_selector.Filter = "|*.exe"; discord_executable_selector.ShowDialog(); if (discord_executable_selector.FileName != string.Empty) { DiscordLauncher.Properties.Settings.Default.discord_app_path = discord_executable_selector.FileName; DiscordLauncher.Properties.Settings.Default.Save(); } } } catch (ArgumentException) { MessageBox.Show("Discord Launcher couldn't open Discord.exe!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); DiscordLauncher.Properties.Settings.Default.discord_app_path = string.Empty; DiscordLauncher.Properties.Settings.Default.Save(); } catch (InvalidOperationException) { MessageBox.Show("Discord Launcher couldn't open Discord.exe!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); DiscordLauncher.Properties.Settings.Default.discord_app_path = string.Empty; DiscordLauncher.Properties.Settings.Default.Save(); } catch (Win32Exception) { MessageBox.Show("Discord Launcher couldn't open Discord.exe!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); DiscordLauncher.Properties.Settings.Default.discord_app_path = string.Empty; DiscordLauncher.Properties.Settings.Default.Save(); } catch (SecurityException) { MessageBox.Show("Discord Launcher couldn't open Discord.exe!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); DiscordLauncher.Properties.Settings.Default.discord_app_path = string.Empty; DiscordLauncher.Properties.Settings.Default.Save(); } } else { DiscordIconTray.ShowBalloonTip(3000, "Discord Launcher", "Running in background.", ToolTipIcon.None); } }