|
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.
Any suggestions?
Also... does anybody know if there's a way to change the color of the slider on the trackbar, and not just the backcolor?
Thanks. 
|
|
|
|
|
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
|
|
|
|
|
How can i set the printer before print something?
i guess i must use Printdialog but i dont know how
|
|
|
|
|
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:
private System.Drawing.Printing.PrintDocument docToPrint =
new System.Drawing.Printing.PrintDocument();
private void Button1_Click(System.Object sender,
System.EventArgs e)
{
PrintDialog1.AllowSomePages = true;
PrintDialog1.ShowHelp = true;
PrintDialog1.Document = docToPrint;
DialogResult result = PrintDialog1.ShowDialog();
if (result==DialogResult.OK)
{
docToPrint.Print();
}
}
private void document_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
string text = "In document_PrintPage method.";
System.Drawing.Font printFont = new System.Drawing.Font
("Arial", 35, System.Drawing.FontStyle.Regular);
e.Graphics.DrawString(text, printFont,
System.Drawing.Brushes.Black, 10, 10);
}
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
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.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
So, SAO-Singleton... I was worried that 1000 users will be sharing one server instance (ie. one SAO-Singleton)
What about SAO-SingleCall. Persists the submitted message on a database.
|
|
|
|
|
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.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
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).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I suggest you make a visit to www.ingorammer.com and view the Remoting FAQ.
His Advanced .NET Remoting book is pretty good too.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
How can i enumerate data sources or find all data sources in c# please explain briefly. if some one know any related article give that link too
Thanks
Inam
|
|
|
|
|
Umm..."data sources" describes ANY source of data from an array to a RDBMS to a simple file. Please be more specific.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
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.
Cheers
|
|
|
|
|
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
WindowsPrinciple(WindowsIdentity.GetCurrent());
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!
Thanks. Michael
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Try
bool isValid = principal.IsInRole("MYDOMAIN\MYGROUP"); This is mentioned in the docs.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath,
Thanks. I had done a load of testing yesterday including creating a method CheckUserAppendingDomain with all of them failing. I realized later that security put me in the group yet I had not logged off and back on. After I logged back in to have my token properly set, I forgot to retest the CheckUserAppendingDomain. That worked!!!
Michael
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Hello I'm really new to the world of programming
And I was wondering if anyone could give me a good source to learn C# from, or "mentor" me help me to get started on C#.
Hopefully when I'm a compitent programmer in C# I want to go on to to learn C++.
If anyone could help me get started I would be very greatful.
Thanks<blink>.
-=LoKi=-
|
|
|
|
|
|
I can't find what topic it's under,I really am an Absolute beginner,The titles of these topics mean nothing to me, Is there anywhere, or anyone who could help me start right from the beginning?
|
|
|
|
|
SO LEARN. Are you just going to go through guessing and without research skills. The link I gave you is to a similar question where I and a bunch of others posted various web sites where you can start learning.
This site is to help community members - not teach you from scratch. There are many tutorials for beginners and lots of articles for intermediate and advanced readers. There are hundreds of books about .NET and C#. There's the MSDN Library that has the complete .NET SDK class library reference plus gigabytes of other information (not including the downloads!). It's all out there.
Besides, how is any one of us supposed to host a class for you? You have to take the initiative yourself. For all of us in these forums that typically are the ones answering questions - how do you think we learned?
Pick up one of many books from Microsoft Press or visit that link I gave you originally and look at the replies for many sites to help get you started. Good research skills are crucial to being a developer. This isn't like flipping burgers were you get trained to know everything you should. This is an ever-growing field with limitless possibilities and hundreds of languages, frameworks, and platforms on which to solve problems.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
You should get Mastering Visual C#.NET by Jason Price and Mike Gunderloy. Sybex publishing, ISBN: 0-7821-2911-0
|
|
|
|
|
Below is my code
try
{
DirectoryEntry m_de = new DirectoryEntry("IIS://localhost/w3svc/1");
int i=0;
object o=i;
o=m_de.Invoke("Status",new object[0]);
m_de.CommitChanges();
this.txt.Text=i.ToString();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
when excuting the line m_de.Invoke("Status",new object[0]);
the application throws a TargeInvocationException
it seems the mothed IIsWebServer.Status can not be found
but I can use "Start"&"Stop" methods
Please help me
|
|
|
|
|
Looking at the IIsWebServer WMI provider class, there is no documented "Status" property. Also, because it's a property, you can't invoke the property but you can invoke the property accessor - try invoking "get_Status" instead (if it existed, which it doesn't seem to). You can also use the Properties property of the DirectoryEntry itself and refer to the property by name (since the returned PropertiesCollection is an IDictionary ). You'll get a PropertyValueCollection and can loop through the values (probably only one for what you want) to get the values.
While there is no documented "Status" property, there is a "ServerState" property that returns an SINT32 (should map to an Int32 in .NET).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
You are right,man.
I'll just do what you say
|
|
|
|