Exemplo n.º 1
0
        public TypefaceListItem(Typeface typeface)
        {
            _displayName = GetDisplayName(typeface);
            _simulated = typeface.IsBoldSimulated || typeface.IsObliqueSimulated;

            this.FontFamily = typeface.FontFamily;
            this.FontWeight = typeface.Weight;
            this.FontStyle = typeface.Style;
            this.FontStretch = typeface.Stretch;

            string itemLabel = _displayName;

            if (_simulated)
            {
                string formatString = Properties.FontDialogResources.ResourceManager.GetString(
                    "simulated", 
                    CultureInfo.CurrentUICulture
                    );
                itemLabel = string.Format(formatString, itemLabel);
            }

            Text = itemLabel;
            ToolTip = itemLabel;

            // In the case of symbol font, apply the default message font to the text so it can be read.
            if (FontFamilyListItem.IsSymbolFont(typeface.FontFamily))
            {
                var range = new TextRange(ContentStart, ContentEnd);
                range.ApplyPropertyValue(TextBlock.FontFamilyProperty, SystemFonts.MessageFontFamily);
            }
        }
Exemplo n.º 2
0
 private void newRoom_OnParticipantJoin(Room room, RoomParticipant participant)
 {
     Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
     {
         var tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd)
         {
             Text = participant.Nick + " joined the room." + Environment.NewLine
         };
         tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Yellow);
     }));
 }
        public void ChangeColor(Color l, RichTextBox richBox, string keyword, float score)
        {
            //设置文字指针为Document初始位置
            //richBox.Document.FlowDirection
            if (position == null)
            {
                position = richBox.Document.ContentStart;
            }
            while (position != null)
            {
                //向前搜索,需要内容为Text
                if (position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text)
                {
                    //拿出Run的Text
                    string text = position.GetTextInRun(LogicalDirection.Forward).ToLower();
                    //可能包含多个keyword,做遍历查找
                    int index = 0;
                    index = text.IndexOf(keyword, 0);
                    if (index != -1)
                    {
                        TextPointer start = position.GetPositionAtOffset(index);
                        TextPointer end   = start.GetPositionAtOffset(keyword.Length);
                        TextRange   range = richBox.Selection;
                        range.Select(start, end);
                        //高亮
                        range.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(l));
                        range.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);

                        Run run        = new Run(score + "", end);
                        var scoreRange = new TextRange(end, end.GetPositionAtOffset(5));
                        scoreRange.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(l));
                        scoreRange.ApplyPropertyValue(Run.BaselineAlignmentProperty, BaselineAlignment.Superscript); //上标

                        position = end.GetNextContextPosition(LogicalDirection.Forward);                             //将指针移到//找到了keyword的位置就将指针移到高亮显示的文字的末尾作为下一次搜索的开始
                        break;
                    }
                }
                //文字指针向前偏移
                position = position.GetNextContextPosition(LogicalDirection.Forward);
            }
        }
