Beispiel #1
0
        private async void ClearTempButton_Click(object sender, RoutedEventArgs e)
        {
            ClearTempButton.IsEnabled = false;

            try
            {
                var path = Path.Combine(UserSettings.All.TemporaryFolder, "ScreenToGif", "Recording");

                if (!Directory.Exists(path))
                {
                    _folderList.Clear();
                    FolderCountLabel.Text = "0";
                    FileCountLabel.Text   = "0";
                    return;
                }

                #region Update the Information

                //Directory.GetDirectories(Path.Combine(UserSettings.All.TemporaryFolder, "ScreenToGif", "Recording")).Select(s => new DirectoryInfo(s)).Where(w => (DateTime.Now - w.CreationTime).Days > 5).ToList();
                _folderList = await Task.Factory.StartNew(() => Directory.GetDirectories(path).Select(x => new DirectoryInfo(x)).ToList());

                #endregion

                if (Dialog.Ask("ScreenToGif", FindResource("TempFiles.KeepRecent") as string, FindResource("TempFiles.KeepRecent.Info") as string))
                {
                    _folderList = await Task.Factory.StartNew(() => _folderList.Where(w => (DateTime.Now - w.CreationTime).Days > 5).ToList());
                }

                foreach (var folder in _folderList)
                {
                    //var project = Path.Combine(folder.FullName, "Project.json");

                    //if (File.Exists(project) && (new FileInfo(project).LastWriteTime - DateTime.Now).Days < 5)
                    //    continue;

                    Directory.Delete(folder.FullName, true);
                }

                #region Update the Information

                _folderList = Directory.GetDirectories(path).Select(x => new DirectoryInfo(x)).ToList();

                #endregion
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Error while cleaning the Temp folder");
            }

            FolderCountLabel.Text     = _folderList.Count.ToString("###,###");
            FileCountLabel.Text       = _folderList.Sum(folder => Directory.EnumerateFiles(folder.FullName).Count()).ToString("###,###");
            ClearTempButton.IsEnabled = _folderList.Any();
        }
Beispiel #2
0
    private void Delete(History history)
    {
        if (!Dialog.Ask(Title, LocalizationHelper.Get("S.Options.Upload.History.Delete.Instruction"), LocalizationHelper.Get("S.Options.Upload.History.Delete.Message")))
        {
            return;
        }

        CurrentPreset?.History.Remove(history);
        DataGrid.ItemsSource   = null;
        DataGrid.ItemsSource   = CurrentPreset?.History;
        DataGrid.SelectedIndex = 0;
    }
Beispiel #3
0
 private void Cancel()
 {
     if (!Dialog.Ask("Are you sure you want to cancel?"))
     {
         return;
     }
     if (State.IsEdit)
     {
         CancelEdit();
     }
     State.ToView();
     Rules.ClearErrors();
     OnPropertyChanged(string.Empty);
 }
        private async void ClearTempButton_Click(object sender, RoutedEventArgs e)
        {
            ClearTempButton.IsEnabled = false;

            try
            {
                var path = Path.Combine(UserSettings.All.TemporaryFolder, "ScreenToGif", "Recording");

                if (!Directory.Exists(path))
                {
                    _folderList.Clear();
                    return;
                }

                _folderList = await Task.Factory.StartNew(() => Directory.GetDirectories(path, "*", SearchOption.TopDirectoryOnly).Select(x => new DirectoryInfo(x)).ToList());

                if (Dialog.Ask("ScreenToGif", LocalizationHelper.Get("TempFiles.KeepRecent"),
                               LocalizationHelper.Get("TempFiles.KeepRecent.Info")))
                {
                    _folderList = await Task.Factory.StartNew(() =>
                                                              _folderList.Where(w => (DateTime.Now - w.CreationTime).Days > 5).ToList());
                }

                foreach (var folder in _folderList)
                {
                    if (MutexList.IsInUse(folder.Name))
                    {
                        continue;
                    }

                    Directory.Delete(folder.FullName, true);
                }

                _folderList = await Task.Factory.StartNew(() => Directory.GetDirectories(path, "*", SearchOption.TopDirectoryOnly).Select(x => new DirectoryInfo(x)).ToList());
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Error while cleaning the Temp folder");
            }
            finally
            {
                App.MainViewModel.CheckDiskSpace();
            }

            ClearTempButton.IsEnabled = _folderList.Any();
        }
