We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Alignment textnode doesn't work

Hi,


I don't understand how the alignment works. If I create 3 textnodes in different possitions and I try to align left the three of then nothing happens. I would like that work like word tool, if you want to align to the left all selected nodes are shifted to the left.

Any ideas? 

Blanca


11 Replies

NG Naganathan Ganesh Babu Syncfusion Team June 30, 2017 06:11 AM UTC

Hi Blanca, 
 
Thanks for contacting Syncfusion support. 
 
In diagram Control, Alignment works based on Diagram.Model’s “AlignmentType” property and it has two types and its explained in below, 
 
1.      SelectedNode – it used to align the node based on the position of the first node contains SelectionList.  
For example:  
If the diagram contains 3 text nodes i.e. TextNode1, TextNode2 and TextNode3.  In the Diagram.View’s “SelectionList” contains the First Node is TextNode2. Then the others nodes aligned based on the TextNode2’s position.  
 
2.      BoundingRectangle. – it is used to align the nodes based on the total bounds area of the selected nodes.  
 
Please refer to the below code example and attached video.  
 
Code example: 
 
[C#] 
 
//Set whether the align the nodes based on the Selected node or selected Bounds area. 
diagram1.Model.AlignmentType = AlignmentType.SelectedNode; 
 
Video: 
 
 
Regards, 
 
Naganathan K G 



BC Blanca Calderon replied to Naganathan Ganesh Babu June 30, 2017 08:10 AM UTC

Hi Blanca, 
 
Thanks for contacting Syncfusion support. 
 
In diagram Control, Alignment works based on Diagram.Model’s “AlignmentType” property and it has two types and its explained in below, 
 
1.      SelectedNode – it used to align the node based on the position of the first node contains SelectionList.  
For example:  
If the diagram contains 3 text nodes i.e. TextNode1, TextNode2 and TextNode3.  In the Diagram.View’s “SelectionList” contains the First Node is TextNode2. Then the others nodes aligned based on the TextNode2’s position.  
 
2.      BoundingRectangle. – it is used to align the nodes based on the total bounds area of the selected nodes.  
 
Please refer to the below code example and attached video.  
 
Code example: 
 
[C#] 
 
//Set whether the align the nodes based on the Selected node or selected Bounds area. 
diagram1.Model.AlignmentType = AlignmentType.SelectedNode; 
 
Video: 
 
 
Regards, 
 
Naganathan K G 


Thank you for your answer but for me it doesn't work. I will send you a video.


Attachment: Video_1498816965_fb8814e7.zip


NG Naganathan Ganesh Babu Syncfusion Team July 3, 2017 06:24 AM UTC

Hi Blanca, 
 
We are unable reproduce reported issue at our end. please check the below attached sample and let us know the reported issue reproduced or not? Also, provide us the version in which the reported issue is reproduced.  
 
Sample: 
 
 
Regards, 
 
Naganathan K G 



BC Blanca Calderon July 3, 2017 06:42 AM UTC

I couldn't open the sample, the dll's are in different version. My version is 13.4200.0.53



NG Naganathan Ganesh Babu Syncfusion Team July 3, 2017 06:52 AM UTC

Hi Blanca, 
 
Sorry for the inconvenience caused. 
 
We have modified and attached the sample in the below link with framework version 2.0 as per your request. 
 
Sample: 
 
 
Regards, 
 
Naganathan K G 



BC Blanca Calderon July 3, 2017 09:34 AM UTC

I don't have problems with rectangle, or lines, I have problems with textnode.



BC Blanca Calderon July 3, 2017 10:32 AM UTC

I'm thinking is because of the textnode size or alignment of the text or something similar, i don't know why.



BC Blanca Calderon July 3, 2017 10:46 AM UTC

And I don't have problem when I append a textnode, example:


 Syncfusion.Windows.Forms.Diagram.TextNode rect2 = new Syncfusion.Windows.Forms.Diagram.TextNode("pruebapuuuu"); //.Rectangle(100, 50, 100, 50);          diagram1.Model.AppendChild(rect2);

I have problems when I use texttool. 


         



NG Naganathan Ganesh Babu Syncfusion Team July 4, 2017 09:11 AM UTC

Hi Blanca, 
 
We have created and verified a sample by drawing a TextNode using TextTool. But still we are unable to reproduce the reported issue at our end. please refer to the below attached sample.  
 
Sample: 
 
 
Please confirm us whether you have done any customization on the Diagram’s TextNode/TextTool class to draw the TextNode? if so, please share your customized code example for creating the TextNode using TextTool, which will help us to analyze further and provide a better solution. 
 
Regards, 
 
Naganathan K G 



BC Blanca Calderon July 10, 2017 08:55 AM UTC

The problem is when you align right and the linestyle color is transparent. Obviously the alignment is correct but, if you don't see the line it's weird. In my case the line in a textbox is always transparent.



NG Naganathan Ganesh Babu Syncfusion Team July 12, 2017 09:22 AM UTC

Hi Blanca, 
 
In Diagram control, the alignment of node is based on the size of the diagram’s nodes not based on the given text size. So, we suggest you to modify the textnode’s size manually based on the given text to achieve your requirement. please refer to the below modified sample and code example in order to change the textnode’s size automatically based on the given text. 
 
Code example: 
 
[C#] 
 
private void AutoNodeSizeChange(TextEditor textEditor) 
{ 
if (diagram1.View.SelectionList.Count == 1 && diagram1.View.SelectionList[0] is TextNode) 
{ 
using (Graphics graphics = diagram1.CreateGraphics()) 
{ 
string currentTxt = textEditor.Text;                    
SizeF stringSize = new SizeF(); 
TextNode txtnode = diagram1.View.SelectionList[0] as TextNode; 
stringSize = graphics.MeasureString(currentTxt, new Font(txtnode.FontStyle.Family, txtnode.FontStyle.Size)); 
txtnode.Size = stringSize; 
txtnode.PinPointOffset = new SizeF(stringSize.Width / 2, stringSize.Height / 2); 
} 
} 
} 
 
Sample: 
 
 
Regards, 
 
Naganathan K G 


Loader.
Up arrow icon