in GraphLayout/tools/GraphmapsWpfControl/GraphmapsViewer.cs [1701:1834]
void InvalidateNodesOfRailGraph(Set<Node> nodesFromVectorTiles)
{
double zf = ZoomFactor;
//start: changing tooltip
String tooltiptext = "";
List<object> ColorSet = new List<object>();
addColorsToSet(ColorSet);
List<GraphmapsNode> coloredNodeList = new List<GraphmapsNode>();
//end: changing tooltip
foreach (var o in _drawingObjectsToIViewerObjects.Values)
{
var vNode = o as GraphmapsNode;
if (vNode != null)
{
//Find the nodes that are selected
if (ColorSet.Contains(vNode.LgNodeInfo.Color))
{
coloredNodeList.Add(vNode);
}
vNode.InvalidateNodeDot(NodeDotWidth);
if (vNode.LgNodeInfo == null) continue;
ArrangeNodeLabel(vNode, zf);
if (nodesFromVectorTiles.Contains(vNode.Node))
SetupTileNode(vNode);
vNode.Node.Attr.LineWidth = GetBorderPathThickness();
if (vNode.LgNodeInfo == null) continue;
double cs = CurrentScale;
double nodeLabelHeight = _lgLayoutSettings.NodeLabelHeightInInches * DpiY / CurrentScale;
double nodeLabelWidth = nodeLabelHeight * vNode.LgNodeInfo.LabelWidthToHeightRatio;
if (vNode.LgNodeInfo.LabelVisibleFromScale >= 0 &&
vNode.LgNodeInfo.LabelVisibleFromScale <= zf
)
{
var offset = Point.Scale(nodeLabelWidth + NodeDotWidth * 1.01, nodeLabelHeight + NodeDotWidth * 1.01,
vNode.LgNodeInfo.LabelOffset);
vNode.InvalidateNodeLabel(nodeLabelHeight, nodeLabelWidth, offset);
}
else if (_lgLayoutSettings.Interactor.SelectedNodeLabels.ContainsKey(vNode.LgNodeInfo)
)
{
var pos = _lgLayoutSettings.Interactor.SelectedNodeLabels[vNode.LgNodeInfo];
var offset = Point.Scale(nodeLabelWidth + NodeDotWidth * 1.01, nodeLabelHeight + NodeDotWidth * 1.01,
LgNodeInfo.GetLabelOffset(pos));
vNode.InvalidateNodeLabel(nodeLabelHeight, nodeLabelWidth, offset);
}
else
{
vNode.HideNodeLabel();
}
}
}
//start: changing tooltip
List<System.Windows.Media.SolidColorBrush> incidentColorSet;
foreach (var o in _drawingObjectsToIViewerObjects.Values)
{
var vNode = o as GraphmapsNode;
if (vNode == null) continue;
tooltiptext = "";
incidentColorSet = new List<System.Windows.Media.SolidColorBrush>();
foreach (var w in coloredNodeList)
{
foreach (var edge in w.Node.GeometryNode.OutEdges)
{
if (vNode.Node.GeometryNode == edge.Target)
{
if(!tooltiptext.Contains(w.Node.LabelText))
tooltiptext = tooltiptext+ "\n" + w.Node.LabelText;
incidentColorSet.Add((SolidColorBrush)w.LgNodeInfo.Color);
}
}
foreach (var edge in w.Node.GeometryNode.InEdges)
{
if (vNode.Node.GeometryNode == edge.Source)
{
if (!tooltiptext.Contains(w.Node.LabelText))
tooltiptext = tooltiptext + "\n" + w.Node.LabelText;
incidentColorSet.Add((SolidColorBrush)w.LgNodeInfo.Color);
}
}
}
if (tooltiptext.Length > 0)
{
tooltiptext = "\nSelected Neighbors:" + tooltiptext;
}
if (vNode.BoundaryPath.Fill!= null && vNode.BoundaryPath.Fill.Equals(Brushes.Yellow))
{
int Ax = 0, Rx = 0, Gx = 0, Bx = 0;
foreach (var c in incidentColorSet)
{
Ax += c.Color.A;
Rx += c.Color.R;
Gx += c.Color.G;
Bx += c.Color.B;
}
byte Ay = 0, Ry = 0, Gy = 0, By = 0;
Ay = (Byte)((int)(Ax / incidentColorSet.Count));
Ry = (Byte)((int)(Rx / incidentColorSet.Count));
Gy = (Byte)((int)(Gx / incidentColorSet.Count));
By = (Byte)((int)(Bx / incidentColorSet.Count));
System.Windows.Media.Color brush = new System.Windows.Media.Color
{
A = Ay,
R = Ry,
G = Gy,
B = By
};
vNode.BoundaryPath.Stroke = new SolidColorBrush(brush);
vNode.BoundaryPath.StrokeThickness = vNode.PathStrokeThickness * 2;
}
else vNode.BoundaryPath.StrokeThickness = vNode.PathStrokeThickness/2;
vNode.BoundaryPath.ToolTip = new ToolTip
{
Content = new TextBlock { Text = vNode.Node.LabelText + tooltiptext }
};
}
//end: changing tooltip
}