|
I am still working on a project to autofill an html form with text fields automatically from a text file. I am running into some trouble. Autofilling on my system is easy. How do you do it when the html is in the browser and on the author's website? I guess it is comparable to google's autofill except im importing from a text file.
ideas?
|
|
|
|
|
I am building a Tetris clone as a tutorial project. I am using a Panel control as the main playing area. The pieces are made up of four Panels that I add to the main playin area panel. When lines are completed I remove the row of Panels by first setting them invisible, performing other tasks, then at the end of the function, removing any invisible Panels:
<br />
foreach ( Panel pnlTmp in this.pnlMain.Controls ) {<br />
if ( pnlTmp.Visible == false ) {<br />
this.pnlMain.Controls.Remove(pnlMain);<br />
}<br />
}<br />
This works great, but as the game goes on, performance starts to take a nose dive. If I do a:
<br />
this.pnlMain.Controls.Clear();<br />
Performance is restored, but I can't keep clearing out ALL the Panels. So it SEEMS that the removed Panels aren't REALLY removed. How do I fully remove them from the main Panel, so that they are truly gone, and performance doesn't suffer more and more as lines are removed?
Thanks!!!
- invid
|
|
|
|
|
centiipede wrote:
// remove the panels
foreach ( Panel pnlTmp in this.pnlMain.Controls ) {
if ( pnlTmp.Visible == false ) {
this.pnlMain.Controls.Remove(pnlMain);//presumably you meant pnlTmp here...
}
}
you might also need to add
<br />
pnlTmp.Dispose();<br />
pnlTmp = null;<br />
to insure it gets garbage collected reasonably soon.
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
|
|
|
|
|
Thanks for the feedback. I have tried the .Dispose() code, and I get a nullReference error. I can try setting it to null, and see if I get a similar error.
Thanks!!
- invid
|
|
|
|
|
the text in bold in my previous post was just a typo then?
Try disposing it before you remove it.
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
|
|
|
|
|
HRMM. None of these seem to do the trick, I have tried the following:
<br />
this.pnlMain.Controls.Remove(pnlTmp);<br />
pnlTmp = null;<br />
= Error, cannot set pnlTmp to null, read only error
<br />
pnlTmp.Dispose();<br />
this.pnlMain.Controls.Remove(pnlTmp);<br />
= nullReference error - probably because pnlTmp is gone
<br />
this.pnlMain.Controls.Remove(pnlTmp);<br />
pnlTmp.Dispose();<br />
= null Reference error - see above
<br />
pnlTmp.Dispose();<br />
= null Reference error - possibly because it may still be in the Controls array, even though I have disposed of it?
There must be a way to 'clean' up controls that you have removed from the Controls array. The performance decline is WAY too horrible for me to just ignore. Once 30 or 40 lines are cleared, any time the bricks are moved etc. the CPU shoots through the roof and the application starts to act like it is stuck in a perpetual loop (well not QUITE that bad, but close).
Thank you SO much for your help so far!!!
If you need me to zip the project up and post it somewhere, to help let me know. I am using .NET 2003 (7.1).
- invid
|
|
|
|
|
Hmmm. Something else is going on that is not obvious to you. Do the panels have any references to each other? (clearing them ALL would get around this, but clearing only 'invisible ones might not)
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
|
|
|
|
|
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
|
|
|
|