Interaction logic for ExceptionViewer.xaml
コード例 #1
0
        private void InnerButton_Click(object sender, RoutedEventArgs e)
        {
            var errorViewer = new ExceptionViewer(_exception.InnerException);
            errorViewer.ShowDialog();

            GC.Collect(1);
        }
コード例 #2
0
ファイル: Webcam.xaml.cs プロジェクト: rob3c/ScreenToGif
        private void Stop_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            try
            {
                _frameCount = 0;

                _timer.Stop();

                if (Stage != Stage.Stopped && Stage != Stage.PreStarting && ListFrames.Any())
                {
                    #region If not Already Stoped nor Pre Starting and FrameCount > 0, Stops

                    ExitArg      = ExitAction.Recorded;
                    DialogResult = false;

                    #endregion
                }
                else if ((Stage == Stage.PreStarting || Stage == Stage.Snapping) && !ListFrames.Any())
                {
                    #region if Pre-Starting or in Snapmode and no Frames, Stops

                    Stage = Stage.Stopped;

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

                    Title = "Screen To Gif";

                    #endregion
                }
            }
            catch (NullReferenceException nll)
            {
                var errorViewer = new ExceptionViewer(nll);
                errorViewer.ShowDialog();
                LogWriter.Log(nll, "NullPointer in the Stop function");
            }
            catch (Exception ex)
            {
                var errorViewer = new ExceptionViewer(ex);
                errorViewer.ShowDialog();
                LogWriter.Log(ex, "Error in the Stop function");
            }
        }
コード例 #3
0
ファイル: Options.xaml.cs プロジェクト: rob3c/ScreenToGif
        private void LanguagePanel_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!IsLoaded)
            {
                return;
            }

            try
            {
                LocalizationHelper.SelectCulture(Settings.Default.Language);
            }
            catch (Exception ex)
            {
                var errorViewer = new ExceptionViewer(ex);
                errorViewer.ShowDialog();
                LogWriter.Log(ex, "Error while trying to set the language.");
            }
        }
コード例 #4
0
ファイル: Options.xaml.cs プロジェクト: rob3c/ScreenToGif
        private void DonateOtherButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var label = CurrencyComboBox.SelectedValue as Label;

                var currency = label.Content.ToString().Substring(0, 3);

                Process.Start(
                    $"https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=JCY2BGLULSWVJ&lc=US&item_name=ScreenToGif&item_number=screentogif&currency_code={currency}&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted");
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Error • Openning the Donation website");

                var exception = new ExceptionViewer(ex);
                exception.ShowDialog();
            }
        }
コード例 #5
0
ファイル: App.xaml.cs プロジェクト: gayancc/screentogif
        private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var exception = e.ExceptionObject as Exception;

            if (exception == null) return;

            LogWriter.Log(exception, "Current Domain Unhandled Exception - Unknow");

            var errorViewer = new ExceptionViewer(exception);
            errorViewer.ShowDialog();
        }
コード例 #6
0
ファイル: App.xaml.cs プロジェクト: gayancc/screentogif
        private void App_OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            LogWriter.Log(e.Exception, "On Dispacher Unhandled Exception - Unknow");

            var errorViewer = new ExceptionViewer(e.Exception);
            errorViewer.ShowDialog();

            e.Handled = true;
        }
コード例 #7
0
ファイル: Recorder.xaml.cs プロジェクト: dbremner/ScreenToGif
        /// <summary>
        /// Stops the recording or the Pre-Start countdown.
        /// </summary>
        private void Stop()
        {
            try
            {
                _capture.Stop();
                FrameRate.Stop();

                FrameCount = 0;

                if (Stage != Stage.Stopped && Stage != Stage.PreStarting && ListFrames.Any())
                {
                    #region Stop

                    ExitArg = ExitAction.Recorded;
                    DialogResult = false;

                    #endregion
                }
                else if ((Stage == Stage.PreStarting || Stage == Stage.Snapping) && !ListFrames.Any())
                {
                    #region if Pre-Starting or in Snapmode and no Frames, Stops

                    Stage = Stage.Stopped;

                    //Enables the controls that are disabled while recording;
                    FpsNumericUpDown.IsEnabled = true;
                    RecordPauseButton.IsEnabled = true;
                    HeightTextBox.IsEnabled = true;
                    WidthTextBox.IsEnabled = true;

                    IsRecording(false);
                    Topmost = true;

                    Title = "Screen To Gif";

                    AutoFitButtons();

                    #endregion
                }
            }
            catch (NullReferenceException nll)
            {
                var errorViewer = new ExceptionViewer(nll);
                errorViewer.ShowDialog();
                LogWriter.Log(nll, "NullPointer on the Stop function");
            }
            catch (Exception ex)
            {
                var errorViewer = new ExceptionViewer(ex);
                errorViewer.ShowDialog();
                LogWriter.Log(ex, "Error on the Stop function");
            }
        }
