コード例 #1
0
ファイル: MainPageRenderer.cs プロジェクト: Wolfteam/TimeIt
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Page> e)
        {
            base.OnElementChanged(e);
            if (e.OldElement != null || Element == null)
            {
                return;
            }

            try
            {
                if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.XamlCompositionBrushBase"))
                {
                    AcrylicBrush myBrush = new AcrylicBrush
                    {
                        BackgroundSource = AcrylicBackgroundSource.HostBackdrop,
                        TintColor        = Windows.UI.Color.FromArgb(255, 200, 200, 200),
                        TintOpacity      = 0.2
                    };

                    Background = myBrush;
                }
                else
                {
                    SolidColorBrush myBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 240, 240, 240));

                    Background = myBrush;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }
        }
コード例 #2
0
        private async void SetBackground()
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                var backgroundBrush = new AcrylicBrush()
                {
                    AlwaysUseFallback = AppSettings.AcrylicEnabled,
                    BackgroundSource  = AcrylicBackgroundSource.HostBackdrop,
                    FallbackColor     = AppSettings.AcrylicTheme.FallbackColor,
                    TintColor         = AppSettings.AcrylicTheme.TintColor,
                    TintOpacity       = AppSettings.AcrylicTheme.TintOpacity,
                };
                if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 9))
                {
                    backgroundBrush.TintLuminosityOpacity = 0.9;
                }

                if (!(new AccessibilitySettings()).HighContrast)
                {
                    Background = backgroundBrush;
                }
                else
                {
                    Background = Application.Current.Resources["ApplicationPageBackgroundThemeBrush"] as SolidColorBrush;
                }
            });
        }
コード例 #3
0
        private void SetGridBackground(string color, ImageFile imageFile)
        {
            Brush backgroundBrush;

            if (imageFile != null && System.IO.File.Exists(imageFile.Path))
            {
                backgroundBrush = new ImageBrush()
                {
                    ImageSource = new BitmapImage(new Uri(
                                                      imageFile.Path,
                                                      UriKind.Absolute)),
                    Stretch = Stretch.UniformToFill
                };
            }
            else
            {
                backgroundBrush = new AcrylicBrush
                {
                    BackgroundSource = AcrylicBackgroundSource.HostBackdrop,
                    FallbackColor    = color.FromString(),
                    TintColor        = color.FromString(),
                    TintOpacity      = ViewModel.BackgroundOpacity
                };
            }

            Root.Background = backgroundBrush;
        }
コード例 #4
0
        private static void OnBackgroundChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (e.NewValue is Color color)
            {
                var type = d.GetType();
                var backgroundProperty = type.GetProperty("Background");
                if (backgroundProperty == null)
                {
                    return;
                }

                var fullColor = Color.FromArgb(0xff, color.R, color.G, color.B);

                if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.AcrylicBrush"))
                {
                    AcrylicBrush myBrush = new AcrylicBrush
                    {
                        BackgroundSource = AcrylicBackgroundSource.Backdrop,
                        TintColor        = fullColor,
                        FallbackColor    = color,
                        TintOpacity      = (double)color.A / 255d
                    };

                    backgroundProperty.SetValue(d, myBrush);
                }
                else
                {
                    backgroundProperty.SetValue(d, new SolidColorBrush(color));
                    ((FrameworkElement)d).Blur(3, duration: 0).Start();
                }
            }
        }