Beispiel #5
0
    private async void DiscardButton_Click(object sender, RoutedEventArgs e)
    {
        if (UserSettings.All.NotifyRecordingDiscard && !Dialog.Ask(LocalizationHelper.Get("S.Recorder.Discard.Title"),
                                                                   LocalizationHelper.Get("S.Recorder.Discard.Instruction"), LocalizationHelper.Get("S.Recorder.Discard.Message"), false))
        {
            return;
        }

        _capture.Stop();
        FrameRate.Stop();
        FrameCount = 0;
        Stage      = RecorderStages.Stopped;

        MainGrid.IsEnabled = false;
        Cursor             = Cursors.AppStarting;

        await Task.Run(Discard);

        //Enables the controls that are disabled while recording;
        FpsNumericUpDown.IsEnabled = true;
        HeightIntegerBox.IsEnabled = true;
        WidthIntegerBox.IsEnabled  = true;
        MainGrid.IsEnabled         = true;

        Cursor      = Cursors.Arrow;
        IsRecording = false;

        DiscardButton.BeginStoryboard(FindResource("HideDiscardStoryboard") as Storyboard, HandoffBehavior.Compose);

        //Removes the current drawings.
        MainInkCanvas.Strokes.Clear();

        //if (!Settings.Default.Snapshot)
        //{
        //Only display the Record text when not in snapshot mode.
        Title = LocalizationHelper.Get("S.Board.Title");
        //}
        //else
        //{
        //    Stage = Stage.Snapping;
        //    EnableSnapshot_Executed(null, null);
        //}

        AutoFitButtons();
    }
Beispiel #6
0
    private async void DiscardButton_Click(object sender, RoutedEventArgs e)
    {
        Pause();

        if (UserSettings.All.NotifyRecordingDiscard && !Dialog.Ask(LocalizationHelper.Get("S.Recorder.Discard.Title"),
                                                                   LocalizationHelper.Get("S.Recorder.Discard.Instruction"), LocalizationHelper.Get("S.Recorder.Discard.Message"), false))
        {
            return;
        }

        _timer.Stop();
        _frameCount = 0;
        Stage       = RecorderStages.Stopped;

        Cursor = Cursors.AppStarting;
        LowerGrid.IsEnabled = false;

        await Task.Run(Discard);

        //Enables the controls that are disabled while recording;
        FpsNumericUpDown.IsEnabled     = true;
        RefreshButton.IsEnabled        = true;
        VideoDevicesComboBox.IsEnabled = true;
        LowerGrid.IsEnabled            = true;

        DiscardButton.BeginStoryboard(FindResource("HideDiscardStoryboard") as Storyboard, HandoffBehavior.Compose);

        Cursor = Cursors.Arrow;

        //if (!UserSettings.All.SnapshotMode)
        {
            //Only display the Record text when not in snapshot mode.
            Title = "ScreenToGif";
            Stage = RecorderStages.Stopped;
        }
        //else
        {
            //Stage = Stage.Snapping;
            //EnableSnapshot_Executed(null, null);
        }

        GC.Collect();
    }
Beispiel #7
0
        private void DiscardButton_Click(object sender, RoutedEventArgs e)
        {
            if (UserSettings.All.NotifyRecordingDiscard && !Dialog.Ask(LocalizationHelper.Get("S.Recorder.Discard.Title"),
                                                                       LocalizationHelper.Get("S.Recorder.Discard.Instruction"), LocalizationHelper.Get("S.Recorder.Discard.Message"), false))
            {
                return;
            }

            _capture.Stop();
            FrameRate.Stop();
            FrameCount = 0;
            Stage      = Stage.Stopped;

            MainGrid.IsEnabled = false;
            Cursor             = Cursors.AppStarting;

            _discardFramesDel = Discard;
            _discardFramesDel.BeginInvoke(DiscardCallback, null);
        }
Beispiel #8
0
        internal void UpdateAction()
        {
            if (Global.UpdateModel == null)
            {
                return;
            }

            var download = new DownloadDialog();
            var result   = download.ShowDialog();

            if (result.HasValue && result.Value)
            {
                NotificationManager.RemoveNotification(s => s.Kind == StatusType.Update);

                //TODO: Check if possible to close.

                if (Dialog.Ask("ScreenToGif", LocalizationHelper.Get("Update.CloseThis"), LocalizationHelper.Get("Update.CloseThis.Detail")))
                {
                    Application.Current.Shutdown(69);
                }
            }
        }
Beispiel #9
0
    private static async void Retry(ResourceDictionary dic, bool isLocal)
    {
        try
        {
            if (!Dialog.Ask(LocalizationHelper.Get("S.SavingSettings.Title"), LocalizationHelper.Get("S.SavingSettings.Instruction"), LocalizationHelper.Get("S.SavingSettings.Message")))
            {
                return;
            }

            //Get a new instance, but elevated.
            var process = ProcessHelper.RestartAsAdminAdvanced("-settings");
            await Task.Delay(500);

            var settings = new XmlWriterSettings
            {
                Indent             = true,
                IndentChars        = "\t",
                OmitXmlDeclaration = true,
                CheckCharacters    = true,
                CloseOutput        = true,
                ConformanceLevel   = ConformanceLevel.Fragment,
                Encoding           = Encoding.UTF8
            };

            //Serialize the settings and pass to the new instance via IPC.
            await using var stream = new StringWriter();
            await using var writer = XmlWriter.Create(stream, settings);
            XamlWriter.Save(dic, writer);
            SettingsPersistenceChannel.SendMessage(process.Id, stream.ToString(), isLocal);

            //Since the other instance only exists to save the settings (no interface is displayed), the process must be stopped.
            process.Kill();
        }
        catch (Exception e)
        {
            LogWriter.Log(e, "Impossible to retry to save the settings.");
        }
    }
