What, with C#? This definitely is not worth it. It requires redefining a lot of structures already defined for C++ in the Platform SDK and P/Invoking a lot of function calls. And for what? Something that's done very rarely? If nothing else, doing this in VC++ would be much faster and easier to do. Use the right tools for the right job. Now when Longhorn comes around, many of these functions and structures should already be wrapped - but for right now, you'd have to do it all and it's definitely not easy!
Just do it the old fashion way. Right-click on "My Computer", go to "Computer Name" and read the directions. In most cases, your domain administrator doesn't allow you to do this yourself so talk to your IT department.
If you're not looking to do this programmatically, you're in the wrong forum big time! This is for C# programming questions.
You could create your own class that wraps a regular array and then use the indexing property to translate your negative indexes into positive indexes in the array that you are wrapping. Something like this:
private Array myArray;
publicobject this[int i]
myArray[i+indexOffset] = value;
// You'd have to fill in the rest yourself ;)
Where indexOffset is the amount you'd have to add to your negative index to get a positive index, or to put it another way, an indexOffset of 10 would let you have an index down to -10, which would translate into the index 0 of the array you're wrapping.
You might also think about inheriting from the Array class instead of wrapping. That might actually be better.
Can't imagine why you'd need to do this though.....
Convert a STRING!!!! to a CLASS!!! I hear you scream. Pull up a pew and let me explain the problem I have.
I am creating an application that pulls various values from an XML file and then uses these values to create various pieces of text within a PDF document. Now using iTextSharp (http://itextsharp.sourceforge.net/index.html[^]) this is fairly easy.
The problem is that I want/need everything to be driven by XML parameters, as an example to set the font of a particular piece of text you would use the following code :
The Font class is also serializable, so don't forget that you can give it a serialization context and let it serialize itself (and you can bet that Microsoft will serializable about any non-default property available).
I have a picture box displaying an image. I want to be able to use 4 trackbars (one on each side) in order to draw 4 lines across the image. The end result will be to divide the image up into 9 regions graphically. I've got the image displaying, and I've got the 4 trackbars drawing the lines I want. The problem I'm running into is twofold.
1. How do I get the line to draw on top of the picture box image? Right now, the lines only appear beneath the picture box.
2. Whenever I move a trackbar slider, the line left from another trackbar is wiped out before the new one is drawn. The end result is that only one line can be displayed at a time, when I want all four to be displayed all at once.
Also... does anybody know if there's a way to change the color of the slider on the trackbar, and not just the backcolor?
as for painting the lines i think you have to override the paint event and as for drawing all at once you should use SetStyle function to the user control and modify the parameter DoubleBuffer to true and you will get good results
Did you look at the documentation for PrintDialog? Seriously - researching problems is an important development skill. If you did, the class documentation has a good example of how exactly this is done:
// Declare the PrintDocument object.private System.Drawing.Printing.PrintDocument docToPrint =
// This method will set properties on the PrintDialog object and// then display the dialog.privatevoid Button1_Click(System.Object sender,
// Allow the user to choose the page range he or she would// like to print.
PrintDialog1.AllowSomePages = true;
// Show the help button.
PrintDialog1.ShowHelp = true;
// Set the Document property to the PrintDocument for// which the PrintPage Event has been handled. To display the// dialog, either this property or the PrinterSettings property// must be set
PrintDialog1.Document = docToPrint;
DialogResult result = PrintDialog1.ShowDialog();
// If the result is OK then print the document.if (result==DialogResult.OK)
// The PrintDialog will print the document// by handling the document's PrintPage event.privatevoid document_PrintPage(object sender,
// Insert code to render the page here.// This code will be called when the control is drawn.// The following code will render a simple// message on the printed document.string text = "In document_PrintPage method.";
System.Drawing.Font printFont = new System.Drawing.Font
("Arial", 35, System.Drawing.FontStyle.Regular);
// Draw the content.
System.Drawing.Brushes.Black, 10, 10);
In order to implement events in remoting, the remoting object must NOT be "SAO-Single call"? Is this correct?
How'd you implement a chat server? Say, when a client call ChatServer.SubmitMsg(string msg) - ChatServer being remote object - ChatServer would then broadcast the message to all other client. How'd you implement or design the architecture?
I'm thinking, since it's one chatserver to many clients, it shouldn't be CAO. But it can't be SAO either. The most suitable choice would be SAO-Singleton. Since SAO-singleton is stateful, a message submitted by one client can be broadcasted to all other clients using events. ie. MsgSubmitEvent can be fired from within SubmitMsg. What do you think?
The server should be a WKO server - Singleton. It should also be thread-safe since multiple clients will be hitting the same server objects.
Look in Samples\Technologies\Remoting\Basic\RemotingEvents in your .NET Framework SDK directory. This has an example that uses a WKO server object with (a) client(s) that connects to it. This is similar to a chat application. There are also several examples of this here on CP.
So you want to instantiate and hook-up an instance for every call?! That's insane. Memory is extremely cheap and process cycles are not. 1000 users sharing one object is far better than 1000 users creating new objects I assure you! This is how most chat servers work, only they typically use raw sockets but a single application. The DirectX 9 SDK has many examples of this too, only using DirectPlay (sockets).
Having a single object also makes it easier to communicate with other connected clients. If each client connects to a separate object, that object will have to waste time persisting messages in a database (extremely inefficient and from everything I've seen - never done) and clients waste time getting it out. All current logging features are responsibilities of the client applications. They simply log what they get from the server (indirectly from the clients).
Look for the examples here on CP. They all use tried-and-true methods for chat servers and clients which are used for IRC, AIM, YM, MSN, etc.
Thanks. It make sense. Just wondering if that SAO-Singleton will become a bottom neck. You definitely don't want to launch long running method calls against the server. Broadcast message also reminds me that perhaps I should take a look at how expensive Event is.
Perhaps this may work. SAO-Singleton simply receives messages. It will pass the message to ONE (but another) SAO-Singleton on server, which will be responsible for broadcasting. Thereby, separating the listening/broadcasting stages - each handled by a different remoting object... hum...
FYI, the term is "bottleneck" - like how the neck of, say, a beer bottle gets narrower and forces larger quantities to trickle through it.
Trust me, with the proper threading, this will work. And you don't need two separate remoting objects. You really should pick up MSPress's ".NET Remoting" or Ingor Rammer's "Advanced Remoting". With a singleton, all the clients are connected to the WKO just like controls would be in the control collection of a parent control (or any collection, for that matter). The Remoting infrastructure takes care of dropping clients as they disconnect or timeout. You just need to filter the messages so that when a message is received (in the form of a struct or remotable class) you, for example, loop through the connected clients (in a collection or in a hashtable of collections or something) and send the message when appropriate. If you thread this, there won't be any problem.
Socket-based chat servers are no different. As soon as they receive a connection it spawns a new thread and passes that connection to be processed in that thread.
There are a ton of examples on the 'net (and several here on CP) that you really should take a look at. This is a basic problem that is solved almost the same way every time (sans the actual communication protocol).
I'm giving up on databinding in my windows form project. It just doesn't work the way I want it too and I'm sick of trying to work around it. So, my question is, what alternatives do I have? Does anybody know of any good articles which illustrate alternative methods of getting data from a datasource and using it to populate windows controls and then getting the data back to the datasource again. I want to try and understand all the nuances of the problem before I rush headlong into coding something (like I usually do!) and then having to trash it two days later.
I am using VS 2002 and the 1.0 framework.
I created two NT security groups for my application. I placed myself into one of those groups. I run NET USER /DOMAIN and it shows that I am in the correct group.
so I do the following:
WindowsPrincipal principal = new
bool isValid = principal.IsInRole("D-U-MYSECGROUP");
This is always returning false, even though the NET USER /DOMAIN clearly shows me in the group. Why?????
Any help appreciated!
_____________________________________________ The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.