コード例 #5
0
        private void AllPageAcylic_Toggled(object sender, RoutedEventArgs e)
        {
            ToggleSwitch toggleSwitch = sender as ToggleSwitch;

            if (toggleSwitch != null)
            {
                if (AllPageAcylic.IsOn == true)
                {
                    AcrylicBrush myBrush = new AcrylicBrush();
                    myBrush.BackgroundSource = AcrylicBackgroundSource.HostBackdrop;
                    myBrush.TintColor        = Color.FromArgb(255, 255, 255, 255);
                    myBrush.FallbackColor    = Color.FromArgb(255, 255, 255, 255);
                    myBrush.TintOpacity      = 0.8;
                    All.Current.AllPageStackPanel.Background  = myBrush;
                    localSettings.Values["SetAllPageAcrylic"] = true;
                    //Add.Current.AddPageGird.Background = myBrush;
                }
                else
                {
                    All.Current.AllPageStackPanel.Background  = new SolidColorBrush(Colors.White);
                    localSettings.Values["SetAllPageAcrylic"] = false;
                    //Add.Current.AddPageGird.Background = new SolidColorBrush(Colors.White);
                }
            }
            toggleSwitch.Toggled += AllPageAcylic_Toggled;
        }
コード例 #6
0
        private void InitializeBackground()
        {
            if (App.IsAcrylicAvailable)
            {
                var acrylicBrush = new AcrylicBrush()
                {
                    BackgroundSource = AcrylicBackgroundSource.HostBackdrop,
                    TintColor        = Colors.White,
                    FallbackColor    = Colors.White,
                    TintOpacity      = 0.8,
                };

                BindingOperations.SetBinding(acrylicBrush, AcrylicBrush.AlwaysUseFallbackProperty,
                                             new Binding()
                {
                    Path = new PropertyPath("ShowIcon")
                });

                Background = acrylicBrush;
            }
            else
            {
                Background = new SolidColorBrush(Colors.White);
            }
        }
コード例 #7
0
        private void SetGridBackgroundTheme(TerminalTheme terminalTheme)
        {
            var color     = terminalTheme.Colors.Background;
            var imageFile = terminalTheme.BackgroundImage;

            Brush backgroundBrush;

            if (imageFile != null && System.IO.File.Exists(imageFile.Path))
            {
                backgroundBrush = new ImageBrush()
                {
                    ImageSource = new BitmapImage(new Uri(
                                                      imageFile.Path,
                                                      UriKind.Absolute)),
                    Stretch = Stretch.UniformToFill
                };
            }
            else
            {
                backgroundBrush = new AcrylicBrush
                {
                    BackgroundSource = AcrylicBackgroundSource.HostBackdrop,
                    FallbackColor    = color.FromString(),
                    TintColor        = color.FromString(),
                    TintOpacity      = ViewModel.BackgroundOpacity
                };
            }

            TerminalContainer.Background = backgroundBrush;
        }
コード例 #8
0
        /// <inheritdoc />
        public Task PointerPressedExecuteAsync()
        {
            _pointerStart = PointerEventArgs.GetCurrentPoint(Canvas).Position;

            // Create selector square
            selectorSquare = new Rectangle();

            selectorSquare.Width  = 1;
            selectorSquare.Height = 1;
            selectorSquare.SetValue(Canvas.LeftProperty, _pointerStart.X);
            selectorSquare.SetValue(Canvas.TopProperty, _pointerStart.Y);

            // Give selector square blue acryl color
            Brush brush = new AcrylicBrush()
            {
                TintColor   = Colors.Blue,
                TintOpacity = 0.1
            };

            selectorSquare.Fill = brush;

            Canvas.Children.Add(selectorSquare);

            return(Task.CompletedTask);
        }
コード例 #9
0
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            var          status = value as NodeStatus?;
            AcrylicBrush brush  = new AcrylicBrush();


            if (value != null)
            {
                switch (status)
                {
                case (NodeStatus.Unknown):
                    brush.TintColor = Colors.LightGray;
                    break;

                case (NodeStatus.Available):
                    brush.TintColor = Colors.Azure;
                    break;

                case (NodeStatus.Timeout):
                    brush.TintColor = Colors.MistyRose;
                    break;

                default:
                    brush.TintColor = Colors.LightGray;
                    break;
                }
            }
            return(brush);
        }
