private void InitDayPanel(int year, int month)
        {
            var count = GrdDay.Children.Count;

            var group = Guid.NewGuid().ToString();

            for (int i = 0; i < 42 - count; i++)
            {
                var border = new Border();
                Grid.SetRow(border, (int)(i / 7));
                Grid.SetColumn(border, i % 7);

                var radioButton = new RadioButton()
                {
                    GroupName = group,
                    Padding   = new Thickness(0),
                    VerticalContentAlignment   = VerticalAlignment.Center,
                    HorizontalContentAlignment = HorizontalAlignment.Center,
                };
                RadioButtonHelper.SetRadioButtonStyle(radioButton, RadioButtonStyle.Button);
                RadioButtonHelper.SetCornerRadius(radioButton, new CornerRadius(0));
                radioButton.Click += RdbDay_Click;

                SetBinding("Foreground", radioButton, ForegroundProperty);
                SetBinding("FontSize", radioButton, FontSizeProperty);
                SetBinding("ThemeBrush", radioButton, RadioButtonHelper.CheckedBackgroundProperty);
                border.Child = radioButton;
                GrdDay.Children.Add(border);
            }

            var currentMonthFirstDay = new DateTime(year, month, 1);
            var date = currentMonthFirstDay.AddDays((int)currentMonthFirstDay.DayOfWeek * -1 + (IsSundayFirst ? 0 : 1));

            for (int i = 0; i < 42; i++)
            {
                var currentDate = date.AddDays(i);
                var radioButton = (GrdDay.Children[i] as Border).Child as RadioButton;

                var isUnlimit = CheckDateLimit(currentDate, DayMonthYear.Day);

                radioButton.IsChecked = isUnlimit ? SelectedDate.Date == currentDate.Date : false;
                radioButton.Opacity   = isUnlimit ? (currentDate.Month == month ? 1 : 0.5) : 0.2;
                radioButton.IsEnabled = isUnlimit;
                radioButton.Content   = currentDate.Day;
                radioButton.Tag       = currentDate;
            }
        }
        private void InitMonthPanel(int year)
        {
            var count = GrdMonth.Children.Count;
            var group = Guid.NewGuid().ToString();

            for (int i = 0; i < 12 - count; i++)
            {
                var border = new Border();
                Grid.SetRow(border, (int)(i / 4));
                Grid.SetColumn(border, i % 4);

                var radioButton = new RadioButton()
                {
                    GroupName = group,
                    Padding   = new Thickness(0),
                    VerticalContentAlignment   = VerticalAlignment.Center,
                    HorizontalContentAlignment = HorizontalAlignment.Center,
                };
                RadioButtonHelper.SetRadioButtonStyle(radioButton, RadioButtonStyle.Button);
                RadioButtonHelper.SetCornerRadius(radioButton, new CornerRadius(0));
                radioButton.Click += RdbMonth_Click;

                SetBinding("Foreground", radioButton, ForegroundProperty);
                SetBinding("FontSize", radioButton, FontSizeProperty);
                SetBinding("ThemeBrush", radioButton, RadioButtonHelper.CheckedBackgroundProperty);
                border.Child = radioButton;
                GrdMonth.Children.Add(border);
            }

            var currentMonthFirstDay = new DateTime(year, 1, 1);

            for (int i = 0; i < 12; i++)
            {
                var currentDate = currentMonthFirstDay.AddMonths(i);

                var radioButton = (GrdMonth.Children[i] as Border).Child as RadioButton;

                var isUnlimit = CheckDateLimit(currentDate, DayMonthYear.Month);

                radioButton.IsChecked = isUnlimit ? (SelectedDate.Year == currentDate.Year && SelectedDate.Month == currentDate.Month) : false;
                radioButton.Opacity   = isUnlimit ? 1 : 0.2;
                radioButton.IsEnabled = isUnlimit;
                radioButton.Content   = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(i + 1);
                radioButton.Tag       = currentDate;
            }
        }
        private void InitYearPanel(int year)
        {
            var count = GrdYear.Children.Count;
            var group = Guid.NewGuid().ToString();

            for (int i = 0; i < 15 - count; i++)
            {
                var border = new Border();
                Grid.SetRow(border, (int)(i / 3));
                Grid.SetColumn(border, i % 3);

                var radioButton = new RadioButton()
                {
                    GroupName = group,
                    Padding   = new Thickness(0),
                    VerticalContentAlignment   = VerticalAlignment.Center,
                    HorizontalContentAlignment = HorizontalAlignment.Center,
                };
                RadioButtonHelper.SetRadioButtonStyle(radioButton, RadioButtonStyle.Button);
                RadioButtonHelper.SetCornerRadius(radioButton, new CornerRadius(0));
                radioButton.Click += RdbYear_Click;

                SetBinding("Foreground", radioButton, ForegroundProperty);
                SetBinding("FontSize", radioButton, FontSizeProperty);
                SetBinding("ThemeBrush", radioButton, RadioButtonHelper.CheckedBackgroundProperty);
                border.Child = radioButton;
                GrdYear.Children.Add(border);
            }

            var firstYear = new DateTime(year, 1, 1).AddYears(-7);

            for (int i = 0; i < 15; i++)
            {
                var currentDate = firstYear.AddYears(i);
                var radioButton = (GrdYear.Children[i] as Border).Child as RadioButton;
                var isUnlimit   = CheckDateLimit(currentDate, DayMonthYear.Year);
                radioButton.IsChecked = isUnlimit ? (SelectedDate.Year == currentDate.Year) : false;
                radioButton.Opacity   = isUnlimit ? 1 : 0.2;
                radioButton.IsEnabled = isUnlimit;
                radioButton.Content   = currentDate.Year;
                radioButton.Tag       = currentDate;
            }
        }
        private void InitMonthPanel(int year)
        {
            var count = GrdMonth.Children.Count;

            for (int i = 0; i < 12 - count; i++)
            {
                var border = new Border();
                Grid.SetRow(border, (int)(i / 4));
                Grid.SetColumn(border, i % 4);

                var radioButton = new RadioButton()
                {
                    GroupName = "CALENDAR_MONTH",
                    MaxHeight = 35,
                };
                RadioButtonHelper.SetRadioButtonStyle(radioButton, RadioButtonStyle.Button);
                RadioButtonHelper.SetCornerRadius(radioButton, 0);
                radioButton.Click += RdbMonth_Click;

                SetBinding("Foreground", radioButton, ForegroundProperty);
                SetBinding("FontSize", radioButton, FontSizeProperty);
                SetBinding("ThemeBrush", radioButton, RadioButtonHelper.CheckedBackgroundProperty);
                border.Child = radioButton;
                GrdMonth.Children.Add(border);
            }

            var currentMonthFirstDay = new DateTime(year, 1, 1);

            for (int i = 0; i < 12; i++)
            {
                var currentDate = currentMonthFirstDay.AddMonths(i);

                var radioButton = (GrdMonth.Children[i] as Border).Child as RadioButton;

                var isUnlimit = CheckDateLimit(currentDate, DayMonthYear.Month);

                radioButton.IsChecked = isUnlimit ? (SelectedDate.Year == currentDate.Year && SelectedDate.Month == currentDate.Month) : false;
                radioButton.Opacity   = isUnlimit ? 1 : 0.2;
                radioButton.IsEnabled = isUnlimit;
                radioButton.Content   = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i + 1);
                radioButton.Tag       = currentDate;
            }
        }
