private void InitializeCalender(PackTracker.History History) { Entity.Pack FirstPack = History.First(); dp_DatePicker.DisplayDateStart = FirstPack.Time; dp_DatePicker.SelectedDate = History.Last().Time.Date; IEnumerable <DateTime> HistoryDates = History.Select(x => x.Time.Date).Distinct(); for (DateTime i = FirstPack.Time.Date; i.Date < DateTime.Today; i = i.AddDays(1)) { if (!HistoryDates.Contains(i)) { dp_DatePicker.BlackoutDates.Add(new CalendarDateRange(i)); } } }
private void InitializeCalender(PackTracker.History History) { var FirstPack = History.First(); this.dp_DatePicker.DisplayDateStart = FirstPack.Time; this.dp_DatePicker.SelectedDate = History.Last().Time.Date; var HistoryDates = History.Select(x => x.Time.Date).Distinct(); for (var i = FirstPack.Time.Date; i.Date < DateTime.Today; i = i.AddDays(1)) { if (!HistoryDates.Contains(i)) { this.dp_DatePicker.BlackoutDates.Add(new CalendarDateRange(i)); } } }
public PityTimerOverlay(PackTracker.History History, PityTimerRepository PityTimers) { InitializeComponent(); DataContext = this; if (History.Count > 0) { _packId = History.Last().Id; Chart_Epic.DataContext = PityTimers.GetPityTimer((int)_packId, Rarity.EPIC, false, true); Chart_Leg.DataContext = PityTimers.GetPityTimer((int)_packId, Rarity.LEGENDARY, false, true); } History.CollectionChanged += (sender, e) => { foreach (Pack Pack in e.NewItems) { Chart_Epic.DataContext = PityTimers.GetPityTimer(Pack.Id, Rarity.EPIC, false, true); Chart_Leg.DataContext = PityTimers.GetPityTimer(Pack.Id, Rarity.LEGENDARY, false, true); _packId = Pack.Id; } OnPropertyChanged("PackId"); }; }
public HistoryDatePicker(PackTracker.History History) { this.InitializeComponent(); this._history = History; if (History.Count > 0) { this.InitializeCalender(History); } else { this.dp_DatePicker.DisplayDateStart = DateTime.Today; History.CollectionChanged += this.InitializeCalender; } this.dp_DatePicker.SelectedDateChanged += (sender, e) => this.OnPropertyChanged("AssociatedPack"); History.CollectionChanged += (sender, e) => { if (e.Action == NotifyCollectionChangedAction.Add) { foreach (var Pack in e.NewItems) { if (Pack is Entity.Pack NewPack) { if (this._associatedPacks.ContainsKey(NewPack.Time.Date)) { this._associatedPacks[NewPack.Time.Date].Add(NewPack); } if (this.dp_DatePicker.SelectedDate != NewPack.Time.Date) { this.dp_DatePicker.SelectedDate = NewPack.Time.Date; } } } } }; this.dp_DatePicker.MouseWheel += (sender, e) => { if (this.dp_DatePicker.SelectedDate == null) { return; } var day = e.Delta < 0 ? -1 : 1; var Date = (DateTime)this.dp_DatePicker.SelectedDate; var First = History.First().Time.Date; var Last = History.Last().Time.Date; do { Date = Date.AddDays(day); if (day == 1) { if (Date > Last) { return; } if (Date < First) { this.dp_DatePicker.SelectedDate = First; return; } } else { if (Date < First) { return; } if (Date > Last) { this.dp_DatePicker.SelectedDate = Last; return; } } } while (this.dp_DatePicker.BlackoutDates.Contains(Date)); this.dp_DatePicker.SelectedDate = Date; }; }