コード例 #8
0
ファイル: Recorder.xaml.cs プロジェクト: koen24/screentogif
        /// <summary>
        /// Stops the recording or the Pre-Start countdown.
        /// </summary>
        private void Stop()
        {
            try
            {
                _frameCount = 0;

                _capture.Stop();

                if (Stage != Stage.Stopped && Stage != Stage.PreStarting && ListFrames.Any())
                {
                    #region Stop

                    ExitArg = ExitAction.Recorded;
                    DialogResult = false;

                    #endregion
                }
                else if ((Stage == Stage.PreStarting || Stage == Stage.Snapping) && !ListFrames.Any())
                {
                    #region if Pre-Starting or in Snapmode and no Frames, Stops

                    Stage = Stage.Stopped;

                    //Enables the controls that are disabled while recording;
                    FpsNumericUpDown.IsEnabled = true;
                    RecordPauseButton.IsEnabled = true;
                    HeightTextBox.IsEnabled = true;
                    WidthTextBox.IsEnabled = true;

                    IsRecording(false);
                    Topmost = true;

                    RecordPauseButton.Text = Properties.Resources.btnRecordPause_Record;
                    RecordPauseButton.Content = (Canvas)FindResource("RecordDark");
                    RecordPauseButton.HorizontalContentAlignment = HorizontalAlignment.Left;
                    Title = Properties.Resources.TitleStoped;

                    AutoFitButtons();

                    #endregion
                }
            }
            catch (NullReferenceException nll)
            {
                var errorViewer = new ExceptionViewer(nll);
                errorViewer.ShowDialog();
                LogWriter.Log(nll, "NullPointer in the Stop function");
            }
            catch (Exception ex)
            {
                var errorViewer = new ExceptionViewer(ex);
                errorViewer.ShowDialog();
                LogWriter.Log(ex, "Error in the Stop function");
            }
        }
コード例 #9
0
ファイル: App.xaml.cs プロジェクト: koen24/screentogif
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            #region Unhandled Exceptions

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            #endregion

            #region Arguments

            try
            {
                if (e.Args.Length > 0)
                {
                    //TODO: Watch for Args...
                }
            }
            catch (Exception ex)
            {
                var errorViewer = new ExceptionViewer(ex);
                errorViewer.ShowDialog();

                LogWriter.Log(ex, "Generic Exception - Arguments");
            }

            #endregion

            #region Language

            try
            {
                if (!Settings.Default.Language.Equals("auto"))
                {
                    Thread.CurrentThread.CurrentCulture = new CultureInfo(Settings.Default.Language);
                    Thread.CurrentThread.CurrentUICulture = new CultureInfo(Settings.Default.Language);
                }
            }
            catch (Exception ex)
            {
                var errorViewer = new ExceptionViewer(ex);
                errorViewer.ShowDialog();

                LogWriter.Log(ex, "Language Settings Exception");
            }

            #endregion

            try
            {
                #region Startup

                if (Settings.Default.StartUp == 0)
                {
                    var startup = new Startup();
                    Current.MainWindow = startup;
                    startup.ShowDialog();
                }
                else if (Settings.Default.StartUp == 3)
                {
                    var edit = new Editor();
                    Current.MainWindow = edit;
                    edit.ShowDialog();
                }
                else
                {
                    var editor = new Editor();
                    List<FrameInfo> frames = null;
                    ExitAction exitArg = ExitAction.Exit;
                    bool? result = null;

                    #region Recorder or Webcam

                    if (Settings.Default.StartUp == 1)
                    {
                        var rec = new Recorder(true);
                        result = rec.ShowDialog();
                        exitArg = rec.ExitArg;
                        frames = rec.ListFrames;
                    }
                    else if (Settings.Default.StartUp == 2)
                    {
                        var web = new Windows.Webcam();
                        result = web.ShowDialog();
                        exitArg = web.ExitArg;
                        frames = web.ListFrames;
                    }

                    #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.ListFrames = frames;
                            Current.MainWindow = editor;
                            editor.ShowDialog();
                        }

                        #endregion
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                var errorViewer = new ExceptionViewer(ex);
                errorViewer.ShowDialog();
                LogWriter.Log(ex, "Generic Exception - Root");
            }
        }
