Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Issues/Queries with NetSample demo application (Read 7070 times)
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Issues/Queries with NetSample demo application
Jan 20th, 2009 at 9:14am
Print Post  
Hi,

In demo application there is an application NetSample which demonstrates that nodes can be created by clicking and also text can be attached to it.

The issue here is that when we delete the node, only the image is getting deleted not the text itself.

Also i would like to know how to achieve following in regard to this sample -
1) We will provide a toolbar that will have images of building, Printer etc. Clicking on one of them will change the wpfdiagram cursor and then clickin on the diagram sheet will draw the corresponding node object and cursor will then change to default and subsequent clicks should not then create node objects until any object from the toolbar is selected again.
2) Above feature should also work in case of links that is there will be a toolbar with different type of link objects and clicking on a link object of tollbar will change the wpf diagram cursor to pen and then we would be able to create links between two nodes and without clicking on link objects the user should not be allowed to create links between objects.
3) The associated text should also get deleted with the node.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Issues/Queries with NetSample demo application
Reply #1 - Jan 20th, 2009 at 1:43pm
Print Post  
Hi,

3) After calling AttachTo(), set mainNode.SubordinateGroup.AutoDeleteItems = true. Another option is to create a text region below the shape outline as in the sample our developer created for you.
1) That sample shows how to change the cursor as well.
2) Set DiagramView.Behavior to DrawLinks when in link drawing mode, DrawShapes if you need to let users draw shapes, or Modify to allow only selecting and moving items.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: Issues/Queries with NetSample demo application
Reply #2 - Mar 5th, 2009 at 9:41am
Print Post  
Hi,

In the same demo application (NetSample) can you suggest me how to align text attached to the node dynamically so that it can be  aligned left/right/top/bottom in respect to the node.

In the sample created by you to get above thing done you said the text region definition needs to be changed how can it be done for all the diagram nodes dynamically (say on a button click)

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Issues/Queries with NetSample demo application
Reply #3 - Mar 5th, 2009 at 12:05pm
Print Post  
Hi,

Do not use the custom shape definition that shows the text below the node. Instead, change the TextFormat property of nodes to align the text. E.g. aligning text to the top-left of a node should look like this:

[code]
StringFotmat sf = new StringFotmat();
sf.Alignment = StringAlignment.Near;
sf.LineAlignment = StringAlignment.Near;
node.TextFormat = sf;
[code]

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: Issues/Queries with NetSample demo application
Reply #4 - Mar 9th, 2009 at 11:53am
Print Post  
Thanks for the reply. I tried it but it seems that it is taking top-left of the node. The thing i want is that the text and node should be disjoint and they should look like separate entity. like this :
1) Say for top alignment:
<Text>
<node>
2) for left alignment
<Text><node>

So, what to do in above case. As we may have a requirement in which a user may opt for left text alignment instead of default bottom, and in that case it does not look good to change my custom shape for each of the diagram node to reflect left text alignment. How to solve this problem?

I think it should be added as a new feature.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Issues/Queries with NetSample demo application
Reply #5 - Mar 9th, 2009 at 2:44pm
Print Post  
You'd have to create a new Shape for each of these cases, or otherwise use a transparent node attached to the main node to display the label. The latter will even allow your users to interactively place the label anywhere they want.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: Issues/Queries with NetSample demo application
Reply #6 - Mar 10th, 2009 at 6:59am
Print Post  
Thanks for the reply.

I think the NetSample example is using the transparent node attached.

I tried altering it as per my requirements but not getting any result.

For my requirement i think that i have to add 4 transparent nodes left/right/top/bottom.

Can you present some codelines to do this also i would like that on button click the text alignment of all the nodes should change.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Issues/Queries with NetSample demo application
Reply #7 - Mar 10th, 2009 at 8:28am
Print Post  
You just need to move the label node to the respective side of the shape node. E.g. to make it left aligned, call labelNode.Move(mainNode.Bounds.Left - labelNode.Bounds.Width, mainNode.Bounds.Top).

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: Issues/Queries with NetSample demo application
Reply #8 - Mar 10th, 2009 at 11:44am
Print Post  
Thanks i will try this and let you know.

