本文整理汇总了C#中System.Windows.Forms.Button.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Button.GetType方法的具体用法?C# Button.GetType怎么用?C# Button.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Button
的用法示例。
在下文中一共展示了Button.GetType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AssignButtonEvent
public static Button AssignButtonEvent(Button b, System.EventHandler e)
{
FieldInfo f1 = typeof(Control).GetField("EventClick", 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]);
b.Click += e;
return b;
}
示例2: RemoveClickEvent
private void RemoveClickEvent(Button b)
{
FieldInfo f1 = typeof(Control).GetField("EventClick", 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]);
}
示例3: CorretEventsForButton
/// <summary>
/// Patches the events for a specific button.
/// </summary>
/// <param name="btn"></param>
private static void CorretEventsForButton(Button btn)
{
Delegate[] EventDelegates = null;
if (EventsPatched.ContainsKey(btn))
throw new InvalidOperationException("Events for this button has been previously patched: '" + btn.Name + "'");
EventsPatched.Add(btn, new Dictionary<string, List<Delegate>>());
foreach (string eventName in EventsToCorrect.Keys)
{
EventInfo eInfo = btn.GetType().GetEvent(eventName);
if (eInfo == null)
throw new InvalidOperationException("Event info for event '" + eventName + "' could not be found");
EventsPatched[btn].Add(eventName, new List<Delegate>());
EventDelegates = ContainerHelper.GetEventSubscribers(btn, eventName);
if (EventDelegates != null)
{
foreach (Delegate del in EventDelegates)
{
EventsPatched[btn][eventName].Add(del);
eInfo.RemoveEventHandler(btn, del);
}
}
eInfo.AddEventHandler(btn, EventsToCorrect[eventName]);
}
}
示例4: setVarBoxesInPanel
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;
//.........这里部分代码省略.........
示例5: en_de_crypt
private static void en_de_crypt(en_de_cryption_mode en_de_cryption_mode_current,
string file_path_from,
string file_path_to,
bool delete_file_path_from,
bool interactive)
{
Form form = new Form();
Label password_1_label = new Label(),
password_2_label = new Label();
int label_width = 150,
label_height = 20,
textbox_width = 200,
textbox_height = 20,
button_width = 80,
button_height = 40;
Color label_forecolor = Color.LightGreen,
password_backcolor = Color.Black,
password_forecolor = Color.LightGreen,
proceed_backcolor = Color.Black,
proceed_forecolor = Color.LightGreen,
cancel_backcolor = Color.Black,
cancel_forecolor = Color.LightGreen,
error_forecolor = Color.Red;
ContentAlignment label_text_alignment = ContentAlignment.MiddleRight,
button_text_alignment = ContentAlignment.MiddleCenter;
TextBox password_1 = new TextBox(),
password_2 = new TextBox();
char password_character = '*';
BorderStyle password_border_style = BorderStyle.Fixed3D;
Font label_font = new Font(FontFamily.GenericMonospace, (float)10.0),
password_font = new Font(FontFamily.GenericMonospace, (float)10.0),
button_font = new Font(FontFamily.GenericMonospace, (float)10.0);
Button proceed = new Button(),
cancel = new Button();
form.StartPosition = FormStartPosition.CenterParent;
form.Width = 400;
form.Height = 180;
form.BackColor = Color.Black;
form.Text = "Please, provide the password for the " +
(en_de_cryption_mode_current == en_de_cryption_mode.encrypt ?
"encryption" : "decryption") +
".";
password_1_label.Bounds = new Rectangle(10, 20, label_width, label_height);
password_1_label.Font = label_font;
password_1_label.ForeColor = label_forecolor;
password_1_label.TextAlign = label_text_alignment;
password_1_label.Text = "Password:";
password_2_label.Bounds = new Rectangle(10, 50, label_width, label_height);
password_2_label.Font = label_font;
password_2_label.ForeColor = label_forecolor;
password_2_label.TextAlign = label_text_alignment;
password_2_label.Text = "Confirm password:";
password_1.Bounds = new Rectangle(160, 20, textbox_width, textbox_height);
password_1.BackColor = password_backcolor;
password_1.ForeColor = password_forecolor;
password_1.BorderStyle = password_border_style;
password_1.PasswordChar = password_character;
password_1.Font = password_font;
password_1.Multiline = false;
password_1.KeyUp += (sender, e) =>
{
if ((Keys)e.KeyValue == Keys.Escape)
cancel.GetType()
.GetMethod("OnClick",
BindingFlags.Instance |
BindingFlags.NonPublic)
.Invoke(cancel, new object[] { null });
if (en_de_cryption_mode_current == en_de_cryption_mode.encrypt) {
if (!string.IsNullOrEmpty(password_1.Text)) {
password_2.Enabled = true;
} else {
proceed.Enabled = false;
password_2.Text = "";
if (password_2.Enabled)
password_2.Enabled = false;
}
} else {
if (!string.IsNullOrEmpty(password_1.Text))
proceed.Enabled = true;
else
proceed.Enabled = false;
}
if ((Keys)e.KeyValue == Keys.Enter &&
!string.IsNullOrEmpty(password_1.Text)) {
if (en_de_cryption_mode_current == en_de_cryption_mode.encrypt)
//.........这里部分代码省略.........