Exemplo n.º 1
0
 public static void AddTextBlock(this Grid grid, string text, int column, int row, int columnSnap = 1, int rowSnap = 1)
 {
     grid.AddChildren(new TextBlock {
         Text = text
     }, column, row, columnSnap, rowSnap);
 }
        public Grid LabelGrid(StateTableViewModel myTable, int isWork)
        {
            Grid myGrid = new Grid();

            myGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(20)
            });
            myGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });

            myGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });
            myGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });

            var    minW   = myTable.W.IndexOfMin();
            Button button = new Button
            {
                Content             = $"Z{myTable.Nodes[minW].Zindex + 1}",
                FontFamily          = TimesNewRoman,
                FontSize            = 14,
                MinWidth            = 28,
                Margin              = new Thickness(2, 0, 2, 0),
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Center,
            };

            button.MouseEnter += (o, e) =>
            {
                myTable.Nodes[minW].ParentMode = true;
                myTable.Nodes[minW].ChildMode  = true;
            };
            button.MouseLeave += (o, e) =>
            {
                myTable.Nodes[minW].ParentMode = false;
                myTable.Nodes[minW].ChildMode  = false;
            };

            if (myTable.Count > 1)
            {
                button.Click += (o, e) =>
                {
                    CreateDependencyTable(myTable);
                };
            }

            myGrid.AddChildren(button, 0, 1, 2, 1, default(Color), false);

            if (isWork < 2)
            {
                Path path = new Path
                {
                    Data = new PathGeometry(new[]
                    {
                        new PathFigure(new Point(7, 0), new[]
                        {
                            new LineSegment(new Point(7, 20), true),
                            new LineSegment(new Point(14, 10), false),
                            new LineSegment(new Point(7, 20), true),
                            new LineSegment(new Point(0, 10), true),
                        }, false),
                    }),
                    Stroke          = Brushes.Black,
                    StrokeThickness = 2,
                };
                TextBlock textBlock = new TextBlock()
                {
                    Text       = isWork.ToString(),
                    Margin     = new Thickness(5, 0, 5, 0),
                    FontFamily = TimesNewRoman,
                    FontSize   = 14,
                };

                if (isWork == 0)
                {
                    myGrid.AddChildren(path, 1, 0, 1, 1, default(Color), false);
                    path.HorizontalAlignment = HorizontalAlignment.Left;
                    myGrid.AddChildren(textBlock, 0, 0, 1, 1, default(Color), false);
                    textBlock.HorizontalAlignment = HorizontalAlignment.Right;
                }
                if (isWork == 1)
                {
                    myGrid.AddChildren(path, 0, 0, 1, 1, default(Color), false);
                    path.HorizontalAlignment = HorizontalAlignment.Right;
                    myGrid.AddChildren(textBlock, 1, 0, 1, 1, default(Color), false);
                    textBlock.HorizontalAlignment = HorizontalAlignment.Left;
                }
            }



            return(myGrid);
        }