Exemplo n.º 1
0
        private void SelectImageForBook(BookRead book)
        {
            _log.Debug("Getting Book information for " + book.Title);

            // https://books.google.co.uk/
            string searchTerm = 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;

                // Update in the DB.
                string errorMsg;
                if (!_mainModel.UpdateBook(book, out errorMsg))
                {
                    MessageBox.Show(errorMsg);
                    return;
                }

                OnPropertyChanged(() => ExistingBookImageSource);
            }
            else
            {
                _log.Debug("Failed Getting Book information for " + book.Title);
            }
        }
Exemplo n.º 2
0
        private void SelectImageForNation(Nation nation)
        {
            _log.Debug("Getting Nation information for " + nation.Name);

            ImageSelectionViewModel selectionViewModel = new ImageSelectionViewModel(_log, nation.Name);

            ImageSelectionWindow imageSelectDialog = new ImageSelectionWindow {
                DataContext = selectionViewModel
            };
            var success = imageSelectDialog.ShowDialog();

            if (success.HasValue && success.Value)
            {
                _log.Debug("Success Getting Nation information for " + nation.Name +
                           "\n   Img = " + selectionViewModel.SelectedImageAddress);

                nation.ImageUri = selectionViewModel.SelectedImageAddress;
                _mainModel.NationDatabase.UpdateDatabaseItem(nation);

                OnPropertyChanged(() => Nations);
            }
            else
            {
                _log.Debug("Failed Getting Nation information for " + nation.Name);
            }
        }
Exemplo n.º 3
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);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// The add user select image command action.
        /// </summary>
        public void UpdateUserSelectImageCommandAction()
        {
            string searchTerm = GetImageSearchTerm(_updateUserName);
            ImageSelectionViewModel selectionViewModel =
                new ImageSelectionViewModel(_log, _updateUserName, searchTerm);

            ImageSelectionWindow imageSelectDialog =
                new ImageSelectionWindow {
                DataContext = selectionViewModel
            };
            bool?success = imageSelectDialog.ShowDialog();

            if (success.HasValue && success.Value)
            {
                _updateUserImage = selectionViewModel.SelectedImageAddress;
                OnPropertyChanged(() => UpdateUserImageSource);
            }
        }