Example #1
0
        static void InitDefaultTheme()
        {
            var accentColor              = Color.FromArgb(255, 0xFF, 0xB6, 0xC1);
            var secondaryAccentColor     = accentColor;
            var backgroundColor          = Colors.White;
            var secondaryBackgroundColor = backgroundColor;
            var foregroundColor          = Colors.Black;
            var foregroundTextColor      = Color.FromArgb(0xC8, 80, 80, 80);
            var disableColor             = Color.FromArgb(0x66, 0x00, 0x00, 0x00);

            _accentBrush              = new SolidColorBrush(accentColor);
            _accentTransparentBrush   = new SolidColorBrush(Color.FromArgb(Opacity, accentColor.R, accentColor.G, accentColor.B));
            _secondaryAccentBrush     = new SolidColorBrush(secondaryAccentColor);
            _backgroundBrush          = new SolidColorBrush(backgroundColor);
            _secondaryBackgroundBrush = new SolidColorBrush(secondaryBackgroundColor);
            _foregroundBrush          = new SolidColorBrush(foregroundColor);
            _foregroundTextBrush      = new SolidColorBrush(foregroundTextColor);
            _disableBrush             = new SolidColorBrush(disableColor);
            _pointerOverBrush         = new SolidColorBrush(accentColor);
            _subtleBrush              = new SolidColorBrush(Color.FromArgb(72, 72, 72, 72));
            _contrastAccentBrush      = new SolidColorBrush(Colors.White);

            var g = new LanguageFontGroup(CultureInfo.CurrentUICulture.Name);

            _appFontFamily = new FontFamily(g.UITextFont.FontFamily);
        }
Example #2
0
        /// <summary>
        /// This is the click handler for the 'Scenario1InputButton' button.  You would replace this with your own handler
        /// if you have a button or buttons on this page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Scenario1InputButton_Click(object sender, RoutedEventArgs e)
        {
            Button b = sender as Button;

            if (b != null)
            {
                var languageFontGroup = new LanguageFontGroup("ja-JP");
                var headingUI         = (Windows.UI.Xaml.Controls.TextBlock) this.Scenario1Heading;
                var textUI            = (Windows.UI.Xaml.Controls.TextBlock) this.Scenario1Text;

                if (this.oriHeadingUI == null)
                {
                    // Store original font style for Reset
                    this.oriHeadingUI = new LocalFontInfo();
                    this.oriTextUI    = new LocalFontInfo();
                    this.oriHeadingUI.Set(headingUI);
                    this.oriTextUI.Set(textUI);
                }

                // Change the Font value with selected font from LanguageFontGroup API
                this.SetFont(headingUI, languageFontGroup.UIHeadingFont);
                this.SetFont(textUI, languageFontGroup.UITextFont);

                this.Output.Visibility = Visibility.Visible;
            }
        }
        private void ApplyFonts_Click(object sender, RoutedEventArgs e)
        {
            var languageFontGroup = new LanguageFontGroup("ja-JP");

            // Change the Font value with selected font from LanguageFontGroup API
            MainPage.ApplyLanguageFont(HeadingTextBlock, languageFontGroup.UIHeadingFont);
            MainPage.ApplyLanguageFont(BodyTextBlock, languageFontGroup.UITextFont);
        }
        private void ApplyFonts_Click(object sender, RoutedEventArgs e)
        {
            var languageFontGroup = new LanguageFontGroup("hi");

            MainPage.ApplyLanguageFont(HeadingTextBlock, languageFontGroup.DocumentHeadingFont);

            // Not all scripts have recommended fonts for "document alternate"
            // categories, so need to verify before using it. Note that Hindi does
            // have document alternate fonts, so in this case the fallback logic is
            // unnecessary, but (for example) Japanese does not have recommendations
            // for the document alternate 2 category.
            MainPage.ApplyLanguageFont(DocumentTextBlock,
                                       languageFontGroup.DocumentAlternate2Font ??
                                       languageFontGroup.DocumentAlternate1Font ??
                                       languageFontGroup.ModernDocumentFont);
        }
        /// <summary>
        /// This is the click handler for the 'Scenario2InputButton' button.  You would replace this with your own handler
        /// if you have a button or buttons on this page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Scenario2InputButton_Click(object sender, RoutedEventArgs e)
        {
            Button b = sender as Button;

            if (b != null)
            {
                var languageFontGroup = new LanguageFontGroup("hi");
                var headingUI         = (Windows.UI.Xaml.Controls.TextBlock) this.Scenario2Heading;
                var textUI            = (Windows.UI.Xaml.Controls.TextBlock) this.Scenario2Text;

                if (this.oriHeadingDoc == null)
                {
                    this.oriHeadingDoc = new LocalFontInfo();
                    this.oriTextDoc    = new LocalFontInfo();
                    this.oriHeadingDoc.Set(headingUI);
                    this.oriTextDoc.Set(textUI);
                }

                this.SetFont(headingUI, languageFontGroup.DocumentHeadingFont);

                // Not all scripts have recommended fonts for "document alternate"
                // categories, so need to verify before using it. Note that Hindi does
                // have document alternate fonts, so in this case the fallback logic is
                // unnecessary, but (for example) Japanese does not have recommendations
                // for the document alternate 2 category.
                if (languageFontGroup.DocumentAlternate2Font != null)
                {
                    this.SetFont(textUI, languageFontGroup.DocumentAlternate2Font);
                }
                else if (languageFontGroup.DocumentAlternate1Font != null)
                {
                    this.SetFont(textUI, languageFontGroup.DocumentAlternate1Font);
                }
                else
                {
                    this.SetFont(textUI, languageFontGroup.ModernDocumentFont);
                }

                this.Output.Visibility = Visibility.Visible;
            }
        }
        public MainPage()
        {
            this.InitializeComponent();

            // Set brushes
            textBlockBrush = Resources["ApplicationForegroundThemeBrush"] as SolidColorBrush;
            textBoxBrush   = Resources["TextBoxForegroundThemeBrush"] as SolidColorBrush;
            errorBrush     = new SolidColorBrush(Colors.Red);

            // Why aren't these set in the generated C# files?
            editBox         = splitContainer.Child1 as TabbableTextBox;
            resultContainer = splitContainer.Child2 as RulerContainer;

            // Set a fixed-pitch font for the TextBox
            Language          language          = new Language(Windows.Globalization.Language.CurrentInputMethodLanguageTag);
            LanguageFontGroup languageFontGroup = new LanguageFontGroup(language.LanguageTag);
            LanguageFont      languageFont      = languageFontGroup.FixedWidthTextFont;

            editBox.FontFamily = new FontFamily(languageFont.FontFamily);

            Loaded += OnLoaded;
            Application.Current.Suspending += OnApplicationSuspending;
        }