Пример #1
0
        private static LayoutTable Table(int rows, int columns, Control[] controls)
        {
            var table = new LayoutTable(rows, columns);

            table.Fill(controls);
            table.FixRows();

            return(table);
        }
Пример #2
0
        public MatchDialog() : base()
        {
            userNameTextBox = new TextBox()
            {
                MaxLength = 10
            };
            blackButton = new RadioButton()
            {
                Text    = "Black",
                Checked = true,
                Height  = userNameTextBox.Height
            };
            whiteButton = new RadioButton()
            {
                Text   = "White",
                Height = userNameTextBox.Height
            };
            boardSizeUpDown = new NumericUpDown()
            {
                Minimum = 2,
                Maximum = 19,
                Value   = 19
            };
            timeUpDown = new NumericUpDown()
            {
                Minimum = 0,
                Maximum = 1000,
                Value   = 30
            };
            byouyomiUpDown = new NumericUpDown()
            {
                Minimum = 0,
                Maximum = 1000
            };

            foreach (var item in new Control[]
            {
                userNameTextBox, blackButton, whiteButton,
                boardSizeUpDown, timeUpDown, byouyomiUpDown
            })
            {
                Layout.Resize(item);
            }

            table = Layout.PropertyTable(
                Layout.Label("Player name:"), userNameTextBox,
                Layout.Label("Your color:"), blackButton,
                null, whiteButton,
                Layout.Label("Board size:"), boardSizeUpDown,
                Layout.Label("Base time:"), timeUpDown,
                Layout.Label("Byouyomi:"), byouyomiUpDown);

            Layout.Bind(table, this);
        }
Пример #3
0
        public static LayoutTable PropertyTable(params Control[] controls)
        {
            var height = controls.Length / 2;

            var table = new LayoutTable(height, 2);

            table.Fill(controls);
            table.FixRows();
            table.FixColumns(0);

            return(table);
        }
Пример #4
0
        public SeekDialog() : base()
        {
            boardSizeUpDown = new NumericUpDown()
            {
                Minimum = 2,
                Maximum = 19,
                Value   = 19
            };
            handicapUpDown = new NumericUpDown()
            {
                Minimum = 0,
                Maximum = 9,
                Value   = 0
            };
            foreach (var item in new Control[] { boardSizeUpDown, handicapUpDown })
            {
                Layout.Resize(item);
            }

            timeRadioButtons = Collection.ToArray(Collection.Map(
                                                      SeekRequest.TimeLabels,
                                                      s => new RadioButton()
            {
                Text   = s,
                Height = boardSizeUpDown.Height
            }));



            var table = new LayoutTable(timeRadioButtons.Length + 1, 1);

            table.Fill(timeRadioButtons);

            table.PutLayout(Layout.PropertyTable(
                                Layout.Label("Board size:"), boardSizeUpDown,
                                Layout.Label("Handicap:"), handicapUpDown),
                            timeRadioButtons.Length, 0);
            table.FixRows();

            Layout.Bind(table, this);
        }
Пример #5
0
        public MatchDialog(MatchRequest request,
                           IgsPlayerInfo stats) : this(request)
        {
            if (Environment.OSVersion.Platform == PlatformID.WinCE)
            {
                userNameTextBox.Width = 0;
                var statsButton = new Button()
                {
                    Text   = "?",
                    Height = userNameTextBox.Height,
                    Width  = userNameTextBox.Height
                };

                var innerTable = new LayoutTable(1, 2);
                innerTable.Fill(userNameTextBox, statsButton);
                innerTable.FixRows();
                innerTable.FixColumns(1);

                table.PutLayout(innerTable, 0, 1);
                table.Apply(this, this.ClientRectangle);

                statsButton.Click += delegate { notification.Visible = true; };

                notification = new Notification()
                {
                    Text = "<html><body><form method='GET' action='notify'><hr/>" +
                           "Name: " + stats.Name +
                           "<br/>Rank: " + stats.Rank.ToString() +
                           "<br/>Wins/Losses: " + stats.GamesWon + "/" +
                           stats.GamesLost +
                           "<hr/></form></body></html>",
                    Caption         = "Stats of " + stats.Name,
                    InitialDuration = 10,
                    Icon            = ConfigManager.GetIcon("game")
                };
            }
        }
Пример #6
0
        private TabPage CreateAccountPage()
        {
            accountsBox = new ListBox();
            GetAccounts(accountsBox);

            addAccountButton    = Layout.Button("Add");
            editAccountButton   = Layout.Button("Edit");
            removeAccountButton = Layout.Button("Remove");

            addAccountButton.Click += delegate
            {
                var dialog = new AccountDialog();
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    var account = dialog.Account;
                    if (ConfigManager.Settings.Accounts.Find(
                            a => a.Name == account.Name) == null)
                    {
                        ConfigManager.Settings.Accounts.Add(account);
                        accountsBox.Items.Add(account.Name);
                        accountsBox.SelectedItem = account.Name;
                    }
                }
            };

            editAccountButton.Click += delegate
            {
                var index = accountsBox.SelectedIndex;
                if (index >= 0)
                {
                    var name   = accountsBox.SelectedItem as string;
                    var dialog = new AccountDialog(
                        ConfigManager.Settings.Accounts.Find(
                            a => a.Name == name) ?? IGSAccount.DefaultAccount);
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        var account = dialog.Account;

                        ConfigManager.Settings.Accounts.RemoveAll(
                            a => a.Name == name);
                        ConfigManager.Settings.Accounts.Insert(index, account);
                        accountsBox.Items[index] = account.Name;
                    }
                }
            };

            removeAccountButton.Click += delegate
            {
                var index = accountsBox.SelectedIndex;
                if (index >= 0)
                {
                    ConfigManager.Settings.Accounts.RemoveAt(index);
                    accountsBox.Items.RemoveAt(index);
                    if (ConfigManager.Settings.Accounts.Count == 0)
                    {
                        ConfigManager.Settings.Accounts.Add(IGSAccount.DefaultAccount);
                        accountsBox.Items.Add(IGSAccount.DefaultAccount.Name);
                    }
                    if (accountsBox.SelectedIndex < 0)
                    {
                        accountsBox.SelectedIndex = accountsBox.Items.Count - 1;
                    }
                }
            };

            var accountTable = new LayoutTable(2, 1);

            accountTable.PutControl(accountsBox, 0, 0);
            accountTable.PutLayout(
                Layout.Flow(addAccountButton,
                            editAccountButton,
                            removeAccountButton),
                1, 0);
            accountTable.FixRows(1);

            var page = new TabPage()
            {
                Text = "Account",
                Dock = DockStyle.Fill
            };

            Layout.Bind(accountTable, page);
            return(page);
        }