Interaction logic for Webcam.xaml
Beispiel #1
0
        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");
            }
        }
Beispiel #2
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 #3
0
        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");
            }
        }
Beispiel #4
0
        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");
            }
        }
Beispiel #5
0
        private void InsertWebcamRecording_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            e.Handled = true;
            Pause();

            var recorder = new Webcam();
            var result = recorder.ShowDialog();

            #region If recording cancelled

            if (!result.HasValue || recorder.ExitArg != ExitAction.Recorded || recorder.ListFrames == null)
            {
                GC.Collect();

                return;
            }

            #endregion

            #region Insert

            var insert = new Insert(ListFrames.CopyList(), recorder.ListFrames, FrameListView.SelectedIndex);
            insert.Owner = this;

            result = insert.ShowDialog();

            if (result.HasValue && result.Value)
            {
                //ActionStack.Did(ListFrames);
                ListFrames = insert.ActualList;
                LoadSelectedStarter(0);
            }

            #endregion
        }
Beispiel #6
0
        private void NewWebcamRecording_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            e.Handled = true;
            Pause();

            var webcam = new Webcam();
            var result = webcam.ShowDialog();

            if (result.HasValue && !result.Value && webcam.ExitArg == ExitAction.Recorded && webcam.ListFrames != null)
            {
                ActionStack.Clear();
                ActionStack.Prepare(webcam.ListFrames[0].ImageLocation);

                LoadNewFrames(webcam.ListFrames);
            }
        }
Beispiel #7
0
        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)
                {
                    Argument.Prepare(e.Args);
                }
            }
            catch (Exception ex)
            {
                var errorViewer = new ExceptionViewer(ex);
                errorViewer.ShowDialog();

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

            #endregion

            #region Language

            try
            {
                LocalizationHelper.SelectCulture(UserSettings.All.LanguageCode);
            }
            catch (Exception ex)
            {
                var errorViewer = new ExceptionViewer(ex);
                errorViewer.ShowDialog();
                LogWriter.Log(ex, "Language Settings Exception.");
            }

            #endregion

            //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();
                    List <FrameInfo> frames = null;
                    var  exitArg            = ExitAction.Exit;
                    bool?result             = null;

                    #region Recorder, Webcam or Border

                    switch (UserSettings.All.StartUp)
                    {
                    case 1:
                        var rec = new Recorder(true);
                        Current.MainWindow = rec;

                        result  = rec.ShowDialog();
                        exitArg = rec.ExitArg;
                        frames  = rec.ListFrames;
                        break;

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

                        result  = web.ShowDialog();
                        exitArg = web.ExitArg;
                        frames  = web.ListFrames;
                        break;

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

                        result  = board.ShowDialog();
                        exitArg = board.ExitArg;
                        frames  = board.ListFrames;
                        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.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");
            }
        }
Beispiel #8
0
        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)
                {
                    Argument.Prepare(e.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
            {
                LocalizationHelper.SelectCulture(Settings.Default.Language);
            }
            catch (Exception ex)
            {
                var errorViewer = new ExceptionViewer(ex);
                errorViewer.ShowDialog();
                LogWriter.Log(ex, "Language Settings Exception.");
            }

            #endregion

            //var select = new SelectFolderDialog();
            //select.ShowDialog();

            //var select = new TestField();
            //select.ShowDialog();

            //return;

            try
            {
                #region Startup

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

                    #region Recorder, Webcam or Border

                    switch (Settings.Default.StartUp)
                    {
                    case 1:
                        var rec = new Recorder(true);
                        Current.MainWindow = rec;

                        result  = rec.ShowDialog();
                        exitArg = rec.ExitArg;
                        frames  = rec.ListFrames;
                        break;

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

                        result  = web.ShowDialog();
                        exitArg = web.ExitArg;
                        frames  = web.ListFrames;
                        break;

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

                        result  = board.ShowDialog();
                        exitArg = board.ExitArg;
                        frames  = board.ListFrames;
                        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.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");
            }
        }
Beispiel #9
0
        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");
            }
        }