Esempio n. 1
0
        // Application OnStartup Override.
        protected override async void OnStartup(StartupEventArgs e)
        {
            Interactions.ShowFirstTimeSetup.RegisterHandler(interaction =>
            {
                var dialog = new DialogHostView();
                dialog.ViewModel.HostedViewModel = Locator.Current.GetService <FirstSetupWizardViewModel>();

                return(Observable.Start(() =>
                {
                    var result = dialog.ShowDialog() == true;
                    interaction.SetOutput(result);
                }, RxApp.MainThreadScheduler));
            });

            var settings      = Locator.Current.GetService <ISettingsManager>();
            var loggerService = Locator.Current.GetService <ILoggerService>();


            // Startup speed boosting (HC)
            ApplicationHelper.StartProfileOptimization();

            loggerService.Log("Starting application");
            await Initializations.InitializeWebview2(loggerService);

            loggerService.Log("Initializing red database");
            Initializations.InitializeThemeHelper();


            // main app viewmodel
            loggerService.Log("Initializing Shell");
            Initializations.InitializeShell(settings);


            loggerService.Log("Initializing Discord RPC API");
            DiscordHelper.InitializeDiscordRPC();

            loggerService.Log("Initializing Github API");
            Initializations.InitializeGitHub();

            // Some things can only be initialized after base.OnStartup(e);
            base.OnStartup(e);

            //loggerService.Info("Initializing NodeNetwork.");
            //NNViewRegistrar.RegisterSplat();
        }
Esempio n. 2
0
        //public IServiceProvider Container { get; private set; }
        //private IHost _host;
        void Init()
        {
            // Set application licenses.
            Initializations.InitializeLicenses();
            //protobuf
            RuntimeTypeModel.Default[typeof(IGameArchive)].AddSubType(20, typeof(Archive));


            //_host = Host
            //    .CreateDefaultBuilder()
            //    .ConfigureServices(services =>
            //    {
            //        services.UseMicrosoftDependencyResolver();
            //        var resolver = Locator.CurrentMutable;
            //        resolver.InitializeSplat();
            //        resolver.InitializeReactiveUI();
            //    })
            //    //.ConfigureLogging(logging =>
            //    //{
            //    //    logging.AddSplat();
            //    //})
            //    .ConfigureServices((hostContext, services) =>
            //    {



            //        // this passes IScreen resolution through to the previous viewmodel registration.
            //        // this is to prevent multiple instances by mistake.
            //        services.AddSingleton<WorkSpaceViewModel>();
            //        //services.AddSingleton<IScreen, WorkSpaceViewModel>(x => x.GetRequiredService<WorkSpaceViewModel>());
            //        services.AddSingleton<IViewFor<WorkSpaceViewModel>, MainView>();



            //    })
            //    .UseEnvironment(Environments.Development)
            //    .Build();

            //// Since MS DI container is a different type,
            //// we need to re-register the built container with Splat again
            //Container = _host.Services;
            //Container.UseMicrosoftDependencyResolver();
        }
        protected override async void OnStartup(StartupEventArgs e)
        {
            var serviceLocator = ServiceLocator.Default;

            serviceLocator.RegisterType <IRibbonService, RibbonService>();

#if DEBUG
            LogManager.AddDebugListener(false);
#endif
            Log.Info("Starting application");
            Log.Info("Initializing MVVM");
            await AppHelper.InitializeMVVM();

            Log.Info("Initializing Theme Helper");
            Initializations.InitializeThemeHelper();
            Log.Info("Initializing Shell");
            await AppHelper.InitializeShell();

            AppHelper.ShowFirstTimeSetup();
            Log.Info("Initializing Discord RPC");
            DiscordHelper.InitializeDiscordRPC();
            Log.Info("Initializing Github");
            Initializations.InitializeGitHub();
            Log.Info("Calling base.OnStartup");
            base.OnStartup(e);
            Log.Info("Initializing NodeNetwork");
            NNViewRegistrar.RegisterSplat();

            NotificationHelper.InitializeNotificationHelper();

            // Temp Fix for MainViewModel.OnClosing
            if (MainWindow != null)
            {
                MainWindow.Closing += OnClosing;
            }
        }
Esempio n. 4
0
        private void Init()
        {
            // Set application licenses.
            Initializations.InitializeLicenses();
            //protobuf
            RuntimeTypeModel.Default[typeof(IGameArchive)].AddSubType(20, typeof(Archive));

            _host = GenericHost.CreateHostBuilder().Build();

            // Since MS DI container is a different type,
            // we need to re-register the built container with Splat again
            Container = _host.Services;
            Container.UseMicrosoftDependencyResolver();

            var path           = Path.Combine(ISettingsManager.GetAppData(), "applog.txt");
            var outputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} [{Level:u3}] {Message:lj}{NewLine}{Exception}";

            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .WriteTo.Console()
                         .WriteTo.MySink(_host.Services.GetService <MySink>())
                         .WriteTo.File(path, outputTemplate: outputTemplate, rollingInterval: RollingInterval.Day)
                         .CreateLogger();
        }