コード例 #10
0
        private void applyAcrylicAccent(Panel panel)
        {
            if (ClassInfo.DeviceType() == ClassInfo.DeviceTypeEnum.Phone)
            {
                return;
            }
            if (ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.AcrylicBrush"))
            {
                var ac    = new AcrylicBrush();
                var brush = Resources["SystemControlChromeMediumLowAcrylicElementMediumBrush"] as AcrylicBrush;
                ac                   = brush;
                ac.TintOpacity       = 0.7;
                ac.BackgroundSource  = AcrylicBackgroundSource.Backdrop;
                Split.PaneBackground = ac;
                return;
            }
            if (ApiInformation.IsMethodPresent("Windows.UI.Xaml.Hosting.ElementCompositionPreview", "SetElementChildVisual"))
            {
                _compositor      = ElementCompositionPreview.GetElementVisual(this).Compositor;
                _hostSprite      = _compositor.CreateSpriteVisual();
                _hostSprite.Size = new Vector2((float)panel.ActualWidth, (float)panel.ActualHeight);

                ElementCompositionPreview.SetElementChildVisual(panel, _hostSprite);
                var b = _compositor.CreateHostBackdropBrush();
                _hostSprite.Brush = _compositor.CreateHostBackdropBrush();
            }
        }
コード例 #11
0
        internal static void SetForeground(this UIElement element, object localValue)
        {
            switch (localValue)
            {
            case SolidColorBrush scb:
                element.SetStyle("color", scb.ColorWithOpacity.ToHexString());
                break;

            case GradientBrush gradient:
                element.SetStyle(
                    ("background", gradient.ToCssString(element.RenderSize)),
                    ("color", "transparent"),
                    ("background-clip", "text")
                    );
                break;

            case AcrylicBrush acrylic:
                acrylic.Apply(element);
                element.SetStyle("background-clip", "text");
                break;

            case UnsetValue uv:

            // TODO: support other foreground types
            default:
                element.ResetStyle("color", "background", "background-clip");
                AcrylicBrush.ResetStyle(element);
                break;
            }
        }
コード例 #12
0
        private void SetAcrylicBrush()
        {
            var dimGrayAcrylicBrush = new AcrylicBrush
            {
                BackgroundSource = AcrylicBackgroundSource.HostBackdrop,
                FallbackColor    = Colors.Transparent,
                TintColor        = Global.TinkColor,
                TintOpacity      = Global.TinkOpacity
            };
            //框架
            var rootGrid = Global.RootGrid;
            var rootRelativePanelAcrylic = (RelativePanel)rootGrid.Children[0];
            var rootSplit                    = (SplitView)rootGrid.Children[2];
            var autoSuggestGrid              = Global.AutoSuggestGrid;
            var iconsListViewGameData        = Global.IconsListViewGameData;
            var iconsListViewSettingAndAbout = Global.IconsListViewSettingAndAbout;

            rootRelativePanelAcrylic.Background = dimGrayAcrylicBrush;
            rootSplit.PaneBackground            = dimGrayAcrylicBrush;
            rootSplit.Background                    = dimGrayAcrylicBrush;
            autoSuggestGrid.Background              = dimGrayAcrylicBrush;
            iconsListViewGameData.Background        = dimGrayAcrylicBrush;
            iconsListViewSettingAndAbout.Background = dimGrayAcrylicBrush;
            //页面
            if (Global.SettingPageRootGrid != null)
            {
                Global.SettingPageRootGrid.Background = dimGrayAcrylicBrush;
            }
            RootStackPanel.Background = dimGrayAcrylicBrush;
        }
コード例 #13
0
ファイル: Utils.cs プロジェクト: kkmaple/ASUS-Router
            public static AcrylicBrush GetAcrylicBrush(AcrylicBackgroundSource acrylicBackground, Color TintColor, Color FallbackColor, double TintOpacity)
            {
                var brush = new AcrylicBrush();

                brush.BackgroundSource = acrylicBackground;
                brush.TintColor        = TintColor;
                brush.FallbackColor    = FallbackColor;
                brush.TintOpacity      = TintOpacity;
                return(brush);
            }
コード例 #14
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            _uisetting = new UISettings();
            _uisetting.ColorValuesChanged += OnColorValuesChanged;
            var bgcolor = _uisetting.GetColorValue(UIColorType.Accent);

            RootGrid.Background = new SolidColorBrush(bgcolor);
            var searchItem = (string)e.Parameter;

            if (string.IsNullOrEmpty(searchItem) == false && searchItem != "...")
            {
                VoiceSearch(searchItem);
            }
            //使用Fluent Design System
            if (Global.GetOsVersion() >= 16299)
            {
                //标题栏
                CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
                var titleBar = ApplicationView.GetForCurrentView().TitleBar;
                titleBar.ButtonBackgroundColor         = Colors.Transparent;
                titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
                titleBar.ButtonHoverBackgroundColor    = Colors.Gray;
                //汉堡菜单按钮和页面标题面板
                RootSplit.OpenPaneLength            = 240;
                RootRelativePanelAcrylic.Visibility = Visibility.Visible;
                RootRelativePanel.Visibility        = Visibility.Collapsed;

                if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.XamlCompositionBrushBase"))
                {
                    //dimGrayAcrylicBrush笔刷
                    var dimGrayAcrylicBrush = new AcrylicBrush
                    {
                        BackgroundSource = AcrylicBackgroundSource.HostBackdrop,
                        FallbackColor    = Colors.Transparent,
                        TintColor        = Global.TinkColor,
                        TintOpacity      = Global.TinkOpacity
                    };
                    RootRelativePanelAcrylic.Background = dimGrayAcrylicBrush;
                    RootSplit.PaneBackground            = dimGrayAcrylicBrush;
                    RootSplit.Background                    = dimGrayAcrylicBrush;
                    HamburgerGrid.BorderThickness           = new Thickness(0);
                    IconsListViewGameData.Background        = dimGrayAcrylicBrush;
                    IconsListViewGameData.BorderThickness   = new Thickness(0);
                    IconsListViewSettingAndAbout.Background = dimGrayAcrylicBrush;
                    AutoSuggestGrid.Background              = null;
                    //汉堡菜单Reveal
                    var buttonRevealStyle = (Style)Application.Current.Resources["ButtonRevealStyle"];
                    HamburgerButtonAcrylic.Style = buttonRevealStyle;

                    var listViewItemRevealStyle = (Style)Application.Current.Resources["ListViewItemRevealStyle"];
                    IconsListViewGameData.ItemContainerStyle        = listViewItemRevealStyle;
                    IconsListViewSettingAndAbout.ItemContainerStyle = listViewItemRevealStyle;
                }
            }
        }
