public void MoveToPrevious() { switch (Type) { case PeriodType.Day: SelectedDate = SelectedDate.AddDays(-1); break; case PeriodType.Week: SelectedDate = SelectedDate.AddDays(-7); break; case PeriodType.Month: SelectedDate = SelectedDate.AddMonths(-1); break; case PeriodType.Year: SelectedDate = SelectedDate.AddYears(-1); break; case PeriodType.All: /// intentionally blank space break; } CalculateDates(); OnPropertyChanged(nameof(Description)); }
/// <summary> /// Обновление занятии /// </summary> /// <param name="children"></param> void UpdateLessons(Children children = null) { // Вычисление дат начала и конца недели var StartWeek = SelectedDate.AddDays(1 - (int)SelectedDate.DayOfWeek); var EndWeek = SelectedDate.AddDays(6 - (int)SelectedDate.DayOfWeek); if (children == null) { Lessons = new ObservableCollection <Lesson>(Db.Lessons.Include(x => x.Room) .Where(x => StartWeek >= x.DateStart && StartWeek <= x.DateEnd && EndWeek >= x.DateStart)); if (SelectedGroup.Name != "Все") { Lessons = new ObservableCollection <Lesson>(Lessons.Where(x => x.Group == SelectedGroup)); } if (SelectedEmployee?.Person.Lastname != "Все") { Lessons = new ObservableCollection <Lesson>(Lessons.Where(x => x.Employee == SelectedEmployee).ToList()); } } else { Lessons = new ObservableCollection <Lesson>(Db.Lessons.Include(x => x.Room) .Where(x => (x.DateStart.DayOfYear >= StartWeek.DayOfYear && x.DateEnd.DayOfYear >= StartWeek.DayOfYear) && children.ChildrenGroups.FirstOrDefault(y => y.Group == x.Group) != null).ToList()); } }
private void UpdateEvents() { var events = EventSource.LoadEvents(this) .Where(o => o.To > SelectedDate) .Where(o => o.From < SelectedDate.AddDays(1)) .OrderByDescending(o => o.From - o.To).ToArray(); PutEvents(events); }
public void GoToPrevious() { if (ViewType == ViewTypes.Day) { SelectedDate = SelectedDate.AddDays(-1); } else { SelectedDate = SelectedDate.AddDays(-7); } }
private bool IsInThisWeek(DateTime date) { int daysToLastDayOfWeek = 7 - (int)SelectedDate.DayOfWeek; DateTime endOfTheWeek = SelectedDate.AddDays(daysToLastDayOfWeek); if (date.Date > SelectedDate.Date && date.Date <= endOfTheWeek.Date) { return(true); } return(false); }
public void GoToNext() { if (ViewType == ViewTypes.Day) { SelectedDate = SelectedDate.AddDays(1); } else { SelectedDate = SelectedDate.AddDays(7); } }
public void GoToSelectedDate() { int delta = DayOfWeek.Monday - SelectedDate.DayOfWeek; if (delta > 0) { delta -= 7; } StartOfWeekDate = SelectedDate.AddDays(delta); CurrentMonthAndYear = GetCurrentMonthAndYear(); StateHasChanged(); }
private void SelectWeek() { dateLock = true; DateTime firstDay = SelectedDate.AddDays(DayOfWeek.Monday - SelectedDate.DayOfWeek); calendar.SelectedDates.Clear(); for (int i = 0; i <= 6; i++) { calendar.SelectedDates.Add(firstDay.AddDays(i)); } dateLock = false; }
public void PrevPage() { switch (Mode) { case WpfScheduler.Mode.Day: SelectedDate = SelectedDate.AddDays(-1); break; case WpfScheduler.Mode.Week: SelectedDate = SelectedDate.AddDays(-7); break; case WpfScheduler.Mode.Month: SelectedDate = SelectedDate.AddMonths(-1); break; } }
/// <summary> /// Обновление дат /// </summary> void UpdateSchedule() { // Вычисление дат начала и конца недели var StartWeek = SelectedDate.AddDays(1 - (int)SelectedDate.DayOfWeek); var EndWeek = SelectedDate.AddDays(7 - (int)SelectedDate.DayOfWeek); Template = new List <ScheduleTemplate>(); for (int i = 0; i < 6; i++) { var ShortName = Culture.DateTimeFormat.GetShortestDayName((DayOfWeek)Enum.GetValues(typeof(DayOfWeek)).GetValue(i + 1)); var Days = StartWeek.AddDays(i).ToString("M", Culture); Template.Add(new ScheduleTemplate { Title = $"{ShortName}, {Days}", DayOfWeek = i + 1, LessonNumber = 0 }); } Today = DateTime.Now.DayOfYear >= StartWeek.DayOfYear && DateTime.Now.DayOfYear <= EndWeek.DayOfYear; }
private void ChangeDate(object parameter) { string stringParameter = parameter as string; if (stringParameter == null) { return; } switch (stringParameter) { case "+": SelectedDate = SelectedDate.AddDays(1d); break; case "-": SelectedDate = SelectedDate.AddDays(-1d); break; default: SelectedDate = DateTime.Today; break; } }
public void PrevWeek() { SelectedDate = SelectedDate.AddDays(-7); }
public TimedTasksViewModel() { Utils.Database.InitDB(); Utils.Database.CreateDB(); PropertyChanged += TimedTasksViewModel_PropertyChanged; tasks = new ObservableCollection <object>(); IncreaseDateByDayCommand = new Command(() => SelectedDate = SelectedDate.AddDays(1)); DecreaseDateByDayCommand = new Command(() => SelectedDate = SelectedDate.AddDays(-1)); IncreaseDateByMonthCommand = new Command(() => SelectedDate = SelectedDate.AddMonths(1)); DecreaseDateByMonthCommand = new Command(() => SelectedDate = SelectedDate.AddMonths(-1)); AddNewTaskCommand = new Command <TaskViewModel>((task) => { Utils.Database.InsertTask(task); RefreshTasks(); }); RemoveTaskCommand = new Command <TaskViewModel>((task) => { Utils.Database.DeleteTask(task); RefreshTasks(); }); UpdateTaskCommand = new Command <TaskViewModel>((task) => { Utils.Database.UpdateTask(task); RefreshTasks(); }); ShowDailyTasksCommand = new Command(() => { TaskSelectOption = TaskSelectOptions.CurrentDay; Utils.AppData.Data.TaskSelectOption = TaskSelectOption.ToString(); }); ShowAllTasksCommand = new Command(() => { TaskSelectOption = TaskSelectOptions.AllDaysByDate; Utils.AppData.Data.TaskSelectOption = TaskSelectOption.ToString(); }); ChangeFinishedVisibilityCommand = new Command(() => { FinishedTasksVisible = !FinishedTasksVisible; var key = TaskSelectOption.ToString(); if (Utils.AppData.Data.GroupVisibilitySetting.ContainsKey(key)) { Utils.AppData.Data.GroupVisibilitySetting[key] = FinishedTasksVisible; } else { Utils.AppData.Data.GroupVisibilitySetting.Add(key, FinishedTasksVisible); } RefreshTasks(); }); LoadSettings(); SetTaskSettings(); RefreshTasks(); }
public void NextWeek() { SelectedDate = SelectedDate.AddDays(7); }
private void OnAddDayExecute() { SelectedDate = SelectedDate.AddDays(1); }
void dateDown_Click(object sender, RoutedEventArgs e) { SelectedDate = SelectedDate.AddDays(-1); }
public void TimeBackward() { SelectedDate = Mode == PerformanceViewMode.Daily ? SelectedDate.AddDays(-1) : SelectedDate.AddMonths(-1); }
private int InsertCurWeekData(ISheet sheet, IRow row, ICell cell, IWorkbook book, int rowNumber) { int dayCnt = 1; //天计数 int dayRowCnt = dayCnt; //行号 int dailyCnt = 1; //日志条数 int rowMerge = 0; //要合并多少行 //算一周的时间 int dayweek = (int)SelectedDate.DayOfWeek; if (dayweek <= 0) { return(0); } string sCurDay = SelectedDate.AddDays(-dayweek + 1).ToShortDateString(); //加载xml _xmlReader.Load(xmlpath); XmlNodeList xnlDate = _xmlReader.GetXmlNodeList(DATENOTE); for (int i = 0; i < xnlDate.Count; i++) { if (xnlDate[i].Attributes[CURRENTDATE].InnerText == sCurDay) { XmlNodeList xmlContent = _xmlReader.GetXmlNodeList(CONTENTNOTE); for (int j = 0; j < xmlContent.Count; j++) { if (xmlContent[j].ParentNode.Attributes[CURRENTDATE].InnerText != sCurDay) { continue; } dayRowCnt = rowNumber + dailyCnt; row = sheet.CreateRow(dayRowCnt); FillCell(sheet, row, cell, book, dayRowCnt, dayRowCnt, 1, 1, xmlContent[j].Attributes[CATEGORY].InnerText, HeaderColor.White); FillCell(sheet, row, cell, book, dayRowCnt, dayRowCnt, 2, 2, xmlContent[j].InnerText, HeaderColor.White); FillCell(sheet, row, cell, book, dayRowCnt, dayRowCnt, 6, 6, xmlContent[j].Attributes[COSTTIME].InnerText, HeaderColor.White); FillCell(sheet, row, cell, book, dayRowCnt, dayRowCnt, 7, 7, xmlContent[j].Attributes[STATE].InnerText, HeaderColor.White); rowMerge++; dailyCnt++; } int rowRange = dayRowCnt - rowMerge + 1; row = sheet.GetRow(rowRange); FillCell(sheet, row, cell, book, rowRange, dayRowCnt, 4, 4, sCurDay, HeaderColor.White); cell = row.GetCell(4); cell.CellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; cell.CellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; FillCell(sheet, row, cell, book, rowRange, dayRowCnt, 5, 5, sCurDay, HeaderColor.White); cell = row.GetCell(5); cell.CellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; cell.CellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; rowMerge = 0; } if (i == xnlDate.Count - 1 && dayCnt <= dayweek) { i = -1; dayCnt++; sCurDay = SelectedDate.AddDays(-dayweek + dayCnt).ToShortDateString(); } } //填充全单元格内容 row = sheet.GetRow(rowNumber + 1); FillCell(sheet, row, cell, book, rowNumber + 1, dayRowCnt, 3, 3, MyName, HeaderColor.White); cell = row.GetCell(3); cell.CellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; cell.CellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; return(dailyCnt); }
private void OnPreviousDateCommandHandler() { SelectedDate = SelectedDate.AddDays(-1); RecordedList.Clear(); RecordedList = ConvertRecords(_timeTrackerRepository.GetEmployeeTimeRecords(_employee.ID, SelectedDate)); }
private void NextDay() { SelectedDate = SelectedDate.AddDays(1); }
public void TimeBackward() { SelectedDate = SelectedDate.AddDays(-1); }
private async Task GenerateGraphs(DateTime birthday, DateTime secondbirthday) { var firstTotalDays = SelectedDate - birthday; var secondTotalDays = SelectedDate - secondbirthday; if (IsMain) { InitMainBounds(); var graphs = InnerGenerateGraphs(birthday); var statesRange = new ConcurrentDictionary <DateTime, GraphState>(); Parallel.For(-Scale / 2, Scale / 2, (i) => { var firstStates = graphs.GetGraphStates(firstTotalDays.Days, i, SelectedDate); var date = SelectedDate.AddDays(i); if (secondbirthday != DateTime.MinValue && secondbirthday != DateTime.Today) { var secondStates = graphs.GetGraphStates(secondTotalDays.Days, i, SelectedDate); statesRange[date] = new GraphState(date, firstStates, secondStates); } else { statesRange[date] = new GraphState(date, firstStates); } }); var statesList = statesRange .OrderBy(x => x.Key) .Select(x => x.Value); var t = DispatcherHelper.RunAsync(() => { GraphStates = new RangeEnabledObservableCollection <GraphState>(); GraphStates.InsertRange(statesList); }); if (birthday != DateTime.Today) { Graph24 = new RangeEnabledObservableCollection <Point>(graphs.ElementAt(0).Points); Graph28 = new RangeEnabledObservableCollection <Point>(graphs.ElementAt(1).Points); Graph33 = new RangeEnabledObservableCollection <Point>(graphs.ElementAt(2).Points); Graph40 = new RangeEnabledObservableCollection <Point>(graphs.ElementAt(3).Points); } if (secondbirthday != DateTime.Today && secondbirthday != DateTime.MinValue) { graphs = InnerGenerateGraphs(secondbirthday); Graph24_2 = new RangeEnabledObservableCollection <Point>(graphs.ElementAt(0).Points); Graph28_2 = new RangeEnabledObservableCollection <Point>(graphs.ElementAt(1).Points); Graph33_2 = new RangeEnabledObservableCollection <Point>(graphs.ElementAt(2).Points); Graph40_2 = new RangeEnabledObservableCollection <Point>(graphs.ElementAt(3).Points); } else { Graph24_2 = null; Graph28_2 = null; Graph33_2 = null; Graph40_2 = null; } await t; } else { InitAuxBounds(); var g56 = new Graph56(); g56.GenerateGraph(firstTotalDays.Days, _auxScale, SelectedDate); var g92 = new Graph92(); g92.GenerateGraph(firstTotalDays.Days, _auxScale, SelectedDate); var g276 = new Graph276(); g276.GenerateGraph(firstTotalDays.Days, _auxScale, SelectedDate); Graph56 = new RangeEnabledObservableCollection <Point>(g56.Points); Graph92 = new RangeEnabledObservableCollection <Point>(g92.Points); Graph276 = new RangeEnabledObservableCollection <Point>(g276.Points); } GenerateTodayLine(); ScrollIntoViewTrigger = Guid.NewGuid(); }
public void TimeForward() { SelectedDate = SelectedDate.AddDays(1); }
public void Filter() { JournalRecords.Clear(); using (var repo = new Repository()) { var records = repo.GetAllWhere <StudentStatusOnLesson>(s => s.Date >= SelectedDate && s.Date <= SelectedDate.AddDays(6) && s.Student.Group.GroupName == SelectedGroup.GroupName && s.ScheduleRecord.Subject.SubjectName == SelectedSubject.SubjectName); foreach (var r in records) { JournalRecord journalRecord = JournalRecords.FirstOrDefault(j => j.Student.StudentId == r.StudentId); if (journalRecord == null) { journalRecord = new JournalRecord(); journalRecord.Student = r.Student; //Заполнить статусы пустыми занчениями journalRecord.Statuses = new List <StudentStatusOnLesson> (Enumerable.Repeat <StudentStatusOnLesson>(null, 6)); } //Добавить статус в нужную ячейку journalRecord.Statuses.Insert(r.ScheduleRecord.DayOfWeek - 1, r); JournalRecords.Add(journalRecord); } } }
private void CalendarChoose_SelectedDatesChanged(object sender, SelectionChangedEventArgs e) { SelecetedDate2.Content = SelectedDate.ToShortDateString(); //CurrentAppoitments = new ObservableCollection<MedicalAppointmentDTO>(); CurrentAppoitments.Clear(); foreach (MedicalAppointmentDTO termin in Appoitments) { if (termin.Beginning.CompareTo(SelectedDate) >= 0 && termin.Beginning.CompareTo(SelectedDate.AddDays(1)) <= 0) { CurrentAppoitments.Add(termin); } } if (CurrentAppoitments.Count >= 1) { } }
public void GetTasks(bool bSilent = false) { try { if (toggl != null) { var p = new TimeEntryParams(); p.StartDate = SelectedDate; p.EndDate = SelectedDate.AddDays(1); var e = toggl.TimeEntry.List(p); var d = new Dictionary <string, string>(); var pr = new List <long>(); foreach (var t in e) { if (t.Description != string.Empty && t.Description != null && !d.ContainsKey(t.Description) && t.Duration > 0) { string project = string.Empty; bool bChecked = false; foreach (var i in togglProjects) { if (i.Id == t.ProjectId) { project = i.Name; bChecked = i.IsChecked; break; } } if (bChecked) { d.Add(t.Description, project); } if (!pr.Contains(Convert.ToInt64(t.ProjectId))) { pr.Add(Convert.ToInt64(t.ProjectId)); } } } togglTasks = new List <TogglTask>(); foreach (var t in d) { togglTasks.Add(new TogglTask(t.Key, t.Value, e, this)); } togglTasks.Sort((c1, c2) => c1.Name.CompareTo(c2.Name)); foreach (var t in togglProjects.ToArray()) { if (!pr.Contains(Convert.ToInt64((t.Id)))) { togglProjects.Remove(t); } } GetTotalTime(); GetTotalTimeAdjusted(); OnPropertyChanged("TogglTasks"); OnPropertyChanged("TogglProjects"); } } catch (Exception ex) { if (!bSilent) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Warning); } } }
private void PreviousDay() { SelectedDate = SelectedDate.AddDays(-1); }
private void RefreshDayPreviews() { // figure out 'dayNum' day of week then populate the day previews int dayOffset = 0; switch (SelectedDate.DayOfWeek.ToString()) { case "Monday": dayOffset = 0; break; case "Tuesday": dayOffset = -1; break; case "Wednesday": dayOffset = -2; break; case "Thursday": dayOffset = -3; break; case "Friday": dayOffset = -4; break; case "Saturday": dayOffset = -5; break; case "Sunday": dayOffset = -6; break; } for (int i = 0; i < DayInfoCount; i++) { //DayInfoPreviews[i] = lck_Comm.GetDayInfo(SelectedStore.Id, Globals.DateTime_to_DayNumber(SelectedDate.AddDays(i + dayOffset))); DayInfoPreviews[i] = lck_Comm.GetDayInfo(Globals.DateTime_to_DayNumber(SelectedDate.AddDays(i + dayOffset))); DayInfoPreviews[i].Clicked -= HandleDayInfoClicked; DayInfoPreviews[i].Clicked += HandleDayInfoClicked; } }
private void OnRemoveDayExecute() { SelectedDate = SelectedDate.AddDays(-1); }