コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="buttonColor"></param>
        public void setupYesNoCancel(Color buttonColor)
        {
            bCancel = setupButton(bCancel, buttonColor, DockStyle.Right);
            bOk     = setupButton(bOk, buttonColor, DockStyle.None);
            bNo     = setupButton(bNo, buttonColor, DockStyle.None);

            bOk.Text         = "Yes";
            bOk.Dock         = DockStyle.Left;
            bOk.DialogResult = DialogResult.Yes;

            bCancel.SendToBack();             // to make it align to the right

            bNo.Dock   = DockStyle.None;
            bNo.Left   = bCancel.Left - 5;          // -(bOk.Width);
            bNo.Height = bCancel.Height;
            bNo.Top    = bCancel.Top;


            bOk.Left   = bNo.Left - bNo.Width - 2;          // -(bOk.Width);
            bOk.Height = bNo.Height;
            bOk.Top    = bNo.Top;

            bCancel.TabIndex = 0;
            bNo.TabIndex     = 1;
            bOk.TabIndex     = 2;

            this.AcceptButton = bCancel;
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        private void setupYesNo(Color buttonColor)
        {
            bOk = setupButton(bOk, buttonColor, DockStyle.None);
            bNo = setupButton(bNo, buttonColor, DockStyle.Right);
            bNo.SendToBack();             // to make it align to the right

            bOk.Text = "Yes";
            //  bCancel.Text = "No";
            bOk.DialogResult = DialogResult.Yes;
            //  bCancel.DialogResult = DialogResult.No;


            // manually ensure that bOK is spaced far enough away from bCancel
            bOk.Dock = DockStyle.Left;
            //bOk.Left = bNo.Left - 5;// -(bOk.Width); OK, Feb 2013 - we commented this out, using the Docking + Margin to accomplish spacing
            bOk.Height = bNo.Height;
            bOk.Top    = bNo.Top;

            bNo.TabIndex      = 0;
            bOk.TabIndex      = 1;
            this.AcceptButton = bNo;
        }
コード例 #3
0
        private void gameButton()
        {
            button = new Button();
            button.Text = "begin";
            button.Height = this.size;
            button.Width = LABELWIDTH;
            button.TextAlign = ContentAlignment.MiddleCenter;
            button.Font = new Font("Arial", 12);
            button.BackColor = Color.Transparent;
            button.Location = new Point(this.platAlly.Location.X + this.platAlly.Size.Width + 20, this.platAlly.Location.Y + LABELWIDTH);
            button.Click += button_Click;
            this.Controls.Add(button);

            Button btnRestart = new Button();
            btnRestart.Text = "RESTART";
            btnRestart.Height = this.size;
            btnRestart.Width = this.size * 3;
            btnRestart.Font = new Font("Arial", 12);
            btnRestart.Location = new Point(size * 27, this.Width / 2);
            btnRestart.SendToBack();
            this.Controls.Add(btnRestart);
            btnRestart.Click += btnRestart_Click;

            button = new Button();
            button.Text = "Join game";
            button.Height = this.size;
            button.Width = LABELWIDTH;
            button.TextAlign = ContentAlignment.MiddleCenter;
            button.Font = new Font("Arial", 12);
            button.BackColor = Color.Transparent;
            button.Location = new Point(this.platAlly.Location.X + this.platAlly.Size.Width + 20, this.platAlly.Location.Y + LABELWIDTH + 50);
            button.Click += button_Click;
            this.Controls.Add(button);

            button = new Button();
            button.Text = "Create game";
            button.Height = this.size;
            button.Width = LABELWIDTH;
            button.TextAlign = ContentAlignment.MiddleCenter;
            button.Font = new Font("Arial", 12);
            button.BackColor = Color.Transparent;
            button.Location = new Point(this.platAlly.Location.X + this.platAlly.Size.Width + 20, this.platAlly.Location.Y + LABELWIDTH + 100);
            button.Click += create_game;     
            this.Controls.Add(button);
        }
コード例 #4
0
ファイル: Nodos.cs プロジェクト: Servtes/GrafoNator
        /// <summary>
        /// Crear los nodos.
        /// </summary>
        /// <param name="numeroDeNodo">El numero de nodo a Crear.</param>
        /// <param name="ejeX">Posicion en el eje X.</param>
        /// <param name="ejeY">Posicion en el eje Y.</param>
        /// <returns>El nodo en las posiciones x,y indicadas</returns>
        public Control CrearNodoN(int numeroDeNodo, int ejeX, int ejeY)
        {
            Button nodo = null;

            switch (numeroDeNodo)
            {
                case 0:
                    nodo = new Button
                               {
                                   //Descripcion de las propiedades
                                   Name = "nodo1",
                                   //Nombre que tendra el Control
                                   Size = new Size(45, 45),
                                   //Tamaño en pixeles
                                   Location = new Point(ejeX, ejeY),
                                   //Posicion en el Panel
                                   Text = "A",
                                   //Texto que contendra
                                   BackColor = Color.Crimson,
                                   //Color del control
                                   ForeColor = Color.White,
                                   //Color del Texto
                               };
                    nodo.SendToBack(); //Pasa al control al fondo de todos los elementos
                    nodo.SendToBack();
                    break;

                case 1:
                    nodo = new Button
                               {
                                   Name = "nodo2",
                                   Size = new Size(45, 45),
                                   Location = new Point(ejeX, ejeY),
                                   Text = "B",
                                   BackColor = Color.Crimson,
                                   ForeColor = Color.White,
                               };
                    nodo.SendToBack();
                    break;

                case 2:
                    nodo = new Button
                               {
                                   Name = "nodo3",
                                   Size = new Size(45, 45),
                                   Location = new Point(ejeX, ejeY),
                                   Text = "C",
                                   BackColor = Color.Crimson,
                                   ForeColor = Color.White,
                               };
                    nodo.SendToBack();
                    nodo.SendToBack();
                    break;

                case 3:
                    nodo = new Button
                               {
                                   Name = "nodo4",
                                   Size = new Size(45, 45),
                                   Location = new Point(ejeX, ejeY),
                                   Text = "D",
                                   BackColor = Color.Crimson,
                                   ForeColor = Color.White,
                               };
                    nodo.SendToBack();
                    nodo.SendToBack();
                    break;

                case 4:
                    nodo = new Button
                               {
                                   Name = "nodo5",
                                   Size = new Size(45, 45),
                                   Location = new Point(ejeX, ejeY),
                                   Text = "E",
                                   BackColor = Color.Crimson,
                                   ForeColor = Color.White,
                               };
                    nodo.SendToBack();
                    nodo.SendToBack();
                    break;

                case 5:
                    nodo = new Button
                               {
                                   Name = "nodo6",
                                   Size = new Size(45, 45),
                                   Location = new Point(ejeX, ejeY),
                                   Text = "F",
                                   BackColor = Color.Crimson,
                                   ForeColor = Color.White,
                               };
                    nodo.SendToBack();
                    nodo.SendToBack();
                    break;

                case 6:
                    nodo = new Button
                               {
                                   Name = "nodo7",
                                   Size = new Size(45, 45),
                                   Location = new Point(ejeX, ejeY),
                                   Text = "G",
                                   BackColor = Color.Crimson,
                                   ForeColor = Color.White,
                               };
                    nodo.SendToBack();
                    nodo.SendToBack();
                    break;

                case 7:
                    nodo = new Button
                               {
                                   Name = "nodo8",
                                   Size = new Size(45, 45),
                                   Location = new Point(ejeX, ejeY),
                                   Text = "H",
                                   BackColor = Color.Crimson,
                                   ForeColor = Color.White,
                               };
                    nodo.SendToBack();
                    nodo.SendToBack();
                    break;
            }
            //Tiempo de espera entre cada llamada.
            Thread.Sleep(100);
            return nodo;
        }
コード例 #5
0
        /// <summary>
        /// Sets
        /// </summary>
        /// <param name="buttons"></param>
        /// <param name="bOkDefault">if true the OK button will be the default button</param>
        public void SetupForButtons(MessageBoxButtons buttons, Color buttonColor, bool bOkDefault)
        {
            switch (buttons)
            {
            case MessageBoxButtons.OK:
            {
                this.AcceptButton = bOk;
                bOk = setupButton(bOk, buttonColor, DockStyle.Right);
            }
            break;

            case MessageBoxButtons.OKCancel:
            {
                bOk     = setupButton(bOk, buttonColor, DockStyle.Left);
                bCancel = setupButton(bCancel, buttonColor, DockStyle.Right);
                bCancel.SendToBack();                 // to make it align to the right

                // manually ensure that bOK is spaced far enough away from bCancel
                bOk.Left   = bCancel.Left - 5;              // -(bOk.Width);
                bOk.Height = bCancel.Height;
                bOk.Top    = bCancel.Top;

                bCancel.TabIndex  = 0;
                bOk.TabIndex      = 1;
                this.AcceptButton = bCancel;
            }
            break;

            case MessageBoxButtons.YesNo:
            {
                setupYesNo(buttonColor);
            } break;

            case MessageBoxButtons.YesNoCancel:
            {
                setupYesNoCancel(buttonColor);
            } break;

            case MessageBoxButtons.RetryCancel:
            {
                setupYesNo(buttonColor);
                bOk.Text         = "Retry";
                bOk.DialogResult = DialogResult.Retry;
                bNo.Text         = "Cancel";
                bNo.DialogResult = DialogResult.Cancel;
            } break;

            case MessageBoxButtons.AbortRetryIgnore:
            {
                setupYesNoCancel(buttonColor);
                bOk.Text         = "Abort";
                bOk.DialogResult = DialogResult.Abort;

                bNo.Text         = "Retry";
                bNo.DialogResult = DialogResult.Retry;

                bCancel.Text         = "Ignore";
                bCancel.DialogResult = DialogResult.Cancel;
            } break;

            default: MessageBox.Show(buttons.ToString() + " is unhandled in NewMessage"); break;
            }

            if (bOkDefault == true)
            {
                this.AcceptButton = bOk;
            }
        }