Ejemplo n.º 1
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();
                }
            }
        }
Ejemplo n.º 2
0
        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);
                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);
            }
        }
Ejemplo n.º 3
0
 public CaptureLastRegion(MainForm mainForm)
     : base(mainForm)
 {
 }
Ejemplo n.º 4
0
        private static void Run()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            IsSilentRun = CLI.IsCommandExist("silent", "s");
            IsSandbox = CLI.IsCommandExist("sandbox");

            if (!IsSandbox)
            {
                IsPortable = CLI.IsCommandExist("portable", "p");

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

                if (!Directory.Exists(PersonalPath))
                {
                    try
                    {
                        Directory.CreateDirectory(PersonalPath);
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(Resources.Program_Run_Unable_to_create_folder_ + string.Format(" \"{0}\"\r\n\r\n{1}", PersonalPath, e),
                            "ShareX - " + Resources.Program_Run_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);
        }
Ejemplo n.º 5
0
        private static void Run()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            IsSilentRun = CLI.IsCommandExist("silent", "s");

#if STEAM
            IsFirstTimeConfig = CLI.IsCommandExist("SteamConfig");
#endif

            NoHotkeys = CLI.IsCommandExist("NoHotkeys");

            DebugHelper.WriteLine(TitleLong);
            DebugHelper.WriteLine("Operating system: " + Environment.OSVersion.VersionString);
            DebugHelper.WriteLine("Command line: " + Environment.CommandLine);
            DebugHelper.WriteLine("Personal path: " + PersonalFolder);

            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();
            SaveAllSettings();
            BackupSettings();

            DebugHelper.Logger.Async = false;
            DebugHelper.WriteLine("ShareX closing");
        }
Ejemplo n.º 6
0
 public CaptureScreen(MainForm mainForm)
     : base(mainForm)
 {
 }
Ejemplo n.º 7
0
 public CaptureActiveWindow(MainForm mainForm)
     : base(mainForm)
 {
 }
Ejemplo n.º 8
0
        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();
                }
            }
        }
Ejemplo n.º 9
0
 public CaptureStrategy(MainForm mainForm)
 {
     this.mainForm = mainForm;
 }
Ejemplo n.º 10
0
 public CaptureCustomRegion(MainForm mainForm)
     : base(mainForm)
 {
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 12
0
 public CaptureActiveMonitor(MainForm mainForm)
     : base(mainForm)
 {
 }
Ejemplo n.º 13
0
        private static void Run()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            DebugHelper.WriteLine(Title);
            DebugHelper.WriteLine("Build: " + Build);
            DebugHelper.WriteLine("Command line: " + Environment.CommandLine);
            DebugHelper.WriteLine("Personal path: " + PersonalFolder);
            DebugHelper.WriteLine("Operating system: " + Helpers.GetWindowsProductName());

            SilentRun = CLI.IsCommandExist("silent", "s");

#if STEAM
            SteamFirstTimeConfig = CLI.IsCommandExist("SteamConfig");
#endif

            IgnoreHotkeyWarning = CLI.IsCommandExist("NoHotkeys");

            CheckPuushMode();
            DebugWriteFlags();
            CleanTempFiles();
            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();
            SaveAllSettings();
            BackupSettings();

            DebugHelper.Logger.Async = false;
            DebugHelper.WriteLine("ShareX closing");
        }