コード例 #15
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            Password password = (Password)e.Parameter;

            ScoreTextBlock.Text = password.Score.ToString();

            titleBar = ApplicationView.GetForCurrentView().TitleBar;
            titleBar.ButtonForegroundColor = Windows.UI.Colors.White;

            backBrush = new AcrylicBrush()
            {
                BackgroundSource = AcrylicBackgroundSource.HostBackdrop, TintColor = (Windows.UI.Color)App.Current.Resources["SystemChromeMediumColor"], TintOpacity = 0.7, TintTransitionDuration = new TimeSpan(0, 0, 2)
            };
            switch (password.StrengthTier)
            {
            case PasswordStrengthTier.Weak:
                Background = backBrush;
                tintColor  = Windows.UI.Colors.Red;
                ScoreTextBlock.Foreground = new AcrylicBrush()
                {
                    BackgroundSource = AcrylicBackgroundSource.HostBackdrop, TintColor = Windows.UI.Colors.Red, TintOpacity = 0.7, FallbackColor = Windows.UI.Colors.Red
                };
                StrengthTierTextBlock.Text = "WEAK";
                break;

            case PasswordStrengthTier.Medium:
                Background = backBrush;
                tintColor  = Windows.UI.Colors.Orange;
                ScoreTextBlock.Foreground = new AcrylicBrush()
                {
                    BackgroundSource = AcrylicBackgroundSource.HostBackdrop, TintColor = Windows.UI.Colors.Orange, TintOpacity = 0.7, FallbackColor = Windows.UI.Colors.Orange
                };
                StrengthTierTextBlock.Text = "MEDIUM STRENGTH";
                break;

            case PasswordStrengthTier.Strong:
                Background = backBrush;
                tintColor  = Windows.UI.Colors.Green;
                ScoreTextBlock.Foreground = new AcrylicBrush()
                {
                    BackgroundSource = AcrylicBackgroundSource.HostBackdrop, TintColor = Windows.UI.Colors.Green, TintOpacity = 0.7, FallbackColor = Windows.UI.Colors.Green
                };
                StrengthTierTextBlock.Text = "STRONG";
                break;
            }

            DispatcherTimer timer = new DispatcherTimer()
            {
                Interval = new TimeSpan(0, 0, 0)
            };

            timer.Tick += (s, ev) => { backBrush.TintColor = tintColor; backBrush.FallbackColor = tintColor; timer.Stop(); };
            timer.Start();
        }
