예제 #1
0
        private void WorkWithTabControl_ChangeTabItemEvent()
        {
            WorksWithFlyouts.CloseAllFlyouts();
            WorksWithFlyouts.ClearBlackoutsDate();

            WorkWithFilters.Filters.OnOtherFilters();
        }
예제 #2
0
        private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            WorksWithFlyouts.ClearBlackoutsDate();

            if (AddNewMission.IsOpen)
            {
                AddNewMission.IsOpen = false;
            }

            TreeView tr = (TreeView)sender;

            if (tr.SelectedItem == null)
            {
                return;
            }
            Mission SelectedMission = (Mission)tr.SelectedItem;

            //MessageBox.Show($"SelectedMission: {SelectedMission.Name} and {SelectedMission.ID}\n StartDate: {SelectedMission.StartDate.ToString()}\n FinishDate: {SelectedMission.FinishDate.ToString()}\n FatherId: {SelectedMission.FatherID}");
            if (SelectedMission.IsFinished)
            {
                return;
            }
            NeedToNotifySelectedItem.Instance.NeedToNotify = SelectedMission;
            EditingSelectedMission.IsOpen = true;
            NeedToNotifySelectedItem.Instance.UpdateBlackoutsDate();
        }
예제 #3
0
 private void Add_Mission_Click(object sender, RoutedEventArgs e)
 {
     if (EditingSelectedMission.IsOpen)
     {
         EditingSelectedMission.IsOpen = false;
     }
     WorksWithFlyouts.ClearBlackoutsDate();
     NeedToNotifySelectedItem.Instance.NewTaskMarks.Clear();
     AddNewMission.IsOpen = true;
 }
예제 #4
0
        private void MakeMissionFinish_Click(object sender, RoutedEventArgs e)
        {
            WorksWithFlyouts.CloseAllFlyouts();
            long id = (long)((Button)e.OriginalSource).Tag;

            Methods.idToMission[id].IsFinished = !Methods.idToMission[id].IsFinished;
            Methods.MakeChildrenFinished(Methods.idToMission[id]);

            WorkWithChart.AllConditions[0].CountCondition = WorkWithChart.GetCountActive(TreeViewModels.Root) - 1;
            WorkWithChart.AllConditions[1].CountCondition = WorkWithChart.GetCountInActive(TreeViewModels.Root);
        }
예제 #5
0
        private void DeleteMissionButton_Click(object sender, RoutedEventArgs e)
        {
            long id = (long)((Button)e.OriginalSource).Tag;

            WorksWithFlyouts.CloseAllFlyouts();
            WorksWithFlyouts.ClearBlackoutsDate();

            List <long> IdsToDelete = new List <long>();

            Methods.GetAllId(Methods.idToMission[id], ref IdsToDelete);

            Methods.idToMission[id].Remove();

            Methods.RemoveMissionFromDict(IdsToDelete);

            WorkWithTabControl.InstanceTabControl.OnTasksEmpty();

            WorkWithChart.AllConditions[0].CountCondition = WorkWithChart.GetCountActive(TreeViewModels.Root) - 1;
            WorkWithChart.AllConditions[1].CountCondition = WorkWithChart.GetCountInActive(TreeViewModels.Root);
        }
