As always I couldn't open the simple. |
Please find the modified sample.
Sample:
|
Anyway I've inserted this part in my code but it doesn't work.
using (Graphics gp = Graphics.FromHwnd(IntPtr.Zero))
{
SizeF size = gp.MeasureString(tn.Text, tn.FontStyle.CreateFont());
tn.SizeToText(size);
}
|
While using dialog box to edit the text in the TextNode the default functionality of Diagram’s TextNode editing also enabled. So, the length of the text is taken from the older value (or DefaultSize of the TextNode) which is already present in the label and the new text length is not taken which is the reason for the reported problem. So, we suggest you to invoke Diagram.Controller.TextEditor’s “EndEdit()” by adding false as an argument will resolve the reported issue.
Code example:
[C#]
diagram1.Controller.TextEditor.EndEdit(false);
using (Graphics gp = Graphics.FromHwnd(IntPtr.Zero))
{
SizeF size = gp.MeasureString(tn.Text, tn.FontStyle.CreateFont());
tn.SizeToText(size);
}
|
TextNode tn = ((TextNode)nodeText) as TextNode;
diagram1.Controller.TextEditor.EndEdit(false);//BC 20-01-2017 Para que ajuste el tamaño del contador al texto que corresponda
if (txtDigits.Text != "" && txtDigits.Text != "0" && txtDecimals.Text != "" && txtUnits.Text != "")
{
if (txtDecimals.Text == "0")
{
tn.Text = "*-" + ec.calcularCeros(Int32.Parse(ec.cambiarEspacio_Ceros(txtDigits.Text))) + " " + txtUnits.Text;
}
else
{
tn.Text = "*-" + ec.calcularCeros(Int32.Parse(ec.cambiarEspacio_Ceros(txtDigits.Text))) + "." + ec.calcularCeros(Int32.Parse(ec.cambiarEspacio_Ceros(txtDecimals.Text))) + " " + txtUnits.Text;
}
}
else
{
if (txtDigits.Text != "" && txtDigits.Text != "0" && txtDecimals.Text != "")
{
if (txtDecimals.Text == "0")
{
tn.Text = "*-" + ec.calcularCeros(Int32.Parse(ec.cambiarEspacio_Ceros(txtDigits.Text)));
}
else
{
tn.Text = "*-" + ec.calcularCeros(Int32.Parse(ec.cambiarEspacio_Ceros(txtDigits.Text))) + "." + ec.calcularCeros(Int32.Parse(ec.cambiarEspacio_Ceros(txtDecimals.Text)));
}
}
}
//BC 20-01-2017 Para que ajuste el tamaño del contador al texto que corresponda
using (Graphics gp = Graphics.FromHwnd(IntPtr.Zero))
{
SizeF size = gp.MeasureString(tn.Text, tn.FontStyle.CreateFont());
tn.SizeToText(size);
}
//[blanca][20-01-2017] Que los contadores no sean editables
diagram1.Controller.TextEditor.EndEdit(true);
this.Close();
When I change the textnode.text I want to invoke Diagram.Controller.TextEditor’s “EndEdit()” = true (when close the form that I use to modify my textnode for example), but it doesn't work.
|
As we have updated previously, the default functionality of Diagram’s TextNode Editing is enabled and if we set “EndEdit(true)” then the default text in TextNode is taken instead of assigning the text from the newly created form. So, we suggest you not to invoke Diagram.Controller.TextEditor’s “EndEdit(True)” method and we suspect invoking of this method is the problem for the reported issue.
|