views:

88

answers:

3

Hi I'm new to C# WPF. There's a flowchart WPF program in C#. The program can display objects and connecting arrows between them. ie eg

========           ========
|      |           |      |
| obj1 |  ------>  | obj2 |
========           ========

1 - How do I add a visual function to each object when right clicking them ? ie when I right mouse click an object, I like to be able to change its properties belonging to an application.

2 - how do I create and generate a file containing the relationship information about the objects above. ie obj1 flows to obj2

Thanks for sharing your thoughts

+2  A: 

1 - Handle the mouse click events for the objects, and do whatever you have to do. 2 - Serialize the object graph to XML or binary format.

Richard Hein
Hi Richard, thanks for responding. Is there a simple tutorial for such a working designer application ?
chz
+2  A: 

1) You will need to write hit-testing code to be used in the mouse click event. You need to check the screen location of each of your objects to determine which (if any) of the objects was "under" the pointer when the mouse was clicked. From there you can display the appropriate context menu for the functionality you want to implement.

2) If you just want to save the information to re-open by the app later, simple serialization to XML or Binary will work fine. If the intent is to make user-readable content, you will need to write a simple csv export or if the output needs to be more complex, a custom serializer.

More Info:

Hit-testing is the general term for evaluating what object has been clicked on, for example, when you click in a DataGridView, hit testing logic can tell you which cell/row/column was clicked on. Many Widget classes, including DataGridView, have a HitTest method which will return an object which provides this information. If the flowcharting tool uses custom drawing for the connected objects, then you will have to do the work of using the click coordinates to determine what element in the flowchart has been clicked on.

http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.hittest.aspx documents the HitTest method for the DataGridView.

http://www.codeproject.com/KB/list/CSharpHitTest.aspx is a sample program on CodeProject which does hit testing logic in a ListView.

cdkMoose
Hi cdkMoose, thanks for responding. What's hit-testing, new terminology to me. Is there a simple tutorial to show this hit-testing code and check screen location of an object ?
chz
Answer updated with info.
cdkMoose
+1  A: 

I am not sure how your application works and what controls you have used but still I would like to point you to this question having links to similar applications -

http://stackoverflow.com/questions/3769113/wpf-silverlight-flowchart-designer/3769240#3769240

akjoshi