Results 1 to 19 of 19

Thread: [RESOLVED] Help me speed this up...

Hybrid View

  1. #1

    Thread Starter
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    Re: Help me speed this up...

    Still need to figure out the block commenter (/* + */) but I think with the addition of a class level boolean, that shouldn't be too bad..

    Bill
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Help me speed this up...

    Have you tried stopping the drawing of the RTB while you colorize the code?

  3. #3

    Thread Starter
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    Re: Help me speed this up...

    I made .Visible to false during read to see if made it faster, but not much difference noticed. Is there any more.. definate way of stopping it?

    Bill
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

  4. #4
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Help me speed this up...

    YOu can use SuspendLayout and ResumeLayout to stop and start the drawing of most controls.

  5. #5

    Thread Starter
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    Re: Help me speed this up...

    Suspend and resume layout only affect resizing and redrawing of controls, from what I got out of my experimenting with it this afternoon.

    It turns out, the original method using the RichTextBox.Find is still faster than the char-by-char method, but not because of calculation time.. The actual char by char writing to the RichTextBox, whether visible, disabled, suspended, or not, is incredibly slow.

    I can load a huge file into the RTB in almost no time using standard streamreader read methods, but char by char it's way too slow. I did some testing with my parsing method, and if I use special characters to define where colors would stop and start, rather than actually coloring/writing them to the RTB, and write that string to the RTB all in black, the text loads at what is not noticably any slower speed.

    Conversely, if I read in the strings one line at a time, and add them to the RTB one character at a time, it's pretty much the same speed as it is when I am writing the formatted text one char at a time.

    So, is there a way, to build a Rich Text string with formatting, and write it line-at-a-time to the RTB? I think if I could do that, the speed would go right up where I want it.

    Bill
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

  6. #6
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Help me speed this up...

    What if you created a dynamic RTB in memory and populated it that way?

    Also instead of doing it char by char, why not load all the text into the RTB and just read it char by char and apply formatting to words.

    I might try and create some code to do this tonight just for fun. If I get something efficient, I will post it.

  7. #7

    Thread Starter
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    Re: Help me speed this up...

    I tried just making a temporary RTB to write to.. it was just as slow. however, I did manage to figure out how RTF files work (more or less)

    http://www.biblioscape.com/rtf15_spec.htm#Heading16

    With that link..

    And, after doing one the slow way, I saved it to an RTF file, and viewed it with notepad. I can see all the formatting, and so on, so I thought I would try to build the formatted strings and insert them using the RichtTextBox.Rtf method instead of using SelectedText. Unfortunately, I get a file format error every time I try to insert a string I'm gonna keep playing with it and see what I can do..

    Bill
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width