Exemple #1
0
        public static void RemoveKeyPressEvent(System.Windows.Forms.TextBox b)
        {
            FieldInfo f1 = typeof(Control).GetField("KeyPress",
                                                    BindingFlags.Static | BindingFlags.NonPublic);
            object       obj = f1.GetValue(b);
            PropertyInfo pi  = b.GetType().GetProperty("Events",
                                                       BindingFlags.NonPublic | BindingFlags.Instance);
            EventHandlerList list = (EventHandlerList)pi.GetValue(b, null);

            list.RemoveHandler(obj, list[obj]);
        }
Exemple #2
0
 /// <summary>
 /// object creator
 /// </summary>
 public NumericUpDownEx()
     : base()
 {
     // get a reference to the underlying UpDownButtons field
     // Underlying private type is System.Windows.Forms.UpDownBase+UpDownButtons
     _upDownButtons = base.Controls[0];
     if (_upDownButtons == null || _upDownButtons.GetType().FullName != "System.Windows.Forms.UpDownBase+UpDownButtons") {
         throw new ArgumentNullException(this.GetType().FullName + ": Can't find internal UpDown buttons field.");
     }
     // Get a reference to the underlying TextBox field.
     // Underlying private type is System.Windows.Forms.UpDownBase+UpDownButtons
     _textbox = base.Controls[1] as TextBox;
     if (_textbox == null || _textbox.GetType().FullName != "System.Windows.Forms.UpDownBase+UpDownEdit") {
         throw new ArgumentNullException(this.GetType().FullName + ": Can't find internal TextBox field.");
     }
     // add handlers (MouseEnter and MouseLeave events of NumericUpDown
     // are not working properly)
     _textbox.MouseEnter += _mouseEnterLeave;
     _textbox.MouseLeave += _mouseEnterLeave;
     _upDownButtons.MouseEnter += _mouseEnterLeave;
     _upDownButtons.MouseLeave += _mouseEnterLeave;
     base.MouseEnter += _mouseEnterLeave;
     base.MouseLeave += _mouseEnterLeave;
 }
        /// <summary>
        /// Transform the text box to be identical to <paramref name="source"/>.
        /// </summary>
        /// <param name="source">The text box to transform into</param>
        /// <param name="hideSource">Hide the source text box after the transformation is complete</param>
        public void Transform(TextBox source, bool hideSource)
        {
            Type type = source.GetType();
            IEnumerator properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(p => p.CanRead && p.CanWrite && !p.Name.Equals("WindowTarget")).GetEnumerator();
            while (properties.MoveNext())
            {
                PropertyInfo property = properties.Current as PropertyInfo;
                object value = property.GetValue(source, null);
                property.SetValue(this, value, null);
            }

            source.Visible = !hideSource;
            this.previousText = this.Text;
        }