コード例 #16
0
        public AcrylicBrush GetAcrylicBrush(Color color)
        {
            var brush = new AcrylicBrush
            {
                TintColor        = color,
                BackgroundSource = AcrylicBackgroundSource.Backdrop,
                TintOpacity      = 0.5,
            };

            return(brush);
        }
コード例 #17
0
        public static AcrylicBrush ColorfulBrush(Color temp)
        {
            AcrylicBrush myBrush = new AcrylicBrush();

            myBrush.BackgroundSource = AcrylicBackgroundSource.HostBackdrop;
            myBrush.TintColor        = temp;
            myBrush.TintColor        = temp;
            myBrush.FallbackColor    = temp;
            myBrush.TintOpacity      = 0.8;
            return(myBrush);
        }
コード例 #18
0
        private void SetupLayout()
        {
            AcrylicBrush myBrush = new AcrylicBrush();

            myBrush.BackgroundSource = AcrylicBackgroundSource.HostBackdrop;
            myBrush.TintColor        = Color.FromArgb(150, 52, 152, 219);
            myBrush.FallbackColor    = Color.FromArgb(150, 52, 152, 219);
            myBrush.TintOpacity      = 0.6;

            LayoutRoot.Background = myBrush;
        }
コード例 #19
0
ファイル: Converters.cs プロジェクト: Dmaxzj/PocketBook
 public object Convert(object value, Type targetType, object parameter, string language)
 {
     Single money = (Single)value;
     // 247, 202, 76
     var color = Color.FromArgb((byte)255, (byte)247, (byte)202, (byte)76);
     var brush = new AcrylicBrush
     {
         TintColor = color,
         TintOpacity = 0.1
     };
     return brush;
 }
