示例#1
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);
                }
            }
        }