|
Thanks Heath,
...but that's not an appealing option either... (ain't I fun to help?!?). The objects need to be able to function without the gui. For example we may need to use then in Console applications for data maintainence or to slice and dice the data in other ways through WebApps, etc, so I think I favor the event-base approach since other application can just ignore the events.
That said, do you know why the get accessor on the DerivedNode.Text property is not called when the node is displayed? That bit baffles me.
Bill
|
|
|
|
|
Then using events would be the logical way to go.
The reason the get accessor is not called is because the TreeView uses the TreeNode type. Its Text property is not virtual so the IL instruction call is used, as opposed to callvirt . Even if you hide it using the new operator, this will not work because the TreeView is using call on the actual TreeNode type. If you were to get the Text property referencing your type (DerivedNode ), then your get accessor would be called.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks again Heath,
As per the usual: you told me what I needed to know. I'll post a generic version of what I come up with here so maybe future TreeNode-noobs won't have to take up forum-bandwidth.
Out,
Bill
|
|
|
|
|
Hello All
I am on a project that is analogous to a game in which you are tasked to draw the number of students on campus as if you are looking from a helicopter. The students can disappear from the screen as they get into classes or buildings and more students can also added as they try to get to classes from outside campus.
I have tried to use the cirular buffering technique to buffer the total number of students at one moment and display the contents on the screen. Let's say that I have a timer that ticks every 100msec which then will try to paint the location of the student on campus.
But then the problem comes when the program tries to get the student objects from the buffer which is a collection of ArrayList's. It kept telling me that the index in the ArrayList that it's trying consume has changed. I couldn't think of how to get around it now. If you could point out what is wrong with my code, or suggest any other technique, it would be very appreciative.
Below is the code similar to mine:
public class Student
{ public string a,b,c; public int id,x,y,z;}
public class CBuffer
{ ArrayList[] buffArrayList = {null,null,null};
int occupiedBufferCount;
public ArrayList BufferSet
{
get
{
lock(this)
{
if (occupiedBufferCount == 0)
Monitor.Wait(this);
ArrayList readValue = buffArrayList[readLocation];
--occupiedBufferCount;
readLocation = (readLocation +1)%buffArrayList.Length;
Monitor.PulseAll(this);
return readValue; } }
set
{
lock(this)
{
if(occupiedBufferCount == buffers.Length)
Monitor.Wait(this);
buffArrayList[writeLocation] = value;
++occupiedBufferCount;
writeLocation = (writeLocation + 1) % buffArrayList.Length;
Monitor.PulseAll(this); } } }
public class Consumer
{ private ArrayList ar;
private CBuffer buff;
Graphics g;
public void Consumer(CBuffer _buff, Graphics _g)
{ buff = _buff; g=_g; }
public void TestDraw()
{
PaintBground();
ar = new ArrayList();
ar = buff.BufferSet;
foreach (Student s in ar)
DrawStudentLocationOnScreen(); }
private void DrawStudentLocationOnScreen(){ ..codes..} }
public class Producer
{ private ArrayList ar;
private CBuffer buff;
public void Producer(CBuffer _buff)
{ buff=_buff;}
public void Produce()
{
GetStudentsFromFile();
ar.Add(student);
buff.BufferSet = ar; }}
|
|
|
|
|
Short answer: You can't do this easily with ArrayLists. With an ArrayList, you can't simultaneously modify and iterate through the collection.
Since you're dealing with a fixed-size buffer, why don't you use a standard array? (ie, Student[] ar = new Student[length]; )
Jeremy Kimball
magnae clunes mihi placent, nec possum de hac re mentiri.
(Large buttocks are pleasing to me, nor am I able to lie concerning this matter)
|
|
|
|
|
Jeremy,
I've thought about your suggestion before. But I think when my timer ticks every 100msec, the number of students and the variables in the Student objects will also change. So I think it wouldn't work in this case. However, if you have a game with fixed number of players or objects on the screen, fixed-size buffer would definitely work.
Thanks,
Tim
|
|
|
|
|
Multithreaded programming is extremely difficult. Even those who are consider experts at it frequently make mistakes. The producer/consumer problem isn't trivial. It is most easily solved with semaphores[^].
public class Buffer
{
private int in = 0;
private int out = 0;
private object[] buffer = new object[CAPACITY];
private Semaphore full = new Semaphore(CAPACITY);
private Semaphore empty = new Semaphore(0);
private Semaphore mutex = new Semaphore(1);
<br>
public object Thing
{
get
{
mutex.WaitOne();
empty.WaitOne();
object t = buffer[out];
out = (out + 1) % buffer.Length;
full.AddOne();
mutex.AddOne();
return t;
}
set
{
full.WaitOne();
mutex.WaitOne();
object t = buffer[in];
in = (in + 1) % buffer.Length;
buffer[in] = value;
mutex.AddOne();
empty.AddOne();
}
}
}
Notice that this implementation isn't trivial. Furthermore, the Semaphore implementation isn't trivial either.
|
|
|
|
|
Thanks, Brian!
I think you are pointing me to the right direction. Never before I had to use this so I'm going to have to some reading. I've just read some on semaphore on MSDN. So, I think it'll take me some time to fully understand and put together a Semaphore object
Regards,
Tim
|
|
|
|
|
It'll take some time to fully understand so be patient. Fortunately the link I provided is for a Semaphore object that has already been coded by a Microsoft employee so you shouldn't have to put one together yourself. Good luck.
|
|
|
|
|
Didn't realize there was a link on "Semaphore" in your first msg. My fault.
Cheers
|
|
|
|
|
I would like to force DataGrid to use my implementation of IComparer when sorting columns.
Can anyone give me some ideas on how to achieve that if possible at all??
Dries
|
|
|
|
|
String.Compare is used internally by the DataView.Sort property (in the set accessor) with no way to override it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Out of curiosity, could you derive a class from DataView (dunno if it's sealed or not, too lazy to open up studio right now) and override the Sort property?
Jeremy Kimball
magnae clunes mihi placent, nec possum de hac re mentiri.
(Large buttocks are pleasing to me, nor am I able to lie concerning this matter)
|
|
|
|
|
It's not virtual, so you'd have to hide it, but the controls like the DataGrid will indirectly refer to your type as a DataView , meaning that its definition of Sort would be used.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ah bugger...you could always decompile System.Data.dll, modify the IL, then recompile it
Jeremy Kimball
Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum immane mittam.
(I have a catapult. Give me all the money, or I will fling an enormous rock at your head)
|
|
|
|
|
Does anyone know how to synchronize 2 database files
(apply the changes on both) in C#
I've tried to add to project references to both Microsoft Active Data Objects 2.7 and Microsoft Jet Replication Objects (2.6?).
and I've read some examples in VB
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/dnacc2k/html/jrorep.htm
it didn't help much

|
|
|
|
|
hai there,
Give me detailed description about Visual Source Safe 6.0c. how can integrate with my .Net projects. Show me some link for detailsed description.
Advance thanks
hai, feel free to contact
Sreejith SS Nair
|
|
|
|
|
Install it, configure it in VS.NET's Tools-<Options, then add your projects to source control by right-clicking and selecting Add to Source Control (or from the File-<Source Control) menu. Note, with VSS 6.0 you can either add a solution (not a good idea in most large development projects where developers may want their own solutions with whatever projects they're responsible for) or a single project - you cannot add multiple projects without problems.
From there, you just check out your files, edit them, test them, then check them back in. Never check-in incomplete code (i.e., that won't compile), otherwise you'll cause problems for anyone else.
The best way to learn is to just try it and check out all the options available. It's really not difficult and there's really not a lot of articles that explain the simple stuff - more so just how to managed certain types of projects like ASP.NET sites, which can be a hastle because of their nature. For those types of articles, just see http://msdn.microsoft.com[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Quick Question : How is remote debug setup?
Sounds simple enough, but there are a few hurdles in the way :
1) I dont have physical access to the machine that will be debugged
2) I cannot install Visual Studio on it, nor run the VS install and just select remote debug tools.
3) The machine I am debugging from is in a standard windows domain, the machine i am debugging to is in a DMZ and cannot see domain logon details - therefore I cannot add myself as a "Debugger Users"
4) I have tried running the debug server with "-anyuser" in "-tcpip" mode but VS still tells me I cannot connect as I need to be part of the "Debugger Users" group
So in summary I need to configure/install remote debugging by transferring the necessary files across the network and then running it in such a way that I am prompted for a user/pass when connecting to the remote debug services or allowing remote debug for any connecting user.
I have followed the instructions located at :
http://msdn.microsoft.com/library/en-us/vsdebug/html/vctskInstallingRemoteDebugMonitor.asp[^]
But this just presents me with :
Visual C++ Remote Debug Monitor(x86) Version 7.10.3077
But I need to be able to debug J#, VB .NET, C#
Any help is greatly appreciated
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
Without physical access or security rights on the remote machine, you're pretty much sunk. You may need to bring IT in on this one, if you can pull them away from all their important work...you know, solitaire, civ, playing XBox in the back room, that sort of stuff.
Once you get install the remote debugging tools, you're pretty much set and you obviously know what you're doing from there.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
If you can't install the debugger tools how do you debug it? Remote Debugger is not a way to work around the lack of debugging tools but a tool to use in special cases and this doesn't sound like its applicable.
You are pretty much stuck without a little help from IT. Remote Deubgging is very iffy when crossing sub-net boundries in the first place let alone a machine sitting in a DMZ (connections between the DMZ and trusted nets should be limited by any sane IT admin). Then there is the question of how domains are configured going between the trusted net and the DMZ. They very well maybe completely seperate domains which adds a wrinkle. Besides, installing the Remote Debugger on a production machine might be a security hazard that maintainers don't want to deal with.
The best thing I can recommend is setting up another machine that closely approximates the machine/system in question. Simply put it might be impossible to get the Remote Debugger to work out of a machine in the DMZ because of security policies in place. Without further input from your IT staff who knows what is going wrong. Hopefully you aren't tinkering with live machines in the first place!
|
|
|
|
|
Hi,
I want to use Keypress event in my windows form. When user press enter that time i want to catch that event. and how to use the keypress event because in visual c# i never seen ASCII keys. Tell me how to catch keypress event and use ASCII values for trap the key which is press by the user.
Thank You for Help,
(Hemant Uttam Mane)
|
|
|
|
|
Web or Win Form?
There are some events and properties in WinForm to see keyboard: KeyPreview, KeyPress, KeyDown etc. See EventArgs and KeyData, KeyChar, KeyCode properties.
Hi,
AW
|
|
|
|
|
There's many ways of doing this. If you want to catch these in your derivative class, override OnKeyDown . External to your class, handle the KeyDown event. This is to catch and potentially "handle" the key without it being passed to the target window. If you don't care about stopping it from being dispatched, you can handle either KeyPress or KeyUp .
In there, you actually use the KeyEventArgs - not the EventArgs like the other response mentioned - to get the Keys enumeration member for pressed keys, or just the ASCII character value itself. See the documentation for the KeyEventArgs members for more details.
If you want to catch keys throughout your application (say, for configurable hot keys), implement the IMessageFilter class and add your implementing using Application.AddMessageFilter . You get a Message structure that contains the message (such as WM_KEYDOWN ) and you can get the data from the WParam and LParam properties. You can also return true to signal that you've handled it and the message should not be dispatched.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i am using visual studio to make some histogram graphs and pie graphs of standered divation but the programme does not recognize the graphics.h header file. how should i make the graphs and please tell what should i do to this heard file (graphics)
help me in graphics
|
|
|
|