コード例 #20
0
        private void SetColorTheme(ColorThemeEnum colorTheme)
        {
            SetSettingsColor();

            string navViewTextBlockID      = "TextBlock" + colorTheme.ToString() + "Style";
            Style  navViewTextBlockIDStyle = (Style)Application.Current.Resources[navViewTextBlockID];

            string pageID = "Page" + colorTheme.ToString() + "Style";

            MainPagePage.Style = (Style)Application.Current.Resources[pageID];

            foreach (var item in MainPageNavView.MenuItems.OfType <NavigationViewItem>())
            {
                TextBlock contentBlock = (TextBlock)item.Content;
                contentBlock.Style = navViewTextBlockIDStyle;
            }

            /*string navViewSepID = "NavigationViewItemSeparator" + colorTheme.ToString() + "Style";
             * Style navViewSepIDStyle = (Style)Application.Current.Resources[navViewSepID];
             * foreach (var item in MainPageNavView.MenuItems.OfType<NavigationViewItemSeparator>())
             * {
             *  NavigationViewItemSeparator separator = (NavigationViewItemSeparator)item;
             *  //separator.Style = navViewSepIDStyle;
             *  separator.Foreground = new SolidColorBrush(Colors.Red);
             * }*/
            /*string iconElementID = "IconElement" + colorTheme.ToString() + "Style";
             * Style iconElementIDStyle = (Style)Application.Current.Resources[iconElementID];
             * NavigationViewItem navSettingsItem = (NavigationViewItem)MainPageNavView.SettingsItem;
             *
             * navSettingsItem.Icon.Style = iconElementIDStyle;*/

            string       navViewBrushID = colorTheme.ToString() + "Acrylic";
            AcrylicBrush acrylicBrush   = (AcrylicBrush)Application.Current.Resources[navViewBrushID];

            NavViewBackgroundBrush.TintColor = acrylicBrush.TintColor;

            string          appColorBrushID = "AltLow" + colorTheme.ToString();
            SolidColorBrush solidBrush      = (SolidColorBrush)Application.Current.Resources[appColorBrushID];

            Color appColor = solidBrush.Color;

            PointerOverNavViewBrush.Color = appColor;

            Windows.UI.ViewManagement.ApplicationView appView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
            appView.TitleBar.BackgroundColor               = appColor; // or {a: 255, r: 0, g: 0, b: 0}
            appView.TitleBar.InactiveBackgroundColor       = appColor;
            appView.TitleBar.ButtonBackgroundColor         = appColor;
            appView.TitleBar.ButtonHoverBackgroundColor    = appColor;
            appView.TitleBar.ButtonPressedBackgroundColor  = appColor;
            appView.TitleBar.ButtonInactiveBackgroundColor = appColor;
        }
コード例 #21
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     if (Global.GetOsVersion() >= 16299)
     {
         var dimGrayAcrylicBrush = new AcrylicBrush
         {
             BackgroundSource = AcrylicBackgroundSource.HostBackdrop,
             FallbackColor    = Colors.Transparent,
             TintColor        = Global.TinkColor,
             TintOpacity      = Global.TinkOpacity
         };
         CookingSimulatorGrid.Background = dimGrayAcrylicBrush;
     }
 }
コード例 #22
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            // Check version for Fluent Design
            try
            {
                if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.XamlCompositionBrushBase"))
                {
                    AcrylicBrush backBrush = new AcrylicBrush
                    {
                        BackgroundSource = AcrylicBackgroundSource.HostBackdrop,
                        TintColor        = Color.FromArgb(255, 246, 246, 246),
                        FallbackColor    = Color.FromArgb(255, 246, 246, 246),
                        TintOpacity      = 0.6
                    };
                    MainGrid.Background = backBrush;
                }
                else
                {
                    SolidColorBrush backBrush = new SolidColorBrush(Color.FromArgb(255, 246, 246, 246));
                    MainGrid.Background = backBrush;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }

            // Calculate today's date on Coptic calendar
            CopticDateDisplay.Text = GregorianDatePicker.Date.Date.ToCopticDate().ToString();

            // Set color for RemoteStatusDisplay
            RemoteStatusDisplay.Foreground = new SolidColorBrush(Colors.Gray);

            // Check if remote is connected

            /*if (Common.RemoteSocket == null)
             * {
             *  Common.IsConnected = false;
             *  RemoteStatusDisplay.Foreground = new SolidColorBrush(Colors.Gray);
             *  RemoteStatusDisplay.Text = "Not Connected";
             *  ConnectDeviceButton.Content = "Connect to Device";
             * }
             * else
             * {
             *  Common.IsConnected = true;
             *  ConnectDeviceButton.Content = "Disconnect";
             *  RemoteStatusDisplay.Foreground = new SolidColorBrush(Colors.Green);
             *  RemoteStatusDisplay.Text = "Connected to " + Common.RemoteInfo.Name;
             * }*/
        }
