Exemple #1
0
        /// <summary>
        /// The from history Location.
        /// </summary>
        /// <param name="location">
        /// The Location.
        /// </param>
        /// <param name="faviconLookup">
        /// The favicon Lookup.
        /// </param>
        /// <returns>
        /// The <see cref="HistoryViewModel"/>.
        /// </returns>
        public static HistoryViewModel FromHistoryLocation(HistoryLocation location, IFavicon faviconLookup)
        {
            HistoryViewModel hvm = new HistoryViewModel()
            {
                Name = string.IsNullOrEmpty(location.Title)
                               ? location.Url.Host
                               : location.Title,
                Date             = location.Date,
                _historyLocation = location,
                _faviconLookup   = faviconLookup
            };

            location.PropertyChanged += hvm.UpdateViewModel;

            return(hvm);
        }
Exemple #2
0
 /// <summary>
 /// The add to history.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="args">
 /// The args.
 /// </param>
 private void AddToHistory(object sender, HistoryPushEventArgs args)
 {
     this._history.AddLast(args.Change);
     this._historyViewModel.Insert(0, HistoryViewModel.FromHistoryLocation(args.Change, this._faviconCache));
     args.Change.PropertyChanged += this.UpdateTitle;
 }
Exemple #3
0
        /// <summary>
        /// The load function.
        /// </summary>
        private void Load()
        {
            using (var db = new DataContext())
            {
                // do not track the query, and load either all or all in x hours based on config
                IQueryable <HistoryLocation> query = db.History.AsNoTracking()
                                                     .Where(history => this._config.OverrideAndLoadAllHistory || DateTime.Now < history.Date.Add(this._config.HistoryTimeSpan))
                                                     .Include(history => history.Url);

                // create history list
                this._history = new LinkedList <HistoryLocation>(query);

                // create view model
                this._historyViewModel = new BindingList <HistoryViewModel>(query
                                                                            .AsEnumerable()
                                                                            .Select(hist => HistoryViewModel.FromHistoryLocation(hist, this._faviconCache))
                                                                            .Reverse()
                                                                            .ToList());
            }
        }