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.
Unfortunately, activation email could not send to your email. Please try again.

Font

Thread ID:

Created:

Updated:

Platform:

Replies:

75907 Aug 14,2008 07:27 AM Aug 18,2008 07:57 AM Windows Forms 3
loading
Tags: Diagram
Segey
Asked On August 14, 2008 07:27 AM

Hi,
How to change Font at TextNode which have arranged on the diagramme.
How to appoint keys Ctrl + '+' and Ctrl + '-' for scaling diagramm.
In advance thanks.


J.Nagarajan [Syncfusion]
Replied On August 14, 2008 08:53 AM

Hi ,

1. Change Font of TextNode:

You can use FontStyle property of the TextNode and you can change the font at run time. Please refer to the below code snippet.

Syncfusion.Windows.Forms.Diagram.TextNode txtnode = new TextNode( "SIMPLE FLOW DIAGRAM" );
txtnode.FontStyle.Size = 20;
txtnode.FontStyle.Italic = true;
txtnode.FontStyle.Bold = true;
txtnode.FontStyle.Family = "Cambria";
txtnode.FontColorStyle.Color = Color.Purple;
txtnode.LineStyle.LineColor = Color.Transparent;
txtnode.SizeToText(SizeF.Empty);
txtnode.PinPoint = new PointF(250, 30);
this.diagram1.Model.AppendChild(txtnode);

2. To appoint keys Ctrl + '+' and Ctrl + '-' for scaling diagram:

For scaling the diagram, you have to derive the ZoomTool and override the ProcessMouseUp() method. To catch the Ctrl + '+' and Ctrl+ '-' key, you have to override ProcessCmdKey() method. Please refer to the below code snippet.

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
this.diagram1.Focus();
if (diagram1.ContainsFocus)
{

if (((keyData & Keys.Control) == Keys.Control) && ((keyData & Keys.Oemplus) == Keys.Oemplus))
{
zoomTool = new CustomZoomTool(this.diagram1.Controller);
this.diagram1.Controller.RegisterTool(zoomTool);
this.diagram1.Controller.ActivateTool(zoomTool);
zoomTool.SingleActionTool = false;
zoomTool.ProcessMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 1));
}
if (((keyData & Keys.Control) == Keys.Control) && ((keyData & Keys.OemMinus) == Keys.OemMinus))
{
if (zoomTool != null)
zoomTool.ProcessMouseUp(new MouseEventArgs(MouseButtons.Right, 0, 0, 1, 1));
}

}
return base.ProcessCmdKey(ref msg, keyData);
}

Here is the working sample.

http://websamples.syncfusion.com/samples/Diagram.Windows/F75907/main.htm

Please refer to it and let me know if this helps.

Regards,
Nagaraj


Segey
Replied On August 15, 2008 01:58 AM

Thanks for the answer. And if I create TextNode in separate class TextField. How to address to it for font change.
In advance thanks.


J.Nagarajan [Syncfusion]
Replied On August 18, 2008 07:57 AM

Hi ,

You can derive a TextNode in a separate class and you can set the font to that TextNode. Please refer to the below code snippet.

class TextField:TextNode
{
public TextField(string Text):base(Text)
{
this.FontStyle.Size = 20;
this.FontStyle.Italic = true;
this.FontStyle.Bold = true;
this.FontStyle.Family = "Cambria";
this.FontColorStyle.Color = Color.Purple;
this.LineStyle.LineColor = Color.Transparent;
this.SizeToText(SizeF.Empty);
this.PinPoint = new PointF(250, 30);
}
}

//To Add TextField to the Diagram Model

TextField m_txtField = new TextField("SIMPLE FLOW DIAGRAM");
this.diagram1.Model.AppendChild(m_txtField);

Please refer to the attached sample for more details.

http://websamples.syncfusion.com/samples/Diagram.Windows/F75907_Aug18/main.htm

Please let me know if this helps.

Thanks,
Nagaraj



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;