/// <summary> /// Initializes the graph we use in this demo. /// </summary> private void InitializeGraph() { // Allow grouping and folding IGraph graph = new FoldingManager().CreateFoldingView().Graph; // Initialize defaults graph.NodeDefaults.Style = new ShinyPlateNodeStyle { Brush = Brushes.DarkOrange }; // Mapper for using custom AutomationIds. This is just a sample that shows how to add a mapper that returns // an automation ID from the model item's tag. In practice you might return a property of the tag object if that // identifies your model item uniquely. graph.MapperRegistry.CreateDelegateMapper(GraphControl.AutomationIdKey, delegate(IModelItem key) { if (key.Tag == null) { return(null); } if (key.Tag is string) { return(key.Tag as string); } return(null); }); // create sample graph var node1 = graph.CreateNode(new RectD(0, 0, 100, 30)); graph.AddLabel(node1, "Node with label"); // Use a custom AutomationId for that node. We just set the tag to a string here, which then gets picked up by // the mapper we added above. node1.Tag = "Custom Automation ID"; var node2 = graph.CreateNode(new PointD(90, 70)); graph.CreateEdge(node2, graph.CreateNode(new PointD(90, 120))); graph.CreateEdge(node2, graph.CreateNode(new PointD(200, 30))); // Node with a templated style – the controls within the template do appear in the UIA tree as well and can be // interacted with. graph.CreateNode(new RectD(100, 150, 150, 150), new NodeControlNodeStyle("NodeStyle")); graph.GroupNodeDefaults.Style = new NodeControlNodeStyle("GroupNodeStyle") { Insets = new InsetsD(3, 20, 3, 3) }; graph.GroupNodes(node1, node2); graphControl.Graph = graph; graphControl.FitGraphBounds(); }