Exemple #1
0
        public static void init()
        {
            int nOfTypes = 7;

            Types = new CaselType[nOfTypes];

            for (int i = 0; i < Types.Length; i++)
            {
                Types[i] = PrillButton.IntToCasel(i);
            }
        }
Exemple #2
0
        public MainWindow()
        {
            InitializeComponent();
            PrillButton.init();

            try
            {
                NumberOfRows    = int.Parse(Interaction.InputBox("How many rows?", "Number of Rows", "10"));
                NumberOfColumns = int.Parse(Microsoft.VisualBasic.Interaction.InputBox("How many columns? (Last column will be used for commands)", "Number of columns", "10"));
            }
            catch
            {
                MessageBox.Show("Invalid value");
                return;
            }
            if (NumberOfColumns <= 0 || NumberOfRows <= 0)
            {
                MessageBox.Show("Values cannot be lower than 0");
                return;
            }
            GridHeigth = GridWidth * NumberOfRows / NumberOfColumns;
            while (GridHeigth > SystemParameters.PrimaryScreenHeight)
            {
                GridWidth  = GridWidth / 2;
                GridHeigth = GridWidth * NumberOfRows / NumberOfColumns;
            }

            // Create the Grid
            Grid DynamicGrid = new Grid();

            DynamicGrid.Width  = GridWidth;
            DynamicGrid.Height = GridHeigth;
            DynamicGrid.HorizontalAlignment = HorizontalAlignment.Left;
            DynamicGrid.VerticalAlignment   = VerticalAlignment.Top;
            DynamicGrid.ShowGridLines       = true;
            DynamicGrid.Background          = new SolidColorBrush(Colors.LightSteelBlue);
            // Create Columns

            ColumnDefinition[] gridCols = new ColumnDefinition[NumberOfColumns];
            for (int i = 0; i < NumberOfColumns; i++)
            {
                gridCols[i] = new ColumnDefinition();
                DynamicGrid.ColumnDefinitions.Add(gridCols[i]);
            }
            // Create Rows

            RowDefinition[] gridRows = new RowDefinition[NumberOfRows];
            for (int i = 0; i < NumberOfRows; i++)
            {
                gridRows[i] = new RowDefinition();
                DynamicGrid.RowDefinitions.Add(gridRows[i]);
            }

            for (int i = 0; i < NumberOfRows; i++)
            {
                for (int j = 0; j < NumberOfColumns; j++)
                {
                    if (j != NumberOfColumns - 1)
                    {
                        buttons[i, j]                   = new CustomButtons.PrillButton();
                        buttons[i, j].Width             = GridWidth / NumberOfColumns;
                        buttons[i, j].Height            = GridHeigth / NumberOfRows;
                        buttons[i, j].Margin            = new Thickness(1);
                        buttons[i, j].VerticalAlignment = VerticalAlignment.Center;
                        buttons[i, j].SetValue(Grid.ColumnProperty, j);
                        buttons[i, j].SetValue(Grid.RowProperty, i);
                        buttons[i, j].Background = Brushes.White;
                        DynamicGrid.Children.Add(buttons[i, j]);
                        //buttons[i, j].Click += new RoutedEventHandler(buttonCheck);
                    }

                    else
                    {
                        buttons[i, j]                   = new PrillButton();
                        buttons[i, j].Background        = Brushes.Gray;
                        buttons[i, j].Width             = GridWidth / NumberOfColumns;
                        buttons[i, j].Height            = GridHeigth / NumberOfRows;
                        buttons[i, j].Margin            = new Thickness(1);
                        buttons[i, j].VerticalAlignment = VerticalAlignment.Center;
                        buttons[i, j].SetValue(Grid.ColumnProperty, j);
                        buttons[i, j].SetValue(Grid.RowProperty, i);
                        buttons[i, j].FontSize = 12;

                        //buttons[i,j].
                        DynamicGrid.Children.Add(buttons[i, j]);
                        ultimaRiga(i);
                    }
                }
            }
            // Display grid into a Window
            Content     = DynamicGrid;
            WindowState = WindowState.Maximized;
            //WindowStyle = WindowStyle.None;
        }