private void mtxt_class_begin_time_TextChanged(object sender, EventArgs e)
        {
            MaskedTextBox msender = (MaskedTextBox)sender;

            DealWithColor(msender);
            if (msender.Text.Length == 5 && msender.ForeColor == Color.Black && GetControlCount <Label>() <= 19 && Convert.ToInt32(msender.Tag.ToString()) == GetControlCount <MaskedTextBox>())
            {
                MaskedTextBox newMtxt = new MaskedTextBox
                {
                    Mask      = "90:00",
                    Size      = new Size(68, 34),
                    TextAlign = System.Windows.Forms.HorizontalAlignment.Center,
                    Font      = new Font(new FontFamily("微软雅黑"), (float)12.10084),
                    Tag       = GetControlCount <MaskedTextBox>() + 1
                };
                groupBox1.Controls.Add(newMtxt);
                newMtxt.Location     = GetControlLocation(newMtxt.GetType());
                newMtxt.TextChanged += mtxt_class_begin_time_TextChanged;

                Label newLabel = new Label
                {
                    AutoSize = true,
                    Text     = "第" + (GetControlCount <Label>() - OTHER_LABLE_IN_GRUOP + 1).ToString() + "节课开始时间",
                    Font     = new Font(new FontFamily("微软雅黑"), (float)12.10084)
                };
                groupBox1.Controls.Add(newLabel);
                newLabel.Location = GetControlLocation(newLabel.GetType());

                newMtxt.Focus();
            }
        }
示例#2
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List <string>           props = new List <string>();
            List <GH_ObjectWrapper> vals  = new List <GH_ObjectWrapper>();
            string mask = "";

            DA.GetDataList(0, props);
            DA.GetDataList(1, vals);
            DA.GetData(2, ref mask);

            MaskedTextBox mtb = new MaskedTextBox()
            {
                ID       = Guid.NewGuid().ToString(),
                Provider = new FixedMaskedTextProvider(mask, cultr, false, ascii),
            };

            for (int i = 0; i < props.Count; i++)
            {
                string n = props[i];
                object val;
                try { val = vals[i].Value; }
                catch (ArgumentOutOfRangeException)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "P, V should correspond each other");
                    return;
                }

                try { Util.SetProp(mtb, n, Util.GetGooVal(val)); }
                catch (Exception ex) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, ex.Message); }
            }

            DA.SetData(1, new GH_ObjectWrapper(mtb));

            PropertyInfo[] allprops  = mtb.GetType().GetProperties();
            List <string>  printouts = new List <string>();

            foreach (PropertyInfo prop in allprops)
            {
                if (prop.CanWrite)
                {
                    printouts.Add(prop.Name + ": " + prop.PropertyType.ToString());
                }
            }
            DA.SetDataList(0, printouts);
            DA.SetData(2, @"The mask format can consist of the following characters:
0 - Required digit from 0-9. 
9 - Optional digit or space. 
# - Optional digit, space, or sign (+/-). If blank, then it is output as a space in the Text value. 
L - Required upper or lowercase letter. 
? - Optional upper or lowercase letter. 
& - Required character. If AsciiOnly is true, then behaves like L. 
C - Optional character. If AsciiOnly is true, then behaves like ?. 
A - Required alphanumeric character. If AsciiOnly is true, then behaves like L. 
a - Optional alphanumeric. If AsciiOnly is true, then behaves like ?. 
. - Decimal placeholder based on the specified Culture for the mask. 
, - Thousands placeholder based on the specified Culture for the mask. 
: - Time separator based on the specified Culture for the mask. 
/ - Date separator based on the specified Culture for the mask. 
$ - Currency symbol based on the specified Culture for the mask. 
< - Shift all characters that follow to lower case. 
> - Shift all characters that follow to upper case. 
| - Disables a previous shift to upper or lower case. 
\ - Escape the following character into a literal. 
All other characters are treated as literal and cannot be moved or deleted.
");
        }