Esempio n. 1
0
        /// <summary>
        /// Configures the splash screen and initializes the main application form
        /// This runs once the splash screen is visible.
        /// </summary>
        protected override void OnCreateMainForm()
        {
            CommandLineArgs clargs = new CommandLineArgs(CommandLineArgs);

            if (clargs.Hide || !Environment.UserInteractive)
            {
                SplashScreen.SafeInvoke(
                    () => ((TVRenameSplash)SplashScreen).Visible = false, true);
            }

            // Update splash screen
            SplashScreen.SafeInvoke(
                () => ((TVRenameSplash)SplashScreen).UpdateStatus("Initializing"), true);

            // Update RegVersion to bring the WebBrowser up to speed
            RegistryHelper.UpdateBrowserEmulationVersion();

            TVDoc doc = LoadSettings(clargs);

            if (TVSettings.Instance.mode == TVSettings.BetaMode.BetaToo || TVSettings.Instance.ShareLogs)
            {
                SetupLogging();
            }

            // Show user interface
            UI ui = new UI(doc, (TVRenameSplash)SplashScreen, !clargs.Unattended && !clargs.Hide && Environment.UserInteractive);

            ui.Text = ui.Text + " " + Helpers.DisplayVersion;

            // Bind IPC actions to the form, this allows another instance to trigger form actions
            RemoteClient.Bind(ui);

            MainForm = ui;
        }
Esempio n. 2
0
        /// <summary>
        /// Configures the splash screen and initializes the main application form
        /// This runs once the splash screen is visible.
        /// </summary>
        protected override void OnCreateMainForm()
        {
            CommandLineArgs parameters = new CommandLineArgs(CommandLineArgs);

            if (parameters.Hide || !Environment.UserInteractive)
            {
                SplashScreen.SafeInvoke(
                    () => ((TVRenameSplash)SplashScreen).Visible = false, true);
            }

            // Update splash screen
            SplashScreen.SafeInvoke(
                () => ((TVRenameSplash)SplashScreen).UpdateStatus("Initializing"), true);

            // Update RegVersion to bring the WebBrowser up to speed
            RegistryHelper.UpdateBrowserEmulationVersion();

            TVDoc doc = LoadSettings(parameters);

            if (TVSettings.Instance.mode == TVSettings.BetaMode.BetaToo || TVSettings.Instance.ShareLogs)
            {
                SetupLogging();
            }

            // Show user interface
            UI ui = new UI(doc, (TVRenameSplash)SplashScreen, !parameters.Unattended && !parameters.Hide && Environment.UserInteractive);

            ui.Text = ui.Text + " " + Helpers.DisplayVersion;

            // Bind IPC actions to the form, this allows another instance to trigger form actions
            try
            {
                RemoteClient.Bind(ui);
            }
            catch (RemotingException ex)
            {
                Logger.Warn(
                    $"Could not create IPC Port: {ex.Message} : TV Rename will not be able to accept incoming commands");
            }

            MainForm = ui;
        }
Esempio n. 3
0
        private void LetsGo(CommandLineArgs clargs, string commandLine)
        {
            //initialize the splash screen and set it as the application main window
            TvRenameSplash  splashScreen = new TvRenameSplash();
            SplashViewModel vm           = new SplashViewModel {
                Version = Helpers.DisplayVersion
            };

            this.MainWindow          = splashScreen;
            splashScreen.DataContext = vm;

            if (clargs.Hide || !Environment.UserInteractive)
            {
                splashScreen.Visibility = Visibility.Hidden;
            }
            else
            {
                splashScreen.Show();
            }

            // Update splash screen
            vm.Status = "Initializing";

            //because we're not on the UI thread, we need to use the Dispatcher
            //associated with the splash screen to update the progress bar
            vm.Progress = 5;


            //in order to ensure the UI stays responsive, we need to
            //do the work on a different thread
            Task.Factory.StartNew(() =>
            {
                splashScreen.Dispatcher.Invoke(() => vm.Status = "Loading Settings...");
                TVDoc doc = LoadSettings(clargs);

                splashScreen.Dispatcher.Invoke(() => vm.Status = "Setup Logging...");
                if (TVSettings.Instance.mode == TVSettings.BetaMode.BetaToo || TVSettings.Instance.ShareLogs)
                {
                    SetupLogging(commandLine);
                }

                splashScreen.Dispatcher.Invoke(() => vm.Status = "Configuring...");
                ConvertSeriesTimeZones(doc, TheTVDB.Instance);
                // Update RegVersion to bring the WebBrowser up to speed
                RegistryHelper.UpdateBrowserEmulationVersion();

                splashScreen.Dispatcher.Invoke(() => vm.Status = "Create Main Window...");

                //once we're done we need to use the Dispatcher
                //to create and show the main window

                Dispatcher.Invoke(() =>
                {
                    // Show user interface

                    MainWindow ui = new MainWindow(doc, vm, splashScreen.Dispatcher, !clargs.Unattended && !clargs.Hide && Environment.UserInteractive);
                    ui.Title      = ui.Title + " " + Helpers.DisplayVersion;

                    // Bind IPC actions to the form, this allows another instance to trigger form actions
                    RemoteClient.Bind(ui, doc);


                    //initialize the main window, set it as the application main window
                    //and close the splash screen
                    this.MainWindow = ui;


                    MainWindow.Show();
                    splashScreen.Close();
                });
            });
        }
