Beispiel #1
0
 public static void FillControls(Dictionary <string, string> collection, System.Windows.Forms.Control.ControlCollection controls)
 {
     foreach (Control control in controls.Cast <Control>().Where(y => y.Tag != null).OrderBy(y => y.TabIndex))
     {
         FillControl(collection, control);
     }
 }
Beispiel #2
0
        private void BindUpdatePreview(System.Windows.Forms.Control.ControlCollection controls)
        {
            controls.Cast <Control>().ForEach(x => { if (x.HasChildren)
                                                     {
                                                         BindUpdatePreview(x.Controls);
                                                     }
                                              });

            foreach (Control ctl in controls)
            {
                if (ctl is NumericUpDown)
                {
                    ((NumericUpDown)ctl).ValueChanged += (sender, e) => UpdateUI();
                }
                else if (ctl is TrackBar)
                {
                    ((TrackBar)ctl).ValueChanged += (sender, e) => UpdateUI();
                }
                else if (ctl is TextBox && ctl != txtCommandLinePreview)
                {
                    ((TextBox)ctl).TextChanged += (sender, e) => UpdateUI();
                }
                else if (ctl is ComboBox)
                {
                    ((ComboBox)ctl).SelectedIndexChanged += (sender, e) => UpdateUI();
                }
            }
        }
Beispiel #3
0
        public static Dictionary <string, string> GetAttributesCollection(System.Windows.Forms.Control.ControlCollection controls, bool validate = false)
        {
            Dictionary <string, string> collection = new Dictionary <string, string>();

            foreach (Control control in controls.Cast <Control>().Where(y => y.Tag != null).OrderBy(y => y.TabIndex))
            {
                string attribute;
                bool   required;
                string defaultvalue;
                if (ControlUtils.GetControlDefinition(control, out attribute, out required, out defaultvalue))
                {
                    var value = ControlUtils.GetValueFromControl(control);
                    if (validate && required && string.IsNullOrEmpty(value))
                    {
                        throw new ArgumentNullException(attribute, "Field cannot be empty");
                    }
                    if (required || value != defaultvalue)
                    {
                        collection.Add(attribute, value);
                    }
                }
            }
            return(collection);
        }
Beispiel #4
0
 public static IEnumerable <WinForms.Control> GetRecursive(this WinForms.Control.ControlCollection collection)
 {
     return(collection.Cast <WinForms.Control>().Flatten(c => c.Controls.Cast <WinForms.Control>()));
 }
 public static IEnumerable <System.Windows.Forms.Control> AsEnumerable(this System.Windows.Forms.Control.ControlCollection source)
 {
     TypeCheckEnumerable(source, (s) => s.AsEnumerable(), (s) => s[0]);
     return(source.Cast <System.Windows.Forms.Control>());
 }