Beispiel #10
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            Global.StartupDateTime = DateTime.Now;

            //Unhandled Exceptions.
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            //Increases the duration of the tooltip display.
            ToolTipService.ShowDurationProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(int.MaxValue));

            //Parse arguments.
            if (e.Args.Length > 0)
            {
                Argument.Prepare(e.Args);
            }

            LocalizationHelper.SelectCulture(UserSettings.All.LanguageCode);
            ThemeHelper.SelectTheme(UserSettings.All.MainTheme.ToString());

            if (UserSettings.All.DisableHardwareAcceleration)
            {
                RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
            }

            #region Net Framework

            var array  = Type.GetType("System.Array");
            var method = array?.GetMethod("Empty");

            if (array == null || method == null)
            {
                var ask = Dialog.Ask("Missing Dependency", "Net Framework 4.6.1 is not present", "In order to properly use this app, you need to download the correct version of the .Net Framework. Open the web page to download?");

                if (ask)
                {
                    Process.Start("https://www.microsoft.com/en-us/download/details.aspx?id=49981");
                    return;
                }
            }

            #endregion

            #region Net Framework HotFixes

            //Only runs on Windows 7 SP1.
            if (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor == 1)
            {
                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        var search = new ManagementObjectSearcher("SELECT HotFixID FROM Win32_QuickFixEngineering WHERE HotFixID = 'KB4055002'").Get();
                        Global.IsHotFix4055002Installed = search.Count > 0;
                    }
                    catch (Exception ex)
                    {
                        LogWriter.Log(ex, "Error while trying to know if a hot fix was installed.");
                    }
                });
            }

            #endregion

            #region Tray icon and view model

            NotifyIcon = (NotifyIcon)FindResource("NotifyIcon");

            if (NotifyIcon != null)
            {
                NotifyIcon.Visibility = UserSettings.All.ShowNotificationIcon || UserSettings.All.StartUp == 5 ? Visibility.Visible : Visibility.Collapsed;

                //using (var iconStream = GetResourceStream(new Uri("pack://application:,,,/Resources/Logo.ico"))?.Stream)
                //{
                //    if (iconStream != null)
                //        NotifyIcon.Icon = new System.Drawing.Icon(iconStream);
                //}
            }

            MainViewModel = (ApplicationViewModel)FindResource("AppViewModel") ?? new ApplicationViewModel();

            RegisterShortcuts();

            #endregion

            //var select = new SelectFolderDialog(); select.ShowDialog(); return;
            //var select = new TestField(); select.ShowDialog(); return;
            //var select = new Encoder(); select.ShowDialog(); return;
            //var select = new EditorEx(); select.ShowDialog(); return;

            #region Tasks

            Task.Factory.StartNew(MainViewModel.ClearTemporaryFilesTask, TaskCreationOptions.LongRunning);
            Task.Factory.StartNew(MainViewModel.UpdateTask, TaskCreationOptions.LongRunning);
            Task.Factory.StartNew(MainViewModel.SendFeedback, TaskCreationOptions.LongRunning);

            #endregion

            #region Startup

            if (UserSettings.All.StartUp == 4 || Argument.FileNames.Any())
            {
                MainViewModel.OpenEditor.Execute(null);
                return;
            }

            if (UserSettings.All.StartUp == 0)
            {
                MainViewModel.OpenLauncher.Execute(null);
                return;
            }

            if (UserSettings.All.StartUp == 1)
            {
                MainViewModel.OpenRecorder.Execute(null);
                return;
            }

            if (UserSettings.All.StartUp == 2)
            {
                MainViewModel.OpenWebcamRecorder.Execute(null);
                return;
            }

            if (UserSettings.All.StartUp == 3)
            {
                MainViewModel.OpenBoardRecorder.Execute(null);
            }

            #endregion
        }
