コード例 #1
0
ファイル: Program.cs プロジェクト: VPKSoft/vamp
        private static void InitGeckoFx()
        {
            // Perform dependency check to make sure all relevant resources are in our output directory.
            // Discarded: var settings = new CefSettings();

            FormSplash.SetStatus(FormSplash.MsgInitGeckoFXEngine, 0);

            string cachePath = Path.Combine(Environment.GetEnvironmentVariable("LOCALAPPDATA"), "vamp#", "geckofx_cache");

            if (!Directory.Exists(cachePath))
            {
                Directory.CreateDirectory(cachePath);
            }

            Xpcom.ProfileDirectory = cachePath;

            string GeckoDLLPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "Firefox" + (Environment.Is64BitProcess ? "_x64" : "_x86"));

            ExceptionLogger.LogMessage(GeckoDLLPath);

            Xpcom.Initialize(GeckoDLLPath);

            GeckoPreferences.User["browser.cache.disk.enable"]         = true;
            GeckoPreferences.User["browser.cache.memory.enable"]       = true;
            GeckoPreferences.User["browser.cache.check doc frequency"] = 3;
            GeckoPreferences.User["browser.cache.disk.capacity"]       = 50000;
            GeckoPreferences.User["browser.cache.memory.capacity()"]   = -1;
            GeckoPreferences.User["full-screen-api.enabled"]           = true;


            FormSplash.SetStatus(FormSplash.MsgInitGeckoFXEngine, 100);
        }
コード例 #2
0
        /// <summary>
        /// Shows the form splash form in a separate thread.
        /// </summary>
        public static void ShowFormSplash()
        {
            if (splashShown) // do not show if already shown..
            {
                return;
            }

            // a new thread is required..
            splashThread = new Thread(new ThreadStart(() =>
            {
                // set the indicator that the splash screen has been shown to avoid another time..
                splashShown = true;

                // construct the splash "screen"..
                formSplash = new FormSplash();
                Application.Run(formSplash); // a separate application run..
            }))
            {
                IsBackground = true // make it a background thread..
            };

            // set it a: The Thread will create and enter a single-threaded apartment.
            // (https://docs.microsoft.com/en-us/dotnet/api/system.threading.apartmentstate)..
            //            splashThread.SetApartmentState(ApartmentState.STA);

            splashThread.Start(); // start the thread..
        }
