Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Node Format and color (Read 6416 times)
SE
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 21
Joined: Jun 5th, 2015
Node Format and color
Jul 2nd, 2015 at 6:23pm
Print Post  
How can I change the textColor inside node and the inner area of the Node color. I cant find the node.TextColor
as described in the below link. And I dont find any examples to change the color of the inside node.
your help is much appreciated

Code:

var node = diagram1.Factory.CreateShapeNode(rect);
node.Font = new Font("Times New Roman", 6, GraphicsUnit.World);

http://www.mindfusion.eu/onlinehelp/flowchartnet/Creating_ShapeNode_objects_prog...
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Node Format and color
Reply #1 - Jul 2nd, 2015 at 7:14pm
Print Post  
Set the TextBrush and Brush properties:
http://www.mindfusion.eu/onlinehelp/flowchartnet/index.htm?Customizing_the_Appea...

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
SE
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 21
Joined: Jun 5th, 2015
Re: Node Format and color
Reply #2 - Jul 7th, 2015 at 4:03pm
Print Post  
Thank you. It helps..

I have an another issue that i want to delete all nodes with no links.. i do see that there are options to delete it manually or link.remove(). But i need to find all nodes which has no links (just standalone nodes) and delete them programttically before it displays the graph. Is it possible?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Node Format and color
Reply #3 - Jul 7th, 2015 at 5:14pm
Print Post  
You could check if GetAllLinks().Count is 0:

Code
Select All
using System.Linq;
...
var standaloneNodes = diagram.Nodes.Where(
	n => n.GetAllLinks().Count == 0).ToList();
foreach (var node in standaloneNodes)
	diagram.Nodes.Remove(node); 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
SE
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 21
Joined: Jun 5th, 2015
Re: Node Format and color
Reply #4 - Jul 14th, 2015 at 7:48pm
Print Post  
Hi, Currently, I am using these properties to set the font and node color.

var node = diagram1.Factory.CreateShapeNode(rect);
                    /* Set the colors of the nodes and Links */

                    node.Font = new Font("Times New Roman", 3, GraphicsUnit.World);
                    node.TextBrush = new MindFusion.Drawing.SolidBrush(Color.Blue);
                    node.Brush = new MindFusion.Drawing.SolidBrush(Color.LightBlue);

For example, lets say the node text as follows:

node.Text = nodeName + "\n" +" " + "\n" + "Start time:" + avgStartTime + "\n" + "Avg.Run time:" + ts;

I want to change the font and color just for avgStartTime value. and also, if the nodeName is = "XXXXX", then i want to change the entire node color as RED. otherwise node color can stay as blue...

Basically I am looking for color change based on the content of the node text.

Can you please let me know if it is feasible.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Node Format and color
Reply #5 - Jul 15th, 2015 at 9:03am
Print Post  
Hi,

Consider using TableNodes, they let you assign different font to each cell:

Code
Select All
var node = diagram.Factory.CreateTableNode(
	rect, 2 /* columns */, 2 /* rows */);

node.Caption = nodeName;
node[0, 0].Text = "Start time:";
node[0, 0].TextFormat.Alignment = StringAlignment.Far;
node[0, 1].Text = "Avg.Run time:";
node[0, 1].TextFormat.Alignment = StringAlignment.Far;
node[1, 0].Text = avgStartTime;
node[1, 0].Font = new Font("Arial", 4, GraphicsUnit.World);
node[1, 0].TextBrush = new MindFusion.Drawing.SolidBrush(Color.Red);
node[1, 1].Text = ts;
node.ResizeToFitText(false);

node.Scrollable = false;
node.CellFrameStyle = CellFrameStyle.None;

node.Font = new Font("Times New Roman", 3, GraphicsUnit.World);
node.TextBrush = new MindFusion.Drawing.SolidBrush(Color.Blue);
node.Brush = new MindFusion.Drawing.SolidBrush(Color.LightBlue); 



If you prefer using ShapeNodes, you could change color and some font attributes for the avgStartTime by setting EnableStyledText and enclosing within <b>,<i>,<color> tags. This won't let you change the font family.

Code
Select All
var node = diagram.Factory.CreateShapeNode(rect);
node.Font = new Font("Times New Roman", 3, GraphicsUnit.World);
node.TextBrush = new MindFusion.Drawing.SolidBrush(Color.Blue);
node.Brush = new MindFusion.Drawing.SolidBrush(Color.LightBlue);

node.PolygonalTextLayout = true;
node.EnableStyledText = true;
node.Text =
	nodeName + "\n" +
	" \n" +
	"Start time:<b><color=#FF0000>" + avgStartTime + "</color></b>\n" +
	"Avg.Run time:" + ts; 



Or otherwise you could set ShapeNode's CustomDraw property and draw the text yourself using any fonts you like by calling GDI+ DrawString method from DrawNode event handler.

Brush cannot change dynamically based on node's text, you will have to set it yourself each time you assign to the Text property. You could possibly implement that via extension method:

Code
Select All
static class ShapeNodeExtensions
{
	static public void SetText(this ShapeNode node, string text)
	{
		node.Text = text;
		node.Brush = text.StartsWith("XXXX") ?
			new MindFusion.Drawing.SolidBrush(Color.LightGreen) :
			new MindFusion.Drawing.SolidBrush(Color.LightBlue);
	}
}

shapeNode.SetText(...); 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint