在WPF Richtextbox中更改fontsize后,应用程序变慢吗?

编程入门 行业动态 更新时间:2024-10-26 22:23:28
本文介绍了在WPF Richtextbox中更改fontsize后,应用程序变慢吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用WP richtextbox.我已经完成了将每行从当前插入符号位置导航到下一行,上一行等工作.它工作正常.我需要在Richtextbox中动态更改字体大小.

i am working with WP richtextbox.i done to navigate each line from current caret position to nextline,previousline etc.it works fine.i need to dynamically change fontsize in richtextbox.

我使用以下方法更改字体大小:

i used this below methods to change font size:

myrichtextbox.SetValue(TextElement.FontSizeProperty, fontSizedouble +10); myrichtextbox.FontSize = (txtAppendValue.FontSize + 10);

有效.但是执行此方法后,其他功能执行时间会很长.在NavigateNextLine()之前需要15ms至20ms.执行后需要40至50ms.i连续调用fontSize 4,5次,然后NavigateNextLine()花费100毫秒t0 120毫秒.

it works.But after execute this methods,the other functionality execution time taken is high.Before that NavigateNextLine() taken 15ms to 20ms.After execution it takes 40 to 50 ms.i continuously call the fontSize 4,5 times then the NavigateNextLine() takes 100ms t0 120 ms.

public void NavigateNextLine() { Int32 lineNumber; txtAppendValue.CaretPosition.GetLineStartPosition(-int.MaxValue, out lineNumber); Int32 iLineIndex = System.Math.Abs(lineNumber); Int32 iCurrentStart = 0; Int32 iCurWordLength = 0; for (Int32 icnt = 0; icnt <= iLineIndex; icnt++) { m_strCurLineText = GetLineText(txtAppendValue.CaretPosition.GetLineStartPosition(lineNumber), 0, null); iCurrentStart = iCurrentStart + m_strCurLineText.Length; lineNumber += 1; } String[] strArr = m_strCurLineText.Split(' '); if (strArr.Length > 0) { iCurWordLength = strArr[0].Length; // Get the first word length of current line if (iCurWordLength == 0) { iCurWordLength = strArr[1].Length; iCurrentStart = iCurrentStart + 1; } } else { iCurWordLength = m_strCurLineText.Length; //to get single word line length } NewStart = iCurrentStart; } String GetLineText(TextPointer TextPointer, int LineRltv = 0, string Default = null) { TextPointer tp1 = TextPointer.GetLineStartPosition(LineRltv); if (tp1 == null) { return Default; } else { tpNextLine2 = tp1.GetLineStartPosition(1); TextRange tr = null; if (tpNextLine2 == null) { tpNextLine2 = txtAppendValue.Document.ContentEnd; } tr = new TextRange(tp1, tpNextLine2); return tr.Text; } }

那是什么问题?如何解决?

SO whats the problem?how to resolve it?

致谢 阿琼

推荐答案

两者均应起作用:

txtAppendValue.ApplyPropertyValue(TextElement.FontSizeProperty, (double)10);

OR

txtAppendValue.ApplyPropertyValue(TextElement.FontSizeProperty, 10.0)

更多推荐

在WPF Richtextbox中更改fontsize后,应用程序变慢吗?

本文发布于:2023-10-07 01:28:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1468053.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   变慢   WPF   Richtextbox   fontsize

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!