ShareX/ShareX/Program.cs

720 lines
24 KiB
C#
Raw Normal View History

2013-11-03 23:53:49 +13:00
#region License Information (GPL v3)
/*
ShareX - A program that allows you to take screenshots and share any file type
2024-01-03 12:57:14 +13:00
Copyright (c) 2007-2024 ShareX Team
2013-11-03 23:53:49 +13:00
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
*/
#endregion License Information (GPL v3)
2014-12-11 09:25:20 +13:00
using ShareX.HelpersLib;
using ShareX.Properties;
2014-12-11 12:19:28 +13:00
using ShareX.UploadersLib;
2013-11-03 23:53:49 +13:00
using System;
2016-06-25 03:33:45 +12:00
using System.Collections.Generic;
2013-11-03 23:53:49 +13:00
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
2013-11-03 23:53:49 +13:00
using System.Windows.Forms;
#if MicrosoftStore
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
#endif
2013-11-03 23:53:49 +13:00
namespace ShareX
{
internal static class Program
{
2024-03-16 20:13:11 +13:00
public const string AppName = "ShareX";
public const string MutexName = "82E6AC09-0FEF-4390-AD9F-0DD3F5561EFC";
public static readonly string PipeName = $"{Environment.MachineName}-{Environment.UserName}-{AppName}";
public const ShareXBuild Build =
2017-04-23 05:38:19 +12:00
#if RELEASE
ShareXBuild.Release;
2017-04-22 03:23:52 +12:00
#elif STEAM
ShareXBuild.Steam;
#elif MicrosoftStore
ShareXBuild.MicrosoftStore;
2017-04-23 05:38:19 +12:00
#elif DEBUG
ShareXBuild.Debug;
#else
ShareXBuild.Unknown;
#endif
public static string VersionText
2014-09-14 01:50:44 +12:00
{
get
{
StringBuilder sbVersionText = new StringBuilder();
2014-09-14 01:50:44 +12:00
Version version = Version.Parse(Application.ProductVersion);
sbVersionText.Append(version.Major + "." + version.Minor);
2021-11-17 15:11:32 +13:00
if (version.Build > 0 || version.Revision > 0) sbVersionText.Append("." + version.Build);
if (version.Revision > 0) sbVersionText.Append("." + version.Revision);
if (Dev) sbVersionText.Append(" Dev");
if (Portable) sbVersionText.Append(" Portable");
return sbVersionText.ToString();
2014-09-14 01:50:44 +12:00
}
}
public static string Title
{
get
{
2024-03-16 20:13:11 +13:00
string title = $"{AppName} {VersionText}";
if (Settings != null && Settings.DevMode)
{
string info = Build.ToString();
if (IsAdmin)
{
info += ", Admin";
}
title += $" ({info})";
}
return title;
}
}
public static string TitleShort
{
get
{
if (Settings != null && Settings.DevMode)
{
return Title;
}
2024-03-16 20:13:11 +13:00
return AppName;
}
}
2024-03-17 15:06:07 +13:00
public static bool Dev { get; } = false;
public static bool MultiInstance { get; private set; }
public static bool Portable { get; private set; }
public static bool SilentRun { get; private set; }
public static bool Sandbox { get; private set; }
public static bool IsAdmin { get; private set; }
public static bool SteamFirstTimeConfig { get; private set; }
2016-06-25 05:24:24 +12:00
public static bool IgnoreHotkeyWarning { get; private set; }
public static bool PuushMode { get; private set; }
2014-09-14 01:50:44 +12:00
internal static ApplicationConfig Settings { get; set; }
internal static TaskSettings DefaultTaskSettings { get; set; }
internal static UploadersConfig UploadersConfig { get; set; }
internal static HotkeysConfig HotkeysConfig { get; set; }
2014-09-14 01:50:44 +12:00
internal static MainForm MainForm { get; private set; }
internal static Stopwatch StartTimer { get; private set; }
internal static HotkeyManager HotkeyManager { get; set; }
internal static WatchFolderManager WatchFolderManager { get; set; }
internal static GitHubUpdateManager UpdateManager { get; private set; }
internal static ShareXCLIManager CLI { get; private set; }
2014-09-14 01:50:44 +12:00
2015-10-27 15:03:24 +13:00
#region Paths
2013-11-03 23:53:49 +13:00
private const string PersonalPathConfigFileName = "PersonalPath.cfg";
2024-03-16 20:13:11 +13:00
public static readonly string DefaultPersonalFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), AppName);
public static readonly string PortablePersonalFolder = FileHelpers.GetAbsolutePath(AppName);
private static string PersonalPathConfigFilePath
{
get
{
string relativePath = FileHelpers.GetAbsolutePath(PersonalPathConfigFileName);
2018-08-27 10:38:11 +12:00
if (File.Exists(relativePath))
{
2018-08-27 10:38:11 +12:00
return relativePath;
}
return CurrentPersonalPathConfigFilePath;
}
}
private static readonly string CurrentPersonalPathConfigFilePath = Path.Combine(DefaultPersonalFolder, PersonalPathConfigFileName);
private static readonly string PreviousPersonalPathConfigFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
2024-03-16 20:13:11 +13:00
AppName, PersonalPathConfigFileName);
private static readonly string PortableCheckFilePath = FileHelpers.GetAbsolutePath("Portable");
public static readonly string NativeMessagingHostFilePath = FileHelpers.GetAbsolutePath("ShareX_NativeMessagingHost.exe");
public static readonly string SteamInAppFilePath = FileHelpers.GetAbsolutePath("Steam");
2013-11-03 23:53:49 +13:00
2015-10-27 15:03:24 +13:00
private static string CustomPersonalPath { get; set; }
2013-11-03 23:53:49 +13:00
2015-10-27 15:03:24 +13:00
public static string PersonalFolder
2013-11-03 23:53:49 +13:00
{
get
{
2014-10-05 06:59:46 +13:00
if (!string.IsNullOrEmpty(CustomPersonalPath))
2013-11-03 23:53:49 +13:00
{
return FileHelpers.ExpandFolderVariables(CustomPersonalPath);
2013-11-03 23:53:49 +13:00
}
2015-10-27 15:03:24 +13:00
return DefaultPersonalFolder;
2013-11-03 23:53:49 +13:00
}
}
2021-12-12 10:21:19 +13:00
public const string HistoryFileName = "History.json";
2017-03-27 08:21:10 +13:00
public static string HistoryFilePath
{
get
{
if (Sandbox) return null;
2021-12-12 10:21:19 +13:00
return Path.Combine(PersonalFolder, HistoryFileName);
2017-03-27 08:21:10 +13:00
}
}
2021-12-12 10:21:19 +13:00
public const string HistoryFileNameOld = "History.xml";
public static string HistoryFilePathOld
{
get
{
if (Sandbox) return null;
2021-12-12 10:21:19 +13:00
return Path.Combine(PersonalFolder, HistoryFileNameOld);
}
}
2021-12-12 10:21:19 +13:00
public const string LogsFolderName = "Logs";
2021-12-12 10:21:19 +13:00
public static string LogsFolder => Path.Combine(PersonalFolder, LogsFolderName);
2016-02-10 14:13:40 +13:00
2014-03-29 01:22:16 +13:00
public static string LogsFilePath
2013-11-03 23:53:49 +13:00
{
get
{
if (SystemOptions.DisableLogging)
{
return null;
}
2021-12-12 10:21:19 +13:00
string fileName = string.Format("ShareX-Log-{0:yyyy-MM}.txt", DateTime.Now);
return Path.Combine(LogsFolder, fileName);
2013-11-03 23:53:49 +13:00
}
}
public static string ScreenshotsParentFolder
2013-11-03 23:53:49 +13:00
{
get
{
if (Settings != null && Settings.UseCustomScreenshotsPath)
2013-11-03 23:53:49 +13:00
{
string path = Settings.CustomScreenshotsPath;
string path2 = Settings.CustomScreenshotsPath2;
if (!string.IsNullOrEmpty(path))
2016-08-20 20:58:11 +12:00
{
path = FileHelpers.ExpandFolderVariables(path);
2016-08-20 20:58:11 +12:00
if (string.IsNullOrEmpty(path2) || Directory.Exists(path))
{
return path;
}
}
2016-08-20 20:58:11 +12:00
if (!string.IsNullOrEmpty(path2))
2016-08-20 20:58:11 +12:00
{
path2 = FileHelpers.ExpandFolderVariables(path2);
if (Directory.Exists(path2))
{
return path2;
}
2016-08-20 20:58:11 +12:00
}
2013-11-03 23:53:49 +13:00
}
2015-10-27 15:03:24 +13:00
return Path.Combine(PersonalFolder, "Screenshots");
2013-11-03 23:53:49 +13:00
}
}
2016-02-10 14:13:40 +13:00
public static string ToolsFolder => Path.Combine(PersonalFolder, "Tools");
public static string ImageEffectsFolder => Path.Combine(PersonalFolder, "ImageEffects");
2015-10-27 15:03:24 +13:00
public static string ChromeHostManifestFilePath => Path.Combine(ToolsFolder, "Chrome-host-manifest.json");
public static string FirefoxHostManifestFilePath => Path.Combine(ToolsFolder, "Firefox-host-manifest.json");
2015-10-01 23:28:08 +13:00
2018-08-27 10:38:11 +12:00
private static string PersonalPathDetectionMethod;
2013-11-03 23:53:49 +13:00
#endregion Paths
private static bool closeSequenceStarted, restartRequested, restartAsAdmin;
2018-10-16 23:02:26 +13:00
2013-11-03 23:53:49 +13:00
[STAThread]
private static void Main(string[] args)
{
2024-03-14 13:20:44 +13:00
HandleExceptions();
2013-11-03 23:53:49 +13:00
2024-03-14 13:20:44 +13:00
StartTimer = Stopwatch.StartNew();
CLI = new ShareXCLIManager(args);
2014-11-07 01:40:42 +13:00
CLI.ParseCommands();
2014-09-07 07:13:21 +12:00
2015-09-12 11:05:31 +12:00
#if STEAM
if (CheckUninstall()) return; // Steam will run ShareX with -Uninstall when uninstalling
#endif
2014-09-07 07:13:21 +12:00
if (CheckAdminTasks()) return; // If ShareX opened just for be able to execute task as Admin
SystemOptions.UpdateSystemOptions();
UpdatePersonalPath();
DebugHelper.Init(LogsFilePath);
MultiInstance = CLI.IsCommandExist("multi", "m");
2024-03-16 20:13:11 +13:00
using (SingleInstanceManager singleInstanceManager = new SingleInstanceManager(MutexName, PipeName, !MultiInstance, args))
{
2024-03-14 15:34:25 +13:00
if (!singleInstanceManager.IsSingleInstance || singleInstanceManager.IsFirstInstance)
2024-03-12 19:16:30 +13:00
{
singleInstanceManager.ArgumentsReceived += SingleInstanceManager_ArgumentsReceived;
2024-03-12 19:16:30 +13:00
using (TimerResolutionManager timerResolutionManager = new TimerResolutionManager())
{
Run();
}
2024-03-12 19:16:30 +13:00
if (restartRequested)
{
DebugHelper.WriteLine("ShareX restarting.");
2024-03-12 19:16:30 +13:00
if (restartAsAdmin)
{
TaskHelpers.RunShareXAsAdmin("-silent");
}
else
{
Process.Start(Application.ExecutablePath);
}
}
}
}
2024-03-12 19:16:30 +13:00
DebugHelper.Flush();
2013-11-03 23:53:49 +13:00
}
private static void Run()
2013-11-03 23:53:49 +13:00
{
2014-10-05 06:59:46 +13:00
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
DebugHelper.WriteLine("ShareX starting.");
DebugHelper.WriteLine("Version: " + VersionText);
2016-06-25 03:33:45 +12:00
DebugHelper.WriteLine("Build: " + Build);
DebugHelper.WriteLine("Command line: " + Environment.CommandLine);
DebugHelper.WriteLine("Personal path: " + PersonalFolder);
2018-08-27 10:38:11 +12:00
if (!string.IsNullOrEmpty(PersonalPathDetectionMethod))
{
DebugHelper.WriteLine("Personal path detection method: " + PersonalPathDetectionMethod);
}
DebugHelper.WriteLine("Operating system: " + Helpers.GetOperatingSystemProductName(true));
IsAdmin = Helpers.IsAdministrator();
DebugHelper.WriteLine("Running as elevated process: " + IsAdmin);
2016-06-25 03:33:45 +12:00
2018-10-02 05:49:37 +13:00
SilentRun = CLI.IsCommandExist("silent", "s");
#if MicrosoftStore
2018-11-17 07:24:52 +13:00
SilentRun = SilentRun || AppInstance.GetActivatedEventArgs()?.Kind == ActivationKind.StartupTask;
#endif
2013-11-03 23:53:49 +13:00
2015-09-30 05:58:38 +13:00
#if STEAM
SteamFirstTimeConfig = CLI.IsCommandExist("SteamConfig");
2015-09-30 05:58:38 +13:00
#endif
2016-06-25 05:24:24 +12:00
IgnoreHotkeyWarning = CLI.IsCommandExist("NoHotkeys");
2015-09-11 12:45:40 +12:00
CreateParentFolders();
RegisterExtensions();
2016-06-25 03:33:45 +12:00
CheckPuushMode();
2016-06-25 05:24:24 +12:00
DebugWriteFlags();
2017-03-27 08:21:10 +13:00
SettingManager.LoadInitialSettings();
2013-11-03 23:53:49 +13:00
Uploader.UpdateServicePointManager();
2023-03-12 20:08:26 +13:00
UpdateManager = new GitHubUpdateManager("ShareX", "ShareX", Portable);
LanguageHelper.ChangeLanguage(Settings.Language);
CleanupManager.CleanupAsync();
Helpers.TryFixHandCursor();
DebugHelper.WriteLine("MainForm init started.");
2014-09-14 01:50:44 +12:00
MainForm = new MainForm();
DebugHelper.WriteLine("MainForm init finished.");
2013-11-03 23:53:49 +13:00
2014-09-14 01:50:44 +12:00
Application.Run(MainForm);
2018-10-16 23:02:26 +13:00
CloseSequence();
}
2014-09-14 01:50:44 +12:00
2018-10-16 23:02:26 +13:00
public static void CloseSequence()
{
if (!closeSequenceStarted)
{
closeSequenceStarted = true;
DebugHelper.WriteLine("ShareX closing.");
WatchFolderManager?.Dispose();
2018-10-16 23:02:26 +13:00
SettingManager.SaveAllSettings();
DebugHelper.WriteLine("ShareX closed.");
}
2014-09-14 01:50:44 +12:00
}
public static void Restart(bool asAdmin = false)
{
restartRequested = true;
restartAsAdmin = asAdmin;
Application.Exit();
}
2024-03-14 15:34:25 +13:00
private static void SingleInstanceManager_ArgumentsReceived(string[] arguments)
2014-09-14 01:50:44 +12:00
{
if (WaitFormLoad(5000))
{
MainForm.InvokeSafe(async () =>
{
2024-03-14 15:34:25 +13:00
await UseCommandLineArgs(arguments);
});
2014-09-14 01:50:44 +12:00
}
}
2013-11-03 23:53:49 +13:00
2014-09-14 01:50:44 +12:00
private static bool WaitFormLoad(int wait)
{
Stopwatch timer = Stopwatch.StartNew();
2014-08-07 14:22:45 +12:00
2014-09-14 01:50:44 +12:00
while (timer.ElapsedMilliseconds < wait)
{
if (MainForm != null && MainForm.IsReady) return true;
2014-08-07 14:22:45 +12:00
2014-09-14 01:50:44 +12:00
Thread.Sleep(10);
2014-08-07 14:22:45 +12:00
}
2014-09-14 01:50:44 +12:00
return false;
}
2013-11-03 23:53:49 +13:00
private static async Task UseCommandLineArgs(string[] args)
2021-06-11 06:44:40 +12:00
{
if (args == null || args.Length < 1)
{
if (MainForm.niTray != null && MainForm.niTray.Visible)
{
// Workaround for Windows startup tray icon bug
MainForm.niTray.Visible = false;
MainForm.niTray.Visible = true;
}
MainForm.ForceActivate();
}
else if (MainForm.Visible)
{
MainForm.ForceActivate();
}
CLIManager cli = new CLIManager(args);
cli.ParseCommands();
await CLI.UseCommandLineArgs(cli.Commands);
2021-06-11 06:44:40 +12:00
}
private static void UpdatePersonalPath()
{
Sandbox = CLI.IsCommandExist("sandbox");
if (!Sandbox)
{
2018-08-27 10:38:11 +12:00
if (CLI.IsCommandExist("portable", "p"))
{
2018-08-27 10:38:11 +12:00
Portable = true;
CustomPersonalPath = PortablePersonalFolder;
2018-08-27 10:38:11 +12:00
PersonalPathDetectionMethod = "Portable CLI flag";
}
else if (File.Exists(PortableCheckFilePath))
{
Portable = true;
CustomPersonalPath = PortablePersonalFolder;
PersonalPathDetectionMethod = $"Portable file ({PortableCheckFilePath})";
}
else if (!string.IsNullOrEmpty(SystemOptions.PersonalPath))
{
CustomPersonalPath = SystemOptions.PersonalPath;
PersonalPathDetectionMethod = "Registry";
}
else
{
#if !MicrosoftStore
2018-08-27 10:38:11 +12:00
MigratePersonalPathConfig();
#endif
string customPersonalPath = ReadPersonalPathConfig();
if (!string.IsNullOrEmpty(customPersonalPath))
{
CustomPersonalPath = FileHelpers.GetAbsolutePath(customPersonalPath);
2018-08-27 10:38:11 +12:00
PersonalPathDetectionMethod = $"PersonalPath.cfg file ({PersonalPathConfigFilePath})";
}
}
if (!Directory.Exists(PersonalFolder))
{
try
{
Directory.CreateDirectory(PersonalFolder);
}
catch (Exception e)
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("{0} \"{1}\"", Resources.Program_Run_Unable_to_create_folder_, PersonalFolder);
sb.AppendLine();
if (!string.IsNullOrEmpty(PersonalPathDetectionMethod))
{
sb.AppendLine("Personal path detection method: " + PersonalPathDetectionMethod);
}
sb.AppendLine();
sb.Append(e);
2022-01-11 03:27:20 +13:00
MessageBox.Show(sb.ToString(), "ShareX - " + Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
CustomPersonalPath = "";
}
}
}
}
private static void CreateParentFolders()
{
if (!Sandbox && Directory.Exists(PersonalFolder))
{
FileHelpers.CreateDirectory(SettingManager.BackupFolder);
FileHelpers.CreateDirectory(ImageEffectsFolder);
FileHelpers.CreateDirectory(ScreenshotsParentFolder);
FileHelpers.CreateDirectory(ToolsFolder);
}
}
private static void RegisterExtensions()
{
#if !MicrosoftStore
if (!Portable)
{
if (!IntegrationHelpers.CheckCustomUploaderExtension())
{
IntegrationHelpers.CreateCustomUploaderExtension(true);
}
if (!IntegrationHelpers.CheckImageEffectExtension())
{
IntegrationHelpers.CreateImageEffectExtension(true);
}
}
#endif
}
public static void UpdateHelpersSpecialFolders()
{
Dictionary<string, string> specialFolders = new Dictionary<string, string>();
specialFolders.Add("ShareXImageEffects", ImageEffectsFolder);
HelpersOptions.ShareXSpecialFolders = specialFolders;
}
private static void MigratePersonalPathConfig()
{
if (File.Exists(PreviousPersonalPathConfigFilePath))
{
try
{
if (!File.Exists(CurrentPersonalPathConfigFilePath))
{
FileHelpers.CreateDirectoryFromFilePath(CurrentPersonalPathConfigFilePath);
File.Move(PreviousPersonalPathConfigFilePath, CurrentPersonalPathConfigFilePath);
}
File.Delete(PreviousPersonalPathConfigFilePath);
Directory.Delete(Path.GetDirectoryName(PreviousPersonalPathConfigFilePath));
}
catch (Exception e)
{
e.ShowError();
}
}
}
public static string ReadPersonalPathConfig()
2013-11-03 23:53:49 +13:00
{
2015-10-27 15:03:24 +13:00
if (File.Exists(PersonalPathConfigFilePath))
2013-11-03 23:53:49 +13:00
{
2015-10-27 15:03:24 +13:00
return File.ReadAllText(PersonalPathConfigFilePath, Encoding.UTF8).Trim();
}
2013-11-03 23:53:49 +13:00
2016-05-25 06:15:45 +12:00
return "";
}
public static bool WritePersonalPathConfig(string path)
{
if (path == null)
{
2016-05-25 06:15:45 +12:00
path = "";
}
else
{
path = path.Trim();
}
2015-10-27 15:03:24 +13:00
bool isDefaultPath = string.IsNullOrEmpty(path) && !File.Exists(PersonalPathConfigFilePath);
if (!isDefaultPath)
{
string currentPath = ReadPersonalPathConfig();
2022-10-15 12:10:59 +13:00
if (!path.Equals(currentPath, StringComparison.OrdinalIgnoreCase))
{
try
{
FileHelpers.CreateDirectoryFromFilePath(PersonalPathConfigFilePath);
2015-10-27 15:03:24 +13:00
File.WriteAllText(PersonalPathConfigFilePath, path, Encoding.UTF8);
return true;
}
2022-05-14 17:23:10 +12:00
catch (UnauthorizedAccessException e)
{
2022-05-14 17:23:10 +12:00
DebugHelper.WriteException(e);
2015-10-27 15:03:24 +13:00
MessageBox.Show(string.Format(Resources.Program_WritePersonalPathConfig_Cant_access_to_file, PersonalPathConfigFilePath),
"ShareX", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
2022-05-14 17:23:10 +12:00
catch (Exception e)
{
DebugHelper.WriteException(e);
e.ShowError();
}
}
2013-11-03 23:53:49 +13:00
}
return false;
2013-11-03 23:53:49 +13:00
}
2024-03-14 13:20:44 +13:00
private static void HandleExceptions()
{
#if DEBUG
if (Debugger.IsAttached)
{
return;
}
#endif
// Add the event handler for handling UI thread exceptions to the event
Application.ThreadException += Application_ThreadException;
// Set the unhandled exception mode to force all Windows Forms errors to go through our handler
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
// Add the event handler for handling non-UI thread exceptions to the event
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
}
2013-11-03 23:53:49 +13:00
private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
OnError(e.Exception);
}
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
2013-11-03 23:53:49 +13:00
{
OnError((Exception)e.ExceptionObject);
}
private static void OnError(Exception e)
{
2022-05-15 09:32:09 +12:00
using (ErrorForm errorForm = new ErrorForm(e.Message, $"{e}\r\n\r\n{Title}", LogsFilePath, Links.GitHubIssues))
2013-11-03 23:53:49 +13:00
{
errorForm.ShowDialog();
}
}
2014-09-07 07:13:21 +12:00
private static bool CheckAdminTasks()
{
2014-11-07 00:27:23 +13:00
if (CLI.IsCommandExist("dnschanger"))
2014-09-07 07:13:21 +12:00
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
2018-04-30 03:30:03 +12:00
Helpers.TryFixHandCursor();
2014-09-07 07:13:21 +12:00
Application.Run(new DNSChangerForm());
return true;
}
return false;
}
2015-09-12 11:05:31 +12:00
private static bool CheckUninstall()
{
2015-09-12 11:38:10 +12:00
if (CLI.IsCommandExist("uninstall"))
2015-09-12 11:05:31 +12:00
{
try
{
IntegrationHelpers.Uninstall();
}
catch
{
}
return true;
}
return false;
}
2016-06-20 18:44:21 +12:00
private static bool CheckPuushMode()
{
string puushPath = FileHelpers.GetAbsolutePath("puush");
PuushMode = File.Exists(puushPath);
return PuushMode;
2016-06-20 18:44:21 +12:00
}
2016-06-25 03:33:45 +12:00
2016-06-25 05:24:24 +12:00
private static void DebugWriteFlags()
2016-06-25 03:33:45 +12:00
{
List<string> flags = new List<string>();
2018-05-19 05:39:01 +12:00
if (Dev) flags.Add(nameof(Dev));
if (MultiInstance) flags.Add(nameof(MultiInstance));
if (Portable) flags.Add(nameof(Portable));
if (SilentRun) flags.Add(nameof(SilentRun));
if (Sandbox) flags.Add(nameof(Sandbox));
if (SteamFirstTimeConfig) flags.Add(nameof(SteamFirstTimeConfig));
2016-06-25 05:24:24 +12:00
if (IgnoreHotkeyWarning) flags.Add(nameof(IgnoreHotkeyWarning));
if (SystemOptions.DisableUpdateCheck) flags.Add(nameof(SystemOptions.DisableUpdateCheck));
if (SystemOptions.DisableUpload) flags.Add(nameof(SystemOptions.DisableUpload));
if (SystemOptions.DisableLogging) flags.Add(nameof(SystemOptions.DisableLogging));
if (PuushMode) flags.Add(nameof(PuushMode));
2016-06-25 03:33:45 +12:00
string output = string.Join(", ", flags);
if (!string.IsNullOrEmpty(output))
{
2016-06-25 05:24:24 +12:00
DebugHelper.WriteLine("Flags: " + output);
2016-06-25 03:33:45 +12:00
}
}
2013-11-03 23:53:49 +13:00
}
}