C#, it's the devil.
by Scott Burns · in Technical Issues · 02/13/2006 (1:27 pm) · 10 replies
Of course I kid, I've just been unfortunate enough to have to update an app written in C# when all my training is mainly C++. There is, of course, zero comments and zero documentation for this app. Its been an interesting couple of days.
All that has to be done is some texture changes, for now. So, I throw myself at the mercy of those around here who know C# to clarify a few things for me.
The buttons in this app use an ImageList for the textures. There's an up and down state for each button. Something I've noticed is that using an ImageList seems to cause every texture to be displayed on each button, and the index you give it brings the proper one to the front. Is this the correct behavior for an ImageList?
All that has to be done is some texture changes, for now. So, I throw myself at the mercy of those around here who know C# to clarify a few things for me.
The buttons in this app use an ImageList for the textures. There's an up and down state for each button. Something I've noticed is that using an ImageList seems to cause every texture to be displayed on each button, and the index you give it brings the proper one to the front. Is this the correct behavior for an ImageList?
#2
That was the way I initially thought of the ImageList when I first started looking at it. It wasn't until I started messing with stuff that it got confusing. When I tried replacing the textures with some .png's that had an alpha channel I saw every texture being displayed over top one another and the one whose index I had referenced seemed to be the one on top.
02/13/2006 (1:52 pm)
Thanks Jason, yeah it is a winForms app. That was the way I initially thought of the ImageList when I first started looking at it. It wasn't until I started messing with stuff that it got confusing. When I tried replacing the textures with some .png's that had an alpha channel I saw every texture being displayed over top one another and the one whose index I had referenced seemed to be the one on top.
#3
there is probably some sort of "clear" or "redraw" function in the gui object you are using (a button?)
02/13/2006 (2:10 pm)
Actually, that "alpha images on top of existing" functionality seems like it should be the desired functionality.there is probably some sort of "clear" or "redraw" function in the gui object you are using (a button?)
#4
i hope that helps.
if not, then you can always "hack" it by disabling the image (set it to null or whatever) then redraw the control, THEN place your new image on it.
edit: or show a completely blank image (with no alpha of course) and then your alpha image on top.
02/13/2006 (2:15 pm)
I took a look at the button docs, and the best i can think of is .Invalidate() or .Refresh()i hope that helps.
if not, then you can always "hack" it by disabling the image (set it to null or whatever) then redraw the control, THEN place your new image on it.
edit: or show a completely blank image (with no alpha of course) and then your alpha image on top.
#5
I'll take a look at that and see if Invalidate and Refresh do anything. With deadline for this thing looming I may just have to take the way out that they apparently took before, which was to make bitmaps of the textures already placed on the background so they didn't have to worry about alphas. That will at least buy me some time to learn more about winForms and C#.
02/14/2006 (6:24 am)
Thanks Jason, I appreciate the help. I'll take a look at that and see if Invalidate and Refresh do anything. With deadline for this thing looming I may just have to take the way out that they apparently took before, which was to make bitmaps of the textures already placed on the background so they didn't have to worry about alphas. That will at least buy me some time to learn more about winForms and C#.
#6
02/14/2006 (6:37 am)
While were on the subject of C#, is it possible to compile independent of .NET ?(Not using the Winforms...)
#7
there is Mono, which is an open source implementation of .NET, but they are kinda far behind in features right now.
and if you want to run this on a computer that doesnt have the .NET framework installed, you can... if you buy a 3rd party tool for $400 that lets you remove your programs dependancy on the .net framework.
i hope that helps,
-Jason
02/14/2006 (12:00 pm)
@Ben: not sure exactly what you are asking....there is Mono, which is an open source implementation of .NET, but they are kinda far behind in features right now.
and if you want to run this on a computer that doesnt have the .NET framework installed, you can... if you buy a 3rd party tool for $400 that lets you remove your programs dependancy on the .net framework.
i hope that helps,
-Jason
#9
for c#, the most highly recomended one at my employer seems to be "Inside C# Second Edition"
http://www.amazon.com/gp/product/0735616485/102-6720779-3565729?v=glance&n=283155
i think the book is pretty good, but by the time i started looking at it i already knew pretty much whatever i needed.
hope that helps.
02/15/2006 (1:28 pm)
For winforms.... not really... i'm not much of a ui developer.for c#, the most highly recomended one at my employer seems to be "Inside C# Second Edition"
http://www.amazon.com/gp/product/0735616485/102-6720779-3565729?v=glance&n=283155
i think the book is pretty good, but by the time i started looking at it i already knew pretty much whatever i needed.
hope that helps.
#10
I managed to find some books on Amazon about winForms, this one looked the best to me.
http://www.amazon.com/gp/product/0735621535/qid=1140040203/sr=1-9/ref=sr_1_9/002-9253610-7558420?s=books&v=glance&n=283155
Now I just have to tell the boss man to order the books.
02/15/2006 (1:57 pm)
Thanks alot. I managed to find some books on Amazon about winForms, this one looked the best to me.
http://www.amazon.com/gp/product/0735621535/qid=1140040203/sr=1-9/ref=sr_1_9/002-9253610-7558420?s=books&v=glance&n=283155
Now I just have to tell the boss man to order the books.
Torque Owner Jason Swearingen
but first, let me clarify something: you seem to be using a winForms app written in c#. FYI, winforms != C#.
C# is the language, the syntax... winforms are the functions/objects/etc that make GUI app development 'easier'. WinForms can be used in any .NET language (C#, VB.NET, J#, C++CLI, etc)
Looking at the msdn docs for System.Windows.Forms.ImageList, it looks like the index tells the button what image to display. So that means that:
That statement seems to be false. You should think of the ImageList as an array, (well, array with extra functionality) and so the only image that gets "displayed" is the one you specify (via the index)
hope that helps,
-Jason