当前位置: 首页>>代码示例>>C#>>正文


C# EventArgs.GetType方法代码示例

本文整理汇总了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
        }
开发者ID:Letractively,项目名称:henoch,代码行数:32,代码来源:Tracer.aspx.cs

示例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);
        }
开发者ID:vilhena,项目名称:PROMPT11-01-VMEssentials.vilhena,代码行数:7,代码来源:Sessao2.cs

示例3: buttonClear_Click

 private void buttonClear_Click(object sender, EventArgs e)
 {
     if (e.GetType() == typeof(MouseEventArgs))
     {
         MouseEventArgs me = e as MouseEventArgs;
         textOutput.Text = "";
     }
 }
开发者ID:guygoudeau,项目名称:Homework,代码行数:8,代码来源:Form1.cs

示例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());
            }
        }
开发者ID:rodchar,项目名称:csgen,代码行数:17,代码来源:Form1.cs

示例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();
     }
 }
开发者ID:DonteWilson,项目名称:Homework,代码行数:12,代码来源:Form1.cs

示例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();
     }
 }
开发者ID:TetsujinOni,项目名称:apphb-logentries-2013,代码行数:9,代码来源:Global.asax.cs

示例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() + " ";
     }
 }
开发者ID:guygoudeau,项目名称:Homework,代码行数:10,代码来源:Form1.cs

示例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);
            }
        }
开发者ID:nbevans,项目名称:EventStreams,代码行数:10,代码来源:XmlEventWriter.cs

示例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());
            }
        }
开发者ID:tiger2soft,项目名称:bbv.Common,代码行数:16,代码来源:DataContractEventArgsSerializer.cs

示例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();
            }
        }
开发者ID:philippdolder,项目名称:appccelerate,代码行数:16,代码来源:XmlEventArgsSerializer.cs

示例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);
     }
 }
开发者ID:soleon,项目名称:Travlexer,代码行数:15,代码来源:EventTrigger.cs

示例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);
     }
 }
开发者ID:gourdon,项目名称:C-,代码行数:13,代码来源:EventLogging.cs

示例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);
                }

            }
        }
开发者ID:ArildF,项目名称:PTB,代码行数:14,代码来源:CommandForEventBehavior.cs

示例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);
    }
开发者ID:huipengly,项目名称:WGestures,代码行数:48,代码来源:EventsListBox.cs

示例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();
        }
开发者ID:uqamgcourtemanche,项目名称:ligne_cliquable,代码行数:18,代码来源:Form1.cs


注:本文中的System.EventArgs.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。