Esempio n. 5
0
        private void Init()
        {
            // Set application licenses.
            Initializations.InitializeLicenses();
            //protobuf
            RuntimeTypeModel.Default[typeof(IGameArchive)].AddSubType(20, typeof(Archive));


            _host = Host
                    .CreateDefaultBuilder()
                    .ConfigureServices(services =>
            {
                services.UseMicrosoftDependencyResolver();
                var resolver = Locator.CurrentMutable;
                resolver.InitializeSplat();
                resolver.InitializeReactiveUI();
            })
                    //.ConfigureLogging(logging =>
                    //{
                    //    logging.AddSplat();
                    //})
                    .ConfigureServices((hostContext, services) =>
            {
                services.AddSingleton <INotificationService, NotificationService>();
                services.AddSingleton(typeof(ISettingsManager), SettingsManager.Load());
                services.AddSingleton <IProgressService <double>, ProgressService <double> >();
                services.AddSingleton <ILoggerService, ReactiveLoggerService>();
                services.AddSingleton <IUpdateService, UpdateService>();

                // singletons
                services.AddSingleton <IHashService, HashService>();
                services.AddSingleton <IRecentlyUsedItemsService, RecentlyUsedItemsService>();
                services.AddSingleton <IProjectManager, ProjectManager>();
                services.AddSingleton <IWatcherService, WatcherService>();

                services.AddSingleton <IArchiveManager, ArchiveManager>();
                services.AddSingleton <MockGameController>();

                // red4 modding tools
                services.AddSingleton <Red4ParserService>();
                services.AddSingleton <MeshTools>();

                services.AddSingleton <IModTools, ModTools>();
                services.AddSingleton <RED4Controller>();

                // red3 modding tools
                //services.AddSingleton<Red3ModTools>();
                //services.AddSingleton<Tw3Controller>();

                services.AddSingleton <IGameControllerFactory, GameControllerFactory>();

                services.AddSingleton <AppViewModel>();
                services.AddSingleton <IViewFor <AppViewModel>, MainView>();

                // register views
                #region shell

                services.AddSingleton <RibbonViewModel>();
                services.AddSingleton <IViewFor <RibbonViewModel>, RibbonView>();

                services.AddSingleton <StatusBarViewModel>();
                services.AddSingleton <IViewFor <StatusBarViewModel>, StatusBarView>();

                #endregion

                #region dialogs

                services.AddTransient <DialogHostViewModel>();
                services.AddTransient <IViewFor <DialogHostViewModel>, DialogHostView>();

                services.AddTransient <AddChunkDialogViewModel>();
                services.AddTransient <IViewFor <AddChunkDialogViewModel>, AddChunkDialog>();

                services.AddTransient <InputDialogViewModel>();
                services.AddTransient <IViewFor <InputDialogViewModel>, InputDialogView>();

                //services.AddSingleton<MaterialsRepositoryDialogViewModel>();
                //services.AddSingleton<IViewFor<MaterialsRepositoryDialogViewModel>, MaterialsRepositoryDialog>();

                services.AddTransient <RenameDialogViewModel>();
                services.AddTransient <IViewFor <RenameDialogViewModel>, RenameDialog>();

                services.AddTransient <NewFileViewModel>();
                services.AddTransient <IViewFor <NewFileViewModel>, NewFileView>();

                #endregion

                #region documents

                services.AddSingleton <AssetBrowserViewModel>();
                services.AddTransient <IViewFor <AssetBrowserViewModel>, AssetBrowserView>();

                services.AddSingleton <LogViewModel>();
                services.AddTransient <IViewFor <LogViewModel>, LogView>();

                services.AddSingleton <ProjectExplorerViewModel>();
                services.AddTransient <IViewFor <ProjectExplorerViewModel>, ProjectExplorerView>();

                services.AddSingleton <PropertiesViewModel>();
                services.AddTransient <IViewFor <PropertiesViewModel>, PropertiesView>();

                #endregion

                #region tools

                //services.AddTransient<CodeEditorViewModel>();
                //services.AddTransient<IViewFor<CodeEditorViewModel>, CodeEditorView>();

                //services.AddTransient<VisualEditorViewModel>();
                //services.AddTransient<IViewFor<VisualEditorViewModel>, VisualEditorView>();

                services.AddSingleton <ImportExportViewModel>();
                services.AddTransient <IViewFor <ImportExportViewModel>, ImportExportView>();

                #endregion

                #region homepage

                services.AddSingleton <HomePageViewModel>();
                services.AddTransient <IViewFor <HomePageViewModel>, HomePageView>();

                services.AddTransient <DebugPageViewModel>();
                services.AddTransient <IViewFor <DebugPageViewModel>, DebugPageView>();

                services.AddTransient <GithubPageViewModel>();
                services.AddTransient <IViewFor <GithubPageViewModel>, GithubPageView>();

                services.AddTransient <SettingsPageViewModel>();
                services.AddTransient <IViewFor <SettingsPageViewModel>, SettingsPageView>();

                services.AddTransient <WebsitePageViewModel>();
                services.AddTransient <IViewFor <WebsitePageViewModel>, WebsitePageView>();

                services.AddTransient <WelcomePageViewModel>();
                services.AddTransient <IViewFor <WelcomePageViewModel>, WelcomePageView>();

                services.AddTransient <WikiPageViewModel>();
                services.AddTransient <IViewFor <WikiPageViewModel>, WikiPageView>();

                #endregion

                #region shared

                //services.AddSingleton<RecentlyUsedItemsViewModel>();
                //services.AddSingleton<IViewFor<RecentlyUsedItemsViewModel>, RecentlyUsedItemsView>();

                #endregion

                #region wizards

                services.AddTransient <BugReportWizardViewModel>();
                services.AddTransient <IViewFor <BugReportWizardViewModel>, BugReportWizardView>();

                services.AddTransient <FeedbackWizardViewModel>();
                services.AddTransient <IViewFor <FeedbackWizardViewModel>, FeedbackWizardView>();

                services.AddTransient <FirstSetupWizardViewModel>();
                services.AddTransient <IViewFor <FirstSetupWizardViewModel>, FirstSetupWizardView>();

                services.AddTransient <InstallerWizardViewModel>();
                services.AddTransient <IViewFor <InstallerWizardViewModel>, InstallerWizardView>();

                services.AddTransient <ProjectWizardViewModel>();
                services.AddTransient <IViewFor <ProjectWizardViewModel>, ProjectWizardView>();

                #endregion
            })
                    .UseEnvironment(Environments.Development)
                    .Build();

            // Since MS DI container is a different type,
            // we need to re-register the built container with Splat again
            Container = _host.Services;
            Container.UseMicrosoftDependencyResolver();
        }
