Page Index Toggle Pages: 1 [2] 3  Send TopicPrint
Very Hot Topic (More than 25 Replies) Customizing node appearance (Read 20354 times)
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Customizing node appearance
Reply #15 - Jan 19th, 2010 at 12:15pm
Print Post  
No. In my version I haven't this property Sad. I use 2.3.0.24359 version
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Customizing node appearance
Reply #16 - Jan 19th, 2010 at 12:30pm
Print Post  
Indeed there isn't, I was looking at the Winforms version. For now you might try setting the point's label you need as a value of the point's Tag property, and get it from there when drawing. We'll add some more information to the args class in the next few days.

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



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Customizing node appearance
Reply #17 - Jan 19th, 2010 at 12:42pm
Print Post  
If I set ShowAnchors=Auto can I make that points are shown as auto and text labels near these points are shown always?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Customizing node appearance
Reply #18 - Jan 19th, 2010 at 3:12pm
Print Post  
Nope, you will have to render the labels as part of the node in such case. E.g. set CustomDraw = Additional and handle the DrawNode event.
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Customizing node appearance
Reply #19 - Jan 19th, 2010 at 3:26pm
Print Post  
Thanks. I'll try
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Customizing node appearance
Reply #20 - Jan 19th, 2010 at 3:39pm
Print Post  
I set
Code
Select All
		m_Diagram.ShapeCustomDraw = CustomDraw.Additional;
		m_Diagram.DrawNode += OnDrawNode;
 


And implement the event handler
Code
Select All
	  void OnDrawNode(Object sender, DrawNodeEventArgs e)
	  {

	  }
 


But this method wasn't called. What is incorrect?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Customizing node appearance
Reply #21 - Jan 19th, 2010 at 3:56pm
Print Post  
If creating nodes from code, you should use the ShapeNode constructor that takes a Diagram argument. Otherwise set the CustomDraw property of individual nodes.

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



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Customizing node appearance
Reply #22 - Jan 19th, 2010 at 4:00pm
Print Post  
Thanks! All is OK
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Customizing node appearance
Reply #23 - Jan 20th, 2010 at 8:55am
Print Post  
Hello, Stoyan. I can't understand. I implement DrawNode as you advise me. And I "go" into my DrawNode function but nothing changes Shocked. Where is my mistake?
Code
Select All
        private void OnDrawNode(Object sender, DrawNodeEventArgs e)
        {
            if (e.Node.GetType() == typeof(TPDENode))
            {
                TPDENode node = e.Node as TPDENode;
                if (node.ShowAnchorIndexes)
                {
                    var anchorPoints = node.AnchorPattern.Points;
                    int nIdx = 1;
                    Typeface typeface = new Typeface(FontFamily, node.Font.Style,
                        node.Font.Weight, FontStretch);
                    foreach (AnchorPoint point in anchorPoints)
                    {
                        FormattedText text = new FormattedText(nIdx.ToString(),
                            CultureInfo.CurrentCulture, FlowDirection.LeftToRight,
                            typeface, node.Font.Size, Brushes.Black);
                        Point anchorPntLocation = new Point();
                        anchorPntLocation.X = node.Bounds.Left + node.Bounds.Width * point.X / 100;
                        anchorPntLocation.Y = node.Bounds.Top + node.Bounds.Height * point.Y / 100;
                        Point textLocation = new Point();
                        Vector offset = new Vector();
                        if ((AnchorPntType)point.Tag == AnchorPntType.Input)
                        {
                            offset.X = -10;
                            offset.Y = -10;
                        }
                        else
                        {
                            offset.X = 10;
                            offset.Y = -10;
                        }
                        textLocation = Vector.Add(offset, anchorPntLocation);
                        e.Graphics.DrawText(text, textLocation);
                        nIdx++;
                    }
                }
            }
        }
 

  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Customizing node appearance
Reply #24 - Jan 20th, 2010 at 9:45am
Print Post  
I think it is necessary to add anchorPntLocation = TransformDiagramToItem(anchorPntLocation);
but there is nothing effect
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Customizing node appearance
Reply #25 - Jan 20th, 2010 at 11:05am
Print Post  
Hi,

There is clipping enabled by default for the Additional custom-draw style. Use the Additional2 instead, and set the point like this:

anchorPntLocation.X = node.Bounds.Width * point.X / 100;
anchorPntLocation.Y = node.Bounds.Height * point.Y / 100;

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



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Customizing node appearance
Reply #26 - Jan 20th, 2010 at 11:10am
Print Post  
Thanks. It really helped
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Customizing node appearance
Reply #27 - Jan 21st, 2010 at 3:35pm
Print Post  
Hello, Stoyan.
In my diagram object AllowInplaceEditing is set to false. But when Active item is the ShapeNode object and user presses F4 button I need to allow inplace editing only for active node and I need to switch node into text editing mode in this time. How can I implement it?
P.S.:How to catch KeyDown event I know Smiley
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Customizing node appearance
Reply #28 - Jan 21st, 2010 at 3:39pm
Print Post  
Hi,

Call diagram.BeginEdit(node).

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



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Customizing node appearance
Reply #29 - Jan 21st, 2010 at 3:46pm
Print Post  
Thanks. I already found it Smiley. Can I catch some KeyDown events in this mode. At first when edit is started and when I am editing text I want to see the text not as 1 string but as I see it according StringFormat of the node. The next, when user presses the enter key I need to accept changes, escape key must cancel changes and exit from edit mode. And Shift+Enter must start the new line. Enter and Escape KeyDowns and cotrolled by properties InplaceEditAcceptOnEnter and InplaceEditCancelOnEsc. But how to catch the Shift+Enter event?
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 [2] 3 
Send TopicPrint