Inheritance: IUISettings
コード例 #1
0
        public MainPageViewModel()
        {
            var uiSettings = new Windows.UI.ViewManagement.UISettings();

            _AccentColor = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Accent);
            ApplicationViewTitleBar titlebar = ApplicationView.GetForCurrentView().TitleBar;

            titlebar.BackgroundColor       = _AccentColor;
            titlebar.ButtonBackgroundColor = _AccentColor;

            if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1, 0))
            {
                var statusBar = StatusBar.GetForCurrentView();
                statusBar.BackgroundColor   = _AccentColor;
                statusBar.ForegroundColor   = Colors.White;
                statusBar.BackgroundOpacity = 1;
            }

            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                _AccentColor = Colors.SkyBlue;
            }
            else
            {
                settings    = SettingsService.Instance;
                BindingDemo = new ObservableCollection <string>
                {
                    "Item 0", "Item 1", "Item 2"
                };
            }
        }
コード例 #2
0
        public SectionView()
        {
            this.InitializeComponent();

            VisualStateManager.GoToState(this, "ContentSteadyState", false);
            _uiSettings = new UISettings();
        }
コード例 #3
0
        public AccentProvider()
        {
            try
            {
                UISettings = new UISettings();

                UISettings.ColorValuesChanged += UISettings_ColorValuesChanged;

                UpdateColors();
            }
            // Due to a bug in the 10240 build of Windows 10 Mobile, the
            // accent color cannot be acquired using this method.
            // Until this is fixed, we'll have to fall back to a default
            // value.
            // This bug should be fixed by Windows 10 Mobile's release.
            catch (InvalidCastException)
            {
                UISettings = null;

                var theme = Application.Current == null ? ApplicationTheme.Dark : Application.Current.RequestedTheme;

                if (theme == ApplicationTheme.Light)
                {
                    BackgroundColor = Colors.White;
                    ForegroundColor = Colors.Black;
                }
                else if (theme == ApplicationTheme.Dark)
                {
                    BackgroundColor = Colors.Black;
                    ForegroundColor = Colors.White;
                }

                object accentColorObj;

                if (Application.Current != null &&
                    Application.Current.Resources.TryGetValue("SystemAccentColor", out accentColorObj) &&
                    accentColorObj is Color)
                {
                    AccentColor = (Color)accentColorObj;
                }
                else
                {
                    AccentColor = Colors.BlueViolet;
                }

                // This is almost certainly wrong - but it's a decent stop gap
                AccentDark3Color = MixColors(Colors.Black, AccentColor);
                AccentDark2Color = MixColors(AccentDark3Color, AccentColor);
                AccentDark1Color = MixColors(AccentDark2Color, AccentColor);

                AccentLight3Color = MixColors(Colors.White, AccentColor);
                AccentLight2Color = MixColors(AccentLight3Color, AccentColor);
                AccentLight1Color = MixColors(AccentLight2Color, AccentColor);

                ComplementColor = Color.FromArgb(0xFF,
                    (byte)(0xFF - AccentColor.R),
                    (byte)(0xFF - AccentColor.G),
                    (byte)(0xFF - AccentColor.B));
            }
        }
コード例 #4
0
        private void ViewModelOnOpenWebView(string html,int id)
        {
            //back nav
            ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(() =>
            {
                ViewModel.WebViewVisibility = false;
                ViewModel.ArticleIndexVisibility = true;
                ViewModelLocator.GeneralMain.CurrentStatus = ViewModel.PrevWorkMode != null &&
                                                      ViewModel.PrevWorkMode.Value == ArticlePageWorkMode.Articles
                    ? "Artilces"
                    : "News";
                ViewModel.CurrentNews = -1;
            }));
            //

            var uiSettings = new UISettings();
            var color = uiSettings.GetColorValue(UIColorType.Accent);
            var color1 = uiSettings.GetColorValue(UIColorType.AccentDark2);
            var color2 = uiSettings.GetColorValue(UIColorType.AccentLight2);
            var css = Css.Replace("AccentColourBase", "#" + color.ToString().Substring(3)).
                Replace("AccentColourLight", "#" + color2.ToString().Substring(3)).
                Replace("AccentColourDark", "#" + color1.ToString().Substring(3))
                .Replace("BodyBackgroundThemeColor",
                    Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "#2d2d2d" : "#e6e6e6")
                .Replace("BodyForegroundThemeColor",
                    Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "white" : "black").Replace(
                        "HorizontalSeparatorColor",
                        Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "#0d0d0d" : "#b3b3b3");
            if (!Settings.ArticlesDisplayScrollBar)
                css += CssRemoveScrollbar;
            css += "</style>";
            ArticleWebView.NavigateToString(css + Begin + html + "</div></body></html>");
        }
