コード例 #1
0
        public static int ShowDialog(IWin32Window owner, string[] options, string question, string title)
        {
            EnumOptionDialoge dlg = new EnumOptionDialoge();

            dlg.Options  = options;
            dlg.Question = question;
            dlg.Text     = title;
            DialogResult dr = dlg.ShowDialog(owner);

            if (dr == DialogResult.OK)
            {
                if (options.IsIndexValid(dlg.SelectedIndex))
                {
                    return(dlg.SelectedIndex);
                }
            }

            return(-1);
        }
コード例 #2
0
        public static object ShowDialog(IWin32Window owner, Type type, string question, string title)
        {
            EnumOptionDialoge dlg = new EnumOptionDialoge();

            dlg.Options  = Enum.GetNames(type);
            dlg.Question = question;
            dlg.Text     = title;
            DialogResult dr = dlg.ShowDialog(owner);

            if (dr == DialogResult.OK)
            {
                if (dlg.SelectedOption != null)
                {
                    return(Enum.Parse(type, dlg.SelectedOption));
                }
            }

            return(null);
        }