Beispiel #11
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            Global.StartupDateTime = DateTime.Now;

            #region Unhandled Exceptions

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            #endregion

            #region Arguments

            try
            {
                if (e.Args.Length > 0)
                {
                    Argument.Prepare(e.Args);
                }
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Generic Exception - Arguments");

                ErrorDialog.Ok("ScreenToGif", "Generic error - arguments", ex.Message, ex);
            }

            #endregion

            #region Language

            try
            {
                LocalizationHelper.SelectCulture(UserSettings.All.LanguageCode);
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Language Settings Exception.");

                ErrorDialog.Ok("ScreenToGif", "Generic error - language", ex.Message, ex);
            }

            #endregion

            #region Net Framework

            var array  = Type.GetType("System.Array");
            var method = array?.GetMethod("Empty");

            if (array == null || method == null)
            {
                var ask = Dialog.Ask("Missing Dependency", "Net Framework 4.6.1 is not present", "In order to properly use this app, you need to download the correct version of the .Net Framework. Open the web page to download?");

                if (ask)
                {
                    Process.Start("https://www.microsoft.com/en-us/download/details.aspx?id=49981");
                    return;
                }
            }

            //try
            //{
            //    //If there's no Array.Empty, means that there's no .Net Framework 4.6.1
            //    //This is not the best way...
            //    Array.Empty<int>();
            //}
            //catch (MissingMethodException ex)
            //{
            //    var ask = Dialog.Ask("Missing Dependency", "Net Framework 4.6.1 is not present", "In order to properly use this app, you need to download the correct version of the .Net Framework. Open the web page to download?");

            //    if (ask)
            //    {
            //        Process.Start("https://www.microsoft.com/en-us/download/details.aspx?id=49981");
            //        return;
            //    }

            //    LogWriter.Log(ex, "Missing .Net Framework 4.6.1");
            //}

            //if (Environment.Version.Build < 30319 && Environment.Version.Revision < 42000)
            //{
            //    var ask = Dialog.Ask("Missing Dependency", "Net Framework 4.6.1 is not present", "In order to properly use this app, you need to download the correct version of the .Net Framework. Open the page to download?");

            //    if (ask)
            //    {
            //        Process.Start("https://www.microsoft.com/en-us/download/details.aspx?id=49981");
            //        return;
            //    }
            //}

            #endregion

            //var select = new RecorderNew();
            //var select = new SelectFolderDialog();
            //var select = new TestField();
            //var select = new Encoder();
            //select.ShowDialog(); return;

            try
            {
                #region Startup

                if (UserSettings.All.StartUp == 0)
                {
                    var startup = new Startup();
                    Current.MainWindow = startup;
                    startup.ShowDialog();
                }
                else if (UserSettings.All.StartUp == 4 || Argument.FileNames.Any())
                {
                    var edit = new Editor();
                    Current.MainWindow = edit;
                    edit.ShowDialog();
                }
                else
                {
                    var         editor  = new Editor();
                    ProjectInfo project = null;
                    var         exitArg = ExitAction.Exit;
                    bool?       result  = null;

                    #region Recorder, Webcam or Border

                    switch (UserSettings.All.StartUp)
                    {
                    case 1:
                        if (UserSettings.All.NewRecorder)
                        {
                            var recNew = new RecorderNew(true);
                            Current.MainWindow = recNew;

                            result  = recNew.ShowDialog();
                            exitArg = recNew.ExitArg;
                            project = recNew.Project;
                            break;
                        }

                        var rec = new Recorder(true);
                        Current.MainWindow = rec;

                        result  = rec.ShowDialog();
                        exitArg = rec.ExitArg;
                        project = rec.Project;
                        break;

                    case 2:
                        var web = new Windows.Webcam(true);
                        Current.MainWindow = web;

                        result  = web.ShowDialog();
                        exitArg = web.ExitArg;
                        project = web.Project;
                        break;

                    case 3:
                        var board = new Board();
                        Current.MainWindow = board;

                        result  = board.ShowDialog();
                        exitArg = board.ExitArg;
                        project = board.Project;
                        break;
                    }

                    #endregion

                    if (result.HasValue && result.Value)
                    {
                        #region If Close

                        Environment.Exit(0);

                        #endregion
                    }
                    else if (result.HasValue)
                    {
                        #region If Backbutton or Stop Clicked

                        if (exitArg == ExitAction.Recorded)
                        {
                            editor.Project     = project;
                            Current.MainWindow = editor;
                            editor.ShowDialog();
                        }

                        #endregion
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Generic Exception - Root");

                ErrorDialog.Ok("ScreenToGif", "Generic error", ex.Message, ex);
            }
        }
Beispiel #12
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            Global.StartupDateTime = DateTime.Now;

            //Unhandled Exceptions.
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            AppDomain.CurrentDomain.AssemblyResolve    += CurrentDomain_AssemblyResolve;

            //Increases the duration of the tooltip display.
            ToolTipService.ShowDurationProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(int.MaxValue));

            #region Set the workaround

            try
            {
                if (UserSettings.All.WorkaroundQuota)
                {
                    BaseCompatibilityPreferences.HandleDispatcherRequestProcessingFailure = BaseCompatibilityPreferences.HandleDispatcherRequestProcessingFailureOptions.Reset;
                }
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Impossible to set the workaround for the quota crash");
            }

            #endregion

            #region Set network connection properties

            try
            {
                ServicePointManager.Expect100Continue = true;
                ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Impossible to set the network properties");
            }

            #endregion

            //Parse arguments.
            if (e.Args.Length > 0)
            {
                Argument.Prepare(e.Args);
            }

            LocalizationHelper.SelectCulture(UserSettings.All.LanguageCode);
            ThemeHelper.SelectTheme(UserSettings.All.MainTheme.ToString());

            #region If set, it allows only one instance per user

            //The singleton works on a per-user and per-executable mode.
            //Meaning that a different user and/or a different executable intances can co-exist.
            //Part of this code wont work on debug mode, since the SetForegroundWindow() needs focus on the foreground window calling the method.
            if (UserSettings.All.SingleInstance)
            {
                try
                {
                    using (var thisProcess = Process.GetCurrentProcess())
                    {
                        var user      = System.Security.Principal.WindowsIdentity.GetCurrent().User;
                        var name      = thisProcess.MainModule?.FileName ?? Assembly.GetEntryAssembly()?.Location ?? "ScreenToGif";
                        var location  = Convert.ToBase64String(Encoding.UTF8.GetBytes(name));
                        var mutexName = (user?.Value ?? Environment.UserName) + "_" + location;

                        _mutex = new Mutex(true, mutexName, out _accepted);

                        //If the mutext failed to be accepted, it means that another process already openned it.
                        if (!_accepted)
                        {
                            var warning = true;

                            //Switch to the other app (get only one, if multiple available). Use name of assembly.
                            using (var process = Process.GetProcessesByName(thisProcess.ProcessName).FirstOrDefault(f => f.MainWindowHandle != thisProcess.MainWindowHandle))
                            {
                                if (process != null)
                                {
                                    var handles = Native.GetWindowHandlesFromProcess(process);

                                    //Show the window before setting focus.
                                    Native.ShowWindow(handles.Count > 0 ? handles[0] : process.Handle, Native.ShowWindowEnum.Show);

                                    //Set user the focus to the window.
                                    Native.SetForegroundWindow(handles.Count > 0 ? handles[0] : process.Handle);
                                    warning = false;
                                }
                            }

                            //If no window available (app is in the system tray), display a warning.
                            if (warning)
                            {
                                Dialog.Ok(LocalizationHelper.Get("S.Warning.Single.Title"), LocalizationHelper.Get("S.Warning.Single.Header"), LocalizationHelper.Get("S.Warning.Single.Message"), Icons.Info);
                            }

                            Environment.Exit(0);
                            return;
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogWriter.Log(ex, "Impossible to check if another instance is running");
                }
            }

            #endregion

            //Render mode.
            RenderOptions.ProcessRenderMode = UserSettings.All.DisableHardwareAcceleration ? RenderMode.SoftwareOnly : RenderMode.Default;

            #region Net Framework

            if (!FrameworkHelper.HasFramework())
            {
                var ask = Dialog.Ask(LocalizationHelper.Get("S.Warning.Net.Title"), LocalizationHelper.Get("S.Warning.Net.Header"), LocalizationHelper.Get("S.Warning.Net.Message"));

                if (ask)
                {
                    Process.Start("http://go.microsoft.com/fwlink/?LinkId=2085155");
                    return;
                }
            }

            #endregion

            #region Net Framework HotFixes

            //Only runs on Windows 7 SP1.
            if (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor == 1)
            {
                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        var search = new ManagementObjectSearcher("SELECT HotFixID FROM Win32_QuickFixEngineering WHERE HotFixID = 'KB4055002'").Get();
                        Global.IsHotFix4055002Installed = search.Count > 0;
                    }
                    catch (Exception ex)
                    {
                        LogWriter.Log(ex, "Error while trying to know if a hot fix was installed.");
                    }
                });
            }

            #endregion

            #region Tray icon and view model

            NotifyIcon = (NotifyIcon)FindResource("NotifyIcon");

            if (NotifyIcon != null)
            {
                NotifyIcon.Visibility = UserSettings.All.ShowNotificationIcon || UserSettings.All.StartMinimized || UserSettings.All.StartUp == 5 ? Visibility.Visible : Visibility.Collapsed;

                //Replace the old option with the new setting.
                if (UserSettings.All.StartUp == 5)
                {
                    UserSettings.All.StartMinimized       = true;
                    UserSettings.All.ShowNotificationIcon = true;
                    UserSettings.All.StartUp = 0;
                }

                //using (var iconStream = GetResourceStream(new Uri("pack://application:,,,/Resources/Logo.ico"))?.Stream)
                //{
                //    if (iconStream != null)
                //        NotifyIcon.Icon = new System.Drawing.Icon(iconStream);
                //}
            }

            MainViewModel = (ApplicationViewModel)FindResource("AppViewModel") ?? new ApplicationViewModel();

            RegisterShortcuts();

            #endregion

            //var select = new SelectFolderDialog(); select.ShowDialog(); return;
            //var select = new TestField(); select.ShowDialog(); return;
            //var select = new Encoder(); select.ShowDialog(); return;
            //var select = new EditorEx(); select.ShowDialog(); return;

            #region Tasks

            Task.Factory.StartNew(MainViewModel.ClearTemporaryFiles, TaskCreationOptions.LongRunning);
            Task.Factory.StartNew(MainViewModel.CheckForUpdates, TaskCreationOptions.LongRunning);
            Task.Factory.StartNew(MainViewModel.SendFeedback, TaskCreationOptions.LongRunning);

            #endregion

            #region Startup

            //When starting minimized, the
            if (UserSettings.All.StartMinimized)
            {
                return;
            }

            if (UserSettings.All.StartUp == 4 || Argument.FileNames.Any())
            {
                MainViewModel.OpenEditor.Execute(null);
                return;
            }

            if (UserSettings.All.StartUp < 1 || UserSettings.All.StartUp > 4)
            {
                MainViewModel.OpenLauncher.Execute(null);
                return;
            }

            if (UserSettings.All.StartUp == 1)
            {
                MainViewModel.OpenRecorder.Execute(null);
                return;
            }

            if (UserSettings.All.StartUp == 2)
            {
                MainViewModel.OpenWebcamRecorder.Execute(null);
                return;
            }

            if (UserSettings.All.StartUp == 3)
            {
                MainViewModel.OpenBoardRecorder.Execute(null);
            }

            #endregion
        }