コード例 #23
0
 protected override async void OnNavigatedTo(NavigationEventArgs e)
 {
     if (Global.GetOsVersion() >= 16299)
     {
         var dimGrayAcrylicBrush = new AcrylicBrush
         {
             BackgroundSource = AcrylicBackgroundSource.HostBackdrop,
             FallbackColor    = Colors.Transparent,
             TintColor        = Global.TinkColor,
             TintOpacity      = Global.TinkOpacity
         };
         RootStackPanel.Background = dimGrayAcrylicBrush;
     }
     await Deserialize();
 }
コード例 #24
0
        public override void UpdateStyle(ReaderStyle inputStyle = null)
        {
            if (inputStyle != null)
            {
                ViewStyle = inputStyle;
            }
            var style = ViewStyle as TxtViewStyle;

            if (style.IsAcrylicBackground)
            {
                var opacity        = Convert.ToInt32(style.Background.A) / 255.0;
                var tempBackground = style.Background;
                tempBackground.A = 255;
                var acrylic = new AcrylicBrush()
                {
                    TintColor        = tempBackground,
                    TintOpacity      = opacity,
                    FallbackColor    = style.Background,
                    BackgroundSource = AcrylicBackgroundSource.HostBackdrop
                };
                Background = acrylic;
            }
            else
            {
                Background = new SolidColorBrush(style.Background);
            }
            foreach (var item in _displayContainer.Children)
            {
                if (item is RichTextBlock rtb)
                {
                    rtb.FontFamily = new FontFamily(style.FontFamily);
                    rtb.FontSize   = style.FontSize;
                    rtb.Foreground = new SolidColorBrush(style.Foreground);
                    rtb.LineHeight = style.LineHeight;
                    rtb.Margin     = style.Padding;
                    var title = rtb.Blocks.FirstOrDefault();
                    if (title != null)
                    {
                        title.FontSize = style.HeaderFontSize;
                        title.Margin   = style.HeaderMargin;
                    }
                }
                else if (item is RichTextBlockOverflow of)
                {
                    of.Margin = style.Padding;
                }
            }
        }
コード例 #25
0
        public Acrylic(Color color, double opacity = 0.6f)
        {
            this.color   = color;
            this.opacity = (float)opacity;

#if WINDOWS_16299
            if (App.UniversalApi >= 5 && Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.AcrylicBrush"))
            {
                var   acrylicBrush = new AcrylicBrush();
                Color tint         = color;
                tint.A = 0xFF;
                acrylicBrush.TintColor        = tint;
                acrylicBrush.TintOpacity      = opacity;
                acrylicBrush.FallbackColor    = color;
                acrylicBrush.BackgroundSource = AcrylicBackgroundSource.Backdrop;
                brush = acrylicBrush;
            }
#endif
        }
コード例 #26
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            Global.FrameTitle.Text = "人物";
            if (e.NavigationMode == NavigationMode.Back)
            {
                EntranceTransition.FromVerticalOffset = 0;
            }
            if (Global.GetOsVersion() >= 16299)
            {
                var dimGrayAcrylicBrush = new AcrylicBrush
                {
                    BackgroundSource = AcrylicBackgroundSource.HostBackdrop,
                    FallbackColor    = Colors.Transparent,
                    TintColor        = Global.TinkColor,
                    TintOpacity      = Global.TinkOpacity
                };
                CharacterStackPanel.Background = dimGrayAcrylicBrush;
            }
            var parameter = (List <string>)e.Parameter;

            await Deserialize();

            if (parameter == null || parameter.Count == 0)
            {
                return;
            }
            var _e = parameter[1];

            if (CharacterGridView.Items == null)
            {
                return;
            }
            foreach (var gridViewItem in _characterData)
            {
                var character = gridViewItem;
                if (character == null || character.Picture != _e)
                {
                    continue;
                }
                Frame.Navigate(typeof(CharacterDialog), character);
                break;
            }
        }
        void UpdateControl()
        {
            brush = new AcrylicBrush()
            {
                TintColor        = tintColor,
                TintOpacity      = tintOpacity,
                BackgroundSource = backgroundSource,
                FallbackColor    = fallbackColor
            };

            try
            {
                Control.GetType().GetProperty("Background").SetValue(Control, brush);
            }
            catch
            {
                Control.GetType().GetProperty("Fill").SetValue(Control, brush);
            }
        }