Esempio n. 4
0
        /// <summary>
        /// Configures the splash screen and initializes the main application form
        /// This runs once the splash screen is visible.
        /// </summary>
        protected override void OnCreateMainForm()
        {
            // Update splash screen
            this.SplashScreen.Invoke(new MethodInvoker(() => ((TVRenameSplash)this.SplashScreen).UpdateStatus("Initializing")));

            // Update RegVersion to bring the WebBrowser up to speed
            RegistryHelper.UpdateBrowserEmulationVersion();

            CommandLineArgs clargs = new CommandLineArgs(this.CommandLineArgs);

            bool   recover     = false;
            string recoverText = string.Empty;

            // Check arguments for forced recover
            if (clargs.ForceRecover)
            {
                recover     = true;
                recoverText = "Recover manually requested.";
            }

            // Check arguments for custom settings path
            if (!string.IsNullOrEmpty(clargs.UserFilePath))
            {
                try
                {
                    PathManager.SetUserDefinedBasePath(clargs.UserFilePath);
                }
                catch (Exception ex)
                {
                    if (!clargs.Unattended && !clargs.Hide)
                    {
                        MessageBox.Show($"Error while setting the User-Defined File Path:{Environment.NewLine}{ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    Logger.Error(ex, $"Error while setting the User-Defined File Path - EXITING: {clargs.UserFilePath}");

                    Environment.Exit(1);
                }
            }

            FileInfo tvdbFile     = PathManager.TVDBFile;
            FileInfo settingsFile = PathManager.TVDocSettingsFile;
            TVDoc    doc;

            do               // Loop until files correctly load
            {
                if (recover) // Recovery required, prompt user
                {
                    RecoverXML recoveryForm = new RecoverXML(recoverText);

                    if (recoveryForm.ShowDialog() == DialogResult.OK)
                    {
                        tvdbFile     = recoveryForm.DBFile;
                        settingsFile = recoveryForm.SettingsFile;
                    }
                    else
                    {
                        // TODO: Throw an error
                        return;
                    }
                }

                // Try loading TheTVDB cache file
                TheTVDB.Instance.setup(tvdbFile, PathManager.TVDBFile, clargs);

                // Try loading settings file
                doc = new TVDoc(settingsFile, clargs);

                if (recover)
                {
                    doc.SetDirty();
                }
                recover = !doc.LoadOK;

                // Continue if correctly loaded
                if (!recover)
                {
                    continue;
                }

                // Set recover message
                recoverText = string.Empty;
                if (!doc.LoadOK && !string.IsNullOrEmpty(doc.LoadErr))
                {
                    recoverText = doc.LoadErr;
                }
                if (!TheTVDB.Instance.LoadOK && !string.IsNullOrEmpty(TheTVDB.Instance.LoadErr))
                {
                    recoverText += $"{Environment.NewLine}{TheTVDB.Instance.LoadErr}";
                }
            } while (recover);

            // Show user interface
            UI ui = new UI(doc, (TVRenameSplash)this.SplashScreen);

            // Bind IPC actions to the form, this allows another instance to trigger form actions
            RemoteClient.Bind(ui, doc);

            this.MainForm = ui;
        }
Esempio n. 5
0
        /// <summary>
        /// Configures the splash screen and initializes the main application form
        /// This runs once the splash screen is visible.
        /// </summary>
        protected override void OnCreateMainForm()
        {
            CommandLineArgs clargs = new CommandLineArgs(CommandLineArgs);

            if (clargs.Hide)
            {
                SplashScreen.SafeInvoke(
                    () => ((TVRenameSplash)SplashScreen).Visible = false, true);
            }

            // Update splash screen
            SplashScreen.SafeInvoke(
                () => ((TVRenameSplash)SplashScreen).UpdateStatus("Initializing"), true);

            // Update RegVersion to bring the WebBrowser up to speed
            RegistryHelper.UpdateBrowserEmulationVersion();

            bool   recover     = false;
            string recoverText = string.Empty;

            // Check arguments for forced recover
            if (clargs.ForceRecover)
            {
                recover     = true;
                recoverText = "Recover manually requested.";
            }

            SetupCustomSettings(clargs);

            FileInfo tvdbFile     = PathManager.TVDBFile;
            FileInfo settingsFile = PathManager.TVDocSettingsFile;
            TVDoc    doc;

            do               // Loop until files correctly load
            {
                if (recover) // Recovery required, prompt user
                {
                    RecoverXML recoveryForm = new RecoverXML(recoverText);

                    if (recoveryForm.ShowDialog() == DialogResult.OK)
                    {
                        tvdbFile     = recoveryForm.DbFile;
                        settingsFile = recoveryForm.SettingsFile;
                    }
                    else
                    {
                        // TODO: Throw an error
                        return;
                    }
                }

                // Try loading TheTVDB cache file
                TheTVDB.Instance.Setup(tvdbFile, PathManager.TVDBFile, clargs);

                // Try loading settings file
                doc = new TVDoc(settingsFile, clargs);

                if (recover)
                {
                    doc.SetDirty();
                }
                recover = !doc.LoadOk;

                // Continue if correctly loaded
                if (!recover)
                {
                    continue;
                }

                // Set recover message
                recoverText = string.Empty;
                if (!doc.LoadOk && !string.IsNullOrEmpty(doc.LoadErr))
                {
                    recoverText = doc.LoadErr;
                }
                if (!TheTVDB.Instance.LoadOk && !string.IsNullOrEmpty(TheTVDB.Instance.LoadErr))
                {
                    recoverText += $"{Environment.NewLine}{TheTVDB.Instance.LoadErr}";
                }
            } while (recover);

            ConvertSeriesTimeZones(doc, TheTVDB.Instance);

            // Show user interface
            UI ui = new UI(doc, (TVRenameSplash)SplashScreen, !clargs.Unattended && !clargs.Hide);

            ui.Text = ui.Text + " " + Helpers.DisplayVersion;

            // Bind IPC actions to the form, this allows another instance to trigger form actions
            RemoteClient.Bind(ui, doc);

            MainForm = ui;
        }