Hey, I made this for a media player for my girlfriend (one that's a bit faster to load than WMP, since she has to be able to fire it up on the spot when she hears noises coming from the bathroom!) But I thought I'd share it to see if anyone had any big improvements, suggestions, etc.. so that I can make it a little more reusable.
Attatched solution contains sample project and the control library/code.
Big thanks to those in the Graphics forum who helped me figure out my rusty GDI+
Bill
Last edited by conipto; Nov 14th, 2005 at 03:20 PM.
Very nice but it scrolls a bit jagged when you use 9 or 10 as the interval. I can only suggest so far after my initial look is that you may be running rundant loops drawing the scrolling text. The RefreshDisplay is called and it does the same thing that the OnPaint does. perhaps doing a .Invalidate would suffice since it will invalidate the region and force an OnPaint anyways. The way you have it now it refreshedisplay and causing an additional onpaint.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Originally invalidate was how I had done it, but it looked awful, since it was drawing the background as well, the whole thing was all flashy the whole time..
Oh thats right. You could add a backbuffer when creating your graphics to eliminate the flicker. This is VB.NET but it should be simple to change to C#.
I think all the loops may be slowing you down too. Maybe looking at the logic a bit to see where we can improve. This is what I saw when I had the speed at 10. There must be a way to increase performance...
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Thanks for the tips! Those were all easy to implement and did make a difference in how it looks. The DesignMode is good to know, because that was ticking me off if I made a looping error and it crashed all of VS.
I modifed the OnPaint method to not draw the grid unless it's in design mode (since it gets drawn .25 seconds after the program starts anyways.) That might cut some redundancy out of the loops.
Yes, it seems to handle a little longer of a string and a little smoother scroll but still I'm curious to figure it out.
How about adding a Text property to the UC so you can at least see the static text its going to scroll in Design Mode? Add it next to the Color and ScrollSpeed?
Also, how about instead of trying to figure out which squares to draw gray and which to draw in the property color in loops and arrays, you just blank out all the squares with gray and draw the lines and then do the .DrawString? You may have to draw the gray lines again but that should still save you valuable processing time not having to loop several times.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
I'm running a P$ 2.8 Hyper Threading system with 1 Gig of dual channel DDR RAM with dual RAID SATA drives. I just let it run a minute or so with the speed of 10 and it got all wiggy on me.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Yes, it seems to handle a little longer of a string and a little smoother scroll but still I'm curious to figure it out.
How about adding a Text property to the UC so you can at least see the static text its going to scroll in Design Mode? Add it next to the Color and ScrollSpeed?
Also, how about instead of trying to figure out which squares to draw gray and which to draw in the property color in loops and arrays, you just blank out all the squares with gray and draw the lines and then do the .DrawString? You may have to draw the gray lines again but that should still save you valuable processing time not having to loop several times.
Try it now, I did change one thing that made a big difference. I am drawing on the refresh to a bitmap in memory, then once it's updated, it's only drawing to the screen once with a Graphics.DrawImage instead of all the FillRectangles. I also made the graphics objects global so they aren't disposing and initializing every time.
P.s. - It has a text property. How can I get the text property to show in the designer? I tried new, override, etc, and it never shows up. Font worked out ok, but why not Text?
In VB.NET we have the Shadows but in C# there is no Shadows. Unless someone knows a way what about renaming it to something that does not conflict withthe Text property?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
"new" is basically the equivalent to "Shadows" as far as I could tell in the book I have. I did try that, but it didn't work.. So for a while it was DisplayText.. but then in the intellisense both show up, and that was confusing.. The text property does work though, I just can't figure out how to make it show in the designer..
I found the way to place attributes for C# but I think there are a couple of issue to solve first. The Color property should be Forecolor and we could rename Text property to ScrollText property?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Here are a few improvements to the Properties and other stuff.
I added the property Attributes to place them in the proper category and added a description too.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Wow, thanks for showing me that. It was I admit driving me nuts having all my properties displaying at the bottom. Well, with your slight improvements on the properties, and now that I've got the graphics wrapped up, it's all wrapped up. Anyone that wants to use it, DL Rob's version for easier properties.
One thing - I am curious why you couldn't see the properties for scrollspeed and color - Those two never gave me any problems..aside from being all the way at the bottom.
Yes, with .NET project attachments its always a space saver too to remove the exe. Maybe you can add a link on your first post to the updated attachment of mine of just update your attachment.
Bill, I couldnt get it to "crash" and the property errors were appearant when I rebuilt the solution. I think its a naming conflict with the class name and the property name?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.