Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Using Custom Item Types (Read 3693 times)
bmosbarg
YaBB Newbies
*
Offline



Posts: 6
Joined: Sep 19th, 2008
Using Custom Item Types
Sep 19th, 2008 at 7:47pm
Print Post  
In the developers guide there is a tutorial called 'Using Custom Items Types' that I have been attempting to use to become familiar with FlowChart.net. I can not get past step 2 using VB.net. Is there another example that would show how to create a line object, a text object and an Arc object. These objects would then be resizable and movable.

Thanks
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Using Custom Item Types
Reply #1 - Sep 20th, 2008 at 8:52am
Print Post  
This is a very basic Arc implementation:

http://mindfusion.eu/_samples/Arc.cs

You might play with the UpdateModify method to improve how mouse movement reflects on the angles. Currently it simply adds the horizontal mouse offset to the angles.

Take a look at the IconNodes sample to see how you might implement serialization for the SweepAngle and StartAngle properties.

This code lets the user draw Arc objects:

diagramView.Behavior = Behavior.Custom;
diagramView.CustomNodeType = typeof(Arc);

You could use Transparent ShapeNode objects to display text, instead of creating a class for text objects. As for lines, you might either use unconnected DiagramLink objects, or implement a Line class similar to Arc.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
bmosbarg
YaBB Newbies
*
Offline



Posts: 6
Joined: Sep 19th, 2008
Re: Using Custom Item Types
Reply #2 - Sep 20th, 2008 at 5:02pm
Print Post  
Thanks so much for your prompt reply, this is a big help.
  
Back to top
 
IP Logged
 
bmosbarg
YaBB Newbies
*
Offline



Posts: 6
Joined: Sep 19th, 2008
Re: Using Custom Item Types
Reply #3 - Sep 22nd, 2008 at 9:00pm
Print Post  
Is it possible to create a handle on the sweepangle and let the user click and drag the location?

Protected Overrides Sub UpdateModify(ByVal current As PointF, ByVal ist As InteractionState)

'Debug.Print(StartAngle & " -- " & sweepAngle)

sweepAngle = 90
'Can I make this a handle that the user can click and drag

End Sub

Thanks
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Using Custom Item Types
Reply #4 - Sep 23rd, 2008 at 7:18am
Print Post  
That sample already shows handles for both StartAngle and SweepAngle, but they might not be easy to spot if you are using the default SquareHandles style. For example set HandlesStyle to DashFrame, and you'll see the elliptical handles added by the Arc.DrawHandles implementation.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
bmosbarg
YaBB Newbies
*
Offline



Posts: 6
Joined: Sep 19th, 2008
Re: Using Custom Item Types
Reply #5 - Sep 25th, 2008 at 7:00pm
Print Post  
The handle is not moving with the mouse correctly, is there a way to correct this?

Thanks.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Using Custom Item Types
Reply #6 - Sep 25th, 2008 at 7:52pm
Print Post  
Right, now it just adds the mouse X offset to the angles, so the pointer position and the angle-adjustment handles do not match. Instead, you could calculate the angle that the mouse pointer makes with respect to the arc center, and set the angle to that value. Check the CustomDraw sample - it has a method for conversion from Cartesian (X/Y) to polar (angle/radius) coordinates, which should help with this.
« Last Edit: May 31st, 2021 at 1:42pm by Slavcho »  
Back to top
 
IP Logged
 
bmosbarg
YaBB Newbies
*
Offline



Posts: 6
Joined: Sep 19th, 2008
Re: Using Custom Item Types
Reply #7 - Sep 25th, 2008 at 8:44pm
Print Post  
Thanks again for the prompt reply.

That is precisely what we are trying to accomplish.
  
Back to top
 
IP Logged
 
bmosbarg
YaBB Newbies
*
Offline



Posts: 6
Joined: Sep 19th, 2008
Re: Using Custom Item Types
Reply #8 - Oct 2nd, 2008 at 4:20pm
Print Post  
I have successfully implemented a line class, but I am having difficulty using the handles to move and resize the line. Do you have any examples?

Thank you.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Using Custom Item Types
Reply #9 - Oct 3rd, 2008 at 10:20am
Print Post  
For lines you would not need to call the base class HitTestHandles and DrawHandles method. Just return 0 or 1 from HitTestHadles and render two selection handles in DrawHandles.

Assuming you have two PointF fields in the Line class, UpdateModify should set one of the points (depending on the current handle being dragged) to the InteractionState.CurrentPoint value. When either point changes, set Bounds to the smallest rectangle that contains both points, so that repainting and hit-testing work correctly.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint