|
Hmm. I do create Brick classes that contain the panels. maybe I should dispose of these bricks when they 'collide', I *think* that the Panels will remain (I hope), it could be these class instances that is the problem...
Well, except that everything gets 'fixed' when I do a pnlMain.Controls.Clear().
Here is a link to a zip of the project if you would like to poke around it a bit.
Techtris
Thanks!!!
|
|
|
|
|
At first I didn't see anything that made sense (except the the Bricks hold four panel references, but they become "unreachable" when the brick is destroyed).
Then I realized what it was: the remove() call is in the middle of iterating the controls array, which means that the 'next' brick is skipped each time one is removed (the iterator can't track the removals, the 'next' brick assumes the index of the one just removed - it 'moves up'). the bricks end up under other bricks, and their visibility changes around, butr eventually you get a bunch of 'orphans'.
To get around this, change the iteration from a foreach loop to a for loop, but iterate in reverse :
<br />
for(i = controls.count -1; i >= 0,i--)<br />
{<br />
pnlTmp = controls[i] as panel; <br />
if (pnlTmp!=null)<br />
{ <br />
if(!pnlTmp.visible){controls.remove(pnlTmp);<br />
}<br />
}<br />
That way you will remove from the bottom and not skip any (when you remove the 4th, the 3rd is still 3rd).
One of the dangers of that convenient foreach, it makes one forget that it is really just a for (i=0; i<count;i++) and="" since="" there="" is="" no="" 'i'="" to="" watch="" in="" the="" debugger,="" youll="" miss="" problem.
this="" still="" speculation:="" i="" couldn't="" run="" project="" bcauste="" c1="" thingy="" reference="" was="" missing="" it="" wouldn't="" build...=""
<small="">Anger is the most impotent of passions. It effects nothing it goes about, and hurts the one who is possessed by it more than the one against whom it is directed.
Carl Sandburg
|
|
|
|
|
OH... I forgot that I have used the componentOne menu control, sorry. What you've said makes PERFECT sense. I will try it and see what happens. If that doesn't do it, I was thinking that maybe instances of the Brick class might be piling up or something like that. If none of these solutions work, I will replace the componentOne menu and repost the project.
Thank you SOO much for your help!!!
- invid
|
|
|
|
|
Thank you VERY much!! This seems to have solved the problem. I will remember this next time I am dynamically removing controls etc.
- invid
|
|
|
|
|
Can anyone point me towards a tutorial on how to use the Windows Color Pallette Selection in a C# program?
I have a menu item that when I click on it I want it to bring up the color pallette selection from windows and allow the user to change the background color of the windows form.
Thanks.
|
|
|
|
|
You don't need a tutorial. It's very simple.
1. Add a ColorDialog control to your form (System.Windows.Forms.ColorDialog)
2. Add a button and _Click event for the button.
3. Add the following code.
<br />
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
this.colorDialog1.ShowDialog(this);<br />
this.BackColor = this.colorDialog1.Color;<br />
}<br />
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
Basically you're right, it's just better style to query the dialog return value:
<br />
if (colorDialog1.ShowDialog(this) == DialogResult.OK)<br />
{<br />
this.BackColor = colorDialog1.Color;<br />
}<br />
mav
|
|
|
|
|
Thanks. I feel like an idiot now that I couldn't find that that.
|
|
|
|
|
I have an app written in C# that is currently calling some DLL's written in FORTRAN. I have a web-based Flash frontend. All very exciting.
I have been asked to port the entire system to run on Solaris 8.
A few details:
FORTRAN is required for intense number crunching.
Solaris will run on SPARC processors.
Does anyone have any experience doing anything like this?
My initial thoughts were to investigate Mono and Java. Mono may be fine, yet I don't know anything about integrating with FORTRAN code at that point. Java is not something I'm super comfortable with in terms of building an enterprise-level app, but I guess a young dog may have to learn new tircks.
Thanks in advance for any suggestions. ;);P
|
|
|
|
|
Larsenal wrote:
I have an app written in C# that is currently calling some DLL's written in FORTRAN. I have a web-based Flash frontend. All very exciting.
I don't know the answer to your question... but I have one myself, if everything works fine, and it's a big "enterprise-level" app, why bother porting it?
Isn't there another solution?
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
That's a great question. Answer: new client REQUIRES it to run within their current server architecture.
So sad... I know.
|
|
|
|
|
Is there such a thing in C#?
I know of the internal class modifier, but I want to grant "friend"-like access to a particular class from a different assembly. The reasons why I need this are long an involved, and the company I work for won't budge on the issue, so I need to find a way to make this work.
Any ideas?
Thanks.
|
|
|
|
|
Not possible with top-level types in C#. There is no real eqivalent to c++ friend access level.
Your only alternative would be to derive the class that needs access from a puplic top level class that contains the class you want to access as a protected or protected internal class, which is a kludge that sort of defeats the pupose of not making the class you need access to public in the first place.
What is your employer REALLY trying to accomplish here? Do you need access to the entire class, or just a few methods? Do you need to instantiate the class in the other assembly?
Would a public wrapper class containing an instance the 'protected' class and exposing only the desired methods suffice (i.e. a facade)?- expose the facade class via a public class factory...
Anger is the most impotent of passions. It effects nothing it goes about, and hurts the one who is possessed by it more than the one against whom it is directed.
Carl Sandburg
|
|
|
|
|
I'm not sure what the attribute is right now, but there is a way to make objects callable only from specified assemblies. If ur calling object is managed and u can place it in an isolated assembly then u can reach the solution u are looking for.
|
|
|
|
|
Apparently, VS2005 has a new attribute
[VisibleFromAssembly="ASSEMBLY_NAME"] which I'll be able to use.
I'm not sure that's the exact attribute name, but it's something similar that can be applied at the class level, for instance, to an internal class.
|
|
|
|
|
How can I Insert the values in the text in the nodes of the Treeview?
|
|
|
|
|
Try checking out the documentation for TreeView.Nodes.Add(string)[^] on MSDN.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have created a propertygrid and a dialog form in Windows Form.
How can I make my dialog form pop up when i click on the attribute of my PropertyGrid?
Can first give a reference site where i can find out the answer cause it is quite urgent.Preferably an executable program..
Deadline approaching... Please help...
Thank you
|
|
|
|
|
Searching about EditorAttribute .. you will find your solution.
And you might need this as well TypeConverterAttribute.
Hope this help
|
|
|
|
|
I have manage to make my PropertyGrid pop up Font form from the System.Windows.Drawing but no luck with my own defined form class, i try to make it pop up like the Font, intead it select all the Windows.Form properties inside my PropertyGrid.
Please help!!!
|
|
|
|
|
I am trying to create a timer that will pause the program for 1.5 seconds. I need something that pauses but does not stop the Thread.
In a nutshell, here is what I am doing. I have two cards that appear on the screen. I want them to stay there for 1.5 seconds and then re-draw back to a default value.
I have tried the Thread.Sleep but that pauses the entire program and prevents the one card from displaying at all (even though the sleep is called after the line to display the card).
Any help would be appreciated.
|
|
|
|
|
Monitor.Wait(new Timespan())
|
|
|
|
|
Can you be more specific. I can't get that to work either.
Here is the code I have tried using:
private void P1Flip_Click(object sender, System.EventArgs e)
{
GetCard(1);
Player1Card = P1Card.GetCardNum();
Invalidate();
P1CardPlayed = true;
P1Flip.Enabled = false;
if (P1CardPlayed && P2CardPlayed)
{
PlayGame();
if ((winner == 1) || (winner == 2))
{
Threading.Thread.Sleep(WaitTime);
Player1Card = 67;
Player2Card = 67;
UpdateCardsLeft();
P1CardPlayed = false;
P2CardPlayed = false;
P1Flip.Enabled = true;
P2Flip.Enabled = true;
}
else
{
ShowWarMessage();
P1War.Enabled = true;
P2War.Enabled = true;
P1CardPlayed = false;
P2CardPlayed = false;
}
}
}
My problem is even though the Threading.Thread.Sleep(WaitTime) is after the Invalidate() command, the screen is not re-drawing until after the WaitTime? This is driving me nuts.
|
|
|
|
|
Bob Bonser wrote:
My problem is even though the Threading.Thread.Sleep(WaitTime) is after the Invalidate() command, the screen is not re-drawing until after the WaitTime? This is driving me nuts.
Try throwing a Application.DoEvents(); in just before you put the thread to sleep. This will give the window the opportunity to respond to the WM_PAINT message it's about to receive.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|