|
What do you mean by "page break"? Are you printing your code?
No matter what one may argue, a long method or a long class is a bad practice: it can always be shorter. Actually, by making it shorter, often you'll find lots of bugs in it.
Don't do a "page break", whatever you meant by it: reduce the size of your code.
Yes, even I am blogging now!
|
|
|
|
|
yeah your best option would be seperate your code into individual files thats the best programing practice you can follow. seperate your program in a logical manner not only is it easier on the compiler but its also easier to navigate and use overall as far as i know there is no way to insert a page break thats a word processor thing
|
|
|
|
|
My "IDE" can handle roughly 600 000 lines but thats purely a GDI+ limitation, and I have been too lazy to work around it.
My suggestion is to generate the file, but make it abstract/virtual, compile to DLL, then load that assembly in your IDE, and inherit from the class.
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
600000 lines are not enough four you?
Are you crazy?
Am I getting insane?
|
|
|
|
|
Insanity and genius are merely a mirror image of each other.
I have written many projects that easily run into the tens of thousands of lines of code. Most who do that very easily are developing very complex programs or even creating new technologies, like I am, that are not even on the market.
I would feel that most of us who are creating new technologies are in the genius/insanity class. We should all be experts at cutting the code to an absolute minimum. A lot of the times you are limited by the compiler and the computer. IMO todays PC computers are "extremely" pathetic for processor power and speed. I have very easily pushed the envolope on a 2.4 ghz pentium and a gig of 800 mhz RIMS for the exe file. We need a supercomputer in a laptop instead of that that cheesy plastic box of copper and silicon they call a computer. Even my desktop with the hot ram, cpu, and SCSI drives is what I consider a flibber.
JMO, anyway.
Thanks so very much for all of you helping out with your answers.
demasoni.com
As we traverse through this thing called life with recursive thoughts we must allways beware of the pointers that will ultimately leave us dangling from a string on the end of a tree branch. ->
Elite ->
|
|
|
|
|
I am having trouble executing my files on my pda after successful execution in .net 2002. I am getting the typeloadexception error and just can't figure it out! The entire error reads:
TypeLoadException
Could not load type
System.Windows.Forms.Form from
assembly System.Windows.Forms,
Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=B77A5C561934E089
Hopefully a simple download or something will fix me. Thanks!
|
|
|
|
|
I would like to place a colored rectangle around whatever control has focus on the form. I have seen this done in C++ using a "Hook" method, but I want to do it in C# and was hoping someone could help me get started or knew of something similar.
Thanks
|
|
|
|
|
The only thing I can think of - in the form constructor, after InitializeComponent(); add loop for attaching to all controls on form event handler for Enter event. The same event handler for all controls, and in this event invoke repaint function in any way.
Robin Panther
|
|
|
|
|
I am writing a small program that using WMI to get windows security logs. The programm suppose to get 50 logs each time and dump them into a text file, then stop.
Currently, my code can start to collect logs, but never stop.
Could anyone tell me how to do this? I tried to modify the WMI query, but it seems the WMI query has very limited functions.
Thank you very much.
----------------------------------------------------------------------------
using System;<br />
using System.Management;<br />
using System.IO; <br />
<br />
class Sample_ManagementEventWatcher<br />
{<br />
[STAThread]<br />
public static int Main(string[] args)<br />
{<br />
<br />
StreamWriter SW;<br />
SW=File.CreateText("logs.txt");<br />
SW.Close();<br />
<br />
MyHandler mh;<br />
EventArrivedEventHandler eventArrivedEventHandler;<br />
ManagementEventWatcher watcher;<br />
string comp = "servername";<br />
mh = new MyHandler();<br />
eventArrivedEventHandler = new EventArrivedEventHandler(mh.Arrived);<br />
watcher = Sample_ManagementEventWatcher.getWatcher(comp);<br />
<br />
watcher.EventArrived += eventArrivedEventHandler;<br />
<br />
watcher.Start();<br />
<br />
Console.WriteLine("Watcher is running, press <enter> to stop...");<br />
Console.ReadLine();<br />
watcher.Stop();<br />
<br />
watcher.EventArrived -= eventArrivedEventHandler;<br />
<br />
return 0;<br />
}<br />
<br />
public static ManagementEventWatcher getWatcher(string comp)<br />
{<br />
ConnectionOptions co;<br />
ManagementPath mp;<br />
ManagementScope ms;<br />
WqlEventQuery EventQuery;<br />
ManagementEventWatcher watcher;<br />
string wql;<br />
string wqlAnd;<br />
<br />
<br />
<br />
co = new ConnectionOptions();<br />
co.Timeout = new TimeSpan(0, 0, 60);<br />
co.EnablePrivileges = true;<br />
<br />
mp = new ManagementPath();<br />
mp.NamespacePath = @"\root\cimv2";<br />
mp.Server = comp;<br />
ms = new ManagementScope(mp, co);<br />
wqlAnd = " AND TargetInstance.Logfile ='Security'";<br />
<br />
wql = "select * from __instancecreationevent where targetinstance isa 'Win32_NTLogEvent'" + wqlAnd;<br />
EventQuery = new WqlEventQuery(wql);<br />
<br />
watcher = new ManagementEventWatcher(ms, EventQuery);<br />
<br />
return watcher;<br />
}<br />
<br />
public class MyHandler<br />
{<br />
public void Arrived(object sender, EventArrivedEventArgs e)<br />
{<br />
ManagementBaseObject mbo =<br />
(ManagementBaseObject)e.NewEvent["TargetInstance"];<br />
Console.WriteLine(mbo.GetText(0));<br />
<br />
StreamWriter SW;<br />
SW=File.AppendText("logs.txt");<br />
SW.WriteLine(mbo.GetText(0));<br />
SW.Close();<br />
<br />
}<br />
}<br />
<br />
}
|
|
|
|
|
Hi! I want to know how to move buttons inside a windows form. I tried in some ways, but nothing..
People said me to use drag&drop property but I think it is not the right way.. Can someone give me a hand? If it is not to ask too much, could you write me the code?
Thanks a lot!
|
|
|
|
|
Use the setbounds function to change the location of a button on a form...
|
|
|
|
|
I am still trying but I don't succeed in understanding how to use it.. HELP ME!!!
I have to use SetBounds property inside MouseMove event?
Could you write me, please, some line of code?
|
|
|
|
|
Just as a starting point (you need to adjust this a bit):
Create an empty form with a button called button1 . Then add the following code:
bool attached = false;
Point oldPos;
private void button1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
attached = true;
oldPos = button1.PointToScreen(new Point(e.X, e.Y));
}
private void button1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
Move(button1.PointToScreen(new Point(e.X, e.Y)));
}
private void button1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
attached = false;
}
private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
Move(PointToScreen(new Point(e.X, e.Y)));
}
private void Move(Point p)
{
if (attached)
{
button1.Left -= oldPos.X - p.X;
button1.Top -= oldPos.Y - p.Y;
oldPos = p;
}
}
Dont forget to attach the eventhandlers
|
|
|
|
|
This is a great solution! Thanks a lot, really. I have just tried it, and it works. Really good. Thanx, thanx and thanx!
|
|
|
|
|
hi im just looking for a simple way to split the data of a file say 7600kb long (or any length) into x amount of 1000kb pieces. The problem im having is toward the end of the file 1000kb will not divide into 7600kb evenly. aggh another complicated problem with a easy solution that i obviously dont know the anwser to.
Jesse
|
|
|
|
|
Here's a typical stream read loop that will copy from src to dest streams:
const int bufferSize = 4096;
byte[] buffer = new byte[bufferSize];
int readBytes;
while ((readBytes = src.Read(buffer, 0, buffer.Length)) != 0)
{
dest.Write(buffer, 0, readBytes);
}
Notice what I'm doing up there: the number of bytes read will be kept on the readBytes variable. So, instead of writing bufferSize bytes (which is always 4kb), I write only what I read - although I asked to read bufferSize, sometimes, it will be lower. The loop stops reading when src.Read returns zero, as there's no more data on the stream to be read.
Your algorithm will need to do something similar to this - actually, if you don't want to use a 1000Kb buffer, it'll be a bit more complicated, but I hope you got the idea.
Yes, even I am blogging now!
|
|
|
|
|
thank you very much for your time. your anwser fixed the problem with only 2 small mods. Thank you very much.
Jesse
The Code Project Is Your Friend...
|
|
|
|
|
Anyone know any strategy or open source of how to create system tray notifier with SmartClient ability to maintain update software itself over HTTP?
We have nearly 100 computers and it will be quite tough for 2 people to update software everytime it patches..
I have a way knowing how to create notifier, but how do I build Smart Client?
Please advise, thank you!
|
|
|
|
|
I have a very strange problem. Using a Tcp connection:
1. the client opens a connection to the server
2. the client sends some data
3. the client keeps the connection open so the server can respond
The server:
1. receives the data
2. sends a response (LingerState is set to 1000ms)
3. closes the connection
Now, the wierd thing is, the client sometimes doesn't get the response. I have to put a delay in BEFORE sending the response.
If I but a delay in AFTER sending the response (but before closing the connection) the response is still not received by the client.
Any ideas? There's no other clients connecting, the connection pooling threads appear to be behaving, etc.
Marc
MyXaml
Advanced Unit Testing
|
|
|
|
|
Try setting the NoDelay option to true, or just maybe u have the same issue as I did, read on...
Make sure the size of a single send, is never more than the buffer size, else it will go into asynhronous mode automatically and return while data is still sending.
:P
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
leppie wrote:
Make sure the size of a single send, is never more than the buffer size, else it will go into asynhronous mode automatically and return while data is still sending.
Ah, thanks for that info. I think my problem was one on of those cases where setting LingerState fixed the problem but I didn't know it because my test case wasn't working.
Who tests the testers?
Marc
MyXaml
Advanced Unit Testing
|
|
|
|
|
|
Hi all,
I'm creating this small tool and need some help on the form I ll be using. The tool consist out of a form that contains 3 buttons. When a button is clicked 'another' should be opened. The form needs to have the same sice and place as the previous one only the content (buttons, ...) need to change.
Is there a proper way to do this? Do I best use a new form for each button clicked or do I use the same form and Hide or Show elements when needed? Maybee there is a better way?
I hope someone can help me out.
Regards
Stijn
|
|
|
|
|
You could just create a user control for each "page" that you want to display. Or you can use something like Al Gardner's Wizard Control
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
I am trying to make a task create a text file every morning. I am doing this in C#. I have the text file creation working but I am having problems with the task scheduling.
|
|
|
|