Ejemplo n.º 1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            //CurrentUser = new User() { Login = "******" };

            //var builder = new ConfigurationBuilder()
            //    .SetBasePath(Directory.GetCurrentDirectory())
            //    .AddJsonFile("sxo-settings.json", optional: false, reloadOnChange: true);

            //Configuration = builder.Build();


            try
            {
                var serviceCollection = new ServiceCollection();
                ConfigureServices(serviceCollection);

                ServiceProvider = serviceCollection.BuildServiceProvider();


                #region DataBase

                IFolderDataService folderDataService = ServiceProvider.GetRequiredService <IFolderDataService>();

                if (folderDataService.Get(rootGuid).Result == null)
                {
                    ClientConfigService clientConfigService = ServiceProvider.GetRequiredService <ClientConfigService>();
                    Folder rootFolder = new Folder()
                    {
                        Id         = rootGuid,
                        Title      = "root",
                        FolderPath = clientConfigService.FilesPath
                    };
                    folderDataService.CreateRootFolder(rootFolder);
                }

                #endregion


                #region NavManager

                MainWindow         mainWindow        = ServiceProvider.GetRequiredService <MainWindow>();
                INavigationService navigationService = ServiceProvider.GetRequiredService <INavigationService>();

                navigationService.Register <FolderPage>("root", ServiceProvider.GetRequiredService <FolderVM>());
                navigationService.Register <SettingsPage>("settings", ServiceProvider.GetRequiredService <SettingsPageVM>());
                navigationService.Register <SearchPage>("searchPage", ServiceProvider.GetRequiredService <SearchPageVM>());
                navigationService.Navigate("root", NavigationType.Root);

                #endregion

                mainWindow.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"{ex.Message}\r\n{ex.StackTrace}");
            }
        }
Ejemplo n.º 2
0
        public ServiceCollectionClass(IFolderDataService folderDataService,
                                      IMemeDataService memeDataService,
                                      IDialogService dialogService,
                                      INavigationService navigationService,
                                      DataStorage searchService,
                                      IMemeTagDataService memeTagDataService,
                                      ClientConfigService clientConfigService)
        {
            _folderDataService  = folderDataService;
            _memeDataService    = memeDataService;
            _dialogService      = dialogService;
            _navigationService  = navigationService;
            _dataStorage        = searchService;
            _memeTagDataService = memeTagDataService;

            _clientConfigService = clientConfigService;
        }
        public StatusMessagesService(ServiceCollectionClass services, MainWindow mainWindowV)
        {
            _mainWindowV       = (IStatusMessagesProvider)mainWindowV;
            _navigationService = services._navigationService;
            _dialogService     = services._dialogService;

            _memeTagDataService = services._memeTagDataService;
            _folderDataService  = services._folderDataService;
            _memeDataService    = services._memeDataService;

            //_dataStorage = services._dataStorage;
            //_dataStorage.OnAddFolder += _dataStorage_OnAddFolder;
            //_dataStorage.OnEditFolder += _dataStorage_OnEditFolder;
            //_dataStorage.OnRemoveFolder += _dataStorage_OnRemoveFolder;

            //_dataStorage.OnAddMeme += _dataStorage_OnAddMeme;
            //_dataStorage.OnEditMeme += _dataStorage_OnEditMeme;
            //_dataStorage.OnRemoveMeme += _dataStorage_OnRemoveMeme;

            //_dataStorage.OnAddMemeTag += _dataStorage_OnAddMemeTag;
            //_dataStorage.OnEditMemeTag += _dataStorage_OnEditMemeTag;
            //_dataStorage.OnRemoveMemeTag += _dataStorage_OnRemoveMemeTag;
        }