Exemplo n.º 4
0
 //设置报错行号为红色
 private void ErrorRedInLine(RichTextBox richTextBox, ArrayList errInfo)
 {
     foreach (Error e in errInfo)
     {
         string errorLienNum = e.line;
         if (errorLienNum == "")
         {
             continue;
         }
         TextPointer textPointer = richTextBox.Document.ContentStart;
         while (textPointer != null)
         {
             if (textPointer.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text)
             {
                 string text  = textPointer.GetTextInRun(LogicalDirection.Forward);
                 int    index = 0;
                 while (index < text.Length)
                 {
                     index = text.IndexOf(errorLienNum, index);
                     if (index == -1)
                     {
                         break;
                     }
                     else
                     {
                         TextPointer start     = textPointer.GetPositionAtOffset(index);
                         TextPointer end       = start.GetPositionAtOffset(errorLienNum.Length);
                         TextRange   textRange = richTextBox.Selection;
                         textRange.Select(start, end);
                         textRange.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(Colors.Red));
                         textRange.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);
                         textRange.Select(richTextBox.Document.ContentEnd, richTextBox.Document.ContentEnd);
                         textRange.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(Colors.Black));
                         index += errorLienNum.Length;
                     }
                 }
             }
             textPointer = textPointer.GetNextContextPosition(LogicalDirection.Forward);
         }
     }
 }
        public void ChangeColor(Color l, RichTextBox richBox, string keyword, float score)
        {
            //Set the text pointer to the initial position of the Document.
            //richBox.Document.FlowDirection
            if (position == null)
            {
                position = richBox.Document.ContentStart;
            }
            while (position != null)
            {
                //Search forward, need content for Text
                if (position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text)
                {
                    //Take out Run's Text.
                    string text = position.GetTextInRun(LogicalDirection.Forward).ToLower();
                    //may contain more than one keyword, do an iterative search
                    int index = 0;
                    index = text.IndexOf(keyword, 0);
                    if (index != -1)
                    {
                        TextPointer start = position.GetPositionAtOffset(index);
                        TextPointer end   = start.GetPositionAtOffset(keyword.Length);
                        TextRange   range = richBox.Selection;
                        range.Select(start, end);
                        //high brightness
                        range.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(l));
                        range.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);

                        Run run        = new Run(score + "", end);
                        var scoreRange = new TextRange(end, end.GetPositionAtOffset(5));
                        scoreRange.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(l));
                        scoreRange.ApplyPropertyValue(Run.BaselineAlignmentProperty, BaselineAlignment.Superscript); //superscript

                        position = end.GetNextContextPosition(LogicalDirection.Forward);                             //Move the pointer to // the end of the highlighted text as the start of the next search once the keyword is found
                        break;
                    }
                }
                //Move the text pointer forward
                position = position.GetNextContextPosition(LogicalDirection.Forward);
            }
        }
Exemplo n.º 6
0
    /// <summary>
    /// Is manipulating a specific string inside of a TextPointer Range (TextBlock, TextBox...)
    /// </summary>
    /// <param name="startPointer">Starting point where to look</param>
    /// <param name="endPointer">Endpoint where to look</param>
    /// <param name="keyword">This is the string you want to manipulate</param>
    /// <param name="fontStyle">The new FontStyle</param>
    /// <param name="fontWeight">The new FontWeight</param>
    /// <param name="fontSize">The new FontSize</param>
    /// <param name="newString">The New String (if you want to replace, can be null)</param>
    public static void FromTextPointer(TextPointer startPointer, TextPointer endPointer, string keyword, FontStyle fontStyle, FontWeight fontWeight, double fontSize, string newString)
    {
        if (startPointer == null)
        {
            throw new ArgumentNullException(nameof(startPointer));
        }
        if (endPointer == null)
        {
            throw new ArgumentNullException(nameof(endPointer));
        }
        if (string.IsNullOrEmpty(keyword))
        {
            throw new ArgumentNullException(keyword);
        }
        TextRange   text    = new TextRange(startPointer, endPointer);
        TextPointer current = text.Start.GetInsertionPosition(LogicalDirection.Forward);

        while (current != null)
        {
            string textInRun = current.GetTextInRun(LogicalDirection.Forward);
            if (!string.IsNullOrWhiteSpace(textInRun))
            {
                int index = textInRun.IndexOf(keyword);
                if (index != -1)
                {
                    TextPointer selectionStart = current.GetPositionAtOffset(index, LogicalDirection.Forward);
                    TextPointer selectionEnd   = selectionStart.GetPositionAtOffset(keyword.Length, LogicalDirection.Forward);
                    TextRange   selection      = new TextRange(selectionStart, selectionEnd);
                    if (!string.IsNullOrEmpty(newString))
                    {
                        selection.Text = newString;
                    }

                    selection.ApplyPropertyValue(TextElement.FontSizeProperty, fontSize);
                    selection.ApplyPropertyValue(TextElement.FontStyleProperty, fontStyle);
                    selection.ApplyPropertyValue(TextElement.FontWeightProperty, fontWeight);
                }
            }
            current = current.GetNextContextPosition(LogicalDirection.Forward);
        }
    }
