private void ShowWorksRanges(object obj) { //показать окно с диапазонами var timeRanges = new List <WorkTimeRange>(); var paths = new Dictionary <int, string>(); foreach (var workTab in WeekTabs[SelectedTabIndex].WorksInTab) { int curWorkID = workTab.WorkBlockContext.Work.ID; var workRanges = WorksVM.GetTimeRanges(curWorkID); paths.Add(workTab.WorkBlockContext.Work.ID, workTab.WorkBlockContext.FullPath); timeRanges.AddRange(workRanges); } var WorksRangesWnd = new WorkTimeRangesView(timeRanges, paths, PlanningTime); WorksRangesWnd.ShowDialog(); if (WorksRangesWnd.WasEdited) { Mouse.SetCursor(Cursors.Wait); //Сдать измненения WorksVM.UpdateTimeRanges(timeRanges, 0); int newSumTime = 0; foreach (var workTab in WeekTabs[SelectedTabIndex].WorksInTab) { workTab.WorkBlockContext.FillTimeRanges(); newSumTime += workTab.WorkBlockContext.Minutes; workTab.WorkBlockContext.WorkVM.UpdateWork(); } SumTime = newSumTime; Mouse.SetCursor(Cursors.Arrow); } }
private static void _initSharedStatics() { Context.Init(); TasksVM.InitFullTree(); TasksVM.InitFave(); WorksVM.Init(); }
private void UpdateWorkTimeRanges() { var DBRanges = new List <WorkTimeRange>(); foreach (var rng in WorkTimeRanges) { WorkTimeRange workRng = new WorkTimeRange() { WorkID = WorkVM.Work.ID, StartTime = rng.StartTime, EndTime = rng.EndTime, ID = rng.ID }; DBRanges.Add(workRng); } WorksVM.UpdateTimeRanges(DBRanges, Work.ID); }
public void FillTimeRanges() { WorkTimeRanges = new ObservableCollection <TimeRange>(); var curWorkTimeRanges = WorksVM.GetTimeRanges(Work.ID); foreach (var rng in curWorkTimeRanges) { TimeRange curWorkRng = new TimeRange(); curWorkRng.UpdateParentWorkTime = timeHandler; curWorkRng.StartTime = rng.StartTime; curWorkRng.ID = rng.ID; curWorkRng.EndTime = rng.EndTime; WorkTimeRanges.Add(curWorkRng); } UpdateWorkTime(); var sortWorkRanges = WorkTimeRanges.OrderBy(r => r.EndTime).ToList(); int lastRngIndex = sortWorkRanges.Count - 1; if (lastRngIndex >= 0) { LastRangeTime = sortWorkRanges[lastRngIndex].EndTime; } }
private void ExpandAllWorks(object obj) { WorksVM.ExpandAll(); }
private void CollapseAllWorks(object obj) { WorksVM.CollapseAll(); }
private bool IsEditing() { return(WorksVM.IsEditing()); }
private void _doWorkCommand(MessageWorkObject obj) { if ((obj.dt.Year != Date.Year || obj.dt.Month != Date.Month || obj.dt.Day != Date.Day) && obj._commandType != WorkCommandEnum.Update) { return; } dialog = null; WorkCommandEnum command = obj._commandType; Work work = obj._work; if (command == WorkCommandEnum.None) { return; } if (command == WorkCommandEnum.Add && (work.StartDate.Date.Year == Date.Date.Year && work.StartDate.Date.Month == Date.Date.Month && work.StartDate.Date.Day == Date.Date.Day)) { var newWorkID = WorksVM.Add(work); Work newWork = WorksVM.Dictionary[newWorkID].Work; AddWork(new WorkInTab(newWorkID, true)); SumTime += newWork.Minutes; MessengerInstance.Send <long>(SumTime); return; } int index = -1; for (int i = 0; i < WorksInTab.Count; i++) { if (WorksInTab[i].WorkBlockContext.Work.ID == work.ID) { index = i; break; } } if (index == -1) { return; } switch (command) { case WorkCommandEnum.Delete: SumTime -= WorksInTab[index].WorkBlockContext.Work.Minutes; WorksVM.Delete(work.ID); WorksInTab[index].WorkBlockContext.UnRegister(); WorksInTab.Remove(WorksInTab[index]); MessengerInstance.Send <long>(SumTime); // todo а это нельзя сделать в сэттере свойства SumTime ? break; case WorkCommandEnum.Update: int oldWorkMinutes = Context.workWork.Read_WorkByID(work.ID).Minutes; Work newWork = WorksVM.Update(work); //Work newWork = WorksVM.Dictionary[work.ID].Work; SumTime -= oldWorkMinutes; if (newWork.StartDate.Date == Date.Date) { WorksInTab[index].WorkBlockContext = new WorkBlockControlViewModel(newWork.ID, false); MainWindow.IsEnable = true; WorksInTab[index].WorkBlockContext.IsEditing = false; SumTime += newWork.Minutes; } else { WorksInTab[index].WorkBlockContext.UnRegister(); WorksInTab.Remove(WorksInTab[index]); } //if (work.StartDate.Date == Date.Date) //{ // AddWork(new WorkInTab(newWork.ID)); // SumTime += newWork.Minutes; //} MessengerInstance.Send <long>(SumTime); break; } }