|
Okay, if I understand you correctly you want to draw a line between nodes 1 and 2, then a moment later between 3 and 4 and so on?
Reading the file should be fairly easy:
ArrayList nodes = new ArrayList();
try
{
using (StreamReader sr = new StreamReader("TestFile.txt"))
{
String line;
while ((line = sr.ReadLine()) != null)
{
string[] values = line.Split(' ');
double x = Convert.ToDouble(values[1]);
double y = Convert.ToDouble(values[2]);
PointF node = new Point(x, y);
nodes.Add(node);
}
}
}
catch (Exception e)
{
}
DISCLAIMER: I typed this directly into the browser, there may be syntax errors.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
In one moment I need line thrue all points, in next moment I get another node set (in my file are meny node sets for diferent moments (time steps), and I should draw a whole new line.. As result I should have an Animation, where one line getting deformed (changes shape).. At first it is straight (First time step-moment):
.................................................. at the End (last step) it should looks like:
......
. .
............... .................. (something like that
I hope that U understand, I appologise about my poor English
|
|
|
|
|
Okay, so you have one file. That file contains many node sets. A node set is a list of coordinates to draw a polyline through (lots of straight lines connecting each node).
How do you determine from your file the start of a new node set? In the example you gave before, each line is numbered sequentially. I don't see anything to mark the start of a new set of nodes.
Incidentally, did you understand my explanantion of reading the file?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
I have sent a sample file to You as attachment in mail message.. Its *.dat file, but You can open it with any text editor
|
|
|
|
|
Okay your file format, with all the spaces properly preserved is as follows (so anyone else can keep up with the thread
$ State Nr.: 150
1 0.0000E+00 -0.4396E+01
2 0.1136E+01 -0.4506E+01
3 0.2217E+01 -0.4706E+01
The easiest thing to do is when reading the file, each line that starts with a $ denotes a new node, so you can use a line like:
if (line[0] == '$')
{
}
So, before you start reading your file you might want to create an array to hold the node sets in, then each time you encounter a dollar symbol at the start of a line you can create a new array to hold each of the nodes in. The array of nodes gets added to the array of the nodesets. A node set is an array of nodes.
Then when you have finshed reading the file you will have an array of node sets (in other words an array of arrays).
Does this help?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
Yes off course it helps, now I knew how to read it from file..
I will have to find a way to plot those lines somehow..
Thank You very much
|
|
|
|
|
For plotting your node list you could derive a class from Panel and then override the OnPaint function.
I'd save the ArrayList of Point s as a property of your new class:
protected ArrayList _graph = new ArrayList();
public ArrayList GraphPoints
{
get { return _graph; }
set { _graph = value; Invalidate(); }
} Then you can write something like this in the overridden function:
protected override void OnPaint(PaintEventArgs pe)
{
Point[] points = new Point[GraphPoints .Count];
GraphPoints .CopyTo(points);
pe.Graphics.DrawLines(Pens.Red, points);
} Regards,
mav
|
|
|
|
|
HI~
I written a class Form1 which inherit system.windows.forms.form
I close a form using "f1.Close()" and then later I new it again using the statement "f1 = new Form1()". When I click and use the control inside the form like tabControl, it causes a "System.ObjectDisposedException" error.
I have new the form again by why still say the object is disposed?
How to solve the problem?
thanks~
|
|
|
|
|
hi,
I didn't get you.
You Wrote
written a class Form1 which inherit system.windows.forms.form
I close a form using "f1.Close()"
that's is fine
you Wrote
I new it again using the statement "f1 = new Form1()".
from where you are calling this ?
You Wrote
When I click and use the control inside the form like tabControl, it causes a "System.ObjectDisposedException" error.
What you mean by this ?
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
sorry~
I have a class group all the form together.
First, I create an instance of class Form1 by using this statement
"Form1 f1 = new Form1()";
Then I somewhere call "f1.Close()".
As the object f1 is close, then I execute this statement again"
"f1 = new Form1();" in the grouping class
note the instance "f1" is the same instance as the previous call.
then after I execute this statement and execute "f1.Show()", f1 is shown on the screen. However, when I use the method of the control and this form, say, "this.textBox1.Text = "something"; ", it causes an System.ObjectDisposedException.
I think I new f1 again through it is closed before. However, exception occurs. WHy?
Thanks
|
|
|
|
|
HI,
On next instance call make sure whether object is alive or not.
if(f1.Equals(null))
f1=new Form1();
else
f1.textbox.text="something";
If this idea doen't surve your purpose then please send me the code block. i can help you. Sure.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
In fact, I have create the instance again after the form is dispose. However, it still throw object dispose exception.
In fact, after the form is closed, the object instance still NOT equal to null. I see it in the watch window.
Is there any other way to solve it?
|
|
|
|
|
hi,
it may simple logical error. if it is possible show me the code.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Hi,
In my application I have to call an external application (System.Diagnostics.Process.Start("C:\\NeckingRa\\Fortran\\necking_contour.exe"), (command window) , which creates one FILE that I need for my calculation, and thats why I need to pause my app untill external app is done (terminated).. Please, can somebody help me?? How can I do it?? Thanks
|
|
|
|
|
|
cant find .EnableRaisingEvents
|
|
|
|
|
It's a property of the Process class. You get an instance of Process from System.Diagnostics.Process.Start() ...
mav
|
|
|
|
|
Firs thankYou for help..
But I am not wery god in it..
I have to make a little application and call extern .exe file, wait untill its done and go on.. this extern .exe file creates a file i need in my calculation..
i have a button, and when I click on it:
private void button3_Click(object sender, System.EventArgs e)
{
System.Diagnostics.Process.Start"C:\\NeckingRa\\Fortran\\necking_contour.exe");
********* Hier I have to wait until this .exe app creates output.dat***************
********* how would U do it? Can U please write it for me, (I am beginer ********
System.IO.File.Exists("C:\\NeckingRa\\Temp\\output.dat");
System.IO.File.Copy("C:\\NeckingRa\\Temp\\output.dat",DSave.FileName,true);
}
|
|
|
|
|
using System.IO;
using System.Diagnostics;
private void button3_Click(object sender, System.EventArgs e)
{
Process p = Process.Start("C:\\NeckingRa\\Fortran\\necking_contour.exe");
p.EnableRaisingEvents = true;
p.Exited += new EventHandler(ProcessExited);
}
private void ProcessExited(object sender, EventArgs e)
{
if (System.IO.File.Exists("C:\\NeckingRa\\Temp\\output.dat"))
System.IO.File.Copy("C:\\NeckingRa\\Temp\\output.dat",DSave.FileName,true);
} The bill is in the mail
mav
|
|
|
|
|
Thank U, it works now.. Great, I am very very thankful for Your Help..
There are still a lot of Great an Cool people outthere in the World..
Once again Thanx
|
|
|
|
|
i want draw something the save to image, but i found that if use "BitBlt" function,if the window is overlaped by another window,"Bitblt" will copy the screen rectangle but not the window what i want.
i kown i can redraw "something" in "Bitmap" and use "Bitmap.Save()" to save to image, but i realy not want to redraw "Something" in "Bitmap",beacause redraw "Something" will waste time.
what can i do?
|
|
|
|
|
i want draw string follow a polyline, how to do in C#? e.g : i want draw a road and its name
|
|
|
|
|
This can be done, but will be tricky. I think the best would be to calculate the angle vector, and then use Graphics.TransformTranslate before writing each character. Perhaps there is something in the GraphicsPath class that mite be better?
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
Hi,
I want to sort a classes by different paramters, but no idea how to do this.
I delcared one class to store card infos, they are (string)name, (int) width and (int)height. I put them into one ArrayList, now I wnat to sort them by name or width or height. but how can I do this?
Could anyone give me some ideas or example code?
thanks for help.
|
|
|
|
|