Exemplo n.º 1
0
        private void ChangeComboBoxes(MyComboBox activatedComboBox)
        {
            string activeValue = GetActiveValue(activatedComboBox);

            //LblArray[0].Text = activatedComboBox.id;
            for (int count = 0; count < numTotalPlayers; count++)
            {
                if (activatedComboBox.id != ComboBoxArray[count].id)
                {
                    ComboBoxArray[count].DeleteElement(activeValue);
                }
                else
                {
                    if (activatedComboBox.previousActiveText != "")
                    {
                        ComboBoxArray[count].DeleteElement(ComboBoxArray[count].previousActiveText);
                        for (int count2 = 0; count2 < numTotalPlayers; count2++)
                        {
                            ComboBoxArray[count2].AppendElement(ComboBoxArray[count].previousActiveText);
                        }
                    }
                    ComboBoxArray[count].previousActiveText = activeValue;
                }
            }
        }
Exemplo n.º 2
0
        private void MakeWindow()
        {
            WindowPosition = (WindowPosition)1;
            Resizable      = false;

            topAlignment = new Alignment(0.5F, 0.5F, 1F, 1F)
            {
                HeightRequest = 10
            };
            bottomAlignment = new Alignment(0.5F, 0.5F, 1F, 1F)
            {
                HeightRequest = 10
            };
            buttonAlignment = new Alignment(0.5F, 0.5F, 1F, 1F)
            {
                WidthRequest = 200
            };

            mainHBox = new VBox
            {
                Name = "mainBox"
            };
            middleBox = new VBox
            {
                Name = "middleBox"
            };
            HBoxArray     = new HBox[numTotalPlayers + 1];
            LblArray      = new Label[numTotalPlayers];
            EntryArray    = new Entry[numTotalPlayers];
            ComboBoxArray = new MyComboBox[numTotalPlayers];

            okBtn = new Button
            {
                Name          = "okBtn",
                Label         = "OK",
                WidthRequest  = 60,
                HeightRequest = 35
            };
            okBtn.Clicked += new EventHandler(OnOkBtnClicked);

            cancelBtn = new Button
            {
                Name          = "cancelBtn",
                Label         = "Cancel",
                WidthRequest  = 60,
                HeightRequest = 35
            };
            cancelBtn.Clicked += new EventHandler(OnCancelBtnClicked);


            for (int playerCount = 0; playerCount < numTotalPlayers; playerCount++)
            {
                if (playerCount < numHumanPlayers)
                {
                    LblArray[playerCount] = new Label
                    {
                        Name = $"Lbl{playerCount}",
                        Text = $"Player_{playerCount} name :"
                    };
                    EntryArray[playerCount] = new Entry
                    {
                        Name = $"Entry{playerCount}"
                    };
                }
                else
                {
                    LblArray[playerCount] = new Label
                    {
                        Name = $"Lbl{playerCount}",
                        Text = $"AI_{playerCount - numHumanPlayers} name :"
                    };
                    EntryArray[playerCount] = new Entry
                    {
                        Name = $"Entry{playerCount}",
                        Text = $"AI_{playerCount - numHumanPlayers}"
                    };
                }

                ComboBoxArray[playerCount] = new MyComboBox(comboBoxColors, playerCount.ToString())
                {
                    Name = $"ComboBox{playerCount}"
                };

                ///////////////////////////////////////////////////////////////////////
                ComboBoxArray[playerCount].Changed += new EventHandler(ComboBoxChanged);
                ///////////////////////////////////////////////////////////////////////

                HBoxArray[playerCount] = new HBox
                {
                    Name = $"HBox{playerCount}"
                };

                HBoxArray[playerCount].Add(LblArray[playerCount]);
                HBoxArray[playerCount].Add(EntryArray[playerCount]);
                HBoxArray[playerCount].Add(ComboBoxArray[playerCount]);

                middleBox.Add(HBoxArray[playerCount]);
            }

            HBoxArray[numTotalPlayers] = new HBox()
            {
                Name = "buttonHBox"
            };
            HBoxArray[numTotalPlayers].Add(buttonAlignment);
            HBoxArray[numTotalPlayers].Add(cancelBtn);
            HBoxArray[numTotalPlayers].Add(okBtn);
            middleBox.Add(HBoxArray[numTotalPlayers]);

            mainHBox.Add(topAlignment);
            mainHBox.Add(middleBox);
            mainHBox.Add(bottomAlignment);

            Add(mainHBox);
        }