コード例 #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);
 }
コード例 #2
0
        /// <summary>
        /// Zajistí vyvolání háčku a eventu
        /// </summary>
        /// <param name="result"></param>
        private void _CallButtonClick(GUI.GuiDialogButtons result)
        {
            GPropertyEventArgs <GUI.GuiDialogButtons> args = new GPropertyEventArgs <GUI.GuiDialogButtons>(result);

            this.OnButtonClick(args);
            if (this.ButtonClick != null)
            {
                this.ButtonClick(this, args);
            }
        }
コード例 #3
0
        /// <summary>
        /// Metoda vrací defaultní titulek pro formulář, podle zadaných tlačítek.
        /// </summary>
        /// <param name="buttons"></param>
        /// <returns></returns>
        protected static string GetDefaultTitleForButtons(GUI.GuiDialogButtons buttons)
        {
            int count = GetButtonsCount(buttons);

            if (count <= 1)
            {
                return("Potvrďte prosím přečtení");
            }
            return("Vyberte prosím odpověď...");
        }
コード例 #4
0
        /// <summary>
        /// Zajistí zobrazení jednoho buttonu
        /// </summary>
        /// <param name="button"></param>
        /// <param name="buttons"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="spaceBefore"></param>
        /// <param name="buttonWidth"></param>
        /// <param name="spaceWidth"></param>
        private void _ShowButton(WinButtonBase button, GUI.GuiDialogButtons buttons, ref float x, float y, float buttonWidth, float spaceBefore, float spaceWidth)
        {
            GUI.GuiDialogButtons buttonValue = (button.Tag is GUI.GuiDialogButtons ? (GUI.GuiDialogButtons)button.Tag : GUI.GuiDialogButtons.None);
            bool isVisible = ((buttons & buttonValue) != 0);

            button.Visible = isVisible;
            if (isVisible)
            {
                x += spaceBefore;
                int ix = (int)Math.Round(x, 0);
                int iy = (int)Math.Round(y, 0);
                int iw = (int)Math.Round(buttonWidth, 0);
                button.Bounds = new Rectangle(ix, iy, iw, ButtonItemHeight);
                x             = x + buttonWidth + spaceWidth;
            }
        }
コード例 #5
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);
 }
コード例 #6
0
        /// <summary>
        /// Vytvoří Button z daných dat, přidá jej do ButtonPanel.Controls a vrátí jej
        /// </summary>
        /// <param name="value"></param>
        /// <param name="image"></param>
        /// <param name="text"></param>
        /// <returns></returns>
        private WinButtonBase _PrepareButton(GUI.GuiDialogButtons value, string image, string text)
        {
            WinButtonBase button = new WinButtonBase()
            {
                Size    = new Size(110, 32),
                Text    = text,
                Image   = Application.App.ResourcesApp.GetImage(image),
                Visible = false,
                Tag     = value
            };

            button.Click    += _Button_Click;
            button.GotFocus += _Button_GotFocus;
            this.ButtonsPanel.Controls.Add(button);
            this._WinButtonList.Add(button);
            return(button);
        }
コード例 #7
0
        /// <summary>
        /// Metoda vrací defaultní ikonu pro formulář, podle zadaných tlačítek.
        /// </summary>
        /// <param name="buttons"></param>
        /// <returns></returns>
        protected static GUI.GuiImage GetDefaultIconForButtons(GUI.GuiDialogButtons buttons)
        {
            int count = GetButtonsCount(buttons);

            if (count == 0)
            {
                return(GUI.GuiDialog.DialogIconWarning);
            }
            if (count > 1)
            {
                return(GUI.GuiDialog.DialogIconQuestion);
            }
            if ((buttons & (GUI.GuiDialogButtons.Ok | GUI.GuiDialogButtons.Ignore | GUI.GuiDialogButtons.Maybe | GUI.GuiDialogButtons.Save | GUI.GuiDialogButtons.Yes)) != 0)
            {
                return(GUI.GuiDialog.DialogIconInfo);       // Je pouze jeden button, a pokud je to Ok, Ignore, Maybe, Save nebo Yes, tak vracím ikonu (i)
            }
            return(GUI.GuiDialog.DialogIconError);
        }
コード例 #8
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);
        }
コード例 #9
0
 /// <summary>
 /// Zobrazí dialog a vrátí volbu uživatele
 /// </summary>
 /// <param name="owner"></param>
 /// <param name="message"></param>
 /// <param name="title"></param>
 /// <param name="buttons"></param>
 /// <param name="icon"></param>
 /// <returns></returns>
 public static GUI.GuiDialogButtons ShowDialog(WinForms.Form owner, string message, string title, GUI.GuiDialogButtons buttons = GUI.GuiDialogButtons.Ok, GUI.GuiImage icon = null)
 {
     GUI.GuiDialogButtons result = Noris.LCS.Base.WorkScheduler.GuiDialogButtons.None;
     using (WinFormDialog form = new WinFormDialog())
     {
         form.SetBounds(owner, 0.45f, 0.30f);
         form.DialogMessage = message;
         form.DialogTitle   = (!String.IsNullOrEmpty(title) ? title : GetDefaultTitleForButtons(buttons));
         if (icon == null || icon.IsEmpty)
         {
             icon = GetDefaultIconForButtons(buttons);
         }
         form.DialogIcon = Application.App.ResourcesApp.GetImage(icon);
         form.Buttons    = buttons;
         form.ShowDialog(owner);
         result = form.GuiResult;
     }
     return(result);
 }
コード例 #10
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);
 }
コード例 #11
0
        /// <summary>
        /// Handler události Button.Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _Button_Click(object sender, EventArgs e)
        {
            WinButtonBase button = sender as WinButtonBase;

            if (button == null)
            {
                return;
            }
            if (!(button.Tag is GUI.GuiDialogButtons))
            {
                return;
            }

            GUI.GuiDialogButtons result = (GUI.GuiDialogButtons)button.Tag;
            this._CallButtonClick(result);

            if (this.CloseOnClick)
            {
                this._GuiResult = result;
                this.Close();
            }
        }
コード例 #12
0
 /// <summary>
 /// Metoda vrátí počet buttonů, které daná proměnná deklaruje
 /// </summary>
 /// <param name="buttons"></param>
 /// <returns></returns>
 protected static int GetButtonsCount(GUI.GuiDialogButtons buttons)
 {
     return(((int)(buttons & Noris.LCS.Base.WorkScheduler.GuiDialogButtons.All)).GetBitsOneCount());
 }