Пример #1
0
        private void CorrectSelection(int k, IEnumerable <int> newSelected)
        {
            var       partToChange = string.Format("PART_Day_{0}", k);
            TextBlock text         = GetTemplateChild(partToChange) as TextBlock;
            var       value        = YearMonthArray();
            var       year         = Convert.ToInt16(value[0]);
            var       month        = Convert.ToInt16(value[1]);
            int       day          = SelectedDay.GetDayIndex(text);

            // this keys keep in account the offset used while drawing.
            var effectiveKey = filterLimit(day, MonthIndex, year);

            if (text != null)
            {
                if (SelectedDay.GetIsDaySelected(text))
                {
                    // looking for a selected value that it shall be not selected anymore.
                    if (!newSelected.Contains(effectiveKey))
                    {
                        SelectedDay.SetIsDaySelected(text, false);
                        text.Background = Brushes.White;
                    }
                }
            }
        }
Пример #2
0
        private void HighlightWorkingDay(int j, int k)
        {
            var       partToChange = string.Format("PART_Day_{0}", k);
            TextBlock text         = GetTemplateChild(partToChange) as TextBlock;

            if (text != null)
            {
                text.MouseLeftButtonDown += Text_MouseLeftButtonDown;
                SelectedDay.SetIsDaySelected(text, false);
                SelectedDay.SetDayIndex(text, k);
                text.Background = Brushes.White;
            }
        }
Пример #3
0
        private void Text_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            TextBlock currentButton = sender as TextBlock;

            if (currentButton != null)
            {
                int day    = SelectedDay.GetDayIndex(currentButton);
                int mIndex = MonthIndex;
                // i shall check if i can stay on the ranges.

                var value = YearMonthArray();
                var year  = Convert.ToInt16(value[0]);
                var month = Convert.ToInt16(value[1]);
                day = filterLimit(day, mIndex, year);
                var        param   = CreateCommand(day, false);
                List <int> daysOff = DaysOff.ToList();
                // avoid correction if it i have just clicked.


                if (SelectedDay.GetIsDaySelected(currentButton))
                {
                    currentButton.Background = Brushes.White;
                    daysOff.Remove(day);
                    SelectedDay.SetIsDaySelected(currentButton, false);
                }
                else
                {
                    param = CreateCommand(day, true);
                    currentButton.Background = Brushes.Yellow;
                    daysOff.Add(day);
                    SelectedDay.SetIsDaySelected(currentButton, true);
                }
                DaysOff = daysOff;
                // this make in a way that the reset command is internally called.

                if ((_resetCommand != null) && (!_resetCommand.Equals(ResetCommand)))
                {
                    ResetCommand = _resetCommand;
                }
                if (SelectedDayCommand != null)
                {
                    SelectedDayCommand.Execute(param);
                }
            }
        }