本文整理汇总了C#中System.EventArgs.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# EventArgs.GetType方法的具体用法?C# EventArgs.GetType怎么用?C# EventArgs.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.EventArgs
的用法示例。
在下文中一共展示了EventArgs.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ObserverNotified
/// <summary>
/// NotifyObserver has been done. Time to update the logapplication/device/resource.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ObserverNotified(object sender, EventArgs e)
{
//Message.Text += e.Message;
#region gettype
Type type = e.GetType();
if (type.UnderlyingSystemType.Name.Equals("NotificationEventArgs"))
{
var notification = (LoggingBase.NotificationEventArgs)e;
Trace.Write("ObserverNotified", notification.Message);
Queue<string> messageQ = Session["ObserverNotified"] as Queue<string>;
if (messageQ != null) messageQ.Enqueue(notification.Message);
Session["ObserverNotified"] = messageQ;
Message.Text = notification.Message;
}
Type senderType = sender.GetType();
if (senderType.UnderlyingSystemType.Name.Equals("Timer"))
{
var timer = (System.Web.UI.Timer)sender;
Message2.Text += DateTime.Now.ToShortTimeString() + "\tFrom " + timer.ToString() + "\n";
}
#endregion
}
示例2: MyEvent
public void MyEvent(object sender, EventArgs args)
{
//controlo gerador, o nome do evento gerado, a data/hora em que foi gerado e o argumento associado.
Console.WriteLine("Controlo={0} || evento={1} || data={2} || argumento={3}"
, ((Control)sender).Name, eventName, DateTime.Now, args.GetType().Name);
}
示例3: buttonClear_Click
private void buttonClear_Click(object sender, EventArgs e)
{
if (e.GetType() == typeof(MouseEventArgs))
{
MouseEventArgs me = e as MouseEventArgs;
textOutput.Text = "";
}
}
示例4: Dgv1Click
void Dgv1Click(object sender, EventArgs e)
{
var ctrl = sender as Control;
if (ctrl.Text != string.Empty && "Next|Prev|First|Last|Search".IndexOf(ctrl.Text) > -1
|| e.GetType().Name == "DataGridViewCellMouseEventArgs")
{
LoadDataSource();
}
if (e.GetType().Name == "DataGridViewCellEventArgs")
{
//This event means a row was selected by double-click
const int RECORD_ID_OFFSET = 3;
MessageBox.Show(dgv1.DataRowViewSelected[RECORD_ID_OFFSET].ToString());
}
}
示例5: pictureBox1_Click
//public class textOutput
//{
// public static string Text { get; internal set; }
//}
private void pictureBox1_Click(object sender, EventArgs e)
{
if(e.GetType() == typeof(MouseEventArgs))
{
MouseEventArgs me = e as MouseEventArgs;
textOutput.Text += me.Location.ToString();
}
}
示例6: Application_BeginRequest
protected void Application_BeginRequest(object sender, EventArgs e)
{
if (logger.IsDebugEnabled)
{
NDC.Push("BeginRequest");
logger.DebugFormat("{0} sent {1}", sender, e.GetType());
NDC.Pop();
}
}
示例7: pictureBox1_Click
private void pictureBox1_Click(object sender, EventArgs e)
{
if(e.GetType() == typeof(MouseEventArgs))
{
MouseEventArgs me = e as MouseEventArgs;
Coords co = new Coords(me.Location.ToString());
coords.Add(co);
textOutput.Text += me.Location.ToString() + " ";
}
}
示例8: Write
public void Write(Stream innerStream, EventArgs args)
{
if (innerStream == null) throw new ArgumentNullException("innerStream");
if (args == null) throw new ArgumentNullException("args");
using (var xw = XmlWriter.Create(innerStream, _xmlWriterSettings)) {
new DataContractSerializer(args.GetType())
.WriteObject(xw, args);
}
}
示例9: Serialize
/// <summary>
/// Serializes the specified event argument into a string representation.
/// </summary>
/// <param name="eventArgs">The <see cref="System.EventArgs"/> instance containing the event data.</param>
/// <returns>The string representation of the specified event argument.</returns>
public string Serialize(EventArgs eventArgs)
{
Ensure.ArgumentNotNull(eventArgs, "eventArgs");
using (MemoryStream ms = new MemoryStream())
{
var serializer = new DataContractSerializer(eventArgs.GetType());
serializer.WriteObject(ms, eventArgs);
return Convert.ToBase64String(ms.ToArray());
}
}
示例10: Serialize
/// <summary>
/// Serializes the specified event argument into a string representation.
/// </summary>
/// <param name="eventArgs">The <see cref="System.EventArgs"/> instance containing the event data.</param>
/// <returns>The string representation of the specified event argument.</returns>
public string Serialize(EventArgs eventArgs)
{
Ensure.ArgumentNotNull(eventArgs, "eventArgs");
using (var sw = new StringWriter(CultureInfo.InvariantCulture))
{
var serializer = new XmlSerializer(eventArgs.GetType());
serializer.Serialize(sw, eventArgs);
return sw.ToString();
}
}
示例11: OnEvent
/// <summary>
/// Checks <see cref="CanTrigger" /> before firing the event associated with this EventTrigger.
/// </summary>
protected override void OnEvent(EventArgs eventArgs)
{
var handledProperty = eventArgs.GetType().GetProperty("Handled");
if (handledProperty != null)
{
handledProperty.SetValue(eventArgs, IsHandled, null);
}
if (CanTrigger)
{
base.OnEvent(eventArgs);
}
}
示例12: Log
static void Log(string title, object sender, EventArgs e)
{
Console.WriteLine("Event: {0}", title);
Console.WriteLine(" Sender: {0}", sender);
Console.WriteLine(" Arguments: {0}", e.GetType());
foreach (PropertyDescriptor prop in
TypeDescriptor.GetProperties(e))
{
string name = prop.DisplayName;
object value = prop.GetValue(e);
Console.WriteLine(" {0}={1}", name, value);
}
}
示例13: OnEvent
private void OnEvent(object sender, EventArgs e)
{
bool handled = InvokeCommandOrAction();
if (handled)
{
var handledProp = e.GetType().GetProperty("Handled");
if (handledProp != null && handledProp.CanWrite && !Passthrough)
{
handledProp.SetValue(e, true, null);
}
}
}
示例14: AddEvent
public void AddEvent(Control sender, string eventName, EventArgs args)
{
StringBuilder eventData;
PropertyInfo[] properties;
eventData = new StringBuilder();
eventData.Append(DateTime.Now.ToLongTimeString());
eventData.Append("\t");
eventData.Append(sender.Name);
eventData.Append(".");
eventData.Append(eventName);
eventData.Append(" (");
properties = args.GetType().GetProperties();
for (int i = 0; i < properties.Length; i++)
{
PropertyInfo property;
string value;
property = properties[i];
try
{
object rawValue;
rawValue = property.GetValue(args, null);
value = rawValue != null ? rawValue.ToString() : null;
}
catch
{
value = null;
}
eventData.AppendFormat("{0} = {1}", property.Name, value);
if (i < properties.Length - 1)
{
eventData.Append(", ");
}
}
eventData.Append(")");
this.Items.Add(eventData.ToString());
this.TopIndex = this.Items.Count - (this.ClientSize.Height / this.ItemHeight);
}
示例15: form1_Click
private void form1_Click(object sender, EventArgs e)
{
MouseEventArgs args;
if(e.GetType() != typeof(MouseEventArgs))
{
return;
}
args = (MouseEventArgs)e;
foreach (TestLineBasedVertice v in Vertices)
{
if (v.TestMousePos(args.X, args.Y)) v.OnClick();
}
Refresh();
}