private static void BuildDiagram(Visio.Page page, List<Category> categories, List<Formula> formulae, List<Rule> rules, List<List> lists, List<Lookup> lookups) { Console.WriteLine("Drawing {0} categories...", categories.Count); DrawCategories(page, categories); Console.WriteLine("Drawing {0} rules...", rules.Count); DrawRules(page, rules); var listsToDraw = lists.Where(l => usedListNames.Contains(l.ListName.ToUpperInvariant())); Console.WriteLine("Drawing {0} lists...", listsToDraw.Count()); DrawLists(page, listsToDraw); var lookupsToDraw = lookups.Where(l => usedLookupNames.Contains(l.TableName.ToUpperInvariant())); Console.WriteLine("Drawing {0} lookup tables...", lookupsToDraw.Count()); DrawLookups(page, lookupsToDraw); var formulaeToDraw = formulae.Where(f => usedFormulaNames.Contains(f.FormulaName.ToUpperInvariant())); Console.WriteLine("Drawing {0} formulas...", formulaeToDraw.Count()); DrawFormulae(page, formulaeToDraw); Console.WriteLine("Drawing {0} relations...", relations.Count); DrawRelations(page); Console.WriteLine(); Console.WriteLine("Laying out the page..."); page.Layout(); Console.WriteLine("Resizing to fit to contents..."); page.ResizeToFitContents(); }
private static Visio.Shape DrawList(Visio.Page page, List list) { string name = LIST_PREFIX + list.ListName; if (!string.IsNullOrEmpty(list.DependsOn) && list.DependsOn.IndexOf("No Dependency", StringComparison.OrdinalIgnoreCase) < 0) { if (list.DependsOn.IndexOf('[') >= 0) // Reference to a category { Match match = matchCategoryAttributeRegex.Match(list.DependsOn); if (match.Success) { relations.Add(Tuple.Create(name, CATEGORY_PREFIX + match.Groups[1].Value, FormulaUse.Value)); } } else // Reference to another list { relations.Add(Tuple.Create(name, LIST_PREFIX + list.DependsOn, FormulaUse.Value)); } } return DrawRectangle(page, name, list.ListName.Length, list.ListName, COLOR_BLUE_LIGHT); }