Click here to Skip to main content
15,885,868 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in WPF i saw some events like StrokeCollected , StrokeErased ,StrokeErasing ,
i want them in my Windows form for my controls like panel or pcitureBox,

is that possible to create a handler to invoke that event ?

thank you in advance
Posted
Comments
Mehdi Gholam 16-Nov-11 1:02am    
I believe they are WPF specific, and not available on winforms.
Sergey Alexandrovich Kryukov 16-Nov-11 2:17am    
Of course. I provided an answer on events and mentioned this.
Unfortunately, OP is in a very deep confusion about the basics, so it's hard to give him effective help. Only going back to basics can help effectively, but OP needs to be convinced. Delusions, delusions...
--SA

An event handler is not used to invoke the event, it is used to handle the event when it is already invoked. So, no, this is not possible.

However, you never need to invoke any event declared in any already created class — this is already done in this class (it it is implemented correctly, of course). Moreover, you never can do it, unless this is your class with the source code which you can modify. You cannot access firing event even if you try to do it in a derived class. This is one of the most important limitation of event instances compared to delegate instances.

All you can do with event declared in some already existing class is to add an event handler to its invocation list or remove previously added handler. Of course you can do it with the events you mentioned in the question. This is all you really need.

[EDIT]

By the way, the class PictureBox is highly misused, it can be used effectively only in very simple situations and there is absolutely no need to use it in WPF. In most situations, it should not be used even in Forms. Explain your ultimate goal if you need to get some help on WPF graphics.

You should better through out the idea of mixing WPF and Forms in one UI. This is in principle possible, but not beneficial, very limited and problematic. It's mostly used for re-using legacy Forms code.

—SA
 
Share this answer
 
v3
Comments
mohanrajkiller 16-Nov-11 2:28am    
i will brief in detail i am trying to implement this project in winforms is that possible???

http://www.codeproject.com/KB/WCF/DrawMeWCF.aspx
Sergey Alexandrovich Kryukov 16-Nov-11 3:54am    
It's surely possible. It's even hard to say, what's better, it depends on some detail. Basically, if you want to get vector graphics, WPF is better as all the bases for it are already well implemented. For pixel graphics, it's a question.
--SA
Sergey Alexandrovich Kryukov 16-Nov-11 3:56am    
I think I pretty much answered to everything in the scope of your original question. If you need details on implementation of graphical application in WPF or Forms, it should be a separate one.

So, will you consider accepting this answer formally (green button) -- thanks.
--SA
Mehdi Gholam 16-Nov-11 3:48am    
5'ed
Sergey Alexandrovich Kryukov 16-Nov-11 3:52am    
Thank you, Mehdi.
--SA
1. You do not invoke events through handlers. Events are invoked based on user actions in UI (in this case) and handler handles it.

2. You can have those events too but for that, you will have to create your own picture box. Why do you need those events anyways? If you could share that, someone can provide you with a solution.


Edit: You will have to handle the Paint event and use the Graphics object to draw the things on screen. Make use of Mouse events to get the coordinates and use Paint event to draw.
 
Share this answer
 
v2
Comments
mohanrajkiller 16-Nov-11 2:31am    
i am just trying to implement this project in winforms so i need those events :(
http://www.codeproject.com/KB/WCF/DrawMeWCF.aspx
dan!sh 16-Nov-11 2:34am    
Updated the reply.
mohanrajkiller 16-Nov-11 2:41am    
Yes i have did that using a panel i am able to draw but i have to pass it on to client screen
Mehdi Gholam 16-Nov-11 3:49am    
5'ed

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900