コード例 #5
0
        private static Color TitltBarButtonColor(UISettings uISettings)
        {
            var settingTheme = SettingHelper.GetValue <int>(SettingHelper.UI.THEME, 0);
            var uiSettings   = new Windows.UI.ViewManagement.UISettings();
            var color        = uiSettings.GetColorValue(UIColorType.Foreground);

            if (settingTheme != 0)
            {
                color = settingTheme == 1 ? Colors.Black : Colors.White;
            }
            return(color);
        }
コード例 #6
0
        public ArticlePage()
        {
            this.InitializeComponent();

            VisualStateManager.GoToState(this, "ContentNotLoadedState", false);

            // Simulate asynchronous loading of content
            _loadTimer = new DispatcherTimer();
            _loadTimer.Interval = TimeSpan.FromSeconds(0.55);
            _loadTimer.Tick += LoadTimer_Tick;

            _uiSettings = new UISettings();
        }
コード例 #7
0
        private string SetWindowsTheme()
        {
            Windows.UI.ViewManagement.UISettings DefaultTheme = new Windows.UI.ViewManagement.UISettings();
            string uiTheme = DefaultTheme.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background).ToString();

            if (uiTheme == "#FF000000")
            {
                return("Dark");
            }
            else // (uiTheme == "#FFFFFFFF")
            {
                return("Light");
            }
        }
コード例 #8
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            // Apply correct coloring when in High Contrast

            ViewManagement.AccessibilitySettings accessibilitySettings = new ViewManagement.AccessibilitySettings();
            if (!(accessibilitySettings.HighContrast) /*Off*/)
            {
                // Use default colors

                this.Background = new SolidColorBrush(Colors.Red);
                this.BorderBrush = new SolidColorBrush(Colors.Black);

                this.Circle4.Fill = new SolidColorBrush(Colors.Blue);
                this.Circle3.Fill = new SolidColorBrush(Colors.Green);
                this.Circle2.Fill = new SolidColorBrush(Colors.Yellow);
                this.Circle1.Fill = new SolidColorBrush(Colors.White);
                this.Circle4.Stroke = this.Circle3.Stroke = this.Circle2.Stroke = this.Circle1.Stroke = new SolidColorBrush(Colors.Black);
            }
            else
            {
                // Use High Contrast Colors

                ViewManagement.UISettings uiSettings = new ViewManagement.UISettings();

                switch (accessibilitySettings.HighContrastScheme)
                {
                    case "High Contrast Black":
                        this.Background = this.Circle4.Fill = this.Circle3.Fill = this.Circle2.Fill = this.Circle1.Fill = new SolidColorBrush(Colors.Black);
                        this.BorderBrush = this.Circle4.Stroke = this.Circle3.Stroke = this.Circle2.Stroke = this.Circle1.Stroke = new SolidColorBrush(Colors.White);
                        break;

                    case "High Contrast White":
                        this.Background = this.Circle4.Fill = this.Circle3.Fill = this.Circle2.Fill = this.Circle1.Fill = new SolidColorBrush(Colors.White);
                        this.BorderBrush = this.Circle4.Stroke = this.Circle3.Stroke = this.Circle2.Stroke = this.Circle1.Stroke = new SolidColorBrush(Colors.Black);
                        break;

                    default: // For all other High Contrast schemes
                        this.Background = new SolidColorBrush(uiSettings.UIElementColor(ViewManagement.UIElementType.ButtonFace));
                        this.BorderBrush = new SolidColorBrush(uiSettings.UIElementColor(ViewManagement.UIElementType.ButtonText));
                        this.Circle4.Fill = this.Circle3.Fill = this.Circle2.Fill = this.Circle1.Fill = new SolidColorBrush(uiSettings.UIElementColor(ViewManagement.UIElementType.Hotlight));
                        this.Circle4.Stroke = this.Circle3.Stroke = this.Circle2.Stroke = this.Circle1.Stroke = new SolidColorBrush(uiSettings.UIElementColor(ViewManagement.UIElementType.HighlightText));
                        break;
                }


            }
        }
