|
Hi
I need to make use a data structure to save a 2D data, let say node_id and node_status and later on I need to manipulate the node_status as necessary. Then I need to count down the nodes as per their staus. Let say the number of nodes whose shatus are 'off', and the rest, whose status are 'on' Should I use an ArrayList ? or an array ? In each case, how do I store, manipulate and search thorugh...and the problem is I am having trouble where/how to collect data into the ArrayList or array.
Thanks. here goes the part of code where I am having problem to implement the data sturcture:
int i;<br />
int num;<br />
int numsect;<br />
<br />
num = NUM_NODES;<br />
ArrayList nbuffer = new ArrayList();<br />
for(i=0; i < num; i++) <br />
{
int j;<br />
numsect = nodes[i].sector_info.numsect;<br />
for(j=0; j < num; j++) <br />
{
double distance, angle, covrdArea;<br />
distance = caldist(nodes[i].lctn, nodes[j].lctn);<br />
<br />
if(distance <= (2*((double)nodes[i].radius)) && distance > 0.0) <br />
{
angle = getangle(nodes[i].lctn, nodes[j].lctn, distance);<br />
<br />
covrdArea = getArea(nodes[i].id, nodes[j].id, distance, angle);<br />
<br />
tw.WriteLine("Distance form Node_" + nodes[i].id + " to Neighbour Node_" + nodes[j].id + " is " + distance);<br />
tw.WriteLine("Angle btw Node_" + nodes[i].id + " in sect " + numsect + " to Neighbour Node_" + <br />
nodes[j].id + " is " + angle);<br />
tw.WriteLine("Neighbouring Node_" + nodes[j].id + " is covering " + covrdArea + " percent of Node_" +<br />
nodes[i].id + "'s sensing area");<br />
<br />
<br />
}
}
tw.WriteLine("----------------- END OF NEIGHBOUR_LIST OF NODE_" + nodes[i].id +" --------------------------");<br />
tw.WriteLine("");<br />
nbuffer.Add(nodes[i].id);<br />
}
nbuffer.Clear();<br />
<br />
tw.Close();<br />
}
Thanks
aussi
|
|
|
|
|
If you're storing a pair, is one of the values unique ? Perhaps a hashtable is a better choice.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Hello ppl,
I am using a tabcontrol for desktop client application(C#/ADO.Net),which has a parser in one tab and report Generator as another tab page. I have used multithreading and assigned a worker thread(say backGroundThread)for the application to parse values - So that the application would repaint itself whenever the user switches back and forth between any window and the application. But as i have used Threading, when parsing is in progress, the user is able to navigate through tabs. So I have to disable the rest of the tabpages in Tabcontrol when parsing in progress.
I tried to reset the tabpage to Parser tab(Sender TabPage) in TabControl_SelectedIndexChanged(object sender, System.EventArgs e)
How do I capture the tabpage(Sender TabPage). i.e name of the tabpage from which the user tried to navigate?
I tried to typecast the sender object to get the sender tabpage.BUt i could not get a break through in identifying the source tabpage.
System.Windows.Forms.TabControl homeTab = (System.Windows.Forms.TabControl)sender;
kindly help me to overcome this problem.
Thanks,
Cheers,
Jagan.
|
|
|
|
|
Below mentioned code will help you to get the index of the Tab page which have the focus.
private void tabPage1_Click(object sender, EventArgs e)<br />
{<br />
TabPage tb=sender as TabPage;<br />
MessageBox.Show("Index is : "+tabControl1.TabPages.IndexOf(tb));<br />
}
Using this code you can achive your requirement.
Sreejith Nair
[ My Articles ]
|
|
|
|
|
Hello sreejith,
Thanks for replying back. But i donot want the name of tab which have the focus.
Let me expain with an example.
Say there are three tabpages - Tabpage tpA,Tabpage tpB,Tabpage tpC in a tabControl and currently user is in Tabpage tpA and clicked on tpB. I want to capture the name of the tab from which the user moved to tpB (either from tbA or tpC).. in otherwords my lastselected tabpage and not the current selected tabpage.
Hope i am clear in explaining my problem.
Cheers,
Jagan
|
|
|
|
|
one way to achive this is keep a global class variable
int lasttabIndex;
At form load time set it to whatever tab you want to open the first time form loads.
There after in event
private void tabControlDeal_SelectedIndexChanged(object sender, System.EventArgs e)<br />
{<br />
TabControl ctrl = (TabControl)sender;<br />
int x = ctrl.SelectedIndex;<br />
<br />
<br />
lasttabIndex = x;<br />
}
Hope this helps
Ruchi
|
|
|
|
|
Thank you ruchi , that was helpful
|
|
|
|
|
Hello all.
I made a NET class library, and now I want to reference it in my application.
The add references dialog allow me to add a reference to the library but I want to reference the library in is Debug version when I'm in the Debug version of the application and its Release version when I'm in release mode ( as I do when I write code in C++ )
Is this possible or I only can reference one dll for Debug and Relese ???
Thanks.
|
|
|
|
|
If your two projects are in the same solution then you reference the project rather than the DLL (properly called an assembly in .NET) and Visual Studio takes care of the Debug/Release versions for you.
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
I think this doesn't works.
We have solution with an appication an a class library. Right now, the class libray is reference as a project, but my boss showed me on Friday that in a Release build the DLL that was copied to the Output Directory was the Debug version so I would prefer to use other solution (if exits)
|
|
|
|
|
That doesn't sound right to me. If you do a release build it should build the release versions of each of the assemblies. Did you do a rebuild of the solution? Make sure by deleting the bin and obj directories and seeing that it is building the right thing.
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
Yeah I know that this strange but my boss showed to me. He made a rebuild of the release version and in the ouput window it showed that the Debug version was copied. Also we look at the dates of the dll and
really the Debug version was copied to the Release output.
|
|
|
|
|
The only thing I can think of is that the properties for the project(s) are messed up somewhere.
I suggest you look at the properties for the project, in the Configuration Properties->Build page check that the Debug and Eelease versions are being put in the right places. For instance, check that the release isn't being put in the Debug folder or vice versa.
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
Is the source for the .DLL in a seperate SOLUTION? What Colin is telling you will work if your .DLL Project and your application project are in the same solution.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
No, there are in the same solution. The only thing to comment is that the application is written in c++ and the dll in c#. I don't know if this can be the reason for the problem
|
|
|
|
|
Then there shouldn't be a problem. If you rebuild the entire solution, instead of a project, AND use project references instead of assembly references in your C++ app, then selecting Release or Debug should apply to all projects in the solution.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks Dave. I will try this.
|
|
|
|
|
Hi~
I am writting C# application to call a VC++ dll by P/Invoke.
There is a CString argument type for the method in C++ dll exposed to C#.
What is the corresponding data type in C#?
Thanks
|
|
|
|
|
You can freely substitute CString objects for const char* and LPCTSTR function arguments. And here in C# you can go for string.
Sreejith Nair
[ My Articles ]
|
|
|
|
|
For the P/Invoke you should use StringBuilder
|
|
|
|
|
Hi all,
I want to write a c# application which can track the action on files in
window, e.g, when an user move a file from one place to another place in window, the C# application can record this event and the destination place.
Could anyone give me some hints how to start it ?
Thanks
Patrick
|
|
|
|
|
|
Hello all.
I'm a beginner in C# and right now I'm developing a class library.
I have seen that when I build the project two directories are created bin and obj.
The first one is the output of the project, which I know I can modify the path in the project settins. This directory have two subdirectories Debug and Release and each one of those two stores the output file and and PDB file.
Also, In the obj directorie, I found the outfut file of the project and the PDB file. I don't know why this directory is created. I would like to avoid this to be created. Also I'm not sure where is placed really the ouput of the project, in the bin directorie, in the obj or in both.
Can anyone explain to me this behavior.
Thanks in advance.
|
|
|
|
|
Jose Vicente wrote:
lso, In the obj directorie, I found the outfut file of the project and the PDB file. I don't know why this directory is created. I would like to avoid this to be created.
It's created during the compile of your project and used for linking various parts of your project together in the final steps of creating your target executables. No, you can't stop it from being created.
Jose Vicente wrote:
Also I'm not sure where is placed really the ouput of the project, in the bin directorie, in the obj or in both.
In the bin folder, under either Debug or Release, depending on what configuration your compile is set for.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|