Exemplo n.º 7
0
        public void ChangeColor(Color fontColor)
        {
            RichTextBox rtb = ((RichTextBox)tabControl.SelectedContent);

            if (rtb != null)
            {
                TextRange selectedRange = rtb.Selection;
                rtb.Focus();
                fontControl.Visibility = Visibility.Hidden;
                selectedRange.ApplyPropertyValue(TextElement.ForegroundProperty, (new BrushConverter().ConvertFromString(fontColor.ToString())));
            }
        }
Exemplo n.º 8
0
        public void ChangeFont(FontFamily newFont)
        {
            RichTextBox rtb = ((RichTextBox)tabControl.SelectedContent);

            if (rtb != null)
            {
                TextRange selectedRange = rtb.Selection;
                rtb.Focus();
                fontControl.Visibility = Visibility.Hidden;
                selectedRange.ApplyPropertyValue(TextElement.FontFamilyProperty, newFont);
            }
        }
        public static void textWithColor(RichTextBox serverConsole, string text, Color color)
        {
            SolidColorBrush bc = new SolidColorBrush(color);
            TextRange       tr = new TextRange(serverConsole.Document.ContentEnd, serverConsole.Document.ContentEnd);

            tr.Text = text;
            try
            {
                tr.ApplyPropertyValue(TextElement.ForegroundProperty, bc);
            }
            catch (FormatException) { }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 文字の背景色を変更。
        /// </summary>
        /// <param name="_key"></param>
        private void ChangeTextBackgroundColor()
        {
            TextRange range_Selected = new TextRange(richTextBox_Body.Selection.Start, richTextBox_Body.Selection.End);

            var backgroundProperty = range_Selected.GetPropertyValue(TextElement.BackgroundProperty);

            if (backgroundProperty == null)                                                        //無色の時は
            {
                range_Selected.ApplyPropertyValue(TextElement.BackgroundProperty, Brushes.Yellow); //黄色に
                return;
            }

            if (backgroundProperty.Equals(DependencyProperty.UnsetValue))                //無色と黄色の両方が存在するとき
            {
                range_Selected.ApplyPropertyValue(TextElement.BackgroundProperty, null); //無色に
            }
            else if (backgroundProperty.ToString() == "#FFFFFF00")                       //黄色の時は
            {
                range_Selected.ApplyPropertyValue(TextElement.BackgroundProperty, null); //無色に
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Appends colored text to document.
        /// </summary>
        /// <param name="rtb"></param>
        /// <param name="color"></param>
        /// <param name="text"></param>
        public static void Append(this RichTextBox rtb,
                                  Color color, string text)
        {
            var endPos = rtb.Document.ContentEnd;
            var rnge   = new TextRange(endPos, endPos);

            rtb.Dispatcher.Invoke(new Action(() => {
                rnge.Text = text;
                rnge.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(color));
                rtb.ScrollToEnd();
            }));
        }
Exemplo n.º 12
0
 public void Log(string text, SolidColorBrush color)
 {
     Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
     {
         var tr = new TextRange(LogWindow.Document.ContentEnd, LogWindow.Document.ContentEnd)
         {
             Text = text + Environment.NewLine
         };
         tr.ApplyPropertyValue(TextElement.ForegroundProperty, color);
         LogWindow.ScrollToEnd();
     }));
 }
