Ejemplo n.º 1
0
 private static void UpdateColor(Led sender)
 {
     sender.RectangleColor.Fill = sender.Fill;
 }
        private static void UpdateGrid(ColorTouchGrid sender)
        {
            sender.Grid_Main.ColumnDefinitions.Clear();
            for (int i = 0; i < sender.Columns; i++)
            {
                sender.Grid_Main.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
            }

            sender.Grid_Main.RowDefinitions.Clear();
            for (int i = 0; i < sender.Rows; i++)
            {
                sender.Grid_Main.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
            }

            sender._Leds = new Led[sender.Rows, sender.Columns];
            sender._TouchCurrent = new byte[sender.Rows, sender.Columns];
            sender._TouchLast = new byte[sender.Rows, sender.Columns];

            sender.Grid_Main.Children.Clear();
            for (int i = 0; i < sender.Rows; i++)
            {
                for (int j = 0; j < sender.Columns; j++)
                {
                    Led led = new Led();
                    led.SetValue(Grid.RowProperty, i);
                    led.SetValue(Grid.ColumnProperty, j);

                    led.MouseEnter += sender.Button_MouseEvent;
                    led.MouseLeave += sender.Button_MouseEvent;

                    led.Fill = Brushes.White;

                    sender._Leds[i, j] = led;

                    sender.Grid_Main.Children.Add(led);
                }
            }
        }