Beispiel #13
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            Global.StartupDateTime = DateTime.Now;

            //Unhandled Exceptions.
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            //Increases the duration of the tooltip display.
            ToolTipService.ShowDurationProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(int.MaxValue));

            #region Arguments

            try
            {
                if (e.Args.Length > 0)
                {
                    Argument.Prepare(e.Args);
                }
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Parsing arguments");

                ExceptionDialog.Ok(ex, "ScreenToGif", "Error while parsing arguments", ex.Message);
            }

            #endregion

            #region Language

            try
            {
                LocalizationHelper.SelectCulture(UserSettings.All.LanguageCode);
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Language Settings Exception");

                ExceptionDialog.Ok(ex, "ScreenToGif", "Error while detecting the app's language", ex.Message);
            }

            #endregion

            #region Net Framework

            var array  = Type.GetType("System.Array");
            var method = array?.GetMethod("Empty");

            if (array == null || method == null)
            {
                var ask = Dialog.Ask("Missing Dependency", "Net Framework 4.6.1 is not present", "In order to properly use this app, you need to download the correct version of the .Net Framework. Open the web page to download?");

                if (ask)
                {
                    Process.Start("https://www.microsoft.com/en-us/download/details.aspx?id=49981");
                    return;
                }
            }

            #endregion

            #region Net Framework HotFixes

            if (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor == 1)
            {
                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        var search = new ManagementObjectSearcher("SELECT HotFixID FROM Win32_QuickFixEngineering WHERE HotFixID = 'KB4055002'").Get();
                        Global.IsHotFix4055002Installed = search.Count > 0;
                    }
                    catch (Exception ex)
                    {
                        LogWriter.Log(ex, "Error while trying to know if a hot fix was installed.");
                    }
                });
            }

            #endregion

            #region Tray icon and view model

            NotifyIcon = (NotifyIcon)FindResource("NotifyIcon");

            if (NotifyIcon != null)
            {
                NotifyIcon.Visibility = UserSettings.All.ShowNotificationIcon ? Visibility.Visible : Visibility.Collapsed;
            }

            MainViewModel = (ApplicationViewModel)FindResource("AppViewModel") ?? new ApplicationViewModel();

            RegisterShortcuts();

            #endregion

            //var select = new SelectFolderDialog(); select.ShowDialog(); return;
            //var select = new TestField(); select.ShowDialog(); return;
            //var select = new Encoder(); select.ShowDialog(); return;

            try
            {
                #region Startup

                if (UserSettings.All.StartUp == 4 || Argument.FileNames.Any())
                {
                    MainViewModel.OpenEditor.Execute(null);
                    return;
                }

                if (UserSettings.All.StartUp == 0)
                {
                    MainViewModel.OpenLauncher.Execute(null);
                    return;
                }

                if (UserSettings.All.StartUp == 1)
                {
                    MainViewModel.OpenRecorder.Execute(null);
                    return;
                }

                if (UserSettings.All.StartUp == 2)
                {
                    MainViewModel.OpenWebcamRecorder.Execute(null);
                    return;
                }

                if (UserSettings.All.StartUp == 3)
                {
                    MainViewModel.OpenBoardRecorder.Execute(null);
                }

                #endregion
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Generic Exception - Root");

                ShowException(ex);
            }
        }