Esempio n. 6
0
        // Application OnStartup Override.
        protected override void OnStartup(StartupEventArgs e)
        {
            // check prerequisites
            // check Webview2
            string keyName  = @"SOFTWARE\Wow6432Node\Microsoft\EdgeUpdate\ClientState\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}";
            string keyvalue = "pv";

            StaticReferences.IsWebView2Enabled = Models.Commonfunctions.RegistryValueExists(Microsoft.Win32.RegistryHive.LocalMachine, keyName, keyvalue);

            // Startup speed boosting (HC)
            ApplicationHelper.StartProfileOptimization();



#if DEBUG
            LogManager.AddDebugListener(false);
#endif

            StaticReferences.Logger.Info("Starting application");

            Initializations.InitializeWebview2();

            StaticReferences.Logger.Info("Initializing MVVM");
            Initializations.InitializeMVVM();

            StaticReferences.Logger.Info("Initializing Theme Helper");
            Initializations.InitializeThemeHelper();

            InitializeCommands();


            StaticReferences.Logger.Info("Initializing Shell");
            /*await*/ Initializations.InitializeShell();
            var growl    = ServiceLocator.Default.ResolveType <INotificationService>();
            var settings = ServiceLocator.Default.ResolveType <ISettingsManager>();
            Helpers.ShowFirstTimeSetup(settings, growl);

            StaticReferences.Logger.Info("Initializing Discord RPC API");
            DiscordHelper.InitializeDiscordRPC();

            StaticReferences.Logger.Info("Initializing Github API");
            Initializations.InitializeGitHub();

            StaticReferences.Logger.Info("Calling base.OnStartup");
            base.OnStartup(e); // Some things can only be initialized after base.OnStartup(e);

            StaticReferences.Logger.Info("Initializing NodeNetwork.");
            NNViewRegistrar.RegisterSplat();

            StaticReferences.Logger.Info("Initializing Notifications.");

            StaticReferences.Logger.Info("Check for new updates");
            //Helpers.CheckForUpdates();
            Initializations.InitializeBk();

            //Window window = new Window();
            //window.AllowsTransparency = true;
            //window.Background = new SolidColorBrush(Colors.Transparent);
            //window.Content = new HomePageView();
            //window.WindowStyle = WindowStyle.None;
            //window.Show();

            // Create WebView Data Folder.
            //Directory.CreateDirectory(@"C:\WebViewData");
            // Message system for video tool.
        }