コード例 #9
0
ファイル: TargetButton.xaml.cs プロジェクト: Team01/Win81App
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            // Apply correct coloring when in High Contrast

            ViewManagement.AccessibilitySettings accessibilitySettings = new ViewManagement.AccessibilitySettings();
            if (!(accessibilitySettings.HighContrast) /*Off*/)
            {
                // Use default colors

                this.Background  = new SolidColorBrush(Colors.Red);
                this.BorderBrush = new SolidColorBrush(Colors.Black);

                this.Circle4.Fill   = new SolidColorBrush(Colors.Blue);
                this.Circle3.Fill   = new SolidColorBrush(Colors.Green);
                this.Circle2.Fill   = new SolidColorBrush(Colors.Yellow);
                this.Circle1.Fill   = new SolidColorBrush(Colors.White);
                this.Circle4.Stroke = this.Circle3.Stroke = this.Circle2.Stroke = this.Circle1.Stroke = new SolidColorBrush(Colors.Black);
            }
            else
            {
                // Use High Contrast Colors

                ViewManagement.UISettings uiSettings = new ViewManagement.UISettings();

                switch (accessibilitySettings.HighContrastScheme)
                {
                case "High Contrast Black":
                    this.Background  = this.Circle4.Fill = this.Circle3.Fill = this.Circle2.Fill = this.Circle1.Fill = new SolidColorBrush(Colors.Black);
                    this.BorderBrush = this.Circle4.Stroke = this.Circle3.Stroke = this.Circle2.Stroke = this.Circle1.Stroke = new SolidColorBrush(Colors.White);
                    break;

                case "High Contrast White":
                    this.Background  = this.Circle4.Fill = this.Circle3.Fill = this.Circle2.Fill = this.Circle1.Fill = new SolidColorBrush(Colors.White);
                    this.BorderBrush = this.Circle4.Stroke = this.Circle3.Stroke = this.Circle2.Stroke = this.Circle1.Stroke = new SolidColorBrush(Colors.Black);
                    break;

                default:     // For all other High Contrast schemes
                    this.Background     = new SolidColorBrush(uiSettings.UIElementColor(ViewManagement.UIElementType.ButtonFace));
                    this.BorderBrush    = new SolidColorBrush(uiSettings.UIElementColor(ViewManagement.UIElementType.ButtonText));
                    this.Circle4.Fill   = this.Circle3.Fill = this.Circle2.Fill = this.Circle1.Fill = new SolidColorBrush(uiSettings.UIElementColor(ViewManagement.UIElementType.Hotlight));
                    this.Circle4.Stroke = this.Circle3.Stroke = this.Circle2.Stroke = this.Circle1.Stroke = new SolidColorBrush(uiSettings.UIElementColor(ViewManagement.UIElementType.HighlightText));
                    break;
                }
            }
        }
コード例 #10
0
        private bool IsLightTheme()
        {
            //get system current theme color, not the app theme
            var DefaultTheme = new Windows.UI.ViewManagement.UISettings();
            var uiTheme      = DefaultTheme.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background).ToString();

            if (uiTheme == "#FF000000")
            {
                RequestedTheme = ElementTheme.Dark;
                return(false);
            }
            else
            {
                RequestedTheme = ElementTheme.Light;
                return(true);
            }
        }
