Click here to Skip to main content
15,917,636 members
Home / Discussions / WPF
   

WPF

 
QuestionDlls Issue Pin
Tauseef A29-Jan-09 23:12
Tauseef A29-Jan-09 23:12 
AnswerRe: Dlls Issue Pin
Michael Sync31-Jan-09 4:56
Michael Sync31-Jan-09 4:56 
QuestionXaml on the Web Pin
Jammer29-Jan-09 23:07
Jammer29-Jan-09 23:07 
AnswerRe: Xaml on the Web Pin
Pete O'Hanlon30-Jan-09 0:40
mvePete O'Hanlon30-Jan-09 0:40 
GeneralRe: Xaml on the Web Pin
Jammer30-Jan-09 0:54
Jammer30-Jan-09 0:54 
GeneralRe: Xaml on the Web Pin
Pete O'Hanlon30-Jan-09 1:31
mvePete O'Hanlon30-Jan-09 1:31 
GeneralRe: Xaml on the Web Pin
Jammer31-Jan-09 22:39
Jammer31-Jan-09 22:39 
GeneralRe: Xaml on the Web Pin
Pete O'Hanlon1-Feb-09 8:28
mvePete O'Hanlon1-Feb-09 8:28 
GeneralRe: Xaml on the Web Pin
Jammer1-Feb-09 10:38
Jammer1-Feb-09 10:38 
AnswerRe: Xaml on the Web Pin
Mark Salsbery2-Feb-09 6:09
Mark Salsbery2-Feb-09 6:09 
GeneralRe: Xaml on the Web Pin
Jammer2-Feb-09 6:36
Jammer2-Feb-09 6:36 
GeneralRe: Xaml on the Web Pin
Mark Salsbery2-Feb-09 6:45
Mark Salsbery2-Feb-09 6:45 
GeneralRe: Xaml on the Web Pin
Jammer2-Feb-09 7:11
Jammer2-Feb-09 7:11 
GeneralRe: Xaml on the Web Pin
Mark Salsbery2-Feb-09 7:16
Mark Salsbery2-Feb-09 7:16 
GeneralRe: Xaml on the Web Pin
Jammer2-Feb-09 7:22
Jammer2-Feb-09 7:22 
GeneralRe: Xaml on the Web Pin
Pete O'Hanlon2-Feb-09 8:32
mvePete O'Hanlon2-Feb-09 8:32 
QuestionWPF ListView/ItemsControl Drag Drop Adorner Pin
snblackout29-Jan-09 18:40
snblackout29-Jan-09 18:40 
AnswerRe: WPF ListView/ItemsControl Drag Drop Adorner Pin
Pete O'Hanlon30-Jan-09 2:27
mvePete O'Hanlon30-Jan-09 2:27 
GeneralRe: WPF ListView/ItemsControl Drag Drop Adorner Pin
snblackout30-Jan-09 4:42
snblackout30-Jan-09 4:42 
GeneralRe: WPF ListView/ItemsControl Drag Drop Adorner Pin
snblackout30-Jan-09 5:33
snblackout30-Jan-09 5:33 
QuestionWPF RichTextBox is slow Pin
uncleashcan29-Jan-09 3:39
uncleashcan29-Jan-09 3:39 
I am trying to make a simple WPF app that takes a regex typed by the user into one RichTextBox, and highlights the matches in a second RichTextBox where the user can type in test data.

I will admit that this is my first foray into WPF, and theres probably something I am doing wrong. I am having two problems:

1. My highlights are not showing up in the right place.. they are off by a couple of characters early in the document, and towards the end they are nowhere close.

2. The performance I am seeing is abominable OMG | :OMG: To highlight about 200 three-character matches in a ~60kb document is taking over ten seconds. There are scenarios where I would need to highlight thousands of matches instead.. I can't fathom how long that would take. I am pretty certain the slow-down is in the action of highlighting, not processing the regex itself.

Just pasting the plain text into the RichTextBox in the first place (where it isnt executing any of my code) takes at least three seconds.

This is a rewrite of a windows forms app that I made a couple of years ago, and I managed to skirt around some of the RichTextBox performance issues there by using Suspend/ResumeLayout() but there doesn't appear to be an analogous tactic in WPF..

I should probably also note that no exceptions are actually being thrown. This was my first guess for the slow-down issue since exceptions take a while to churn out.. but the catch(...) in my code isn't being hit...

My machine is a Pentium 4 2.2ghz running Windows XP SP2. Here is the meat of my code.. what am I doing wrong?

void HighlightRegexMatches()
{
    if (!pHighlighting)
    {
        pHighlighting = true;

        Regex r = null;

        string p = new TextRange(
            rtbPattern.Document.ContentStart,
            rtbPattern.Document.ContentEnd
            ).Text.Replace("\r\n", "");

        try
        {
            r = new Regex(p);
        }
        catch (Exception ex)
        {
            // User typed an invalid regex, so cancel.

            pHighlighting = false;
        }

        if (r == null) return;

        try
        {
            string s = new TextRange(
                rtbTestData.Document.ContentStart,
                rtbTestData.Document.ContentEnd
                ).Text;

            MatchCollection c = r.Matches(s);

            FlowDocument d = rtbTestData.Document;

            TextRange allText = new TextRange(d.ContentStart, d.ContentEnd);

            allText.ApplyPropertyValue(TextElement.BackgroundProperty, Brushes.Transparent);

            int count = 0;

            foreach (Match m in c)
            {
                TextPointer start = d.ContentStart.GetPositionAtOffset(m.Index);

                TextPointer end = d.ContentStart.GetPositionAtOffset(m.Index + m.Length);

                TextRange t = new TextRange(start, end);

                t.ApplyPropertyValue(TextElement.BackgroundProperty, Brushes.HotPink);

                count++;
            }
        }
        catch (Exception ex)
        {
        }
        finally
        {
            pHighlighting = false;
        }
    }
}

GeneralRe: WPF RichTextBox is slow Pin
ejhuntington30-Jan-09 7:18
ejhuntington30-Jan-09 7:18 
QuestionDeep Zoom - Generate on Demand/Dynamically Pin
Dominic Pettifer28-Jan-09 14:46
Dominic Pettifer28-Jan-09 14:46 
AnswerRe: Deep Zoom - Generate on Demand/Dynamically Pin
ColinM12328-Jan-09 16:59
ColinM12328-Jan-09 16:59 
AnswerRe: Deep Zoom - Generate on Demand/Dynamically Pin
Mark Salsbery29-Jan-09 5:39
Mark Salsbery29-Jan-09 5:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.