/// <summary>
        /// Add a particular button on the right top of the form
        /// </summary>
        private void AddWindowButton(WindowButtons button)
        {
            var newButton = new YamuiFormButton(this)
            {
                Type = button,
            };

            _windowButtonList.Add(button, newButton);
        }
示例#2
0
        /// <summary>
        /// Add a particular button on the right top of the form
        /// </summary>
        private void AddWindowButton(WindowButtons button)
        {
            if (_windowButtonList == null)
            {
                _windowButtonList = new Dictionary <WindowButtons, YamuiFormButton>();
            }

            if (_windowButtonList.ContainsKey(button))
            {
                return;
            }

            var newButton = new YamuiFormButton();

            switch (button)
            {
            case WindowButtons.Close:
                newButton.Text = @"r";
                _mainFormToolTip.SetToolTip(newButton, "<b>Close</b> this window");
                break;

            case WindowButtons.Minimize:
                newButton.Text = @"0";
                _mainFormToolTip.SetToolTip(newButton, "<b>Minimize</b> this window");
                break;

            case WindowButtons.Maximize:
                newButton.Text = WindowState == FormWindowState.Normal ? @"1" : @"2";
                _mainFormToolTip.SetToolTip(newButton, "<b>" + (WindowState == FormWindowState.Normal ? "Maximize" : "Restore") + "</b> this window");
                break;

            case WindowButtons.CloseAllVisible:
                newButton.Text = ((char)(126)).ToString();
                _mainFormToolTip.SetToolTip(newButton, "<b>Close all</b> notification windows");
                break;
            }

            newButton.Tag     = button;
            newButton.Size    = new Size(25, 20);
            newButton.Anchor  = AnchorStyles.Top | AnchorStyles.Right;
            newButton.TabStop = false; //remove the form controls from the tab stop
            newButton.Click  += OnWindowButtonClick;
            Controls.Add(newButton);

            _windowButtonList.Add(button, newButton);
        }
示例#3
0
        private void UpdateWindowButtonPosition()
        {
            if (!ControlBox)
            {
                return;
            }

            var priorityOrder = new Dictionary <int, WindowButtons>(3)
            {
                { 0, WindowButtons.Close }, { 1, WindowButtons.Maximize }, { 2, WindowButtons.Minimize }
            };

            var firstButtonLocation      = new Point(ClientRectangle.Width - BorderWidth - 25, BorderWidth);
            var lastDrawedButtonPosition = firstButtonLocation.X - 25;

            YamuiFormButton firstButton = null;

            foreach (var button in priorityOrder)
            {
                var buttonExists = _windowButtonList.ContainsKey(button.Value);

                if (firstButton == null && buttonExists)
                {
                    firstButton          = _windowButtonList[button.Value];
                    firstButton.Location = firstButtonLocation;
                    continue;
                }

                if (firstButton == null || !buttonExists)
                {
                    continue;
                }

                _windowButtonList[button.Value].Location = new Point(lastDrawedButtonPosition, BorderWidth);
                lastDrawedButtonPosition = lastDrawedButtonPosition - 25;
            }

            if (_windowButtonList.ContainsKey(WindowButtons.CloseAllVisible))
            {
                _windowButtonList[WindowButtons.CloseAllVisible].Location = new Point(ClientRectangle.Width - BorderWidth - 25, BorderWidth + 25);
            }

            Refresh();
        }
示例#4
0
        private void AddWindowButton(WindowButtons button)
        {
            if (_windowButtonList == null)
                _windowButtonList = new Dictionary<WindowButtons, YamuiFormButton>();

            if (_windowButtonList.ContainsKey(button))
                return;

            var newButton = new YamuiFormButton();

            switch (button) {
                case WindowButtons.Close:
                    newButton.Text = @"r";
                    _mainFormToolTip.SetToolTip(newButton, "<b>Close</b> this window");
                    break;
                case WindowButtons.Minimize:
                    newButton.Text = @"0";
                    _mainFormToolTip.SetToolTip(newButton, "<b>Minimize</b> this window");
                    break;
                case WindowButtons.Maximize:
                    newButton.Text = WindowState == FormWindowState.Normal ? @"1" : @"2";
                    _mainFormToolTip.SetToolTip(newButton, "<b>" + (WindowState == FormWindowState.Normal ? "Maximize" : "Restore") + "</b> this window");
                    break;
                case WindowButtons.CloseAllVisible:
                    newButton.Text = ((char)(126)).ToString();
                    _mainFormToolTip.SetToolTip(newButton, "<b>Close all visible</b> notification windows");
                    break;
            }

            newButton.Tag = button;
            newButton.Size = new Size(25, 20);
            newButton.Anchor = AnchorStyles.Top | AnchorStyles.Right;
            newButton.TabStop = false; //remove the form controls from the tab stop
            newButton.Click += WindowButton_Click;
            Controls.Add(newButton);

            _windowButtonList.Add(button, newButton);
        }