コード例 #1
0
ファイル: Program.cs プロジェクト: mikeogod/ShareX
        private static void Main(string[] args)
        {
            Application.ThreadException += Application_ThreadException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            StartTimer = Stopwatch.StartNew(); // For be able to show startup time

            Arguments = args;

            if (CheckAdminTasks())
            {
                return;                    // If ShareX opened just for be able to execute task as Admin
            }
            IsMultiInstance = CLIHelper.CheckArgs(Arguments, "multi", "m");

            if (IsMultiInstance || ApplicationInstanceManager.CreateSingleInstance(SingleInstanceCallback, Arguments))
            {
                using (Mutex mutex = new Mutex(false, "82E6AC09-0FEF-4390-AD9F-0DD3F5561EFC")) // Required for installer
                {
                    Run();
                }

                if (restarting)
                {
                    Process.Start(Application.ExecutablePath);
                }
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: OriginalCliff/itsfv
        private static void Main(string[] args)
        {
            Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            AppDomain.CurrentDomain.AssemblyLoad       += new AssemblyLoadEventHandler(CurrentDomain_AssemblyLoad);

            try
            {
                IsPortable = CLIHelper.CheckArgs(args, "p", "portable");

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                if (Environment.OSVersion.Version.Major >= 6)
                {
                    SetProcessDPIAware();
                }

                LogViewer = new LogViewer();

                MainForm = new ValidatorWizard();
                SettingsReader.DoWork             += SettingsReader_DoWork;
                SettingsReader.RunWorkerCompleted += MainForm.SettingsReader_RunWorkerCompleted;
                SettingsReader.RunWorkerAsync();

                Application.Run(MainForm);
                Program.Config.Write(ConfigCoreFilePath);
            }
            finally
            {
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: boilingstar/ShareX
        private static void StartupHandler(object sender, StartupEventArgs e)
        {
            string appGuid = ((GuidAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(GuidAttribute), false).GetValue(0)).Value.ToString();

            using (Mutex mutex = new Mutex(false, appGuid)) // Required for installer
            {
                IsSilentRun = CLIHelper.CheckArgs(Arguments, "silent", "s");
                IsSandbox   = CLIHelper.CheckArgs(Arguments, "sandbox");

                if (!IsSandbox)
                {
                    IsPortable = CLIHelper.CheckArgs(Arguments, "portable", "p");

                    if (IsPortable)
                    {
                        CustomPersonalPath = PortablePersonalPath;
                    }
                    else
                    {
                        CheckPersonalPathConfig();
                    }

                    if (!string.IsNullOrEmpty(PersonalPath) && !Directory.Exists(PersonalPath))
                    {
                        Directory.CreateDirectory(PersonalPath);
                    }
                }

                DebugHelper.WriteLine("{0} started", Title);
                DebugHelper.WriteLine("Operating system: " + Environment.OSVersion.VersionString);
                DebugHelper.WriteLine("Command line: " + Environment.CommandLine);
                DebugHelper.WriteLine("Personal path: " + PersonalPath);

                string gitHash = GetGitHash();
                if (!string.IsNullOrEmpty(gitHash))
                {
                    DebugHelper.WriteLine("Git: https://github.com/ShareX/ShareX/tree/" + gitHash);
                }

                SettingsResetEvent         = new ManualResetEvent(false);
                UploaderSettingsResetEvent = new ManualResetEvent(false);
                HotkeySettingsResetEvent   = new ManualResetEvent(false);
                TaskEx.Run(() => LoadSettings());

                DebugHelper.WriteLine("MainForm init started");
                MainForm = new MainForm();
                applicationBase.MainForm = MainForm;
                DebugHelper.WriteLine("MainForm init finished");

                if (Settings == null)
                {
                    SettingsResetEvent.WaitOne();
                }
            }
        }
コード例 #4
0
        private static void Main(string[] args)
        {
            StartTimer = Stopwatch.StartNew();

            IsMultiInstance = CLIHelper.CheckArgs(args, "m", "multi");

            if (!IsMultiInstance && !ApplicationInstanceManager.CreateSingleInstance(SingleInstanceCallback))
            {
                return;
            }

            IsSilentRun = CLIHelper.CheckArgs(args, "s", "silent");

            if (CLIHelper.CheckArgs(args, "p", "portable") && !Directory.Exists(PortablePersonalPath))
            {
                Directory.CreateDirectory(PortablePersonalPath);
            }

            IsPortable = Directory.Exists(PortablePersonalPath);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            MyLogger             = new Logger();
            DebugHelper.MyLogger = MyLogger;
            MyLogger.WriteLine("{0} {1} r{2} started", Application.ProductName, Application.ProductVersion, AppRevision);
            MyLogger.WriteLine("Operating system: " + Environment.OSVersion.VersionString);
            MyLogger.WriteLine("CommandLine: " + Environment.CommandLine);
            MyLogger.WriteLine("IsMultiInstance: " + IsMultiInstance);
            MyLogger.WriteLine("IsSilentRun: " + IsSilentRun);
            MyLogger.WriteLine("IsPortable: " + IsPortable);

            SettingsResetEvent         = new ManualResetEvent(false);
            UploaderSettingsResetEvent = new ManualResetEvent(false);
            ThreadPool.QueueUserWorkItem(state => LoadSettings());

            MyLogger.WriteLine("new MainForm() started");
            mainForm = new MainForm();
            MyLogger.WriteLine("new MainForm() finished");

            if (Settings == null)
            {
                SettingsResetEvent.WaitOne();
            }

            Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.Run(mainForm);

            Settings.Save();

            MyLogger.WriteLine("ZUploader closing");
            MyLogger.SaveLog(LogFilePath);
        }
コード例 #5
0
        private static bool CheckAdminTasks()
        {
            if (CLIHelper.CheckArgs(Arguments, "dnschanger"))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new DNSChangerForm());
                return(true);
            }

            return(false);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: Z1ni/ShareX
        private static void Main(string[] args)
        {
            Application.ThreadException += Application_ThreadException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            StartTimer = Stopwatch.StartNew();

            IsMultiInstance = CLIHelper.CheckArgs(args, "multi", "m");

            if (IsMultiInstance || ApplicationInstanceManager.CreateSingleInstance(SingleInstanceCallback))
            {
                Run(args);
            }
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: boilingstar/ShareX
        private static void Main(string[] args)
        {
            Application.ThreadException += Application_ThreadException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            StartTimer = Stopwatch.StartNew(); // For be able to show startup time

            Arguments = args;
            bool forceMultiInstance = CLIHelper.CheckArgs(Arguments, "multi", "m");

            Application.SetCompatibleTextRenderingDefault(false);
            applicationBase                      = new ShareXApplicationBase(!forceMultiInstance);
            applicationBase.Startup             += StartupHandler;
            applicationBase.StartupNextInstance += StartupNextInstanceHandler;
            applicationBase.Shutdown            += ShutdownHandler;
            applicationBase.Run(Arguments);
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: Z1ni/ShareX
        private static void Run(string[] args)
        {
            string appGuid = ((GuidAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(GuidAttribute), false).GetValue(0)).Value.ToString();

            using (Mutex mutex = new Mutex(false, appGuid)) // Required for installer
            {
                IsSilentRun = CLIHelper.CheckArgs(args, "silent", "s");
                IsSandbox   = CLIHelper.CheckArgs(args, "sandbox");

                if (!IsSandbox)
                {
                    IsPortable = CLIHelper.CheckArgs(args, "portable", "p");

                    if (IsPortable)
                    {
                        CustomPersonalPath = PortablePersonalPath;
                    }
                    else
                    {
                        CheckPersonalPathConfig();
                    }

                    if (!string.IsNullOrEmpty(PersonalPath) && !Directory.Exists(PersonalPath))
                    {
                        Directory.CreateDirectory(PersonalPath);
                    }
                }

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                DebugHelper.WriteLine("{0} started", Title);
                DebugHelper.WriteLine("Operating system: " + Environment.OSVersion.VersionString);
                DebugHelper.WriteLine("Command line: " + Environment.CommandLine);
                DebugHelper.WriteLine("Personal path: " + PersonalPath);

                SettingsResetEvent         = new ManualResetEvent(false);
                UploaderSettingsResetEvent = new ManualResetEvent(false);
                HotkeySettingsResetEvent   = new ManualResetEvent(false);
                ThreadPool.QueueUserWorkItem(state => LoadSettings());

                DebugHelper.WriteLine("MainForm init started");
                MainForm = new MainForm();
                DebugHelper.WriteLine("MainForm init finished");

                if (Settings == null)
                {
                    SettingsResetEvent.WaitOne();
                }

                Application.Run(MainForm);

                if (WatchFolderManager != null)
                {
                    WatchFolderManager.Dispose();
                }
                SaveSettings();
                BackupSettings();

                DebugHelper.WriteLine("ShareX closing");
                DebugHelper.Logger.SaveLog(LogsFilePath);
            }
        }
コード例 #9
0
        private static void Run()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            IsSilentRun = CLIHelper.CheckArgs(Arguments, "silent", "s");
            IsSandbox   = CLIHelper.CheckArgs(Arguments, "sandbox");

            if (!IsSandbox)
            {
                IsPortable = CLIHelper.CheckArgs(Arguments, "portable", "p");

                if (IsPortable)
                {
                    CustomPersonalPath = PortablePersonalPath;
                }
                else
                {
                    CheckPersonalPathConfig();
                }

                if (!Directory.Exists(PersonalPath))
                {
                    try
                    {
                        Directory.CreateDirectory(PersonalPath);
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("Unable to create folder: \"" + PersonalPath + "\"\r\n\r\n" + e.ToString(), "ShareX - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        CustomPersonalPath = "";
                    }
                }
            }

            DebugHelper.WriteLine("{0} started", Title);
            DebugHelper.WriteLine("Operating system: " + Environment.OSVersion.VersionString);
            DebugHelper.WriteLine("Command line: " + Environment.CommandLine);
            DebugHelper.WriteLine("Personal path: " + PersonalPath);

            string gitHash = GetGitHash();

            if (!string.IsNullOrEmpty(gitHash))
            {
                DebugHelper.WriteLine("Git: https://github.com/ShareX/ShareX/tree/" + gitHash);
            }

            LoadProgramSettings();

            UploaderSettingsResetEvent = new ManualResetEvent(false);
            HotkeySettingsResetEvent   = new ManualResetEvent(false);
            TaskEx.Run(() => LoadSettings());

            LanguageHelper.ChangeLanguage(Settings.Language);

            DebugHelper.WriteLine("MainForm init started");
            MainForm = new MainForm();
            DebugHelper.WriteLine("MainForm init finished");

            Application.Run(MainForm);

            if (WatchFolderManager != null)
            {
                WatchFolderManager.Dispose();
            }
            SaveSettings();
            BackupSettings();

            DebugHelper.WriteLine("ShareX closing");
            DebugHelper.Logger.SaveLog(LogsFilePath);
        }
コード例 #10
0
        private static void Run(string[] args)
        {
            Mutex mutex = null;

            try
            {
                mutex = new Mutex(false, @"Global\82E6AC09-0FEF-4390-AD9F-0DD3F5561EFC"); // Required for installer

                IsSilentRun = CLIHelper.CheckArgs(args, "silent", "s");
                IsSandbox   = CLIHelper.CheckArgs(args, "sandbox");

                if (!IsSandbox)
                {
                    IsPortable = CLIHelper.CheckArgs(args, "portable", "p");

                    if (IsPortable)
                    {
                        CustomPersonalPath = PortablePersonalPath;
                    }
                    else
                    {
                        CheckPersonalPathConfig();
                    }

                    if (!string.IsNullOrEmpty(PersonalPath) && !Directory.Exists(PersonalPath))
                    {
                        Directory.CreateDirectory(PersonalPath);
                    }
                }

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                DebugHelper.WriteLine("{0} started", FullTitle);
                DebugHelper.WriteLine("Operating system: " + Environment.OSVersion.VersionString);
                DebugHelper.WriteLine("Command line: " + Environment.CommandLine);
                DebugHelper.WriteLine("Personal path: " + PersonalPath);

                SettingsResetEvent         = new ManualResetEvent(false);
                UploaderSettingsResetEvent = new ManualResetEvent(false);
                HotkeySettingsResetEvent   = new ManualResetEvent(false);
                ThreadPool.QueueUserWorkItem(state => LoadSettings());

                DebugHelper.WriteLine("MainForm init started");
                MainForm = new MainForm();
                DebugHelper.WriteLine("MainForm init finished");

                if (Settings == null)
                {
                    SettingsResetEvent.WaitOne();
                }

                Application.Run(MainForm);

                if (WatchFolderManager != null)
                {
                    WatchFolderManager.Dispose();
                }
                SaveSettings();
                BackupSettings();

                DebugHelper.WriteLine("ShareX closing");
                DebugHelper.Logger.SaveLog(LogFilePath);
            }
            finally
            {
                if (mutex != null)
                {
                    mutex.Close();
                }
            }
        }
コード例 #11
0
        private static void Run()
        {
            IsSilentRun = CLIHelper.CheckArgs(Arguments, "silent", "s");
            IsSandbox   = CLIHelper.CheckArgs(Arguments, "sandbox");

            if (!IsSandbox)
            {
                IsPortable = CLIHelper.CheckArgs(Arguments, "portable", "p");

                if (IsPortable)
                {
                    CustomPersonalPath = PortablePersonalPath;
                }
                else
                {
                    CheckPersonalPathConfig();
                }

                if (!string.IsNullOrEmpty(PersonalPath) && !Directory.Exists(PersonalPath))
                {
                    Directory.CreateDirectory(PersonalPath);
                }
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            DebugHelper.WriteLine("{0} started", Title);
            DebugHelper.WriteLine("Operating system: " + Environment.OSVersion.VersionString);
            DebugHelper.WriteLine("Command line: " + Environment.CommandLine);
            DebugHelper.WriteLine("Personal path: " + PersonalPath);

            string gitHash = GetGitHash();

            if (!string.IsNullOrEmpty(gitHash))
            {
                DebugHelper.WriteLine("Git: https://github.com/ShareX/ShareX/tree/" + gitHash);
            }

            SettingsResetEvent         = new ManualResetEvent(false);
            UploaderSettingsResetEvent = new ManualResetEvent(false);
            HotkeySettingsResetEvent   = new ManualResetEvent(false);
            TaskEx.Run(() => LoadSettings());

            DebugHelper.WriteLine("MainForm init started");
            MainForm = new MainForm();
            DebugHelper.WriteLine("MainForm init finished");

            if (Settings == null)
            {
                SettingsResetEvent.WaitOne();
            }

            Application.Run(MainForm);

            if (WatchFolderManager != null)
            {
                WatchFolderManager.Dispose();
            }
            SaveSettings();
            BackupSettings();

            DebugHelper.WriteLine("ShareX closing");
            DebugHelper.Logger.SaveLog(LogsFilePath);
        }