Exemplo n.º 13
0
        public void UpdateWord(RichTextBox obj)
        {
            obj.SelectAll();
            obj.Selection.Text = "";

            TextRange txt_front = new TextRange(obj.Document.ContentEnd, obj.Document.ContentEnd);

            txt_front.Text = front;
            txt_front.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Red);

            TextRange txt_btw = new TextRange(obj.Document.ContentEnd, obj.Document.ContentEnd);

            txt_btw.Text = btw.ToString();
            txt_btw.ApplyPropertyValue(TextElement.BackgroundProperty, Brushes.Blue);

            TextRange txt_back = new TextRange(obj.Document.ContentEnd, obj.Document.ContentEnd);

            txt_back.Text = back;
            txt_back.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Black);
            txt_back.ApplyPropertyValue(TextElement.BackgroundProperty, null);
        }
Exemplo n.º 14
0
 private void GroupChatClient_OnParticipantJoin(Room room, RoomParticipant participant)
 {
     Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
     {
         TextRange tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd);
         tr.Text      = participant.Nick + " joined the room." + Environment.NewLine;
         tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Yellow);
         ChatText.ScrollToEnd();
         participants.Add(new SmallPlayer(participant));
         ParticipantList.Items.Refresh();
     }));
 }
Exemplo n.º 15
0
 void AddConsoleText(string message, RichTextBox textBox, object color)
 {
     textBox.Dispatcher.Invoke(new Action(() =>
     {
         TextRange range = new TextRange(textBox.Document.ContentEnd, textBox.Document.ContentEnd)
         {
             Text = message
         };
         range.ApplyPropertyValue(TextElement.ForegroundProperty, color);
         textBox.ScrollToEnd();
     }));
 }
Exemplo n.º 16
0
 void timer_Tick(object sender, EventArgs e)
 {
     try
     {
         var range = new TextRange(Document.ContentStart, Document.ContentEnd);
         range.ApplyPropertyValue(FrameworkElement.LanguageProperty, Document.Language);
     }
     finally
     {
         textChanged = false;
     }
 }
Exemplo n.º 17
0
        private void AppendColor(string szMsg, string szColor)
        {
            BrushConverter bc = new BrushConverter();
            TextRange      tr = new TextRange(richTextBox.Document.ContentEnd, richTextBox.Document.ContentEnd);

            tr.Text = szMsg;
            try {
                tr.ApplyPropertyValue(TextElement.ForegroundProperty,
                                      bc.ConvertFromString(szColor));
            }
            catch (FormatException) { }
        }
Exemplo n.º 18
0
        public static void AppendText(this RichTextBox box, string text, string color)
        {
            BrushConverter bc = new BrushConverter();
            TextRange      tr = new TextRange(box.Document.ContentEnd, box.Document.ContentEnd);

            tr.Text = text;
            try
            {
                tr.ApplyPropertyValue(TextElement.ForegroundProperty, bc.ConvertFromString(color));
            }
            catch (FormatException) { }
        }
        private void ControllerOnOverlayFontChanged(bool fromView, Font font)
        {
            var tf = Utils.NewTypeFaceFromFont(font);

            RichTextBoxContent.FontFamily = tf.FontFamily;
            RichTextBoxContent.FontStyle  = tf.Style;
            RichTextBoxContent.FontWeight = tf.Weight;
            RichTextBoxContent.FontSize   = font.Size * 96.0 / 72.0;
            var range = new TextRange(RichTextBoxContent.Document.ContentStart, RichTextBoxContent.Document.ContentEnd);

            range.ApplyPropertyValue(TextElement.FontSizeProperty, font.Size * 96.0 / 72.0);
        }
Exemplo n.º 20
0
        /// <summary>
        ///     The extra time stamp.
        /// </summary>
        private void ExtraTimeStamp()
        {
            var textRange = new TextRange(
                this.RichTextBoxOutput.Document.ContentEnd,
                this.RichTextBoxOutput.Document.ContentEnd)
            {
                Text = DateTime.Now.ToString(
                    "[HH:mm] ")
            };

            textRange.ApplyPropertyValue(TextElement.ForegroundProperty, new BrushConverter().ConvertFromString("ForestGreen") ?? throw new InvalidOperationException("What the heck?"));
        }
