private void Change(ColorType colorType)
        {
            if (this.changeColor != null)
            {
                this.changeColor.Kill();
            }

            this.changeColor      = this.controlledCamera.DOColor(colorType.ToColor(), this.duration).SetEase(this.ease);
            this.CurrentColorType = colorType;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 初始化BackgroundController对象
        /// </summary>
        private BackgroundController()
        {
            UIS = new UISettings();
            UIS.ColorValuesChanged += UIS_ColorValuesChanged;

            ApplicationData.Current.DataChanged += Current_DataChanged;

            if (ApplicationData.Current.LocalSettings.Values["SolidColorType"] is string ColorType)
            {
                SolidColorBackgroundBrush = new SolidColorBrush(ColorType.ToColor());
            }
            else
            {
                if (UIS.GetColorValue(UIColorType.Background) == Colors.White)
                {
                    SolidColorBackgroundBrush = new SolidColorBrush(Colors.White);
                }
                else
                {
                    SolidColorBackgroundBrush = new SolidColorBrush("#1E1E1E".ToColor());
                }
            }

            if (ApplicationData.Current.LocalSettings.Values["UIDisplayMode"] is int ModeIndex)
            {
                switch (ModeIndex)
                {
                case 0:
                {
                    AcrylicBackgroundBrush = new AcrylicBrush
                    {
                        BackgroundSource = AcrylicBackgroundSource.HostBackdrop,
                        TintColor        = Colors.LightSlateGray,
                        TintOpacity      = 0.4,
                        FallbackColor    = Colors.DimGray
                    };

                    CurrentType = BackgroundBrushType.Acrylic;

                    break;
                }

                case 1:
                {
                    AcrylicBackgroundBrush = new AcrylicBrush
                    {
                        BackgroundSource = AcrylicBackgroundSource.HostBackdrop,
                        TintColor        = Colors.LightSlateGray,
                        TintOpacity      = 0.4,
                        FallbackColor    = Colors.DimGray
                    };

                    if (SolidColorBackgroundBrush.Color == Colors.White && AppThemeController.Current.Theme == ElementTheme.Dark)
                    {
                        AppThemeController.Current.Theme = ElementTheme.Light;
                    }
                    else if (SolidColorBackgroundBrush.Color == "#1E1E1E".ToColor() && AppThemeController.Current.Theme == ElementTheme.Light)
                    {
                        AppThemeController.Current.Theme = ElementTheme.Dark;
                    }

                    CurrentType = BackgroundBrushType.SolidColor;

                    break;
                }

                default:
                {
                    if (double.TryParse(Convert.ToString(ApplicationData.Current.LocalSettings.Values["BackgroundTintOpacity"]), out double TintOpacity))
                    {
                        if (double.TryParse(Convert.ToString(ApplicationData.Current.LocalSettings.Values["BackgroundTintLuminosity"]), out double TintLuminosity))
                        {
                            AcrylicBackgroundBrush = new AcrylicBrush
                            {
                                BackgroundSource                                                  = AcrylicBackgroundSource.HostBackdrop,
                                TintColor                                                         = ApplicationData.Current.LocalSettings.Values["AcrylicThemeColor"] is string Color?Color.ToColor() : Colors.LightSlateGray,
                                                                            TintOpacity           = 1 - TintOpacity,
                                                                            TintLuminosityOpacity = 1 - TintLuminosity,
                                                                            FallbackColor         = Colors.DimGray
                            };
                        }
                        else
                        {
                            AcrylicBackgroundBrush = new AcrylicBrush
                            {
                                BackgroundSource                                  = AcrylicBackgroundSource.HostBackdrop,
                                TintColor                                         = ApplicationData.Current.LocalSettings.Values["AcrylicThemeColor"] is string Color?Color.ToColor() : Colors.LightSlateGray,
                                                                    TintOpacity   = 1 - TintOpacity,
                                                                    FallbackColor = Colors.DimGray
                            };
                        }
                    }
                    else
                    {
                        AcrylicBackgroundBrush = new AcrylicBrush
                        {
                            BackgroundSource = AcrylicBackgroundSource.HostBackdrop,
                            TintColor        = Colors.LightSlateGray,
                            TintOpacity      = 0.4,
                            FallbackColor    = Colors.DimGray
                        };
                    }

                    if (ApplicationData.Current.LocalSettings.Values["CustomUISubMode"] is string SubMode)
                    {
                        CurrentType = Enum.Parse <BackgroundBrushType>(SubMode);

                        if (CurrentType == BackgroundBrushType.Acrylic && ApplicationData.Current.LocalSettings.Values["PreventFallBack"] is bool IsPrevent)
                        {
                            IsCompositionAcrylicEnabled = IsPrevent;
                        }
                    }

                    break;
                }
                }
            }
            else
            {
                AcrylicBackgroundBrush = new AcrylicBrush
                {
                    BackgroundSource = AcrylicBackgroundSource.HostBackdrop,
                    TintColor        = Colors.LightSlateGray,
                    TintOpacity      = 0.4,
                    FallbackColor    = Colors.DimGray
                };

                CurrentType = BackgroundBrushType.Acrylic;

                ApplicationData.Current.LocalSettings.Values["BackgroundTintOpacity"] = 0.6;
            }
        }