コード例 #10
0
ファイル: Options.xaml.cs プロジェクト: dbremner/ScreenToGif
        private void DonateOtherButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var label = CurrencyComboBox.SelectedValue as Label;

                var currency = label.Content.ToString().Substring(0, 3);

                Process.Start(
                    $"https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=JCY2BGLULSWVJ&lc=US&item_name=ScreenToGif&item_number=screentogif&currency_code={currency}&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted");
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Error • Openning the Donation website");

                var exception = new ExceptionViewer(ex);
                exception.ShowDialog();
            }
        }
コード例 #11
0
ファイル: Editor.xaml.cs プロジェクト: dbremner/ScreenToGif
        private void Delete_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            Pause();

            try
            {
                #region Validation

                if (ListFrames.Count == FrameListView.SelectedItems.Count)
                {
                    if (Dialog.Ask(FindResource("Editor.Remove.Title").ToString(),
                        FindResource("Editor.Remove.Instruction").ToString(),
                        FindResource("Editor.Remove.Message").ToString(), Dialog.Icons.Question))
                    {
                        DiscardProject_Executed(null, null);
                    }

                    return;
                }

                #endregion

                ActionStack.Did(ListFrames);

                var selected = FrameListView.SelectedItems.OfType<FrameListBoxItem>().ToList();
                var selectedOrdered = selected.OrderByDescending(x => x.FrameNumber).ToList();
                var list = selectedOrdered.Select(item => ListFrames[item.FrameNumber]).ToList();

                FrameListView.SelectedItem = null;

                list.ForEach(x => File.Delete(x.ImageLocation));
                selectedOrdered.ForEach(x => ListFrames.RemoveAt(x.FrameNumber));
                selectedOrdered.ForEach(x => FrameListView.Items.Remove(x));

                AdjustFrameNumbers(selectedOrdered.Last().FrameNumber);
                SelectNear(selectedOrdered.Last().FrameNumber);
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Error While Trying to Delete Frames");

                var errorViewer = new ExceptionViewer(ex);
                errorViewer.ShowDialog();
            }
        }
コード例 #12
0
ファイル: Editor.xaml.cs プロジェクト: akappel/screentogif
        private void Delete_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            Pause();

            try
            {
                #region Validation

                if (ListFrames.Count == FrameListView.SelectedItems.Count)
                {
                    if (Dialog.Ask("Remove All", "Do you want to remove all frames?", "You are trying to remove all frames. \n\rYou can't undo this operation.", Dialog.Icons.Question))
                    {
                        DiscardProject_Executed(null, null);
                    }

                    return;
                }

                #endregion

                ActionStack.Did(ListFrames);

                var selected = FrameListView.SelectedItems.OfType<FrameListBoxItem>().ToList();
                var list = selected.Select(item => ListFrames[item.FrameNumber]).ToList();

                FrameListView.SelectedItem = null;

                list.ForEach(x => File.Delete(x.ImageLocation));
                selected.OrderByDescending(x => x.FrameNumber).ToList().ForEach(x => ListFrames.RemoveAt(x.FrameNumber));
                selected.OrderByDescending(x => x.FrameNumber).ToList().ForEach(x => FrameListView.Items.Remove(x));

                AdjustFrameNumbers(selected[0].FrameNumber);
                SelectNear(selected[0].FrameNumber);
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Error While Trying to Delete Frames");

                var errorViewer = new ExceptionViewer(ex);
                errorViewer.ShowDialog();
            }
        }
コード例 #13
0
ファイル: Options.xaml.cs プロジェクト: koen24/screentogif
        private void LanguagePanel_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!IsLoaded) return;
            RestartButton.Visibility = !Settings.Default.Language.Equals(_initialLanguage)
                ? Visibility.Visible : Visibility.Collapsed;

            if (Settings.Default.Language.Equals("auto"))
            {
                //TODO: Get the real system's language and return;
                return;
            }

            try
            {
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(Settings.Default.Language);
            }
            catch (Exception ex)
            {
                var errorViewer = new ExceptionViewer(ex);
                errorViewer.ShowDialog();
                LogWriter.Log(ex, "Error while trying to set the language.");
            }
        }
コード例 #14
0
ファイル: Options.xaml.cs プロジェクト: gayancc/screentogif
        private void DonateButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Process.Start("https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=JCY2BGLULSWVJ&lc=US&item_name=ScreenToGif&item_number=screentogif&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted");
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Error • Openning the Donation website");

                var exception = new ExceptionViewer(ex);
                exception.ShowDialog();
            }
        }
