private void UnitProd1_UserControlClicked(object sender, EventArgs e)
 {
     UnitProduction sender1 = (UnitProduction)sender;
     var            Name    = sender1.UnitProdBttText;
     TabProces      proc    = FindProces(Name);
 }
        private void CreateDynamicWPFGrid()
        {
            // Create the Grid
            var DynamicScrollViewer = new ScrollViewer();

            DynamicScrollViewer.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            DynamicScrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            var DynamicGrid = new Grid {
                ShowGridLines = false
            };

            //  DynamicGrid.Width = 800;
            // DynamicGrid.Height= 450;
            DynamicGrid.HorizontalAlignment = HorizontalAlignment.Left;

            DynamicGrid.VerticalAlignment = VerticalAlignment.Top;

            //    DynamicGrid.ShowGridLines = true;

            DynamicGrid.Background = new SolidColorBrush(Colors.LightSteelBlue);
            // Create Columns
            for (var i = 0; i < 15; i++)
            {
                var gridCol1 = new ColumnDefinition()
                {
                    Width = new GridLength(120)
                };

                DynamicGrid.ColumnDefinitions.Add(gridCol1);
            }
            // Create Rows

            for (var i = 0; i < 10; i++)
            {
                var gridRow1 = new RowDefinition();


                DynamicGrid.RowDefinitions.Add(gridRow1);
            }



            var temp1       = my_ListProses[0];
            int count       = 0;
            int countSubmod = 0;

            for (int iTy = -1; iTy < my_ListProses.Count(); iTy++)
            {
                if (iTy >= 0)
                {
                    temp1 = my_ListProses[iTy];
                }
                int id = count;
                if (temp1.ISubmodule)
                {
                    var connect1 = new UnitProductionConnection();
                    connect1.Name1 = temp1.ModuleA + " -> " + temp1.ModuleB;
                    connect1.Name2 = temp1.ModuleB + " <- " + temp1.ModuleA;
                    if (countSubmod > 0)
                    {
                        Grid.SetRow(connect1, 3);
                    }
                    else
                    {
                        Grid.SetRow(connect1, 5);
                    }

                    Grid.SetColumn(connect1, (id - 1) * 2);
                    DynamicGrid.Children.Add(connect1);

                    var UnitProd1 = new UnitProduction();
                    UnitProd1.Name = temp1.ModuleB;
                    UnitProd1.UserControlClicked += UnitProd1_UserControlClicked;
                    Grid.SetColumn(UnitProd1, (id - 1) * 2);
                    if (countSubmod > 0)
                    {
                        Grid.SetRow(UnitProd1, 2);
                    }
                    else
                    {
                        Grid.SetRow(UnitProd1, 6);
                    }
                    DynamicGrid.Children.Add(UnitProd1);
                    countSubmod++;
                }
                else
                {
                    if (id > 0)
                    {
                        var connect1 = new UnitProductionConnection();
                        connect1.Name1 = temp1.ModuleA + " -> " + temp1.ModuleB;
                        connect1.Name2 = temp1.ModuleB + " <- " + temp1.ModuleA;
                        Grid.SetRow(connect1, 4);
                        Grid.SetColumn(connect1, id * 2 - 1);
                        DynamicGrid.Children.Add(connect1);
                    }
                    var UnitProd1 = new UnitProduction();
                    UnitProd1.UserControlClicked += UnitProd1_UserControlClicked;
                    if (id > 0)
                    {
                        UnitProd1.Name = temp1.ModuleB;
                    }
                    else
                    {
                        UnitProd1.Name = temp1.ModuleA;
                    }
                    Grid.SetColumn(UnitProd1, id * 2);
                    Grid.SetRow(UnitProd1, 4);
                    DynamicGrid.Children.Add(UnitProd1);



                    count++;
                }
            }



            DynamicScrollViewer.Content = DynamicGrid;
            // Display grid into a Window

            this.Content = DynamicScrollViewer;
        }