Beispiel #1
0
 /// <summary>
 /// Vrací výchozí hodnotu pro výsledek dialogu, který bude vrácen po zavření okna bez výběru konkrétního buttonu.
 /// </summary>
 /// <returns></returns>
 private GUI.GuiDialogButtons _SearchCloseResponse()
 {
     GUI.GuiDialogButtons buttons = this._Buttons;
     if (buttons.HasFlag(GUI.GuiDialogButtons.Cancel))
     {
         return(GUI.GuiDialogButtons.Cancel);
     }
     if (buttons.HasFlag(GUI.GuiDialogButtons.No))
     {
         return(GUI.GuiDialogButtons.No);
     }
     if (buttons.HasFlag(GUI.GuiDialogButtons.Abort))
     {
         return(GUI.GuiDialogButtons.Abort);
     }
     if (buttons.HasFlag(GUI.GuiDialogButtons.Ignore))
     {
         return(GUI.GuiDialogButtons.Ignore);
     }
     if (buttons.HasFlag(GUI.GuiDialogButtons.Ok))
     {
         return(GUI.GuiDialogButtons.Ok);
     }
     return(GUI.GuiDialogButtons.Cancel);
 }
Beispiel #2
0
 /// <summary>
 /// Vrací defaultní button pro funkci <see cref="WinForms.Form.CancelButton"/>
 /// </summary>
 /// <returns></returns>
 private WinButtonBase _SearchCancelButton()
 {
     GUI.GuiDialogButtons buttons = this._Buttons;
     if (buttons.HasFlag(GUI.GuiDialogButtons.Cancel))
     {
         return(this.ButtonCancel);
     }
     if (buttons.HasFlag(GUI.GuiDialogButtons.No))
     {
         return(this.ButtonNo);
     }
     if (buttons.HasFlag(GUI.GuiDialogButtons.Abort))
     {
         return(this.ButtonAbort);
     }
     return(null);
 }
Beispiel #3
0
 /// <summary>
 /// Vrací defaultní button pro funkci <see cref="WinForms.Form.AcceptButton"/>
 /// </summary>
 /// <returns></returns>
 private WinButtonBase _SearchAcceptButton()
 {
     GUI.GuiDialogButtons buttons = this._Buttons;
     if (buttons.HasFlag(GUI.GuiDialogButtons.Ok))
     {
         return(this.ButtonOk);
     }
     if (buttons.HasFlag(GUI.GuiDialogButtons.Yes))
     {
         return(this.ButtonYes);
     }
     if (buttons.HasFlag(GUI.GuiDialogButtons.Save))
     {
         return(this.ButtonSave);
     }
     if (buttons.HasFlag(GUI.GuiDialogButtons.Retry))
     {
         return(this.ButtonRetry);
     }
     return(null);
 }
Beispiel #4
0
        /// <summary>
        /// Metoda zajistí zobrazení buttonů
        /// </summary>
        private void _ShowButtons(GUI.GuiDialogButtons buttons)
        {
            int count = GetButtonsCount(buttons);          // Kolik buttonů budeme zobrazovat?

            if (count == 0)
            {
                buttons = GUI.GuiDialogButtons.Ok;
                count   = 1;
            }
            bool  isCancelIndented = (count >= 3 && buttons.HasFlag(GUI.GuiDialogButtons.Cancel));       // true pokud má být zobrazen button Cancel s odsazením
            float buttonWidth      = 126;                                                                // Optimální šířka jednoho buttonu, když bude dost místa
            float borderWidth      = 12;                                                                 // Šířka okrajů
            float spaceWidth       = 9;                                                                  // Šířka mezery
            float spaceCancel      = (isCancelIndented ? 24 : 0);                                        // Extra odsazení buttonu Cancel
            float contentWidth     = ((count * buttonWidth) + spaceCancel + ((count - 1) * spaceWidth)); // Tolik místa bychom potřebovali pro všechny buttony při optimální šířce jednoho buttonu
            float parentWidth      = this.ButtonsPanel.Width;                                            // Tolik místa na buttony reálně máme v controlu
            float parentHeight     = this.ButtonsPanel.Height;                                           // Výška prostoru
            float disponibleWidth  = parentWidth - (2f * borderWidth);

            if (contentWidth > disponibleWidth)
            {
                buttonWidth = (disponibleWidth - spaceCancel - (spaceWidth * (count - 1))) / count;
                if (buttonWidth < 50f)
                {
                    buttonWidth = 50f;
                }
                contentWidth = ((count * buttonWidth) + spaceCancel + ((count - 1) * spaceWidth));  // Tolik místa zaberou buttony při upravené šířce buttonWidth
            }

            float x, y;

            _AlignContent(parentWidth, parentHeight, contentWidth, borderWidth, this.ButtonsAlignment, out x, out y);

            this._ShowButton(this.ButtonOk, buttons, ref x, y, buttonWidth, 0, spaceWidth);
            this._ShowButton(this.ButtonYes, buttons, ref x, y, buttonWidth, 0, spaceWidth);
            this._ShowButton(this.ButtonNo, buttons, ref x, y, buttonWidth, 0, spaceWidth);
            this._ShowButton(this.ButtonAbort, buttons, ref x, y, buttonWidth, 0, spaceWidth);
            this._ShowButton(this.ButtonRetry, buttons, ref x, y, buttonWidth, 0, spaceWidth);
            this._ShowButton(this.ButtonIgnore, buttons, ref x, y, buttonWidth, 0, spaceWidth);
            this._ShowButton(this.ButtonSave, buttons, ref x, y, buttonWidth, 0, spaceWidth);
            this._ShowButton(this.ButtonMaybe, buttons, ref x, y, buttonWidth, 0, spaceWidth);
            this._ShowButton(this.ButtonCancel, buttons, ref x, y, buttonWidth, spaceCancel, spaceWidth);
        }