コード例 #28
0
 private async void SetBackground()
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         var backgroundBrush = new AcrylicBrush()
         {
             AlwaysUseFallback = AppSettings.AcrylicEnabled,
             BackgroundSource  = AcrylicBackgroundSource.HostBackdrop,
             FallbackColor     = AppSettings.AcrylicTheme.FallbackColor,
             TintColor         = AppSettings.AcrylicTheme.TintColor,
             TintOpacity       = AppSettings.AcrylicTheme.TintOpacity,
         };
         if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
         {
             backgroundBrush.TintLuminosityOpacity = 0.9;
         }
         Background = backgroundBrush;
     });
 }
コード例 #29
0
        private VisualTheme BuildTheme(string themeId, string nameResKey, bool lightTheme, Color accentColor)
        {
            AcrylicBrush backgroundAcrylic = new AcrylicBrush
            {
                BackgroundSource = AcrylicBackgroundSource.HostBackdrop,
                FallbackColor    = accentColor,
                TintColor        = accentColor,
                TintOpacity      = _setting.BackgroundTintOpacity,
            };
            AcrylicBrush backgroundAcrylic2 = new AcrylicBrush
            {
                BackgroundSource = AcrylicBackgroundSource.HostBackdrop,
                FallbackColor    = accentColor,
                TintColor        = accentColor,
                TintOpacity      = (_setting.BackgroundTintOpacity + .15) > 1 ? 1 : _setting.BackgroundTintOpacity + .15
            };
            AcrylicBrush inAppAcrylic = new AcrylicBrush
            {
                BackgroundSource = AcrylicBackgroundSource.Backdrop,
                FallbackColor    = accentColor,
                TintColor        = accentColor,
                TintOpacity      = (_setting.BackgroundTintOpacity + .05) > 1 ? 1 : _setting.BackgroundTintOpacity + .05
            };
            var    etheme            = (lightTheme) ? ElementTheme.Light : ElementTheme.Dark;
            string descriptionResKey = (lightTheme) ? "ThemeGeneralLightDescription" : "ThemeGeneralDarkDescription";
            var    theme             = new VisualTheme
            {
                ThemeId                 = themeId,
                FriendlyName            = _loader.GetString(nameResKey),
                Description             = _loader.GetString(descriptionResKey),
                Theme                   = etheme,
                BackgroundAcrylicBrush  = backgroundAcrylic,
                BackgroundAcrylicBrush2 = backgroundAcrylic2,
                InAppAcrylicBrush       = inAppAcrylic,
                SolidBackgroundBrush    = new SolidColorBrush(accentColor),
                PreviewBrush            = new SolidColorBrush(accentColor),
            };

            theme.BaseThemeBackgroundBrush    = etheme == ElementTheme.Dark ? new SolidColorBrush(Color.FromArgb(255, 28, 28, 28)) : new SolidColorBrush(Colors.White);
            _setting.afterTintOpacityChanged += theme.UpdateTintOpacity;
            return(theme);
        }
コード例 #30
0
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            var time  = ((TimeSpan)value).TotalMilliseconds;
            var brush = new AcrylicBrush {
                BackgroundSource = AcrylicBackgroundSource.Backdrop, TintOpacity = 0.6
            };

            if (time > 0.0)
            {
                brush.TintColor     = Color.FromArgb(255, 255, 40, 37);
                brush.FallbackColor = Color.FromArgb(255, 255, 40, 37);
            }
            else
            {
                brush.TintColor     = Color.FromArgb(255, 0, 179, 65);
                brush.FallbackColor = Color.FromArgb(255, 0, 179, 65);
            }

            return(brush);
        }