コード例 #11
0
        private async void webView_DOMContentLoaded(WebView sender, WebViewDOMContentLoadedEventArgs args)
        {
            try
            {
                // inject event handler to arbitrary page once the DOM is loaded
                // in this case add event handler to click on the main element
                //await webView.InvokeScriptAsync("eval", new[] { "NotifyApp.setKeyCombination(243);" });

                var    uiSettings = new Windows.UI.ViewManagement.UISettings();
                var    rgba       = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Accent);
                string colr       = rgba.R.ToString();
                string colg       = rgba.G.ToString();
                string colb       = rgba.B.ToString();

                //string fn = "javascript:(function(){var style = document.getElementById('customcss');if(!style){style = document.createElement('STYLE');}style.type='text/css';style.id='customcss';style.innerText = '#react-root div header div{background-color:#000!important}[role=banner] [role=button] span{color:#fff}[role=navigation]{display:none!important}[role=banner] form{display:none!important}#react-root div header nav{background-color:#000!important}main div [role=region]{background-color:#d5d1d1!important;color:#fff!important}main>div>div{background-color:#000!important}main div [role=article]{background-color:#272525!important}main div [role=article] [data-testid=tweet] span{color:#b1b1b1!important}[data-testid=sidebarColumn]{background-color:#000!important}[data-testid=sidebarColumn] div{background-color:#363636!important;color:#eee!important}';document.getElementsByTagName('HEAD')[0].appendChild(style);})()";
                string loading    = "div[aria-label^=\"Load\"] svg{color: " + colr + "," + colg + "," + colb + ")!important}";
                string csstyle    = "[role=banner] [role=navigation]{display:none!important}[role=banner] form{display:none!important}[role=banner] [role=button] svg{display:none!important}body{-ms-user-select: none!important}div[aria-label^=Load]{display: none!important}";
                string buttons    = "/*Rounded class*/.rn-qb5c1y{border-bottom-left-radius: 0;}.rn-sqtsar{border-bottom-right-radius: 0;}.rn-waaub4{border-top-right-radius: 0;}.rn-1bxrh7q{border-top-left-radius: 0;}";
                string postmedia  = ".rn-v31qbu{border-bottom-left-radius: 0;}.rn-1mm01xx{border-bottom-right-radius: 0;}.rn-3mf89h{border-top-right-radius: 0;}.rn-12oo7hk{border-top-left-radius: 0;}";
                string lightbox   = ".rn-17ru5vd{border-bottom-left-radius: 0;}.rn-21wlf0{border-bottom-right-radius: 0;}.rn-1a1bgtt{border-top-right-radius: 0;}.rn-1nul30p{border-top-left-radius: 0;}";
                string buttoncol  = ".rn-8184n4 {color: rgb(" + colr + "," + colg + "," + colb + ")}.rn-162msjx {border-left-color: rgb(" + colr + "," + colg + "," + colb + ")}.rn-11kq4yi {border-bottom-color: rgb(" + colr + "," + colg + "," + colb + ")}.rn-biwm0c {border-right-color: rgb(" + colr + "," + colg + "," + colb + ")}.rn-1vhfjxp {border-top-color: rgb(" + colr + "," + colg + "," + colb + ")}";
                string navcolors  = ".Pdo9ySC3::after {background-color: rgb(" + colr + "," + colg + "," + colb + ")}.Pdo9ySC3{color: #25974f!important}._3XRskxP3:hover, .Pdo9ySC3 {color: rgb(" + colr + "," + colg + "," + colb + ")}";
                string bgcolor    = ".rn-10pympv {background-color: rgb(" + colr + "," + colr + "," + colb + ")}";
                string linkcolor  = ".rn-wjcbme {color: rgb(" + colr + "," + colg + "," + colb + ")}._3fUfiuOH {color: rgb(" + colr + "," + colg + "," + colb + ")}";
                string navcolors2 = ".COfxu8s-._2t1-zb7t{border-bottom-color: rgb(" + colr + "," + colg + "," + colb + "); color: rgb(" + colr + "," + colg + "," + colb + ");}.COfxu8s-._2t1-zb7t:hover{border-bottom-color: rgb(" + colr + "," + colg + "," + colb + "); color: rgb(" + colr + "," + colg + "," + colb + ");}.COfxu8s-:hover {color: rgb(" + colr + "," + colg + "," + colb + ")}";
                //string likecolor = ".rn-c4vgha {color: rgb(" + colr + "," + colg + "," + colb + ")!important}";

                string fn = "javascript:(function(){var style = document.getElementById('customcss');if(!style){style = document.createElement('STYLE');}style.type='text/css';style.id='customcss';style.innerText = '"
                            + loading
                            + csstyle
                            + buttons
                            + postmedia
                            + lightbox
                            + buttoncol
                            + navcolors
                            + bgcolor
                            + linkcolor
                            + navcolors2
                            + "';document.getElementsByTagName('HEAD')[0].appendChild(style);})()";
                this.webView.InvokeScriptAsync("eval", new string[] { fn });
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }
        }