Exemple #4
0
        public void setVarBoxesInPanel()
        {
            panelVariableControls.Controls.Clear();
            int locationX = dataViewer.RowHeadersWidth;
            int colNum = 0;
            int j = 0; ;
            for (int i = 1; i < dataViewer.Columns.Count; i++)
            {
                j++;
                int defaultWidth = dataViewer.Columns[colNum].Width;
                int defaultHeight = 21;
                int currentYLoc = 0;
                //Main comboBox
                string comboboxName = i + "ComboMain";
                ComboBox newCombo = new ComboBox();
                newCombo.Name = comboboxName;
                newCombo.Width = defaultWidth;
                newCombo.Height = defaultHeight;
                newCombo.Location = new Point(locationX, currentYLoc);
                currentYLoc += defaultHeight;
                newCombo.Items.Add("Variable");
                newCombo.Items.Add("DateTime");
                newCombo.Items.Add("Date");
                newCombo.Items.Add("Time");
                panelVariableControls.Controls.Add(newCombo);
                EventInfo comboMainChanged = newCombo.GetType().GetEvent("TextChanged");
                comboMainChanged.AddEventHandler(newCombo, new EventHandler(this.comboMainChanged));
                comboBoxes.Add(newCombo);

                //Secondary comboBox (Variable Name/DateTime format)
                comboboxName = i + "Combo2";
                ComboBox newCombo2 = new ComboBox();
                newCombo2.Name = comboboxName;
                newCombo2.Width = defaultWidth;
                newCombo2.Height = defaultHeight;
                newCombo2.Enabled = false;
                newCombo2.Location = new Point(locationX, currentYLoc);
                currentYLoc += defaultHeight;
                panelVariableControls.Controls.Add(newCombo2);
                EventInfo combo2Changed = newCombo2.GetType().GetEvent("TextChanged");
                combo2Changed.AddEventHandler(newCombo2, new EventHandler(this.combo2Changed));
                newCombo2.AutoCompleteMode = AutoCompleteMode.Append;
                newCombo2.AutoCompleteSource = AutoCompleteSource.ListItems;

                //3rd comboBox (Units)
                comboboxName = i + "Combo3";
                ComboBox newCombo3 = new ComboBox();
                newCombo3.Name = comboboxName;
                newCombo3.Width = defaultWidth;
                newCombo3.Height = defaultHeight;
                newCombo3.Enabled = false;
                newCombo3.Location = new Point(locationX, currentYLoc);
                currentYLoc += defaultHeight;
                panelVariableControls.Controls.Add(newCombo3);
                EventInfo combo3Changed = newCombo3.GetType().GetEvent("TextChanged");
                combo3Changed.AddEventHandler(newCombo3, new EventHandler(this.combo3Changed));

                //4th comboBox (Sensor Location Type)
                comboboxName = i + "Combo4";
                ComboBox newCombo4 = new ComboBox();
                newCombo4.Name = comboboxName;
                newCombo4.Width = defaultWidth;
                newCombo4.Height = defaultHeight;
                newCombo4.Enabled = false;
                newCombo4.Location = new Point(locationX, currentYLoc);
                newCombo4.Items.Add("d - Depth below surface");
                newCombo4.Items.Add("h - Height above surface");
                newCombo4.Items.Add("e - Elevation from bottom");
                newCombo4.Items.Add("m - Masl");
                newCombo4.Items.Add("i - Integrated depth range");
                newCombo4.Items.Add("v - Variable depth");
                newCombo4.Items.Add("n - Position NA");
                newCombo4.AutoCompleteMode = AutoCompleteMode.Append;
                newCombo4.AutoCompleteSource = AutoCompleteSource.ListItems;

                currentYLoc += defaultHeight;
                panelVariableControls.Controls.Add(newCombo4);
                EventInfo combo4Changed = newCombo4.GetType().GetEvent("TextChanged");
                combo4Changed.AddEventHandler(newCombo4, new EventHandler(this.combo4Changed));

                //TextBox (Sensor Displacement 1)
                comboboxName = i + "Text1";
                TextBox newCombo5 = new TextBox();
                newCombo5.Name = comboboxName;
                newCombo5.Width = defaultWidth;
                newCombo5.Height = defaultHeight;
                newCombo5.Enabled = false;
                newCombo5.Location = new Point(locationX, currentYLoc);
                currentYLoc += defaultHeight;
                panelVariableControls.Controls.Add(newCombo5);
                EventInfo Text1Changed = newCombo5.GetType().GetEvent("TextChanged");
                Text1Changed.AddEventHandler(newCombo5, new EventHandler(this.Text1Changed));
                newCombo5.KeyDown += new KeyEventHandler(Text1_KeyDown);

                //Button (Accept new Header)
                comboboxName = i + "Btn";
                Button newButton = new Button();
                newButton.Name = comboboxName;
                newButton.Width = defaultWidth;
                newButton.Height = defaultHeight;
                newButton.Enabled = false;
                newButton.Location = new Point(locationX, currentYLoc);
                currentYLoc += defaultHeight;
                panelVariableControls.Controls.Add(newButton);
                EventInfo useNewHeaderClicked = newButton.GetType().GetEvent("Click");
                useNewHeaderClicked.AddEventHandler(newButton, new EventHandler(this.useNewHeaderClicked));
                EventInfo hoverNewHeaderButton = newButton.GetType().GetEvent("MouseHover");
                hoverNewHeaderButton.AddEventHandler(newButton, new EventHandler(this.hoverNewHeaderButton));

                locationX += defaultWidth;
                colNum++;
            }
        }
Exemple #5
0
 static string GetTextBoxState(TextBox textbox)
 {
     return textbox.GetType().ToString() + ":" + StringUtil.EscapeString(textbox.Text, ":;,");
 }