コード例 #3
0
        /// <summary>
        /// Invokes the splash "screen" to close..
        /// </summary>
        public static void CloseFormSplash()
        {
            formSplash.Invoke(new MethodInvoker(() =>
            {
                using (formSplash)
                {
                    formSplash.Close();
                    formSplash = null;
                }
            }));

            while (!splashThread.Join(100))
            {
                Application.DoEvents();
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: VPKSoft/vamp
        private static void LoadApp()
        {
            string subProcessPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                                           Environment.Is64BitProcess ? "x64" : "x86",
                                                           "CefSharp.BrowserSubprocess.exe");


            ExceptionLogger.LogMessage($"CefSharp subprocess: '{subProcessPath}'");


            FormSplash.SetStatus(FormSplash.MsgInitChromiumEmbeddedFrameworkSettings, 0);

            //Perform dependency check to make sure all relevant resources are in our output directory.
            var settings = new CefSettings
            {
                BrowserSubprocessPath = subProcessPath
            };

            string cachePath = Path.Combine(Environment.GetEnvironmentVariable("LOCALAPPDATA"), "vamp#", "CefCache");

            if (!Directory.Exists(cachePath))
            {
                Directory.CreateDirectory(cachePath);
            }

            settings.CachePath = cachePath;


            settings.LogSeverity = LogSeverity.Warning;
            settings.LogFile     = Path.Combine(settings.CachePath, "cef.log");
            Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null);
            FormSplash.SetStatus(FormSplash.MsgInitChromiumEmbeddedFrameworkSettings, 100);

            FormMain formMain = new FormMain();

            FormSplash.CloseFormSplash();
            Application.Run(formMain);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: VPKSoft/vamp
        // Will attempt to load missing assembly from either x86 or x64 subdirectory
        private static Assembly Resolver(object sender, ResolveEventArgs args)
        {
            FormSplash.SetStatus(FormSplash.MsgLoadChromiumEmbeddedFramework, 0);

            Assembly assembly = null;

            if (args.Name.StartsWith("CefSharp"))
            {
                ExceptionLogger.LogMessage("CefSharp queued..");

                string assemblyName     = args.Name.Split(new[] { ',' }, 2)[0] + ".dll";
                string archSpecificPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                                                 Environment.Is64BitProcess ? "x64" : "x86",
                                                                 assemblyName);

                ExceptionLogger.LogMessage($"CefSharp assembly: '{archSpecificPath}'");

                assembly = System.IO.File.Exists(archSpecificPath)
                           ? Assembly.LoadFile(archSpecificPath)
                           : null;
            }
            FormSplash.SetStatus(FormSplash.MsgLoadChromiumEmbeddedFramework, 100);
            return(assembly);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: VPKSoft/vamp
        static void Main()
        {
            string[] args = Environment.GetCommandLineArgs();

            bool runSetting          = false;
            bool runPhotoAlbumEditor = false;

            Process localizeProcess = Utils.CreateDBLocalizeProcess(VPKSoft.Utils.Paths.AppInstallDir);

            //localizeProcess.

            if (localizeProcess != null)
            {
                localizeProcess.Start();
                return;
            }

            foreach (string arg in args)
            {
                if (arg == "--configure")
                {
                    runSetting = true;
                }

                if (arg == "--photos")
                {
                    runPhotoAlbumEditor = true;
                }
            }

            if (runSetting)
            {
                if (VPKSoft.Utils.AppRunning.CheckIfRunning("vamp#_normal_setting"))
                {
                    return;
                }
                else
                {
                    ExceptionLogger.Bind(1); // bind before any visual objects are created..
                    ExceptionLogger.ApplicationCrash += ExceptionLogger_ApplicationCrash;
                    Settings.InitSettings();
                    DBLangEngine.UseCulture = Settings.Culture; // set the localization value..
                    Application.Run(new FormSettings());
                    ExceptionLogger.UnBind();                   // unbind so the truncate thread is stopped successfully..
                    return;
                }
            }
            if (runPhotoAlbumEditor)
            {
                if (VPKSoft.Utils.AppRunning.CheckIfRunning("vamp#_normal_photos"))
                {
                    return;
                }
                else
                {
                    ExceptionLogger.Bind(2); // bind before any visual objects are created..
                    ExceptionLogger.ApplicationCrash += ExceptionLogger_ApplicationCrash;
                    Settings.InitSettings();
                    DBLangEngine.UseCulture = Settings.Culture; // set the localization value..
                    Application.Run(new FormPhotoAlbumEditor());
                    ExceptionLogger.UnBind();                   // unbind so the truncate thread is stopped successfully..
                    return;
                }
            }
            else
            {
                if (VPKSoft.Utils.AppRunning.CheckIfRunning("vamp#_normal"))
                {
                    return;
                }
            }

            if (Utils.ShouldLocalize() == null)
            {
                FormSplash.ShowFormSplash();
            }

            FormSplash.SetStatus(FormSplash.MsgBindExceptionLogger, 100);
            ExceptionLogger.Bind(); // bind before any visual objects are created
            ExceptionLogger.ApplicationCrash += ExceptionLogger_ApplicationCrash;
            FormSplash.SetStatus(FormSplash.MsgVisualStyles, 0);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            FormSplash.SetStatus(FormSplash.MsgVisualStyles, 100);

            AppDomain.CurrentDomain.AssemblyResolve += Resolver;

            // Save languages
            if (VPKSoft.LangLib.Utils.ShouldLocalize() != null)
            {
                new FormMain();
                new FormPlayer();
                new FormSelectSubtitle();
                new FormDialogSelectFileOrDirectory();
                new FormWebBrowserGecko(string.Empty);
                new FormWebBrowserChromium(string.Empty);
                new FormDialogSelectPlaybackPosition();
                new FormDialogSelectLocation();
                new FormAmpMusicPlayer();
                new FormDialogError();
                new FormDialogSelectCustomContent();
                new FormSplash();
                new FormSettings();
                new FormTMDBLoadProgress();
                new FormPhotoAlbumEditor();
                new FormDialogPhotoAlbumQueryName();
                new FormSelectMovie();
                new FormDialogPhotoAlbumSelectBaseDirectory();
                new FormDialogConfirmQuery();
                ExceptionLogger.UnBind(); // unbind so the truncate thread is stopped successfully..
                return;
            }

            Settings.InitSettings();
            DBLangEngine.UseCulture = Settings.Culture; // set the localization value..

            ExceptionLogger.LogMessage(AppDomain.CurrentDomain.BaseDirectory);

            InitGeckoFx();

            LoadApp(); // Initialize the Chromium web browser

            Xpcom.Shutdown();
            ExceptionLogger.UnBind(); // unbind so the truncate thread is stopped successfully..
        }