Exemple #1
0
        private void UpdateButtons()
        {
            FormButton button;
            switch (_type)
            {
                case TitleBarType.CloseOnly:
                    buttonList.Clear();

                    button = new FormButton() { Margin = new Padding(0,0,0,0) };
                    button.Type = ButtonType.CLOSE;

                    buttonList.Add(button);

                    break;
                case TitleBarType.CloseMinimize:
                    buttonList.Clear();

                    button = new FormButton() { Margin = new Padding(0, 0, 0, 0) };
                    button.Type = ButtonType.CLOSE;

                    buttonList.Add(button);

                    button = new FormButton() { Margin = new Padding(0, 0, 0, 0) };
                    button.Type = ButtonType.MINIMIZE;

                    buttonList.Add(button);

                    break;
                case TitleBarType.CloseQuestion:
                    buttonList.Clear();

                    button = new FormButton() { Margin = new Padding(0, 0, 0, 0) };
                    button.Type = ButtonType.CLOSE;

                    buttonList.Add(button);

                    button = new FormButton() { Margin = new Padding(0, 0, 0, 0) };
                    button.Type = ButtonType.QUESTION;

                    buttonList.Add(button);

                    break;
                case TitleBarType.Full:

                    buttonList.Clear();

                    button = new FormButton() { Margin = new Padding(0,0,0,0) };
                    button.Type = ButtonType.CLOSE;

                    buttonList.Add(button);

                    button = new FormButton() { Margin = new Padding(0,0,0,0) };
                    button.Type = ButtonType.MAXIMIZE;

                    buttonList.Add(button);

                    button = new FormButton() { Margin = new Padding(0,0,0,0) };
                    button.Type = ButtonType.MINIMIZE;

                    buttonList.Add(button);

                    button = new FormButton() { Margin = new Padding(0,0,0,0) };
                    button.Type = ButtonType.QUESTION;

                    buttonList.Add(button);
                    break;
                default:
                    buttonList.Clear();

                    button = new FormButton() { Margin = new Padding(0,0,0,0) };
                    button.Type = ButtonType.CLOSE;

                    buttonList.Add(button);

                    button = new FormButton() { Margin = new Padding(0,0,0,0) };
                    button.Type = ButtonType.MAXIMIZE;

                    buttonList.Add(button);

                    button = new FormButton() { Margin = new Padding(0,0,0,0) };
                    button.Type = ButtonType.MINIMIZE;

                    buttonList.Add(button);
                    break;
            }

            this.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;

            this.Controls.Clear();
            for (int i = 0; i < buttonList.Count; i++)
            {
                this.Controls.Add(buttonList[i]);
            }
        }
        private void UpdateButtons()
        {
            FormButton button;

            switch (_type)
            {
            case TitleBarType.CloseOnly:
                buttonList.Clear();

                button = new FormButton()
                {
                    Margin = new Padding(0, 0, 0, 0)
                };
                button.Type = ButtonType.CLOSE;

                buttonList.Add(button);

                break;

            case TitleBarType.CloseMinimize:
                buttonList.Clear();

                button = new FormButton()
                {
                    Margin = new Padding(0, 0, 0, 0)
                };
                button.Type = ButtonType.CLOSE;

                buttonList.Add(button);

                button = new FormButton()
                {
                    Margin = new Padding(0, 0, 0, 0)
                };
                button.Type = ButtonType.MINIMIZE;

                buttonList.Add(button);

                break;

            case TitleBarType.CloseQuestion:
                buttonList.Clear();

                button = new FormButton()
                {
                    Margin = new Padding(0, 0, 0, 0)
                };
                button.Type = ButtonType.CLOSE;

                buttonList.Add(button);

                button = new FormButton()
                {
                    Margin = new Padding(0, 0, 0, 0)
                };
                button.Type = ButtonType.QUESTION;

                buttonList.Add(button);

                break;

            case TitleBarType.Full:

                buttonList.Clear();

                button = new FormButton()
                {
                    Margin = new Padding(0, 0, 0, 0)
                };
                button.Type = ButtonType.CLOSE;

                buttonList.Add(button);

                button = new FormButton()
                {
                    Margin = new Padding(0, 0, 0, 0)
                };
                button.Type = ButtonType.MAXIMIZE;

                buttonList.Add(button);

                button = new FormButton()
                {
                    Margin = new Padding(0, 0, 0, 0)
                };
                button.Type = ButtonType.MINIMIZE;

                buttonList.Add(button);

                button = new FormButton()
                {
                    Margin = new Padding(0, 0, 0, 0)
                };
                button.Type = ButtonType.QUESTION;

                buttonList.Add(button);
                break;

            default:
                buttonList.Clear();

                button = new FormButton()
                {
                    Margin = new Padding(0, 0, 0, 0)
                };
                button.Type = ButtonType.CLOSE;

                buttonList.Add(button);

                button = new FormButton()
                {
                    Margin = new Padding(0, 0, 0, 0)
                };
                button.Type = ButtonType.MAXIMIZE;

                buttonList.Add(button);

                button = new FormButton()
                {
                    Margin = new Padding(0, 0, 0, 0)
                };
                button.Type = ButtonType.MINIMIZE;

                buttonList.Add(button);
                break;
            }

            this.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;

            this.Controls.Clear();
            for (int i = 0; i < buttonList.Count; i++)
            {
                this.Controls.Add(buttonList[i]);
            }
        }