コード例 #1
0
        public static int?ShowList(string title, bool multiline, string defaultText, params string[] items)
        {
            List <Resco.Controls.MessageBox.MenuItem> list = new List <Resco.Controls.MessageBox.MenuItem>();

            for (int i = 0; i < items.Length; i++)
            {
                list.Add(new Resco.Controls.MessageBox.MenuItem(items[i], i));
            }
            if (!string.IsNullOrEmpty(defaultText))
            {
                list.Add(new Resco.Controls.MessageBox.MenuItem(defaultText, null));
            }
            return(PopupMenuForm.Show <int?>(MessageBoxIcon.None, multiline, title, null, list.ToArray()));
        }
コード例 #2
0
ファイル: PopupMenuForm.cs プロジェクト: windygu/haina
        public static T Show <T>(MessageBoxIcon icon, bool bMultiLine, string text, T defaultResult, params Resco.Controls.MessageBox.MenuItem[] items)
        {
            T result;

            if (CachedForm == null)
            {
                CachedForm = new PopupMenuForm(defaultResult);
            }
            try
            {
                CachedForm.m_title.SetText(text, bMultiLine);
                CachedForm.m_menu.Items  = items;
                CachedForm.m_icon        = icon;
                CachedForm.m_bFirstPaint = true;
                CachedForm.ShowDialog();
                result = (T)CachedForm.Result;
            }
            catch
            {
                CachedForm.Hide();
                throw;
            }
            return(result);
        }
コード例 #3
0
        public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
        {
            DialogResult result;

            DialogResult[] resultArray;
            MakeButtonCache();
            if (string.IsNullOrEmpty(text))
            {
                text = caption;
            }
            if (text == null)
            {
                text = string.Empty;
            }
            bool bMultiLine = (text.Length > 0x10) || (text.IndexOf('\n') >= 0);

            switch (buttons)
            {
            case MessageBoxButtons.OK:
                resultArray = new DialogResult[] { DialogResult.OK };
                break;

            case MessageBoxButtons.OKCancel:
                resultArray = new DialogResult[] { DialogResult.OK, DialogResult.Cancel };
                break;

            case MessageBoxButtons.AbortRetryIgnore:
                resultArray = new DialogResult[] { DialogResult.Abort, DialogResult.Retry, DialogResult.Ignore };
                break;

            case MessageBoxButtons.YesNoCancel:
                resultArray = new DialogResult[] { DialogResult.Yes, DialogResult.No, DialogResult.Cancel };
                break;

            case MessageBoxButtons.YesNo:
                resultArray = new DialogResult[] { DialogResult.Yes, DialogResult.No };
                break;

            case MessageBoxButtons.RetryCancel:
                resultArray = new DialogResult[] { DialogResult.Retry, DialogResult.Cancel };
                break;

            default:
                throw new ArgumentOutOfRangeException("buttons");
            }
            if (defaultButton == MessageBoxDefaultButton.Button1)
            {
                result = resultArray[0];
            }
            else if ((defaultButton == MessageBoxDefaultButton.Button2) && (resultArray.Length > 1))
            {
                result = resultArray[1];
            }
            else if ((defaultButton == MessageBoxDefaultButton.Button3) && (resultArray.Length > 2))
            {
                result = resultArray[2];
            }
            else
            {
                result = ~DialogResult.None;
            }
            for (int i = 0; i < resultArray.Length; i++)
            {
                DialogResult result2 = resultArray[i];
                string       str;
                DefaultButtonLabels.TryGetValue(result2, out str);
                m_yesNoCancel[i].Set(str, result2);
            }
            Resco.Controls.MessageBox.MenuItem[] items = new Resco.Controls.MessageBox.MenuItem[resultArray.Length];
            for (int j = 0; j < resultArray.Length; j++)
            {
                items[j] = m_yesNoCancel[j];
            }
            return(PopupMenuForm.Show <DialogResult>(icon, bMultiLine, text, result, items));
        }
コード例 #4
0
 public static DialogResult Show(MessageBoxIcon icon, bool bMultiLine, string text, params Resco.Controls.MessageBox.MenuItem[] items)
 {
     return(PopupMenuForm.Show <DialogResult>(icon, bMultiLine, text, DialogResult.Cancel, items));
 }