示例#1
0
        /// <summary>
        /// 在对话框中显示提示,等待用户输入文本或单击按钮,然后返回包含文本框内容的字符串。
        /// </summary>
        /// <param name="Prompt">String类型的变量或表达式,作为消息显示在对话框中</param>
        /// <param name="Caption">String类型的变量或表达式,作为对话框的标题</param>
        /// <param name="DefaultValue">String类型的变量或表达式,作为文本框的默认值</param>
        /// <returns>返回值为字符串</returns>
        public static string InputBox(string Prompt, string Caption, string DefaultValue)
        {
            if (Prompt.Length > PromptLengthMAX)
            {
                InputBoxParameterException iex = new InputBoxParameterException("参数错误。参数Prompt的长度不可超过" + PromptLengthMAX + "个字符");
                throw iex;
            }
            if (Caption.Length > CaptionLengthMAX)
            {
                InputBoxParameterException iex = new InputBoxParameterException("参数错误。参数Caption的长度不可超过" + CaptionLengthMAX + "个字符");
                throw iex;
            }
            if (DefaultValue.Length > DefaultValueLengthMAX)
            {
                InputBoxParameterException iex = new InputBoxParameterException("参数错误。参数DefaultValue的长度不可超过" + DefaultValueLengthMAX + "个字符");
                throw iex;
            }
            string Value;
            Input  fi = Input.fi;

            fi.Caption.Text  = Prompt;
            fi.Text          = Caption;
            fi.Value         = DefaultValue;
            fi.txtValue.Text = fi.Value;

            fi.Height = Math.Max(240, fi.Caption.Height + 100);
            fi.ShowDialog();
            Value = fi.Value;
            if (AutoInitialization)
            {
                Initialization();
            }
            return(Value);
        }
示例#2
0
        /// <summary>
        /// 在对话框中显示提示,等待用户输入文本或单击按钮,然后返回包含文本框内容的字符串。
        /// </summary>
        /// <param name="Prompt">String类型的变量或表达式,作为消息显示在对话框中</param>
        /// <returns>返回值为字符串</returns>
        public static string InputBox(string Prompt)
        {
            if (Prompt.Length > PromptLengthMAX)
            {
                InputBoxParameterException iex = new InputBoxParameterException("参数错误。参数Prompt的长度不可超过" + PromptLengthMAX + "个字符");
                throw iex;
            }
            string Value;
            Input  fi = Input.fi;

            fi.Caption.Text = Prompt;
            string name = Application.ExecutablePath.Replace("/", "\\");

            while (name.IndexOf("\\") > 0)
            {
                name = name.Substring(name.IndexOf("\\") + 1);
            }
            fi.Text          = name; //Caption;
            fi.Value         = "";   // DefaultValue;
            fi.txtValue.Text = fi.Value;

            fi.Height = Math.Max(240, fi.Caption.Height + 100);
            fi.ShowDialog();
            Value = fi.Value;
            if (AutoInitialization)
            {
                Initialization();
            }
            return(Value);
        }
示例#3
0
        /// <summary>
        /// 在对话框中显示提示,等待用户输入文本或单击按钮,然后返回包含文本框内容的字符串。
        /// </summary>
        /// <param name="Prompt">String类型的变量或表达式,作为消息显示在对话框中</param>
        /// <param name="Caption">String类型的变量或表达式,作为对话框的标题</param>
        /// <param name="DefaultValue">String类型的变量或表达式,作为文本框的默认值</param>
        /// <param name="CancelButtonEnabled">指示取消按钮是否可用</param>
        /// <param name="ButtonLanguage">指示按钮所使用的语言</param>
        /// <returns>返回值为字符串</returns>
        public static string InputBox(string Prompt, string Caption, string DefaultValue, CancelButtonEnabled CancelButtonEnabled, ButtonLanguage ButtonLanguage)
        {
            if (Prompt.Length > PromptLengthMAX)
            {
                InputBoxParameterException iex = new InputBoxParameterException("参数错误。参数Prompt的长度不可超过" + PromptLengthMAX + "个字符");
                throw iex;
            }
            if (Caption.Length > CaptionLengthMAX)
            {
                InputBoxParameterException iex = new InputBoxParameterException("参数错误。参数Caption的长度不可超过" + CaptionLengthMAX + "个字符");
                throw iex;
            }
            if (DefaultValue.Length > DefaultValueLengthMAX)
            {
                InputBoxParameterException iex = new InputBoxParameterException("参数错误。参数DefaultValue的长度不可超过" + DefaultValueLengthMAX + "个字符");
                throw iex;
            }
            string Value;
            Input  fi = Input.fi;

            fi.Caption.Text  = Prompt;
            fi.Text          = Caption;
            fi.Value         = DefaultValue;
            fi.txtValue.Text = fi.Value;
            if (CancelButtonEnabled == CancelButtonEnabled.Invisible)
            {
                fi.Cancel.Enabled = false;
            }
            if (ButtonLanguage == ButtonLanguage.Chinese)
            {
                fi.OK.Text     = "确定(&O)";
                fi.Cancel.Text = "取消(&C)";
            }
            else if (ButtonLanguage == ButtonLanguage.English)
            {
                fi.OK.Text     = "&OK";
                fi.Cancel.Text = "&Cancel";
            }
            //else if (ButtonLanguage == ButtonLanguage.Japanese)
            //{
            //    fi.OK.Text = "かくてい";
            //    fi.Cancel.Text = "キヤソセル";
            //}
            fi.Height = Math.Max(240, fi.Caption.Height + 100);
            fi.ShowDialog();
            Value = fi.Value;
            if (AutoInitialization)
            {
                Initialization();
            }
            return(Value);
        }
示例#4
0
 /// <summary>
 /// 内部函数。使用内部指令更改窗体容易出错的参数。
 /// </summary>
 /// <param name="Command">窗体参数更改指令</param>
 public static void SetParameter(string Command)
 {
     if (Command.Length > 10 && Command.Substring(0, 7) == "Command")
     {
         try
         {
             if (Command.Substring(7, 3) == "PPM")
             {
                 PromptLengthMAX = Convert.ToInt32(Command.Substring(10));
             }
             else if (Command.Substring(7, 3) == "PCM")
             {
                 CaptionLengthMAX = Convert.ToInt32(Command.Substring(10));
             }
             else if (Command.Substring(7, 3) == "PDM")
             {
                 DefaultValueLengthMAX = Convert.ToInt32(Command.Substring(10));
             }
             else
             {
                 int c = 0;
                 c = 1 / c;
             }
         }
         catch
         {
             InputBoxParameterException iex = new InputBoxParameterException("参数错误。参数Command不符合规则");
             throw iex;
         }
     }
     else
     {
         InputBoxParameterException iex = new InputBoxParameterException("参数错误。参数Command不符合规则");
         throw iex;
     }
 }