Beispiel #5
0
        private void InitHourPanel()
        {
            var count = StkHour.Children.Count;

            for (int i = 0; i < 24 - count; i++)
            {
                var border = new Border()
                {
                    Height = 35
                };

                Grid.SetRow(border, (int)(i / 7));
                Grid.SetColumn(border, i % 7);

                var radioButton = new RadioButton()
                {
                    GroupName = "CLOCK_HOUR",
                };
                RadioButtonHelper.SetRadioButtonStyle(radioButton, RadioButtonStyle.Button);
                RadioButtonHelper.SetCornerRadius(radioButton, 0);
                radioButton.Click += RdbHour_Click;

                SetBinding("Foreground", radioButton, ForegroundProperty);
                SetBinding("FontSize", radioButton, FontSizeProperty);
                SetBinding("ThemeBrush", radioButton, RadioButtonHelper.CheckedBackgroundProperty);
                border.Child = radioButton;
                StkHour.Children.Add(border);
            }

            for (int i = 0; i < 24; i++)
            {
                var radioButton = (StkHour.Children[i] as Border).Child as RadioButton;

                radioButton.IsChecked = SelectedTime.Hour == i;
                radioButton.Content   = i.ToString("00");
                radioButton.Tag       = i;
            }

            ScrollHour.ScrollToVerticalOffset((SelectedTime.Hour - 3) * 35);
        }
        private void InitYearPanel(int year)
        {
            var count = GrdYear.Children.Count;

            for (int i = 0; i < 15 - count; i++)
            {
                var border = new Border();
                Grid.SetRow(border, (int)(i / 3));
                Grid.SetColumn(border, i % 3);

                var radioButton = new RadioButton()
                {
                    GroupName = "CALENDAR_YEAR",
                    MaxHeight = 35,
                };
                RadioButtonHelper.SetRadioButtonStyle(radioButton, RadioButtonStyle.Button);
                RadioButtonHelper.SetCornerRadius(radioButton, 0);
                radioButton.Click += RdbYear_Click;

                SetBinding("Foreground", radioButton, ForegroundProperty);
                SetBinding("FontSize", radioButton, FontSizeProperty);
                SetBinding("ThemeBrush", radioButton, RadioButtonHelper.CheckedBackgroundProperty);
                border.Child = radioButton;
                GrdYear.Children.Add(border);
            }

            var firstYear = new DateTime(year, 1, 1).AddYears(-7);

            for (int i = 0; i < 15; i++)
            {
                var currentDate = firstYear.AddYears(i);
                var radioButton = (GrdYear.Children[i] as Border).Child as RadioButton;
                var isUnlimit   = CheckDateLimit(currentDate, DayMonthYear.Year);
                radioButton.IsChecked = isUnlimit ? (SelectedDate.Year == currentDate.Year) : false;
                radioButton.Opacity   = isUnlimit ? 1 : 0.2;
                radioButton.IsEnabled = isUnlimit;
                radioButton.Content   = currentDate.Year;
                radioButton.Tag       = currentDate;
            }
        }
Beispiel #7
0
        private void InitDialHour()
        {
            var count = CvaDial.Children.Count;

            for (int i = 0; i < 24 - count; i++)
            {
                var border = new Border()
                {
                    Height = 30, Width = 30
                };
                var point = GetPointOnEllipse(360.0 * i / 24);
                Canvas.SetLeft(border, point.X - 15);
                Canvas.SetTop(border, point.Y - 15);


                var radioButton = new RadioButton()
                {
                    GroupName = "CLOCK_HOUR",
                };
                RadioButtonHelper.SetRadioButtonStyle(radioButton, RadioButtonStyle.Button);
                RadioButtonHelper.SetCornerRadius(radioButton, 15);
                radioButton.Click += RdbHour_Click;

                SetBinding("Foreground", radioButton, ForegroundProperty);
                SetBinding("FontSize", radioButton, FontSizeProperty);
                SetBinding("ThemeBrush", radioButton, RadioButtonHelper.CheckedBackgroundProperty);
                border.Child = radioButton;
                CvaDial.Children.Add(border);
            }

            for (int i = 0; i < 24; i++)
            {
                var radioButton = (CvaDial.Children[i] as Border).Child as RadioButton;

                radioButton.IsChecked = SelectedTime.Hour == i;
                radioButton.Content   = i.ToString("00");
                radioButton.Tag       = i;
            }
        }