Exemple #1
0
        private void ChangeMonth(DateTime dt)
        {
            var easing = new CircleEase {
                EasingMode = EasingMode.EaseInOut
            };
            var animDur = TimeSpan.FromMilliseconds(300);

            CalendarDays.BeginAnimation(OpacityProperty, new DoubleAnimation(CalendarDays.Opacity, 0, animDur)
            {
                EasingFunction = easing
            });
            PersianTitle.BeginAnimation(OpacityProperty, new DoubleAnimation(PersianTitle.Opacity, 0, animDur)
            {
                EasingFunction = easing
            });
            GregorianTitle.BeginAnimation(OpacityProperty, new DoubleAnimation(GregorianTitle.Opacity, 0, animDur)
            {
                EasingFunction = easing
            });
            HijriTitle.BeginAnimation(OpacityProperty, new DoubleAnimation(HijriTitle.Opacity, 0, animDur)
            {
                EasingFunction = easing
            });

            var timer = new DispatcherTimer {
                Interval = animDur
            };

            timer.Start();
            timer.Tick += (sender, args) =>
            {
                ((DispatcherTimer)sender)?.Stop();
                NowDateTime = dt;
                DesignCalendar();

                CalendarDays.BeginAnimation(OpacityProperty,
                                            new DoubleAnimation(CalendarDays.Opacity, 1, animDur)
                {
                    EasingFunction = easing
                });
                PersianTitle.BeginAnimation(OpacityProperty,
                                            new DoubleAnimation(PersianTitle.Opacity, 1, animDur)
                {
                    EasingFunction = easing
                });
                GregorianTitle.BeginAnimation(OpacityProperty,
                                              new DoubleAnimation(GregorianTitle.Opacity, 1, animDur)
                {
                    EasingFunction = easing
                });
                HijriTitle.BeginAnimation(OpacityProperty,
                                          new DoubleAnimation(HijriTitle.Opacity, 1, animDur)
                {
                    EasingFunction = easing
                });
            };
        }
Exemple #2
0
        private void SetTheme()
        {
            if (IsDark)
            {
                CurrentThemeThemeNoiseColor      = Theme.WhiteTheme.ThemeColor;
                CurrentThemeThemeNoiseOpacity    = Theme.WhiteTheme.ThemeBlurinessOpacity;
                CurrentThemeThemeNoiseRatioInt   = Theme.WhiteTheme.ThemeBlurinessRatio;
                CurrentThemeHasEventDayBackColor = Theme.WhiteTheme.HasEventDayBackColor;
                CurrentThemeDayLeadForecolor     = Theme.WhiteTheme.DayLeadColor;
                CurrentThemePersianDayForecolor  = Theme.WhiteTheme.PersianDayColor;
                CurrentThemeGregHijrForecolor    = Theme.WhiteTheme.GregorianHijriColor;
                CurrentThemeTodayForecolor       = Theme.WhiteTheme.TodayForecolor;
                CurrentThemeSeparator            = Theme.WhiteTheme.Separator;
                CurrentThemeChangeMonthForecolor = Theme.WhiteTheme.ChangeMonth;
                IsDark = false;
            }
            else
            {
                CurrentThemeThemeNoiseColor      = Theme.DarkTheme.ThemeColor;
                CurrentThemeThemeNoiseOpacity    = Theme.DarkTheme.ThemeBlurinessOpacity;
                CurrentThemeThemeNoiseRatioInt   = Theme.DarkTheme.ThemeBlurinessRatio;
                CurrentThemeHasEventDayBackColor = Theme.DarkTheme.HasEventDayBackColor;
                CurrentThemeDayLeadForecolor     = Theme.DarkTheme.DayLeadColor;
                CurrentThemePersianDayForecolor  = Theme.DarkTheme.PersianDayColor;
                CurrentThemeGregHijrForecolor    = Theme.DarkTheme.GregorianHijriColor;
                CurrentThemeTodayForecolor       = Theme.DarkTheme.TodayForecolor;
                CurrentThemeSeparator            = Theme.DarkTheme.Separator;
                CurrentThemeChangeMonthForecolor = Theme.DarkTheme.ChangeMonth;
                IsDark = true;
            }

            var animationDuration = TimeSpan.FromMilliseconds(300);

            ThemeNoise.CreateStoryBoard(CurrentThemeThemeNoiseColor, "(Border.Background).(SolidColorBrush.Color)");
            PersianTitle.CreateStoryBoard(CurrentThemeDayLeadForecolor, "(TextBlock.Foreground).(SolidColorBrush.Color)");
            GregorianTitle.CreateStoryBoard(CurrentThemeDayLeadForecolor, "(TextBlock.Foreground).(SolidColorBrush.Color)");
            HijriTitle.CreateStoryBoard(CurrentThemeDayLeadForecolor, "(TextBlock.Foreground).(SolidColorBrush.Color)");
            TodayDate.CreateStoryBoard(CurrentThemeTodayForecolor, "(Button.Foreground).(SolidColorBrush.Color)");
            Separator.CreateStoryBoard(CurrentThemeSeparator, "Background.Color");
            BtnPrevMonth.CreateStoryBoard(CurrentThemeChangeMonthForecolor, "(Button.Foreground).(SolidColorBrush.Color)");
            BtnNextMonth.CreateStoryBoard(CurrentThemeChangeMonthForecolor, "(Button.Foreground).(SolidColorBrush.Color)");

            DesignCalendar(NowDateTime);

            foreach (var day in CalendarDays.Children)
            {
                var dayDetails = ((day as Button)?.Content as Grid)?.Children;
                if (dayDetails == null)
                {
                    continue;
                }

                foreach (var dayDetail in dayDetails)
                {
                    switch (dayDetail)
                    {
                    case TextBlock persianDay:
                        persianDay.CreateStoryBoard(CurrentThemePersianDayForecolor, "(TextBlock.Foreground).(SolidColorBrush.Color)");
                        break;

                    case Grid customDays:
                        foreach (var cusDay in customDays.Children)
                        {
                            if (cusDay is TextBlock customDay)
                            {
                                customDay.CreateStoryBoard(CurrentThemeGregHijrForecolor,
                                                           "(TextBlock.Foreground).(SolidColorBrush.Color)");
                            }
                        }
                        break;
                    }
                }
            }

            ThemeNoise.BeginAnimation(OpacityProperty, new DoubleAnimation(ThemeNoise.Opacity, CurrentThemeThemeNoiseOpacity, animationDuration));
            ThemeNoiseRatio.Ratio = CurrentThemeThemeNoiseRatioInt;
            DesignCalendar(NowDateTime);
        }