コード例 #12
0
 public static async Task SetTitleBar()
 {
     await Window.Current.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         UISettings uiSettings = new UISettings();
         try
         {
             ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
             titleBar.BackgroundColor = uiSettings.GetColorValue(UIColorType.Accent);
             titleBar.InactiveBackgroundColor = uiSettings.GetColorValue(UIColorType.AccentDark1);
             titleBar.ButtonBackgroundColor = uiSettings.GetColorValue(UIColorType.Accent);
             titleBar.ButtonInactiveBackgroundColor = uiSettings.GetColorValue(UIColorType.AccentDark1);
             titleBar.ButtonHoverBackgroundColor = uiSettings.GetColorValue(UIColorType.AccentLight1);
             titleBar.ButtonHoverForegroundColor = uiSettings.GetColorValue(UIColorType.Accent);
             titleBar.ButtonPressedBackgroundColor = uiSettings.GetColorValue(UIColorType.AccentLight3);
         }
         catch (InvalidCastException)
         {
         }
     });
 }
コード例 #13
0
 private void ViewModelOnOnWebViewNavigationRequest(string content, bool b)
 {
     var uiSettings = new UISettings();
     var color = uiSettings.GetColorValue(UIColorType.Accent);
     var color1 = uiSettings.GetColorValue(UIColorType.AccentDark2);
     var color2 = uiSettings.GetColorValue(UIColorType.AccentLight2);
     var css = MalArticlesPage.Css.Replace("AccentColourBase", "#" + color.ToString().Substring(3)).
         Replace("AccentColourLight", "#" + color2.ToString().Substring(3)).
         Replace("AccentColourDark", "#" + color1.ToString().Substring(3))
         .Replace("BodyBackgroundThemeColor",
             Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "#2d2d2d" : "#e6e6e6")
         .Replace("BodyForegroundThemeColor",
             Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "white" : "black").Replace(
                 "HorizontalSeparatorColor",
                 Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "#0d0d0d" : "#b3b3b3");
     css += "</style>";
     if (content.Length < 400)
         AboutMeWebView.Height = 300;
     else if (content.Length < 800)
         AboutMeWebView.Height = 500;
     else
         AboutMeWebView.Height = 800;
     AboutMeWebView.NavigateToString(css + content);
 }