I have one more query

1) I have written following code for custom shape node:

[code]
shapeNode = new MindFusion.Diagramming.Wpf.Shape(new ElementTemplate[]{
new LineTemplate(50, 0, 100, 50),
new LineTemplate(100, 50, 50, 100),
new LineTemplate(50, 100, 0, 50),
new LineTemplate(0, 50, 50, 0),
},null,
new ElementTemplate[]{
new LineTemplate(0, 100, 100, 100),
new LineTemplate(100, 100, 100, 150),
new LineTemplate(100, 150, 0, 150),
new LineTemplate(0, 150, 0, 100)
}, FillRule.Nonzero, "");

ShapeNode node = new ShapeNode(diagram);
node.Bounds = new Rect(new Point(100, 100), new Size(45, 45));
Uri uri = new Uri(@"..\..\Test.png", UriKind.RelativeOrAbsolute);
node.Image = new BitmapImage(uri);
node.ImageAlign = ImageAlign.Center;
node.TextFormat.Alignment = StringAlignment.Center;
node.Text = "Hello Test";
[/code]

The problem with above code is that the text attached to the node i.e. "Hello Test" is getting clipped and we see only "Hello". What we like here is that the text can be given of any length and the text region should adjust its width accordingly.

How to achieve this?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Issues/Queries with NetSample demo application
Reply #9 - Mar 10th, 2009 at 12:43pm
Print Post  
You could call node.ResizetoFitText().
  
Back to top
 
IP Logged
 
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: Issues/Queries with NetSample demo application
Reply #10 - Mar 10th, 2009 at 1:03pm
Print Post  
Thanks for the reply.

Tried this, its not working (still only "Hello" is appearing) and second thing we do not want our node region to resize only text region width should be adjusted according to the text length.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Issues/Queries with NetSample demo application
Reply #11 - Mar 10th, 2009 at 3:29pm
Print Post  
If you are going to use attached nodes as labels, you could call ResizeToFitText on them. Otherwise I suppose we could add a ShapeNode.ClipText property that you could disable to achieve what you need.
  
Back to top
 
IP Logged
 
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: Issues/Queries with NetSample demo application
Reply #12 - Mar 12th, 2009 at 5:46am
Print Post  
Hi,

I tried attached node method see below code for example:

[code]
ShapeNode mainNode = diagram.Factory.CreateShapeNode(
new Point(100, 100), new Size(45, 45));
Uri uri = new Uri(@"..\..\Test.png", UriKind.RelativeOrAbsolute);
mainNode.Image = new BitmapImage(uri);
mainNode.ImageAlign = ImageAlign.Center;
mainNode.Shape = Shapes.Decision;
mainNode.EnabledHandles = AdjustmentHandles.Move;

ShapeNode labelNode = diagram.Factory.CreateShapeNode(
mainNode.Bounds.X - 10, mainNode.Bounds.Y + mainNode.Bounds.Height,
mainNode.Bounds.Width + 20, 15);

labelNode.AttachTo(mainNode, AttachToNode.MiddleLeft);
labelNode.Locked = true;
labelNode.Transparent = true;
labelNode.Text = "This is a long text string";

labelNode.ResizeToFitText(FitSize.KeepHeight);
[/code]

Then also the text is getting clipped along the width but when i change ResizeToFitText(FitSize.KeepHeight) to ResizeToFitText(FitSize.KeepWidth) full text can be seen as wrapped one but the problem is i want to keep text height as it is and the label node should resize in width.

Can you suggest. What i am missing here?

Thanks in advance,
Anurodh
« Last Edit: Mar 12th, 2009 at 6:52am by anurodhora »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Issues/Queries with NetSample demo application
Reply #13 - Mar 12th, 2009 at 9:04am
Print Post  
What's your Diagram.DefaultShape? There might be some problem in ResizeToFitText if the shape's text regions is smaller than the node, so try changing labelNode.Shape to Shapes.Rectangle.

Stoyan
  
Back to top
 
IP Logged
 
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: Issues/Queries with NetSample demo application
Reply #14 - Mar 12th, 2009 at 9:26am
Print Post  
Thanks for the reply.

Tried but not working same problem.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint