|
i am developing this for my client where in which,
a leser beam interact with the device which is connected to system, i need to take the input from Console(command prompt)--which is a partial output of my appliatin
and depending upon the input(which will be given by user in cmd prompt) i need to frame tables,waves etc...PRogramatically
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
Hello prashanth ,
I dont know If I am getting correctly,
means your application is interacting with one seperate console window from which you have to take input and to the same window you have to show the output correct??
nishu
|
|
|
|
|
its not exactly...
see in my application i have a submit button in my window form,
when i run my application.i mean in run time when i click button --COMMAND ) should be capable of taking input which typed in cmd prompt.
got?
please help me...nishu
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
Prashanth,
I got now ,but just one question more only one console window is there during runtime of your application?????i willl reply soon the solution .
nishu
|
|
|
|
|
Hi nishu,
did u found the solution...
here i am with one more requist...
please tell me, where do i get a tool?
I Want a tool which takes input values from the developed Commandprompt.
and this tool should be capable of convert these values in to sin waves,CW, or gauges..etc forms.
I hope u got my requirement. please help me with reference.
thnx in advance,pashi.
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
Following is the code ....
But problem is that ir works only in framework 2.0
System.Diagnostics.Process pr = new System.Diagnostics.Process();
pr.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
pr.StartInfo.FileName = "cmd.exe";
pr.StartInfo.UseShellExecute = false;
pr.StartInfo.RedirectStandardInput = true;
pr.StartInfo.RedirectStandardOutput = true;
pr.Start();
pr.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(pr_OutputDataReceived);
pr.BeginOutputReadLine();
System.IO.StreamWriter swWriter = pr.StandardInput;
swWriter.WriteLine("echo SomeTextHere\n");
swWriter.Flush();
...
//Define a delagate function
delegate void SetTextCallback(string text);
//Define a function for setting
void SetText(string text)
{
if (this.textBox1.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke(d, new object[] { text });
}
else
{
this.textBox1.Text = text;
}
}
void pr_OutputDataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e)
{
//event fired and u have data use it thread-safe
SetText(e.Data);
}
Rahul Kulkarni
|
|
|
|
|
hi,all
how can i drag a line with mouse from a point to another
and it is extended whenever i drag it with mouse
thanx
|
|
|
|
|
If you want the line to disappear when the mouse is lifted, use the CreateGraphics method to draw it, otherwise you need to handle the paint event. Either way, you want to handle the mouse down, mouse move and mouse up events, you need to store the position where the mouse went down, and keep painting new lines from there to where they mouse is as you move it.
What do you want to achieve ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
hi, Christian
i donot want it to disappear but tie two points (actually two images) and when i move image the line extended
|
|
|
|
|
What do you mean, two images ? What do you want to do ?
If you want to draw two lines that persist, you need to handle the paint event, then when you call Invalidate(), the paint event will redraw your form. Store a bool to say if the mouse button is down, and two points, one for each end of the line. Set both to the current mouse pos when the mouse goes down, set one to the mouse position when it moves, and in your paint event, draw a line between them, if the mouse is down ( via that flag you set )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
thanx Christian
about ur question
iam making a mobile simulator project and i want to tie
for example mobile node with base station node
thanx alot
generator
|
|
|
|
|
OK, that's a little more complex, you need to then store the locations of 'objects' you want to draw lines between ( assuming you don't want to allow arbitrary lines to be drawn ).
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
( assuming you don't want to allow arbitrary lines to be drawn ).
what is the mean of this
generator
|
|
|
|
|
You want lines to only be drawn between components, or just anywhere that people feel like it ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
In my application I need to use a timer. Depending on it the text of a Label control must be changed and when the time counter reaches the value of '0' an event must happen.
Now so far I wasn't even able to change the value of Label Text property.
I can't figure out what is wrong. Samples I tried from books and MSDN worked just fine, but not the timer in my application. All I get is an infinite 'while' loop. This is the code I used:
this.countDownTimer.Enabled = true;
while(this.timeCounter > 0)
{
this.countDownTimer.Tick += new EventHandler(this.countDownTimer_Tick);
}
this.countDownTimer.Enabled = false;
private void countDownTimer_Tick(object sender, EventArgs e)
{
this.timeCounter--;
this.lblTimeLeft.Text = timeCounter.ToString();
}
Would someone be so kind to help me with this. I have wasted a full day trying to make it work but no luck so far. Thank you!
|
|
|
|
|
vitaco wrote: while(this.timeCounter > 0){ this.countDownTimer.Tick += new EventHandler(this.countDownTimer_Tick); }
If timerCounter > 0, then your loop will run forever, as nothing is going to decrement it. also, your tick event is going to have many, many events tied to it ( that function will be called over and over ).
I think you're confusing timers and threads. Your timer will try to run, but it won't be able to, because your while loop will be eating the processor time.
Also, only set the tick event once, setting it more than once causes the function to be called over and over. Just remove the while loop, and start the timer ( you don't even to that, as far as I can see ), and it should work fine.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Well, I removed the 'while' loop. When I run the Debug mode I can see (as previously) that the line "this.countDownTimer.Tick += new EventHandler(this.countDownTimer_Tick)" never leads to execution of "countDownTimer_Tick". The lines of code
timeCounter--;
this.lblTimeLeft.Text = timeCounter.ToString();
are never accessed.
I'm certainly missing something. Can you help me with the actual line/lines of code that should do the trick?
|
|
|
|
|
in your first post u are disabling the timer after registering. remove this line
this.countDownTimer.Enabled = false;
and add it after
this.lblTimeLeft.Text = timeCounter.ToString();
Regards
Shajeel
|
|
|
|
|
As I said, the Timer has a Start method, I believe. Or, it's Enabled property has to be 'true'.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I've tried both. But it just doesn't work.
If I get it right when the program gets to the line
this.countDown.Start();
the 'countDown_Tick' must be executed. In my case it does not. For some
reason the program just 'remarks' the line and executes it after all the rest of the code is passed. I will illustrate the way it goes when I run it in the Debug mode.
//Step 1. The program enters the 'if' body
if(useTimeLimit)
{
this.pnlTimer.Enabled = true;
this.lblTimeLeft.Visible = true;
timeCounter = TimeLimit;
this.countDownTimer.Start();
and then goes further without going to 'countDown_Tick'
}
//Step 3. It goes through the rest of code in the method
else
{
some other code
}
some other code;
some other code;
//Step 4. After it goes through all the code in the method (Step 3)
the program executes the 'countDown_Tick'
private void countDownTimer_Tick(object sender, EventArgs e)
{
while (timeCounter > 0)
{
timeCounter--;
this.lblTimeLeft.Text = timeCounter.ToString();
}
this.countDownTimer.Stop();
}
I know this is stupid, but imagine how stupid I feel in such a situation! Please help!
|
|
|
|
|
vitaco wrote: I've tried both. But it just doesn't work.
If I get it right when the program gets to the line
this.countDown.Start();
the 'countDown_Tick' must be executed.
No i think you misunderstood timer functionality. After Start() function timer interval is started and once interval is elapsed countDownTimer_Tick is called. It is not a function, why do you want it to act like a function. If you want to execute a function then simply call it yourself.
Regards
Shajeel
|
|
|
|
|
create simple window application with form, button, label and timer. In button click and timer tick add following code.
private void button1_Click(object sender, System.EventArgs e)
{
this.timer1.Tick += new EventHandler(timer1_Tick);
this.timer1.Interval = 1000;
this.timer1.Start();
}
private int currentSecond = 0;
private void timer1_Tick(object sender, EventArgs e)
{
this.label1.Text = currentSecond++.ToString();
}
Hope this help
Regards
Shajeel
|
|
|
|
|
Yes it helped! Thank you! Now I will have to get the idea!
Christian Graus also helped me to understand something, namely "A timer will never tick until the method that called it ends". I didn't know that! Probably I will have to call a new method inside the while loop to change the Text property of the Label. Thank you both!
|
|
|
|
|
A timer will never tick until the method that called it ends, the tick is another function call that gets added to the list of pending events. It's not a direct function call, even if the time interval is 0. Timers are not that precise.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Really depends on what timer you are using. A UI timer obviously won't fire until the current queue of messages is empty, but System.Threading.Timer and System.Timers.Timer can both potentially fire even before the method that started them ends.
|
|
|
|