Esempio n. 1
0
        private void ArrangeButtons(TransferConfirmEventArgs evt)
        {
            const int buttonHeight = 24;
            const int buttonWidth  = 128;
            const int gap          = 3;


            int buttons = 0;

            foreach (KeyValuePair <System.Windows.Forms.Button, TransferConfirmNextActions> en in _btns)
            {
                bool b = evt.CanPerform(en.Value);
                en.Key.Visible = b;
                if (b)
                {
                    buttons++;
                }
            }

            int count = this.ClientSize.Width / (buttonWidth + gap);
            int y     = this.ClientSize.Height - (buttonHeight + gap) * ((buttons / count) + ((buttons % count) == 0 ? 0 : 1)) - 4;
            int x     = (this.ClientSize.Width - count * buttonWidth - gap) / 2;

            int i = 0;

            foreach (KeyValuePair <System.Windows.Forms.Button, TransferConfirmNextActions> en in _btns)
            {
                bool b = evt.CanPerform(en.Value);
                en.Key.Visible = b;
                if (b)
                {
                    en.Key.Left = x + (buttonWidth + gap) * (i % count);
                    en.Key.Top  = y + (buttonHeight + gap) * (i / count);
                    i++;
                }
            }
        }
        /// <summary>
        /// Arranges buttons.
        /// </summary>
        /// <param name="evt">The event arguments.</param>
        private void ArrangeButtons(TransferConfirmEventArgs evt)
        {
            int buttonHeight = 0;
            int y            = txtMessage.Top;

            foreach (KeyValuePair <System.Windows.Forms.Button, TransferConfirmNextActions> en in _btns)
            {
                bool b = evt.CanPerform(en.Value);
                en.Key.Visible = b;
                if (buttonHeight == 0)
                {
                    buttonHeight = en.Key.Height;
                }
                if (!b)
                {
                    continue;
                }
                en.Key.Top = y;
                y         += buttonHeight + 3;
            }
        }