コード例 #14
0
ファイル: Scenario3.xaml.cs プロジェクト: mbin/Win81App
        // Plots a graph of the passed easing function using the given sampling interval on the "Graph" Canvas control 
        private void PlotEasingFunctionGraph(EasingFunctionBase easingFunction, double samplingInterval)
        {
            UISettings UserSettings = new UISettings();
            Graph.Children.Clear();

            Path path = new Path();
            PathGeometry pathGeometry = new PathGeometry();
            PathFigure pathFigure = new PathFigure() { StartPoint = new Point(0, 0) };
            PathSegmentCollection pathSegmentCollection = new PathSegmentCollection();

            // Note that an easing function is just like a regular function that operates on doubles.
            // Here we plot the range of the easing function's output on the y-axis of a graph.
            for (double i = 0; i < 1; i += samplingInterval)
            {
                double x = i * GraphContainer.Width;
                double y = easingFunction.Ease(i) * GraphContainer.Height;

                LineSegment segment = new LineSegment();
                segment.Point = new Point(x, y);
                pathSegmentCollection.Add(segment);
            }

            pathFigure.Segments = pathSegmentCollection;
            pathGeometry.Figures.Add(pathFigure);
            path.Data = pathGeometry;
            path.Stroke = new SolidColorBrush(UserSettings.UIElementColor(UIElementType.ButtonText));
            path.StrokeThickness = 1;

            // Add the path to the Canvas
            Graph.Children.Add(path);
        }
コード例 #15
0
ファイル: TitleBar.xaml.cs プロジェクト: mcooley/calculator
 private void ColorValuesChanged(Windows.UI.ViewManagement.UISettings sender, object e)
 {
     _ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(() => { SetTitleBarControlColors(); }));
 }
コード例 #16
0
        private async void TopicWebView_OnDOMContentLoaded(WebView sender, WebViewDOMContentLoadedEventArgs args)
        {
            var uiSettings = new UISettings();
            var color = uiSettings.GetColorValue(UIColorType.Accent);
            //this chain of commands will remove unnecessary stuff
            string bodyLight = Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "#3d3d3d" : "#d0d0d0";
            string bodyLighter = Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "#2f2f2f" : "#e6e6e6";
            string bodyDarker = Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "#212121" : "#cacaca";
            string fontColor = Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "white" : "black";
            string fontColorInverted = Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "black" : "white";

            var zoom = 100*ActualWidth/500;
            _prevSize = new Size(ActualWidth, ActualHeight);
            List<string> commands;
            if (_args.CreateNewTopic)
            {
                commands = new List<string>
                {
                    @"document.getElementById(""headerSmall"").outerHTML='';document.getElementById(""menu"").outerHTML='';document.getElementsByClassName(""js-sns-icon-container icon-block-small"")[0].outerHTML='';document.getElementsByTagName(""footer"")[0].innerHTML='';document.getElementsByClassName(""mauto clearfix pt24"")[0].outerHTML='';",
                    @"$(""#contentWrapper"").find('div:first').remove();",
                    $@"$(""#contentWrapper"").css(""background-color"", ""{bodyLighter}"").css(""width"", ""700px"");;",
                    $@"$(""body"").css(""font-family"", ""Segoe UI"").css(""color"", ""{fontColor}"").css(""background-color"", ""{bodyLighter}"").css(""width"", ""700px"");;",
                    @"$(""footer"").remove()",
                    $@"$(""textarea"").css(""background-color"",""{bodyDarker}"").css(""color"", ""{fontColor}"")",
                    $@"$(""td"").css(""color"", ""{fontColor}"")",
                    $@"$(""a"").css(""color"", ""#{color.ToString().Substring(3)}"");",
                    $@"$(""#content"").css(""border-color"", ""{bodyLighter}"").css(""background-color"",""{bodyLighter}"");",
                    $@"$(""html"").css(""zoom"", ""{Math.Floor(zoom)}%"").css(""background-color"", ""{bodyLighter}"").css(""width"", ""700px"");",
                    @"$(""iframe"").remove()",
                    $@"$(""#dialog"").css(""border-color"", ""{bodyLight}"")",
                    $@"$(""td"").css(""border-color"", ""{bodyDarker}"")",
                    $@"$("".inputtext"").css(""background-color"", ""{bodyDarker}"").css(""color"", ""{fontColor}"")",
                    $@"$("".normal_header"").css(""color"", ""{fontColor}"")",
                    $@"$("".inputButton"").css(""background-color"", ""{bodyLight}"").css(""border-color"",""{fontColorInverted}"");",
                    $@"$("".bgbdrContainer"").css(""background-color"", ""{bodyDarker}"").css(""border-color"",""{fontColorInverted}"");",
                };
            }
            else
            {
                commands = new List<string>
                {
                    @"$("".header"").remove();
                      $(""iframe"").remove();
                      $("".select.filter-sort"").remove();
                      $("".anchor-ad"").remove();
                      $(""footer"").remove();
                      $("".page-title"").remove();
                      $("".sns-unit"").remove();",
                    $@"$(""a"").css(""color"", ""#{color.ToString().Substring(3)}"");",
                    $@"$("".comment-title"").css(""background-color"",""{bodyLighter}"")",
                    $@"$("".breadcrumb"").css(""background-color"",""{bodyLighter}"")",       
                    $@"$("".num"").removeClass().css(""font-size"",""30px"").css(""color"", ""{fontColor}"").css(""margin"", ""13px"")",
                    $@"$("".icon-next"").not(""a.prev"").removeClass().css(""font-size"",""30px"").html(""»"")",
                    $@"$("".icon-next.prev"").css(""font-size"",""20px"").removeClass().html(""«"")",
                    $@"$("".db-ib"").removeClass().css(""font-size"",""30px"").css(""color"",""#{color.ToString().Substring(3)}"")",
                    $@"$("".btn-post-comment"").css(""background-color"",""{bodyLight}"").css(""color"", ""{fontColor}"").css(""border-color"", ""{bodyDarker}"")",
                    $@"$(""body"").css(""font-family"", ""Segoe UI"").css(""color"", ""{fontColor}"").css(""background-color"", ""{bodyLighter}"");",
                };
            }
            
            foreach (var command in commands)
            {
                try
                {
                    await TopicWebView.InvokeScriptAsync("eval", new string[] {command});
                }
                catch (Exception)
                {
                    //htm.. no it's javascript this time oh, how fun!
                }

            }
            ViewModel.LoadingTopic = false;
        }
