Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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);

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?

regards Arjun

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
276 views
Welcome To Ask or Share your Answers For Others

1 Answer

Both should work:

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

OR

txtAppendValue.ApplyPropertyValue(TextElement.FontSizeProperty, 10.0)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...