Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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")
                };
            }
        }
Ejemplo n.º 3
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);
        }