Exemplo n.º 21
0
        // =====================================================
        // Visualization
        // =====================================================

        private void AddHyperlinkToConsole(string message, string linkName, string linkURL)
        {
            TextRange rangeOfText = new TextRange(OutputTextBox.Document.ContentEnd, OutputTextBox.Document.ContentEnd);

            rangeOfText.Text = message;
            rangeOfText.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.White);
            rangeOfText.ApplyPropertyValue(TextElement.BackgroundProperty, Brushes.Transparent);

            rangeOfText      = new TextRange(OutputTextBox.Document.ContentEnd, OutputTextBox.Document.ContentEnd);
            rangeOfText.Text = linkName;
            rangeOfText.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Blue);

            Hyperlink link = new Hyperlink(rangeOfText.Start, rangeOfText.End);

            link.IsEnabled        = true;
            link.NavigateUri      = new Uri(linkURL);
            link.RequestNavigate += OnHyperlinkClicked;

            rangeOfText      = new TextRange(OutputTextBox.Document.ContentEnd, OutputTextBox.Document.ContentEnd);
            rangeOfText.Text = "\r";
        }
Exemplo n.º 22
0
 private static void ChangeTextColor(HashSet <string> keywords, Brush foreground, TextRange text, TextPointer position, string textInRun)
 {
     foreach (var keyword in keywords)
     {
         int index = textInRun.IndexOf(keyword);
         if (index != -1 && CheckForSpaceAfterKeyword(textInRun, keyword, index))
         {
             TextRange selection = CreateSelection(position, keyword.Length, index);
             selection.ApplyPropertyValue(TextElement.ForegroundProperty, foreground);
         }
     }
 }
Exemplo n.º 23
0
 private void SldFontSize_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
 {
     if (this.sldFontSize.IsFocused && this.sldFontSize.Value > 0)
     {
         TextRange range;
         if (!this.rtbEditor.Selection.IsEmpty)
         {
             range = new TextRange(this.rtbEditor.Selection.Start, this.rtbEditor.Selection.End);
             range.ApplyPropertyValue(FontSizeProperty, this.sldFontSize.Value);
         }
     }
 }
Exemplo n.º 24
0
        public static void AppendText(this RichTextBox box, string userName, string text, Color color)
        {
            TextRange head = new TextRange(box.Document.ContentEnd, box.Document.ContentEnd);

            head.Text = $"[{DateTime.Now:T}]<{userName}>: ";
            head.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(color));
            TextRange msg = new TextRange(box.Document.ContentEnd, box.Document.ContentEnd);

            msg.Text = $"{text}\r";
            msg.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(Colors.Black));
            box.ScrollToEnd();
        }
Exemplo n.º 25
0
        private void ChatButton_Click(object sender, RoutedEventArgs e)
        {
            TextRange tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd);

            tr.Text = Client.LoginPacket.AllSummonerData.Summoner.Name + ": ";
            tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Yellow);
            tr      = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd);
            tr.Text = ChatTextBox.Text + Environment.NewLine;
            tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.White);
            newRoom.PublicMessage(ChatTextBox.Text);
            ChatTextBox.Text = "";
        }
Exemplo n.º 26
0
        /// <summary>
        /// Extension method for writing color to a RichTextBox.
        /// </summary>
        /// <param name="box">the RichTextBox to be written to.</param>
        /// <param name="text">the text to be written to the RichTextBox.</param>
        /// <param name="color">the color of the text, defined by the Color structure.</param>
        /// <param name="sameLine">True if the text is to be written to the same line as the last text.</param>
        public static void AppendText(this RichTextBox box, string text, string color, bool sameLine)
        {
            var bc = new BrushConverter();
            var tr = new TextRange(box.Document.ContentEnd, box.Document.ContentEnd);

            if (!sameLine)
            {
                tr.Text = "\r\n" + text;
            }
            else
            {
                tr.Text = text;
            }
            try { tr.ApplyPropertyValue(TextElement.ForegroundProperty, bc.ConvertFromString(color)); }
            catch (FormatException e)
            {
                tr.ApplyPropertyValue(TextElement.ForegroundProperty, bc.ConvertFromString("Black"));
                Log.Write("Color not found.", LogType.ERROR);
                Log.Write(e);
            }
        }
