/// <summary> /// Marks the given paths. /// </summary> /// <remarks> /// Also highlights the source and target nodes. /// </remarks> private void MarkPaths(ResultItemCollection <Path> paths, List <INode> sources, List <INode> targets) { // Mapping from items to their list of color groups var item2ColorGroups = new Dictionary <IModelItem, List <ColorGroup> >(); // Prepare the item to color groups mapping int i = 0; foreach (var path in paths) { var group = new ColorGroup(i++); foreach (var item in path.Nodes.Cast <IModelItem>().Concat(path.Edges)) { List <ColorGroup> list; if (!item2ColorGroups.TryGetValue(item, out list)) { list = new List <ColorGroup>(); item2ColorGroups[item] = list; } list.Add(group); } } // Set the initial tags for all paths foreach (var pair in item2ColorGroups) { pair.Key.Tag = new Tag { ColorGroups = pair.Value, CurrentColor = pair.Value.First().Color }; } MarkSourceAndTargetNodes(sources, targets); }
public Color DetermineElementColor(Color[] colors, Component component, ISet <Component> affectedComponents, Dictionary <Component, Color> color2AffectedComponent, Component largestComponent, ResultItemCollection <Component> allComponents, IGraph graph, IModelItem element) { var componentId = allComponents.ToList().IndexOf(component); if (null == IncrementalElements) { return(colors[componentId % colors.Length]); } var currentColor = ((Tag)element.Tag).CurrentColor; if (affectedComponents.Contains(component)) { if (!color2AffectedComponent.ContainsKey(component)) { Color l; if (largestComponent == component && 1 != component.InducedEdges.Count) { l = GenerateMajorColor(component); } else { l = largestComponent == component && 1 == component.InducedEdges.Count ? HasValidColorTag(element) ? (Color)element.Tag : GenerateUniqueColor(graph, colors) : element is IEdge ? (IncrementalElements[((IEdge)element).GetSourceNode()] && IncrementalElements[((IEdge)element).GetTargetNode()]) ? GenerateUniqueColor(graph, colors) : !EdgeRemoved && element.Tag is Tag && currentColor.HasValue ? currentColor.Value : GenerateUniqueColor(graph, colors) : !EdgeRemoved && element.Tag is Tag && currentColor.HasValue ? currentColor.Value : GenerateUniqueColor(graph, colors); } color2AffectedComponent[component] = l; } return(color2AffectedComponent[component]); } return(currentColor.Value); }
private ResultItemCollection ParseItems(HtmlDocument htmlDoc, string currentUrl) { var resultItems = new ResultItemCollection(); foreach (var itemConfig in _siteConfig.Items) { if (itemConfig.UrlPattern != null && !Regex.IsMatch(currentUrl, itemConfig.UrlPattern, RegexOptions.IgnoreCase)) continue; var item = new ResultItem(itemConfig.Name); foreach (var propertyConfig in itemConfig.Properties) { var propNodes = htmlDoc.DocumentNode.SelectNodes(propertyConfig.Selector); if (propNodes == null) continue; foreach (var propNode in propNodes) { var property = new ResultItemProperty() { Name = propertyConfig.Name, Value = propNode.InnerText }; item.Properties.Add(property); } } resultItems.Add(item); } return resultItems; }