Beispiel #14
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            Global.StartupDateTime = DateTime.Now;

            //Unhandled Exceptions.
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            //Increases the duration of the tooltip display.
            ToolTipService.ShowDurationProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(int.MaxValue));

            //Set network connection properties.
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;

            //Parse arguments.
            if (e.Args.Length > 0)
            {
                Argument.Prepare(e.Args);
            }

            LocalizationHelper.SelectCulture(UserSettings.All.LanguageCode);
            ThemeHelper.SelectTheme(UserSettings.All.MainTheme.ToString());

            //Render mode.
            RenderOptions.ProcessRenderMode = UserSettings.All.DisableHardwareAcceleration ? RenderMode.SoftwareOnly : RenderMode.Default;

            #region Net Framework

            if (!FrameworkHelper.HasFramework())
            {
                var ask = Dialog.Ask(LocalizationHelper.Get("S.Warning.Net.Title"), LocalizationHelper.Get("S.Warning.Net.Header"), LocalizationHelper.Get("S.Warning.Net.Message"));

                if (ask)
                {
                    Process.Start("http://go.microsoft.com/fwlink/?LinkId=2085155");
                    return;
                }
            }

            #endregion

            #region Net Framework HotFixes

            //Only runs on Windows 7 SP1.
            if (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor == 1)
            {
                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        var search = new ManagementObjectSearcher("SELECT HotFixID FROM Win32_QuickFixEngineering WHERE HotFixID = 'KB4055002'").Get();
                        Global.IsHotFix4055002Installed = search.Count > 0;
                    }
                    catch (Exception ex)
                    {
                        LogWriter.Log(ex, "Error while trying to know if a hot fix was installed.");
                    }
                });
            }

            #endregion

            #region Tray icon and view model

            NotifyIcon = (NotifyIcon)FindResource("NotifyIcon");

            if (NotifyIcon != null)
            {
                NotifyIcon.Visibility = UserSettings.All.ShowNotificationIcon || UserSettings.All.StartMinimized || UserSettings.All.StartUp == 5 ? Visibility.Visible : Visibility.Collapsed;

                //Replace the old option with the new setting.
                if (UserSettings.All.StartUp == 5)
                {
                    UserSettings.All.StartMinimized       = true;
                    UserSettings.All.ShowNotificationIcon = true;
                    UserSettings.All.StartUp = 0;
                }

                //using (var iconStream = GetResourceStream(new Uri("pack://application:,,,/Resources/Logo.ico"))?.Stream)
                //{
                //    if (iconStream != null)
                //        NotifyIcon.Icon = new System.Drawing.Icon(iconStream);
                //}
            }

            MainViewModel = (ApplicationViewModel)FindResource("AppViewModel") ?? new ApplicationViewModel();

            RegisterShortcuts();

            #endregion

            //var select = new SelectFolderDialog(); select.ShowDialog(); return;
            //var select = new TestField(); select.ShowDialog(); return;
            //var select = new Encoder(); select.ShowDialog(); return;
            //var select = new EditorEx(); select.ShowDialog(); return;

            #region Tasks

            Task.Factory.StartNew(MainViewModel.ClearTemporaryFilesTask, TaskCreationOptions.LongRunning);
            Task.Factory.StartNew(MainViewModel.UpdateTask, TaskCreationOptions.LongRunning);
            Task.Factory.StartNew(MainViewModel.SendFeedback, TaskCreationOptions.LongRunning);

            #endregion

            #region Startup

            //When starting minimized, the
            if (UserSettings.All.StartMinimized)
            {
                return;
            }

            if (UserSettings.All.StartUp == 4 || Argument.FileNames.Any())
            {
                MainViewModel.OpenEditor.Execute(null);
                return;
            }

            if (UserSettings.All.StartUp < 1 || UserSettings.All.StartUp > 4)
            {
                MainViewModel.OpenLauncher.Execute(null);
                return;
            }

            if (UserSettings.All.StartUp == 1)
            {
                MainViewModel.OpenRecorder.Execute(null);
                return;
            }

            if (UserSettings.All.StartUp == 2)
            {
                MainViewModel.OpenWebcamRecorder.Execute(null);
                return;
            }

            if (UserSettings.All.StartUp == 3)
            {
                MainViewModel.OpenBoardRecorder.Execute(null);
            }

            #endregion
        }