Exemplo n.º 27
0
 void changeStringColor(string str)
 {
     MainWindow.window.Dispatcher.BeginInvoke(
         (Action)(() =>
     {
         TextPointer textEnd = MainWindow.window.chatInfo.Document.ContentEnd;
         TextRange range = new TextRange(textEnd, textEnd);
         range.Text = str;
         range.ApplyPropertyValue(RichTextBox.ForegroundProperty, brushFromString(color));
         MainWindow.window.chatInfo.ScrollToEnd();
     }));
 }
Exemplo n.º 28
0
        private void HighlightRun(Run run, Regex regex)
        {
            var tags = new List <Tuple <TextPointer, TextPointer, string> >();

            var matches = regex.Matches(run.Text);

            foreach (Match match in matches)
            {
                tags.Add(new Tuple <TextPointer, TextPointer, string>(
                             run.ContentStart.GetPositionAtOffset(match.Index, LogicalDirection.Forward),
                             run.ContentStart.GetPositionAtOffset(match.Index + match.Length, LogicalDirection.Backward),
                             match.Value
                             ));
            }
            foreach (var tag in tags)
            {
                TextRange range = new TextRange(tag.Item1, tag.Item2);
                range.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(Colors.Blue));
                range.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);
            }
        }
Exemplo n.º 29
0
        private void ToolStripButtonBackcolor_Click(object sender, RoutedEventArgs e)
        {
            ColorDialog colorDialog = new ColorDialog();

            //colorDialog.Owner = this;
            if ((bool)colorDialog.ShowDialog())
            {
                TextRange range = new TextRange(rtbEditor.Selection.Start, rtbEditor.Selection.End);

                range.ApplyPropertyValue(FlowDocument.BackgroundProperty, new SolidColorBrush(colorDialog.SelectedColor));
            }
        }
Exemplo n.º 30
0
        void continueButton_Click(object sender, RoutedEventArgs e)
        {
            // We need to reset the color of the
            // previously hit breakpoint textrange
            if (currentHighlight != null)
            {
                currentHighlight.ApplyPropertyValue(TextElement.BackgroundProperty, Brushes.Transparent);
            }

            // Allow the executing thread to continue
            breakpointEvent.Set();
        }
Exemplo n.º 31
0
        /// <summary>
        /// Overloads RichTextBox.AppendText() with a version that takes a color as an argument.
        /// NOTE: color is "sticky", and will affect the next call to the built-in AppendText()
        /// method.
        /// </summary>
        /// <remarks>
        /// Adapted from https://stackoverflow.com/a/23402165/294248
        ///
        /// TODO(someday): figure out how to reset the color for future calls.
        /// </remarks>
        public static void AppendText(this RichTextBox box, string text, Color color)
        {
            TextRange tr = new TextRange(box.Document.ContentEnd, box.Document.ContentEnd);

            tr.Text = text;
            try {
                tr.ApplyPropertyValue(TextElement.ForegroundProperty,
                                      new SolidColorBrush(color));
            } catch (FormatException ex) {
                Debug.WriteLine("RTB AppendText extension failed: " + ex);
            }
        }
Exemplo n.º 32
0
        public FontFamilyListItem(FontFamily fontFamily)
        {
            _displayName = GetDisplayName(fontFamily);

            this.FontFamily = fontFamily;
            this.Text = _displayName;
            this.ToolTip = _displayName;

            // In the case of symbol font, apply the default message font to the text so it can be read.
            if (IsSymbolFont(fontFamily))
            {
                var range = new TextRange(ContentStart, ContentEnd);
                range.ApplyPropertyValue(TextBlock.FontFamilyProperty, SystemFonts.MessageFontFamily);
            }
        }