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();
            }
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UsersViewModel"/> class.
        /// </summary>
        /// <param name="mainWindow">
        /// The main window.
        /// </param>
        /// <param name="log">
        /// The log.
        /// </param>
        /// <param name="mainModel">
        /// The main model.
        /// </param>
        /// <param name="parent">
        /// The parent.
        /// </param>
        public UsersViewModel(
            MainWindow mainWindow, log4net.ILog log, MainBooksModel mainModel, MainViewModel parent)
        {
            _mainWindow = mainWindow;
            _log        = log;
            _mainModel  = mainModel;
            _parent     = parent;
            _userName   = _mainModel.DefaultUserName;

            _booksReadFromEmail = new ObservableCollection <IBookRead>();
        }
        public DataLoaderViewModel(
            MainWindow mainWindow, log4net.ILog log,
            MainBooksModel mainModel, MainViewModel parent)
        {
            _mainWindow = mainWindow;
            _log        = log;
            _mainModel  = mainModel;
            _parent     = parent;

            IsDataLoaded = (_mainModel.BooksRead.Count > 0);
        }
Example #4
0
        public DataUpdaterViewModel(
            MainWindow mainWindow, log4net.ILog log,
            MainBooksModel mainModel, MainViewModel parent)
        {
            _mainWindow = mainWindow;
            _log        = log;
            _mainModel  = mainModel;
            _parent     = parent;

            InitialiseNewBook();
            InitialiseEditBook();
        }
        public DiagramsViewModel(
            MainWindow mainWindow, log4net.ILog log,
            MainBooksModel mainModel, MainViewModel parent)
        {
            _mainWindow = mainWindow;
            _log        = log;
            _mainModel  = mainModel;
            _parent     = parent;

            SetupBooksReadByCountryModel();
            SetupPagesReadByCountryModel();
            SetupPagesByCountryModel();
        }
Example #6
0
        public DataGridsViewModel(
            MainWindow mainWindow, log4net.ILog log,
            MainBooksModel mainModel, MainViewModel parent)
        {
            _mainWindow = mainWindow;
            _log        = log;
            _mainModel  = mainModel;
            _parent     = parent;

            _rawBooksData        = new List <object>();
            _languageDeltasTable = new DataTable("LanguageDeltas");
            _countryDeltasTable  = new DataTable("CountryeDeltas");
        }