Beispiel #15
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            Global.StartupDateTime = DateTime.Now;

            //Unhandled Exceptions.
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            //Increases the duration of the tooltip display.
            ToolTipService.ShowDurationProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(int.MaxValue));

            #region Arguments

            try
            {
                if (e.Args.Length > 0)
                {
                    Argument.Prepare(e.Args);
                }
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Generic Exception - Arguments");

                ErrorDialog.Ok("ScreenToGif", "Generic error - arguments", ex.Message, ex);
            }

            #endregion

            #region Language

            try
            {
                LocalizationHelper.SelectCulture(UserSettings.All.LanguageCode);
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Language Settings Exception.");

                ErrorDialog.Ok("ScreenToGif", "Generic error - language", ex.Message, ex);
            }

            #endregion

            #region Net Framework

            var array  = Type.GetType("System.Array");
            var method = array?.GetMethod("Empty");

            if (array == null || method == null)
            {
                var ask = Dialog.Ask("Missing Dependency", "Net Framework 4.6.1 is not present", "In order to properly use this app, you need to download the correct version of the .Net Framework. Open the web page to download?");

                if (ask)
                {
                    Process.Start("https://www.microsoft.com/en-us/download/details.aspx?id=49981");
                    return;
                }
            }

            #endregion

            #region Tray icon and view model

            NotifyIcon = (NotifyIcon)FindResource("NotifyIcon");

            if (NotifyIcon != null)
            {
                NotifyIcon.Visibility = UserSettings.All.ShowNotificationIcon ? Visibility.Visible : Visibility.Collapsed;
            }

            MainViewModel = (ApplicationViewModel)FindResource("AppViewModel") ?? new ApplicationViewModel();

            #endregion

            //var select = new SelectFolderDialog(); select.ShowDialog(); return;
            //var select = new TestField(); select.ShowDialog(); return;
            //var select = new Encoder(); select.ShowDialog(); return;

            try
            {
                #region Startup

                if (UserSettings.All.StartUp == 4 || Argument.FileNames.Any())
                {
                    MainViewModel.OpenEditor.Execute(null);
                    return;
                }

                if (UserSettings.All.StartUp == 0)
                {
                    MainViewModel.OpenLauncher.Execute(null);
                    return;
                }

                if (UserSettings.All.StartUp == 1)
                {
                    MainViewModel.OpenRecorder.Execute(null);
                    return;
                }

                if (UserSettings.All.StartUp == 2)
                {
                    MainViewModel.OpenWebcamRecorder.Execute(null);
                    return;
                }

                if (UserSettings.All.StartUp == 3)
                {
                    MainViewModel.OpenBoardRecorder.Execute(null);
                }

                #endregion
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Generic Exception - Root");

                ErrorDialog.Ok("ScreenToGif", "Generic error", ex.Message, ex);
            }
        }
