private void SetGraph(GD.Graph graph) { try { string activeItemName = graph.UserData as string; // Can't work out how to set the caption, without also setting // the tab text, which we do not want. This at least tells us. lblCaption.Text = activeItemName; this.ToolTipText = string.Format("{0} [{1}]", GetID(), activeItemName); // This can fail with 'trim a spline' error. _viewer.Graph = graph; _viewer.Visible = true; _viewer.ZoomFraction = 0.1; //_viewer.ZoomMode // Heuristic adjustment. _defaultZoom = 1.0f; if (graph.NodeCount <= 1) { _defaultZoom = 0.35f; } else if (graph.NodeCount <= 2) { _defaultZoom = 0.45f; } else if (graph.NodeCount <= 3) { _defaultZoom = 0.6f; } else if (graph.NodeCount <= 4) { _defaultZoom = 0.8f; } if (oldnodecount == graph.NodeCount) { _defaultZoom = olddefaultzoom; } _viewer.ZoomF = _defaultZoom; if (1==1) { olddefaultzoom = (float)_viewer.ZoomF; oldnodecount = _viewer.Graph.NodeCount; } } catch (InvalidOperationException) { _logView.LogStr("GLEE Layout error, try again with different aspect ratio"); _failed = true; } // Show these, incase we've failed. Will be hidden if all ok. if (_failed) { lblPleaseWait.Text = "Layout failed"; btnRefresh.Visible = true; } }
private bool Hilite(GD.Node node) { bool result = false; if (_hiliteNodes.ContainsKey(node)) return result; _hiliteNodes.Add(node, new AffectedNode(node.Attr.Color, node.Attr.Fillcolor, node.Attr.Fontcolor)); Color color = _options.HiliteColor; GD.Color gcolor = new GD.Color(color.A, color.R, color.G, color.B); node.Attr.Fillcolor = gcolor; color = _options.HiliteLineColor; gcolor = new GD.Color(color.A, color.R, color.G, color.B); // We need access to the builder here :/ if (_activeItem != null && _builders.ContainsKey(_activeItem)) { BaseGraphBuilder builder = _builders[_activeItem]; foreach (KeyValuePair<string, List<object>> pair in builder.AddedEdges) { foreach (GD.Edge edge in pair.Value) { if (edge.Source == node.Id || edge.Target == node.Id) { // Abuse the userdata to hang onto the old color. edge.UserData = new AffectedEdge(edge.Attr.Color); edge.Attr.Color = gcolor; } } } result = true; } return result; }
private List<BaseItem> GetItemList(GD.Node node) { List<BaseItem> list = new List<BaseItem>(); if (node != null && node.UserData != null) { if (node.UserData is BaseItem) { BaseItem item = node.UserData as BaseItem; list.Add(item); } else if (node.UserData is List<BaseItem>) { list = node.UserData as List<BaseItem>; } else _logView.Debug("GetItemList reports invalid UserData"); } return list; }
private BaseItem GetItem(GD.Node node) { BaseItem item = null; if (node != null && node.UserData != null) { if (node.UserData is BaseItem) { item = node.UserData as BaseItem; } else if (node.UserData is List<BaseItem>) { // Iterate over nodes with multiple items. if (_prevNode == node) _prevIdx++; else _prevIdx = 0; List<BaseItem> list = node.UserData as List<BaseItem>; item = list[_prevIdx % list.Count]; } else _logView.Debug("GetItem reports invalid UserData"); _prevNode = node; } return item; }
internal AffectedNode(GD.Color color, GD.Color fillColor, GD.Color fontColor) { Color = color; FillColor = fillColor; FontColor = fontColor; }
internal AffectedEdge(GD.Color color) { Color = color; }