コード例 #17
0
        private async void TopicWebView_OnDOMContentLoaded(WebView sender, WebViewDOMContentLoadedEventArgs args)
        {
            var uiSettings = new UISettings();
            var color = uiSettings.GetColorValue(UIColorType.Accent);
            //this chain of commands will remove unnecessary stuff
            string bodyLight = Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "#3d3d3d" : "#d0d0d0";
            string bodyLighter = Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "#2f2f2f" : "#e6e6e6";
            string bodyDarker = Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "#212121" : "#cacaca";
            string fontColor = Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "white" : "black";
            string fontColorInverted = Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "black" : "white";

            var zoom = 100*ActualWidth/(_args.CreateNewTopic ? 800 : 1060);
            _prevSize = new Size(ActualWidth, ActualHeight);
            List<string> commands;
            if (_args.CreateNewTopic)
            {
                commands = new List<string>
                {
                    @"document.getElementById(""headerSmall"").outerHTML='';document.getElementById(""menu"").outerHTML='';document.getElementsByClassName(""js-sns-icon-container icon-block-small"")[0].outerHTML='';document.getElementsByTagName(""footer"")[0].innerHTML='';document.getElementsByClassName(""mauto clearfix pt24"")[0].outerHTML='';",
                    @"$(""#contentWrapper"").find('div:first').remove();",
                    $@"$(""#contentWrapper"").css(""background-color"", ""{bodyLighter}"");",
                    $@"$(""body"").css(""font-family"", ""Segoe UI"").css(""color"", ""{fontColor}"").css(""background-color"", ""{bodyLighter}"");",
                    @"$(""footer"").remove()",
                    @"$(""input[name='preview']:first"").remove()",
                    $@"$(""textarea"").css(""background-color"",""{bodyDarker}"").css(""color"", ""{fontColor}"")",
                    $@"$(""td"").css(""color"", ""{fontColor}"")",
                    $@"$(""a"").css(""color"", ""#{color.ToString().Substring(3)}"");",
                    $@"$(""#content"").css(""border-color"", ""{bodyLighter}"").css(""background-color"",""{bodyLighter}"");",
                    $@"$(""html"").css(""zoom"", ""{Math.Floor(zoom)}%"").css(""background-color"", ""{bodyLighter}"");",
                    @"$(""iframe"").remove()",
                    $@"$(""#dialog"").css(""border-color"", ""{bodyLight}"")",
                    $@"$(""td"").css(""border-color"", ""{bodyDarker}"")",
                    $@"$("".inputtext"").css(""background-color"", ""{bodyDarker}"").css(""color"", ""{fontColor}"")",
                    $@"$("".normal_header"").css(""color"", ""{fontColor}"")",
                    $@"$("".inputButton"").css(""background-color"", ""{bodyLight}"").css(""border-color"",""{fontColorInverted}"");",
                    $@"$("".bgbdrContainer"").css(""background-color"", ""{bodyDarker}"").css(""border-color"",""{fontColorInverted}"");",
                };
            }
            else
            {
                commands = new List<string>
                {
                    @"document.getElementById(""headerSmall"").outerHTML='';document.getElementById(""menu"").outerHTML='';document.getElementsByClassName(""js-sns-icon-container icon-block-small"")[0].outerHTML='';document.getElementsByTagName(""footer"")[0].innerHTML='';document.getElementsByClassName(""mauto clearfix pt24"")[0].outerHTML='';",
                    @"$(""#contentWrapper"").find('div:first').remove();",                 
                    @"$(""div[id^="" +""ad-skin"" + ""]"").remove();",
                    $@"$(""#contentWrapper"").css(""background-color"", ""{bodyLighter}"");",
                    $@"$(""body"").css(""font-family"", ""Segoe UI"").css(""color"", ""{fontColor}"").css(""background-color"", ""{bodyLighter}"");",
                    $@"$(""td"").css(""background-color"", ""{bodyDarker}"").css(""border-color"", ""{bodyDarker}"");",
                    $@"$("".forum_boardrow2"").css(""background-color"", ""{bodyDarker}"");",
                    $@"$("".forum_boardrow1"").css(""background-color"", ""{bodyLighter}"").css(""border-color"",""{fontColorInverted}"");",
                    $@"$("".forum_category"").css(""background-color"", ""{bodyLight}"");",
                    $@"$("".forum_boardrowspacer"").css(""background-color"", ""{bodyLighter}"");",
                    $@"$("".btn-forum"").css(""background-color"", ""{bodyLight}"").css(""border-color"",""{fontColorInverted}"");",
                    $@"$(""html"").css(""zoom"", ""{Math.Floor(zoom)}%"");",
                    @"$("".wrapper"").find("".fl-r.ar"").remove()",
                    $@"$("".inputButton"").css(""border-color"",""{fontColorInverted}"").css(""background-color"",""{bodyLight}"")",
                    $@"$(""a"").css(""color"", ""#{color.ToString().Substring(3)}"");",
                    $@"$(""#content"").css(""border-color"", ""{bodyLighter}"").css(""background-color"",""{bodyLighter}"");",
                    $@"$("".forum_category,.forum_locheader"").css(""color"",""{fontColor}"");",
                    $@"$("".codetext"").css(""background-color"",""{bodyDarker}"");",
                    $@"$("".quotetext"").css(""background-color"",""{bodyLight}"").css(""border-color"",""{bodyLighter}"");",
                    $@"$("".vote_container"").css(""background-color"",""#{color.ToString().Substring(3)}"")",
                    $@"$(""textarea"").css(""background-color"",""{bodyDarker}"").css(""color"", ""{fontColor}"")",
                    
                };
            }
            
            foreach (var command in commands)
            {
                try
                {
                    await TopicWebView.InvokeScriptAsync("eval", new string[] {command});
                }
                catch (Exception)
                {
                    //htm.. no it's javascript this time oh, how fun!
                }

            }
            ViewModel.LoadingTopic = false;
        }
コード例 #18
0
 public UISettingsEvents(UISettings This)
 {
     this.This = This;
 }