Ejemplo n.º 1
0
        public MainViewModel(MainWindow mainWindow, log4net.ILog log)
        {
            _mainWindow = mainWindow;
            _log        = log;

            _mainModel = new MainBooksModel(log);

            _dataLoaderVM     = new DataLoaderViewModel(_mainWindow, log, _mainModel, this);
            _dataUpdaterVM    = new DataUpdaterViewModel(_mainWindow, log, _mainModel, this);
            _dataGridsVM      = new DataGridsViewModel(_mainWindow, log, _mainModel, this);
            _chartsVM         = new ChartsViewModel(_mainWindow, log, _mainModel, this);
            _diagramsVM       = new DiagramsViewModel(_mainWindow, log, _mainModel, this);
            _mailboxLoaderVM  = new MailboxLoaderViewModel(_mainWindow, log, _mainModel, this);
            _chartSelectionVM = new ChartSelectionViewModel(_mainWindow, log, _mainModel, this);
            _mailboxLoaderVM  = new MailboxLoaderViewModel(_mainWindow, log, _mainModel, this);
            _exportersVM      = new ExportersViewModel(_mainWindow, log, _mainModel, this);
            _reportsVM        = new ReportsViewModel(_mainWindow, log, _mainModel, this);
            _bloggerVM        = new BloggerViewModel(_mainWindow, log, _mainModel, this);
            _usersVM          = new UsersViewModel(_mainWindow, log, _mainModel, this);

            if (_mainModel.ConnectedToDbSuccessfully)
            {
                UpdateData();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The command action to add a new book from the email to the database.
        /// </summary>
        public void SelectImageForBookCommandAction(object parameter)
        {
            BookRead book = _newBook;

            if (book != null)
            {
                _log.Debug("Getting Book information for " + book.Title);

                // https://books.google.co.uk/
                string searchTerm = DataUpdaterViewModel.GetImageSearchTerm(book);
                ImageSelectionViewModel selectionViewModel = new ImageSelectionViewModel(_log, book.Title, searchTerm);

                ImageSelectionWindow imageSelectDialog = new ImageSelectionWindow {
                    DataContext = selectionViewModel
                };
                var success = imageSelectDialog.ShowDialog();
                if (success.HasValue && success.Value)
                {
                    _log.Debug("Success Getting image information for " + book.Title +
                               "\n   Img = " + selectionViewModel.SelectedImageAddress);

                    book.ImageUrl = selectionViewModel.SelectedImageAddress;

                    OnPropertyChanged(() => NewBookImageSource);
                }
                else
                {
                    _log.Debug("Failed Getting Book information for " + book.Title);
                }
            }
        }