Beispiel #16
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            Global.StartupDateTime = DateTime.Now;

            //Unhandled Exceptions.
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            //Increases the duration of the tooltip display.
            ToolTipService.ShowDurationProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(int.MaxValue));

            LocalizationHelper.SelectCulture("en");

            if (UserSettings.All.DisableHardwareAcceleration)
            {
                RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
            }

            #region Net Framework

            var array  = Type.GetType("System.Array");
            var method = array?.GetMethod("Empty");

            if (array == null || method == null)
            {
                var ask = Dialog.Ask("Missing Dependency", "Net Framework 4.6.1 is not present", "In order to properly use this app, you need to download the correct version of the .Net Framework. Open the web page to download?");

                if (ask)
                {
                    Process.Start("https://www.microsoft.com/en-us/download/details.aspx?id=49981");
                    return;
                }
            }

            #endregion

            #region Net Framework HotFixes

            //Only runs on Windows 7 SP1.
            if (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor == 1)
            {
                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        var search = new ManagementObjectSearcher("SELECT HotFixID FROM Win32_QuickFixEngineering WHERE HotFixID = 'KB4055002'").Get();
                        Global.IsHotFix4055002Installed = search.Count > 0;
                    }
                    catch (Exception ex)
                    {
                        LogWriter.Log(ex, "Error while trying to know if a hot fix was installed.");
                    }
                });
            }

            #endregion

            MainViewModel = (ApplicationViewModel)FindResource("AppViewModel") ?? new ApplicationViewModel();

            RegisterShortcuts();

            //var select = new SelectFolderDialog(); select.ShowDialog(); return;
            //var select = new TestField(); select.ShowDialog(); return;
            //var select = new Encoder(); select.ShowDialog(); return;

            #region Tasks

            Task.Factory.StartNew(MainViewModel.ClearTemporaryFilesTask, TaskCreationOptions.LongRunning);

            #endregion

            MainViewModel.OpenRecorder.Execute(null);
        }