Example #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MailboxLoaderViewModel"/> class.
        /// </summary>
        /// <param name="mainWindow">
        /// The main window.
        /// </param>
        /// <param name="log">
        /// The log.
        /// </param>
        /// <param name="mainModel">
        /// The main model.
        /// </param>
        /// <param name="parent">
        /// The parent.
        /// </param>
        public MailboxLoaderViewModel(
            MainWindow mainWindow, log4net.ILog log, MainBooksModel mainModel, MainViewModel parent)
        {
            _mainWindow = mainWindow;
            _log        = log;
            _mainModel  = mainModel;
            _parent     = parent;
            _userName   = _mainModel.DefaultUserName;

            IsDataLoaded  = mainModel.BooksRead.Count > 0;
            ReadingEmails = false;

            _booksReadFromEmail = new ObservableCollection <IBookRead>();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MailboxLoaderViewModel"/> class.
        /// </summary>
        /// <param name="mainWindow">The main window.</param>
        /// <param name="log">The log.</param>
        /// <param name="mainModel">The main model.</param>
        /// <param name="parent">The parent.</param>
        public ExportersViewModel(
            MainWindow mainWindow, log4net.ILog log, MainBooksModel mainModel, MainViewModel parent)
        {
            _mainWindow = mainWindow;
            _log        = log;
            _mainModel  = mainModel;
            _parent     = parent;
            _userName   = _mainModel.DefaultUserName;
            _defaultDestinationEmail = _mainModel.DefaultRecipientName;
            OutputDirectory          = _mainModel.DefaultExportDirectory;

            ConnectingToMailbox = false;
            ConnectedToMailbox  = false;
            SendingExportEmail  = false;
        }
        public ReportsViewModel(
            MainWindow mainWindow, log4net.ILog log,
            MainBooksModel mainModel, MainViewModel parent)
        {
            _mainWindow = mainWindow;
            _log        = log;
            _mainModel  = mainModel;
            _parent     = parent;

            if (!_mainModel.TalliedMonths.Any())
            {
                return;
            }

            DateTime lastMonth = FirstMonth = _mainModel.TalliedMonths.Last().MonthDate;

            FirstMonth     = _mainModel.TalliedMonths.First().MonthDate;
            lastMonth      = lastMonth.AddMonths(1);
            lastMonth      = lastMonth.AddDays(-1);
            LastMonth      = lastMonth;
            _selectedMonth = lastMonth.AddMonths(-1);
            TalliedMonths  = new ObservableCollection <TalliedMonth>();
            _mainModel.SelectedMonthTally = GetSelectedMonthTally();

            PlotCurrentMonthPagesReadByLanguage =
                new OxyPlotPair(new CurrentMonthPagesReadByLanguagePlotGenerator(), "CurrentMonthPagesReadByLanguage");
            PlotCurrentMonthPagesReadByCountry =
                new OxyPlotPair(new CurrentMonthPagesReadByCountryPlotGenerator(), "CurrentMonthPagesReadByCountry");

            PlotCurrentMonthDocumentPagesReadByLanguage =
                new OxyPlotPair(new CurrentMonthPagesReadByLanguagePlotGenerator(), "CurrentMonthPagesReadByLanguage");
            PlotCurrentMonthDocumentPagesReadByCountry =
                new OxyPlotPair(new CurrentMonthPagesReadByCountryPlotGenerator(), "CurrentMonthPagesReadByCountry");

            PlotCurrentMonthPrintPagesReadByLanguage =
                new OxyPlotPair(new CurrentMonthPagesReadByLanguagePlotGenerator(), "CurrentMonthPagesReadByLanguage");
            PlotCurrentMonthPrintPagesReadByCountry =
                new OxyPlotPair(new CurrentMonthPagesReadByCountryPlotGenerator(), "CurrentMonthPagesReadByCountry");

            ReportsTallies =
                new ObservableCollection <MonthlyReportsTally>
            {
                new MonthlyReportsTally(_mainModel.SelectedMonthTally),
                new MonthlyReportsTally(_mainModel.BookDeltas.Last().OverallTally)
            };
        }
Example #10
0
        public ChartSelectionViewModel(
            MainWindow mainWindow, log4net.ILog log,
            MainBooksModel mainModel, MainViewModel parent)
        {
            _mainWindow = mainWindow;
            _log        = log;
            _mainModel  = mainModel;
            _parent     = parent;

            PlotOverallBookAndPageTallies =
                new OxyPlotPair(new OverallBookAndPageTalliesPlotGenerator(), "OverallBookAndPage");
            PlotDaysPerBook =
                new OxyPlotPair(new DaysPerBookPlotGenerator(), "DaysPerBook");
            PlotPageRate =
                new OxyPlotPair(new PageRatePlotGenerator(), "PageRate");
            PlotPagesPerBook =
                new OxyPlotPair(new PagesPerBookPlotGenerator(), "PagesPerBook");

            AvailableCharts = new List <ChartPair>()
            {
                new ChartPair {
                    Name = "Overall Books and Pages", Plot = PlotOverallBookAndPageTallies
                },
                new ChartPair {
                    Name = "Days Per Book", Plot = PlotDaysPerBook
                },
                new ChartPair {
                    Name = "Page Rate", Plot = PlotPageRate
                },
                new ChartPair {
                    Name = "Pages per Book", Plot = PlotPagesPerBook
                },
            };

            SelectedChart = AvailableCharts.First();

#if Works
            PlotBooksInTranslation =
                new OxyPlotPair(new BooksInTranslationPlotGenerator(), "BooksInTranslation");
            PlotDaysPerBookWithTime =
                new OxyPlotPair(new DaysPerBookWithTimePlotGenerator(), "DaysPerBook");
            PlotPagesPerDayWithTime =
                new OxyPlotPair(new PagesPerDayWithTimePlotGenerator(), "PagesPerDayWithTime");
            PlotAverageDaysPerBook =
                new OxyPlotPair(new AverageDaysPerBookPlotGenerator(), "AverageDaysPerBook");
            PlotPercentageBooksReadByLanguage =
                new OxyPlotPair(new PercentageBooksReadByLanguagePlotGenerator(), "PercentageBooksReadByLanguage");
            PlotTotalBooksReadByLanguage =
                new OxyPlotPair(new TotalBooksReadByLanguagePlotGenerator(), "TotalBooksReadByLanguage");
            PlotPercentagePagesReadByLanguage =
                new OxyPlotPair(new PercentagePagesReadByLanguagePlotGenerator(), "PercentagePagesReadByLanguage");
            PlotTotalPagesReadByLanguage =
                new OxyPlotPair(new TotalPagesReadByLanguagePlotGenerator(), "TotalPagesReadByLanguage");
            PlotPercentageBooksReadByCountry =
                new OxyPlotPair(new PercentageBooksReadByCountryPlotGenerator(), "PercentageBooksReadByCountry");
            PlotTotalBooksReadByCountry =
                new OxyPlotPair(new TotalBooksReadByCountryPlotGenerator(), "TotalBooksReadByCountry");
            PlotPercentagePagesReadByCountry =
                new OxyPlotPair(new PercentagePagesReadByCountryPlotGenerator(), "PercentagePagesReadByCountry");
            PlotTotalPagesReadByCountry =
                new OxyPlotPair(new TotalPagesReadByCountryPlotGenerator(), "TotalPagesReadByCountry");
            PlotTotalPagesReadByLanguage =
                new OxyPlotPair(new TotalPagesReadByLanguagePlotGenerator(), "TotalPagesReadByLanguage");
            PlotBooksAndPagesThisYear =
                new OxyPlotPair(new BooksAndPagesThisYearPlotGenerator(), "BooksAndPagesThisYear");
            PlotCurrentPagesReadByCountry =
                new OxyPlotPair(new CurrentPagesReadByCountryPlotGenerator(), "CurrentPagesReadByCountry");
            PlotCurrentBooksReadByCountry =
                new OxyPlotPair(new CurrentBooksReadByCountryPlotGenerator(), "CurrentBooksReadByCountry");
            PlotBooksAndPagesLastTen =
                new OxyPlotPair(new BooksAndPagesLastTenPlotGenerator(), "BooksAndPagesLastTen", true);
            PlotBooksAndPagesLastTenTranslation =
                new OxyPlotPair(new BooksAndPagesLastTenTranslationPlotGenerator(), "BooksAndPagesLastTenTranslation", true);
            PlotCountryLocationsBooksAndPages =
                new OxyPlotPair(new CountryLocationsBooksAndPagesPlotGenerator(), "CountryLocationsBooksAndPages", true);
            PlotCountryLocationsBooksRead =
                new OxyPlotPair(new CountryLocationsBooksReadPlotGenerator(), "CountryLocationsBooksRead", true);
            PlotLatitudeWithTime =
                new OxyPlotPair(new LatitudeWithTimePlotGenerator(), "LatitudeWithTime");
            PlotLongitudeWithTime =
                new OxyPlotPair(new LongitudeWithTimePlotGenerator(), "LongitudeWithTime");
            PlotTalliesPerCalendarYear =
                new OxyPlotPair(new TalliesPerCalendarYearPlotGenerator(), "TalliesPerCalendar");
            PlotMonthlyBookTalliesByCalendarYear =
                new OxyPlotPair(new MonthlyBookTalliesByCalendarYearPlotGenerator(
                                    MonthlyBookTalliesByCalendarYearPlotGenerator.ChartType.BooksAsColumns),
                                "MonthlyBookTalliesByCalendarYear");
            PlotMonthlyPageTalliesByCalendarYear =
                new OxyPlotPair(new MonthlyBookTalliesByCalendarYearPlotGenerator(
                                    MonthlyBookTalliesByCalendarYearPlotGenerator.ChartType.PagesAsColumns),
                                "MonthlyPageTalliesByCalendarYear");
            PlotMonthlyBookAndPageTalliesByCalendarYear =
                new OxyPlotPair(new MonthlyBookTalliesByCalendarYearPlotGenerator(
                                    MonthlyBookTalliesByCalendarYearPlotGenerator.ChartType.BothAsLines),
                                "MonthlyBookAndPageTalliesByCalendarYear");

            PlotWorldCountriesMap =
                new OxyPlotPair(new WorldCountriesMapPlotGenerator(), "WorldCountriesMap", true);
            PlotWorldCountriesMapBooksRead =
                new OxyPlotPair(new WorldCountriesMapBooksReadPlotGenerator(), "WorldCountriesMapBooksRead", true);
            PlotWorldCountriesMapPagesRead =
                new OxyPlotPair(new WorldCountriesMapPagesReadPlotGenerator(), "WorldCountriesMapPagesRead", true);
            PlotWorldCountriesMapWithBooksRead =
                new OxyPlotPair(new WorldCountriesMapWithBooksReadPlotGenerator(), "WorldCountriesMapWithBooksRead", true);
            PlotWorldCountriesMapLastTenLatLong =
                new OxyPlotPair(new WorldCountriesMapLastTenLatLongPlotGenerator(), "WorldCountriesMapLastTenLatLong", true);
#endif
        }
 public PlotModel SetupPlot(MainBooksModel mainModel)
 {
     _mainModel = mainModel;
     return(SetupCurrentPagesReadByCountryPlot());
 }
 public void UpdateData(MainBooksModel booksModel)
 {
     Model = _plotGenerator.SetupPlot(booksModel);
 }
 public PlotModel SetupPlot(MainBooksModel mainModel)
 {
     _mainModel = mainModel;
     return(SetupTalliesPerCalendarYearPlot());
 }