예제 #6
0
        private void SaveNewMissionButton_Click(object sender, RoutedEventArgs e)
        {
            Mission newMission;

            string name = (Methods.TextIsEmpty(MissionNameTextBox.Text)) ? "Без названия" : MissionNameTextBox.Text;

            newMission             = new Mission(name, 0);
            newMission.IsImportant = (bool)ToggleSwitchIsImportant.IsChecked;

            DateTime start, finish;

            if (StartDateTimePicker.SelectedDate == null || StartDateTimePicker.SelectedDate == DateTime.MinValue.Date)
            {
                start = DateTime.MinValue.Date;
            }
            else
            {
                start = (DateTime)StartDateTimePicker.SelectedDate;
            }

            if (FinishDateTimePicker.SelectedDate == null || FinishDateTimePicker.SelectedDate == DateTime.MaxValue.Date)
            {
                finish = DateTime.MaxValue.Date;
            }
            else
            {
                finish = (DateTime)FinishDateTimePicker.SelectedDate;
            }

            DateTime helpDateTime;

            if (DateTime.Compare(finish, start) <= 0)
            {
                helpDateTime = finish;
                finish       = start;
                start        = helpDateTime;
            }

            newMission.StartDate  = start;
            newMission.FinishDate = finish;

            newMission.FirstColor  = (FirstColor.IsChecked == null) ? false : (bool)FirstColor.IsChecked;
            newMission.SecondColor = (SecondColor.IsChecked == null) ? false : (bool)SecondColor.IsChecked;
            newMission.ThirdColor  = (ThirdColor.IsChecked == null) ? false : (bool)ThirdColor.IsChecked;
            newMission.FourthColor = (FourthColor.IsChecked == null) ? false : (bool)FourthColor.IsChecked;
            newMission.FifthColor  = (FifthColor.IsChecked == null) ? false : (bool)FifthColor.IsChecked;


            for (int i = 0; i < NeedToNotifySelectedItem.Instance.NewTaskMarks.Count; i++)
            {
                newMission.Marks.Insert(0, new MiniMark(NeedToNotifySelectedItem.Instance.NewTaskMarks[i].MarkText));
            }

            long id = (long)((Button)e.OriginalSource).Tag;

            if (NeedToNotifySelectedItem.Instance.NotifyOpenFlyout)
            {
                NeedToNotifySelectedItem.Instance.NotifyOpenFlyout = false;
                newMission.FatherID = id;
            }
            else
            {
                newMission.FatherID = 0;
            }
            Methods.idToMission[newMission.FatherID].Add(newMission);
            Methods.idToMission[newMission.ID] = newMission;
            WorksWithFlyouts.CloseFlyout();
            ClearFlyout();
            WorkWithFilters.Filters.OnOtherFilters();
            WorkWithTabControl.InstanceTabControl.OnTasksEmpty();

            WorkWithChart.AllConditions[0].CountCondition = WorkWithChart.GetCountActive(TreeViewModels.Root);
            WorkWithChart.AllConditions[1].CountCondition = WorkWithChart.GetCountInActive(TreeViewModels.Root);
        }
        //Для каждой задачи выставляем ограницения на установку дат начала и конца в зависимости от детей и отцов задачи
        private void Instance_UpdateDatePicker()
        {
            StartDateTimePicker.DisplayDate  = DateTime.Today;
            FinishDateTimePicker.DisplayDate = DateTime.Today;
            Mission selectMission = NeedToNotifySelectedItem.Instance.NeedToNotify;

            if (selectMission == null)
            {
                WorksWithFlyouts.CloseAllFlyouts();
                return;
            }
            #region Ограничение задачи относительно подзадач
            DateTime minChildDate = DateTime.MaxValue.Date, maxChildDate = DateTime.MinValue.Date;
            DateTime minMiddleDate = DateTime.MaxValue.Date, maxMiddleDate = DateTime.MinValue.Date;
            for (int i = 0; i < selectMission.Children.Count; i++)
            {
                if (selectMission.Children[i].StartDate != DateTime.MinValue.Date &&
                    selectMission.Children[i].FinishDate == DateTime.MaxValue.Date)
                {
                    if (DateTime.Compare(selectMission.Children[i].StartDate, minMiddleDate) < 0)
                    {
                        minMiddleDate = selectMission.Children[i].StartDate;
                    }
                    if (DateTime.Compare(maxMiddleDate, selectMission.Children[i].StartDate) < 0)
                    {
                        maxMiddleDate = selectMission.Children[i].StartDate;
                    }
                }
                else if (selectMission.Children[i].StartDate == DateTime.MinValue.Date &&
                         selectMission.Children[i].FinishDate != DateTime.MaxValue.Date)
                {
                    if (DateTime.Compare(selectMission.Children[i].FinishDate, minMiddleDate) < 0)
                    {
                        minMiddleDate = selectMission.Children[i].FinishDate;
                    }
                    if (DateTime.Compare(maxMiddleDate, selectMission.Children[i].FinishDate) < 0)
                    {
                        maxMiddleDate = selectMission.Children[i].FinishDate;
                    }
                }
                if (selectMission.Children[i].StartDate != DateTime.MinValue.Date &&
                    DateTime.Compare(selectMission.Children[i].StartDate, minChildDate) < 0)
                {
                    minChildDate = selectMission.Children[i].StartDate;
                }
                if (selectMission.Children[i].FinishDate != DateTime.MaxValue.Date &&
                    DateTime.Compare(maxChildDate, selectMission.Children[i].FinishDate) < 0)
                {
                    maxChildDate = selectMission.Children[i].FinishDate;
                }
            }
            StartDateTimePicker.BlackoutDates.Clear();
            FinishDateTimePicker.BlackoutDates.Clear();
            if (minChildDate != DateTime.MaxValue.Date &&
                maxChildDate != DateTime.MinValue.Date)
            {
                CalendarDateRange childDateForStart  = new CalendarDateRange(minChildDate.AddDays(1), DateTime.MaxValue.Date);
                CalendarDateRange childDateForFinish = new CalendarDateRange(DateTime.MinValue.Date, maxChildDate.AddDays(-1));
                StartDateTimePicker.BlackoutDates.Add(childDateForStart);
                FinishDateTimePicker.BlackoutDates.Add(childDateForFinish);
            }
            else if (minMiddleDate != DateTime.MaxValue.Date && maxMiddleDate != DateTime.MinValue.Date)
            {
                CalendarDateRange childDateForStart  = new CalendarDateRange(minMiddleDate.AddDays(1), DateTime.MaxValue.Date);
                CalendarDateRange childDateForFinish = new CalendarDateRange(DateTime.MinValue.Date, maxMiddleDate.AddDays(-1));
                StartDateTimePicker.BlackoutDates.Add(childDateForStart);
                FinishDateTimePicker.BlackoutDates.Add(childDateForFinish);
            }
            #endregion

            #region Ограничение задачи относительно задачи-отца
            if (NeedToNotifySelectedItem.Instance.NeedToNotify.FatherID != 0 && Methods.idToMission[NeedToNotifySelectedItem.Instance.NeedToNotify.FatherID].StartDate != DateTime.MinValue.Date)
            {
                DateTime          minDate  = Methods.idToMission[NeedToNotifySelectedItem.Instance.NeedToNotify.FatherID].StartDate.AddDays(-1);
                CalendarDateRange rangeMin = new CalendarDateRange(DateTime.MinValue.Date.AddDays(1), minDate);
                StartDateTimePicker.BlackoutDates.Add(rangeMin);
                FinishDateTimePicker.BlackoutDates.Add(rangeMin);
            }
            if (NeedToNotifySelectedItem.Instance.NeedToNotify.FatherID != 0 && Methods.idToMission[NeedToNotifySelectedItem.Instance.NeedToNotify.FatherID].FinishDate != DateTime.MaxValue.Date)
            {
                DateTime          maxDate  = Methods.idToMission[NeedToNotifySelectedItem.Instance.NeedToNotify.FatherID].FinishDate.AddDays(1);
                CalendarDateRange rangeMax = new CalendarDateRange(maxDate, DateTime.MaxValue.Date.AddDays(-1));
                StartDateTimePicker.BlackoutDates.Add(rangeMax);
                FinishDateTimePicker.BlackoutDates.Add(rangeMax);
            }
            #endregion
        }