Ejemplo n.º 1
0
 private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
 {
     ItemSetGraph.Layout(LayoutType.Sugiyama, new SugiyamaSettings()
     {
         HorizontalDistance = 10,
         VerticalDistance   = 10
     });
 }
Ejemplo n.º 2
0
        private void InitializeGraph()
        {
            var stateToShape = new Dictionary <AnalyzerState, RadDiagramShape>();

            foreach (var state in slr1Table.States.Values)
            {
                var shape = new RadDiagramShape()
                {
                    Content = String.Join("\n", from item in state.ItemSet select item.ToString())
                };
                shape.Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.RectangleShape);
                ItemSetGraph.Items.Add(shape);
                stateToShape.Add(state, shape);
            }

            foreach (var state in slr1Table.States.Values)
            {
                foreach (var kv in state.Action)
                {
                    if (kv.Value is ShiftOperation so)
                    {
                        var connection = new RadDiagramConnection()
                        {
                            Source  = stateToShape[state],
                            Target  = stateToShape[so.NextState],
                            Content = new TextBlock()
                            {
                                Text = kv.Key.Name
                            }
                        };
                        ItemSetGraph.Items.Add(connection);
                    }
                }

                foreach (var kv in state.GotoTable)
                {
                    var connection = new RadDiagramConnection()
                    {
                        Source  = stateToShape[state],
                        Target  = stateToShape[kv.Value],
                        Content = new TextBlock()
                        {
                            Text = kv.Key.ToString()
                        }
                    };
                    ItemSetGraph.Items.Add(connection);
                }
            }
            ItemSetGraph.AutoLayout = true;
            ItemSetGraph.Layout(LayoutType.Sugiyama, new SugiyamaSettings()
            {
                HorizontalDistance = 10,
                VerticalDistance   = 10,
                Orientation        = Telerik.Windows.Diagrams.Core.Orientation.Horizontal,
            });
        }