コード例 #15
0
ファイル: App.xaml.cs プロジェクト: gayancc/screentogif
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            #region Unhandled Exceptions

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            #endregion

            #region Arguments

            try
            {
                if (e.Args.Length > 0)
                {
                    //TODO: Watch for Args...
                }
            }
            catch (Exception ex)
            {
                var errorViewer = new ExceptionViewer(ex);
                errorViewer.ShowDialog();

                LogWriter.Log(ex, "Generic Exception - Arguments");
            }

            #endregion

            #region Upgrade Application Settings

            //See http://stackoverflow.com/questions/534261/how-do-you-keep-user-config-settings-across-different-assembly-versions-in-net
            if (Settings.Default.UpgradeRequired)
            {
                Settings.Default.Upgrade();
                Settings.Default.UpgradeRequired = false;
                Settings.Default.Save();
            }

            #endregion

            #region Language

            try
            {
                if (!Settings.Default.Language.Equals("auto"))
                {
                    Thread.CurrentThread.CurrentCulture = new CultureInfo(Settings.Default.Language);
                    Thread.CurrentThread.CurrentUICulture = new CultureInfo(Settings.Default.Language);
                }
            }
            catch (Exception ex)
            {
                var errorViewer = new ExceptionViewer(ex);
                errorViewer.ShowDialog();

                LogWriter.Log(ex, "Language Settings Exception");
            }

            #endregion

            try
            {
                #region Startup

                if (Settings.Default.StartUp == 0)
                {
                    var startup = new Startup();
                    Current.MainWindow = startup;
                    startup.ShowDialog();
                }
                else if (Settings.Default.StartUp == 4)
                {
                    var edit = new Editor();
                    Current.MainWindow = edit;
                    edit.ShowDialog();
                }
                else
                {
                    var editor = new Editor();
                    List<FrameInfo> frames = null;
                    ExitAction exitArg = ExitAction.Exit;
                    bool? result = null;

                    #region Recorder or Webcam

                    if (Settings.Default.StartUp == 1)
                    {
                        var rec = new Recorder(true);
                        result = rec.ShowDialog();
                        exitArg = rec.ExitArg;
                        frames = rec.ListFrames;
                    }
                    else if (Settings.Default.StartUp == 2)
                    {
                        var web = new Windows.Webcam();
                        result = web.ShowDialog();
                        exitArg = web.ExitArg;
                        frames = web.ListFrames;
                    }
                    else if (Settings.Default.StartUp == 3)
                    {
                        var board = new Board();
                        result = board.ShowDialog();
                        exitArg = board.ExitArg;
                        frames = board.ListFrames;
                    }

                    #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.ListFrames = frames;
                            Current.MainWindow = editor;
                            editor.ShowDialog();
                        }

                        #endregion
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                var errorViewer = new ExceptionViewer(ex);
                errorViewer.ShowDialog();
                LogWriter.Log(ex, "Generic Exception - Root");
            }
        }
コード例 #16
0
ファイル: Webcam.xaml.cs プロジェクト: koen24/screentogif
        private void Stop_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            try
            {
                _frameCount = 0;

                _timer.Stop();

                if (Stage != Stage.Stopped && Stage != Stage.PreStarting && ListFrames.Any())
                {
                    #region If not Already Stoped nor Pre Starting and FrameCount > 0, Stops

                    ExitArg = ExitAction.Recorded;
                    DialogResult = false;

                    #endregion
                }
                else if ((Stage == Stage.PreStarting || Stage == Stage.Snapping) && !ListFrames.Any())
                {
                    #region if Pre-Starting or in Snapmode and no Frames, Stops

                    Stage = Stage.Stopped;

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

                    RecordPauseButton.Text = Properties.Resources.btnRecordPause_Record;
                    RecordPauseButton.Content = (Canvas)FindResource("Vector.Record.Dark");
                    Title = Properties.Resources.TitleStoped;

                    #endregion
                }
            }
            catch (NullReferenceException nll)
            {
                var errorViewer = new ExceptionViewer(nll);
                errorViewer.ShowDialog();
                LogWriter.Log(nll, "NullPointer in the Stop function");
            }
            catch (Exception ex)
            {
                var errorViewer = new ExceptionViewer(ex);
                errorViewer.ShowDialog();
                LogWriter.Log(ex, "Error in the Stop function");
            }
        }
コード例 #17
0
ファイル: Options.xaml.cs プロジェクト: dbremner/ScreenToGif
        private void LanguagePanel_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!IsLoaded) return;

            try
            {
                LocalizationHelper.SelectCulture(Settings.Default.Language);
            }
            catch (Exception ex)
            {
                var errorViewer = new ExceptionViewer(ex);
                errorViewer.ShowDialog();
                LogWriter.Log(ex, "Error while trying to set the language.");
            }
        }