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); }
/// <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 }
private void buttonClear_Click(object sender, EventArgs e) { if (e.GetType() == typeof(MouseEventArgs)) { MouseEventArgs me = e as MouseEventArgs; textOutput.Text = ""; } }
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()); } }
//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(); } }
protected void Application_BeginRequest(object sender, EventArgs e) { if (logger.IsDebugEnabled) { NDC.Push("BeginRequest"); logger.DebugFormat("{0} sent {1}", sender, e.GetType()); NDC.Pop(); } }
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() + " "; } }
private void OnNavBarVisibilityChanged(object sender, System.EventArgs e) { var occludedHeightProp = e.GetType().GetProperties().SingleOrDefault(p => p.Name == "OccludedHeight"); if (occludedHeightProp != null) { var occludedHeight = (double)occludedHeightProp.GetValue(e); UpdateMargin(occludedHeight); } }
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); } }
/// <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()); } }
/// <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(); } }
/// <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); } }
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); } }
/* * Alternate between the Modes and Settings pages */ private void CurrentPageChanged(object sender, System.EventArgs e) { Debug.WriteLine(e.GetType().ToString()); var tabPage = this.FindByName <BaseCarouselPage>("BaseCarouselPage"); if (tabPage.Title == "Modes") { tabPage.Title = "Settings"; } else if (tabPage.Title == "Settings") { tabPage.Title = "Modes"; } }
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); } } }
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); }
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(); }
/// <summary> /// On Publish End event to clear the caching from the framework /// </summary> /// <param name="sender"></param> /// <param name="args"></param> public void OnPublishEnd(object sender, EventArgs args) { //item saved is called when an item is published (because the item is being saved in the web database) //when this happens, we don't want our code to move the item anywhere, so escape out of this function. if ((global::Sitecore.Context.Job != null && !global::Sitecore.Context.Job.Category.Equals("publish", StringComparison.OrdinalIgnoreCase))) { return; } // complete site list for publish System.Xml.XmlNodeList siteList = null; // setup default for publish remote string eventName = "publish:end:remote"; // what action was undertaken if (!args.GetType().ToString().Equals("Sitecore.Data.Events.PublishEndRemoteEventArgs")) { eventName = ((global::Sitecore.Events.SitecoreEventArgs)args).EventName; } else { // publish end remote event args global::Sitecore.Data.Events.PublishEndRemoteEventArgs pargs = (global::Sitecore.Data.Events.PublishEndRemoteEventArgs)args; } // get the sitelist siteList = global::Sitecore.Configuration.Factory.GetConfigNodes(string.Format("/sitecore/events/event[@name='{0}']/handler[@type='Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel']/sites/site", eventName)); // make sure we hav a site list to clean up if (siteList != null) { // cycle through the site lists foreach (System.Xml.XmlNode xNode in siteList) { global::Sitecore.Sites.SiteContext site = global::Sitecore.Configuration.Factory.GetSite(xNode.InnerText); if (site != null) { // clear the caching util Cache.ClearSitecoreCache(site.Name, site.Database.Name); } } } }
/// <summary> /// 分发事件 /// </summary> /// <param name="topic">事件主题</param> /// <param name="e">参数</param> public void DispachEvent(string topic, EventArgs e) { Dictionary<MethodInfo, List<object>> eventList = subscribers[topic]; foreach (MethodInfo method in eventList.Keys) { foreach (object receiver in eventList[method]) { try { InvokeMehtod(receiver, method, e); logger.Debug("已经将事件参数 [" + e.GetType().Name + "] 提交 [" + receiver.GetType().Name + "] 类的 [" + method.Name + "] 方法"); } catch (Exception ex) { logger.Warn("分发事件时发生错误", ex); } } } }
protected override void OnClick(EventArgs e) { base.OnClick(e); if (null != Grid && e.GetType().Equals(typeof(MouseEventArgs))) { MouseEventArgs me = (MouseEventArgs)e; int x = me.X / CELL_WIDTH, y = me.Y / CELL_WIDTH; /* * change the state of the cell (x,y) */ if (_grid[x, y].IsAlive) { _grid[x, y].IsAlive = false; } else { _grid[x, y].IsAlive = true; } _grid[x, y].OnChangeWrapper(); } }
private void pictureBox1_Click(object sender, EventArgs e) { if (e.GetType() == typeof(MouseEventArgs)) { string coordinates; MouseEventArgs me = e as MouseEventArgs; //textOutput.Text += me.Location.ToString(); coordinates = me.Location.ToString(); Coord mouse = new Coord(coordinates); List<Coord> mice = new List<Coord>(); mice.Add(mouse); foreach (Coord m in mice) { textOutput.Text += m.mouseCo; } } }
void ListViewClicked_tp2Lv(object sender, EventArgs e) { //This event means a row was selected by double-click if (e.GetType().Name == "DataGridViewCellEventArgs") { _tp2Lv.Visible = false; _tp2Dv = new ucDetailView(); _tp2Dv.DetailClicked += DetailClicked_tp2Dv; _tp2Dv.Dock = System.Windows.Forms.DockStyle.Fill; //Comment out DynamicStuff method in user control //to see Main design view, if needed. //Todo: Wire actual id to detail view //Use _tp2Lv.DataRowViewSelected to get selected row info DataPayload d = new DataPayload(); d = DAL.GetRecord("Customers", "CustomerID", "ALFKI"); _tp2Dv.DataPayload = d; tabPage2.Controls.Add(_tp2Dv); } }
private void DynamicUIEventHandler(object sender, EventArgs e) { if (sender != null && e != null) { Type senderType = sender.GetType(); Type eventArgsType = e.GetType(); string eventName = string.Empty; string elementName = string.Empty; string elementType = senderType.ToString(); PropertyInfo elementNamePI = senderType.GetProperty("Name"); if (elementNamePI != null && elementNamePI.CanRead) { elementName = (string)elementNamePI.GetValue(sender); } PropertyInfo routedEventPI = eventArgsType.GetProperty("RoutedEvent"); if (routedEventPI != null && routedEventPI.CanRead) { var routedEvent = routedEventPI.GetValue(e); Type routedEventType = routedEvent.GetType(); PropertyInfo routedEventNamePI = routedEventType.GetProperty("Name"); if (routedEventNamePI != null && routedEventNamePI.CanRead) { eventName = (string)routedEventNamePI.GetValue(routedEvent); } } Instance.InsertUIEvent(Instance.ApplicationId.ToString(), Instance.SessionId.ToString(), "testUserId", eventName, elementType, elementName); } }
private void NotifyIcon_Click(object sender, EventArgs e) { if (e.GetType() == typeof(MouseEventArgs)) { MouseEventArgs mouseEvent = e as MouseEventArgs; if (mouseEvent.Button == MouseButtons.Left) { //左クリック if (targetWindow != null) { targetWindow.Show(); targetWindow.WindowState = LastViewState; targetWindow.Activate(); } } } }
private void graphTypeControlArray_Click(object sender, System.EventArgs e) { Debug.WriteLine(e.GetType()); Debug.WriteLine(sender.GetType()); drawarea.Invalidate(); }
public override void Application_Start(object sender, EventArgs e) { base.Application_Start(sender, e); //execute the initializer method. ApplicationInitialization.Execute(); #region mono #if MONO Kooboo.HealthMonitoring.Log.Logger = (exception) => { string msgFormat = @" Event message: {0} Event time: {1} Event time {2} Exception information: Exception type: {3} Exception message: {0} Request information: Request URL: {4} User host address: {5} User: {6} Is authenticated: {7} Thread information: Thread ID: {8} Stack trace: {9} "; string[] args = new string[13]; args[0] = exception.Message; args[1] = DateTime.Now.ToString(System.Globalization.CultureInfo.InstalledUICulture); args[2] = DateTime.UtcNow.ToString(System.Globalization.CultureInfo.InstalledUICulture); args[3] = e.GetType().ToString(); if (System.Web.HttpContext.Current != null) { var request = HttpContext.Current.Request; args[4] = request.RawUrl; args[5] = request.UserHostAddress; args[6] = HttpContext.Current.User.Identity.Name; args[7] = HttpContext.Current.User.Identity.IsAuthenticated.ToString(); } args[8] = System.Threading.Thread.CurrentThread.ManagedThreadId.ToString(); args[9] = exception.StackTrace; Kooboo.CMS.Web.HealthMonitoring.TextFileLogger.Log(string.Format(msgFormat, args)); }; #endif #endregion // ControllerBuilder.Current.SetControllerFactory(new Kooboo.CMS.Sites.CMSControllerFactory()); #region MVC Inject DependencyResolver.SetResolver(new Kooboo.CMS.Common.DependencyResolver(EngineContext.Current, DependencyResolver.Current)); #endregion //ViewEngine for module. ViewEngines.Engines.Insert(0, new Kooboo.CMS.Sites.Extension.ModuleArea.ModuleRazorViewEngine()); ViewEngines.Engines.Insert(1, new Kooboo.CMS.Sites.Extension.ModuleArea.ModuleWebFormViewEngine()); ViewEngines.Engines.Insert(2, new CustomRazorViewEngine()); AreaRegistration.RegisterAllAreas(); #region Binders ModelBinders.Binders.DefaultBinder = new JsonModelBinder(); ModelBinders.Binders.Add(typeof(DynamicDictionary), new DynamicDictionaryBinder()); ModelBinders.Binders.Add(typeof(Kooboo.CMS.Sites.DataRule.IDataRule), new Kooboo.CMS.Web.Areas.Sites.ModelBinders.DataRuleBinder()); ModelBinders.Binders.Add(typeof(Kooboo.CMS.Sites.DataRule.DataRuleBase), new Kooboo.CMS.Web.Areas.Sites.ModelBinders.DataRuleBinder()); ModelBinders.Binders.Add(typeof(Kooboo.CMS.Sites.Models.PagePosition), new Kooboo.CMS.Web.Areas.Sites.ModelBinders.PagePositionBinder()); ModelBinders.Binders.Add(typeof(Kooboo.CMS.Sites.Models.Parameter), new Kooboo.CMS.Web.Areas.Sites.ModelBinders.ParameterBinder()); #endregion RegisterRoutes(RouteTable.Routes); Kooboo.CMS.Content.Persistence.Providers.RepositoryProvider.TestDbConnection(); }
void HandleButtonOkhandleClicked(object sender, EventArgs e) { if (!episodeEditor.IsValid()) { iMetaLibrary.Logger.Log("e type: " + e.GetType()); return; } episodeEditor.Save(); // save changes on active episode // save the nfo file... List<iMetaLibrary.Metadata.TvEpisodeMeta> episodes = new List<iMetaLibrary.Metadata.TvEpisodeMeta>(); var enumerator = store.GetEnumerator(); float rating = 0; while(enumerator.MoveNext()) { var episode = ((TvEpisodeNode)enumerator.Current).Meta; episodes.Add(episode); rating += episode.Rating; } this.Meta.Episodes = episodes.ToArray(); this.Meta.Save(); if(episodes.Count > 0) this.Meta.Rating = rating / episodes.Count; this.DefaultResponse = ResponseType.Ok; this.Destroy();
public static void Handler(object sender, System.EventArgs args) { Debug.Log(string.Format("{0} detected: {1}", args.GetType().Name, (sender as TreeViewItem).Header)); }
/// <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) { m_Locker = Session["m_Locker"]; lock (m_Locker) { //Message.Text += e.Message; #region gettype int countNotifications = 0; int countMaxNotifications = 0; HttpSessionState session = null; MySession mySession = null; Queue<string> jobQueue = new Queue<string>(); Type type = e.GetType(); if (type.UnderlyingSystemType.Name.Equals("NotificationEventArgs")) { var notification = (LoggingBase.NotificationEventArgs)e; ///result.Text += notification.Message; Trace.Write("ObserverNotified", notification.Message); session = notification.Session; mySession = GetMySession(notification.Session.SessionID); bool taskQIsEmpty = mySession.TaskQIsEmtpty;// DeadLock => session["TaskQ-Empty"] is bool ? (bool)session["TaskQ-Empty"] : false; ///////////////////////////////////////// /// WAIT UNTIL THERE ARE NO TASKS. while (!taskQIsEmpty) { Monitor.Wait(m_Locker); mySession = GetMySession(mySession.SessionId); taskQIsEmpty = mySession.TaskQIsEmtpty; Monitor.PulseAll(m_Locker); } ///////////////////////////////////////// //session["ObserverNotified"] = m_MessageQ; ERROR if (session != null) { m_MessageQ = session["ObserverNotified"] as Queue<string>; jobQueue = session["TotalJobQueue"] as Queue<string>; countNotifications = session["countNotifications"] is int ? (int)session["countNotifications"] : 0; } Monitor.PulseAll(m_Locker); if (m_MessageQ != null && jobQueue != null) { m_MessageQ.Enqueue(notification.Message); jobQueue.Enqueue(notification.Message); ///Thread.Sleep(10); if (session != null) { session["ObserverNotified"] = m_MessageQ; session["TotalJobQueue"] = jobQueue; } } #region store/restore counters for this session countNotifications++; if (countNotifications == m_MaxValue + 1) { countMaxNotifications = m_MaxValue + 1; if (session != null) session["countMaxNotifications"] = countMaxNotifications; } if (countNotifications == m_MaxValue + 1) { if (session != null) session["countNotifications"] = 0; } else if (session != null) session["countNotifications"] = countNotifications; #endregion if ((countNotifications + 1) % 30 == 0) { UpdateTaskQReadyStatus(mySession, false); Monitor.PulseAll(m_Locker); } } Type senderType = sender.GetType(); if (senderType.UnderlyingSystemType.Name.Equals("Timer")) { var timer = (System.Web.UI.Timer)sender; //result.Text += DateTime.Now.ToShortTimeString() + "\tFrom " + timer.ToString() + "\n"; if (m_MessageQ != null && m_MessageQ.Count > 0) result.Text += m_MessageQ.Dequeue(); } #endregion } }
public void EventHandler(object sender, EventArgs args) { Console.WriteLine("Control: {0}; EventName: {1}; EventDate: {2}; ArgType: {3}", sender.ToString(), Info.Name, DateTime.Now.ToString(), args.GetType().ToString()); }
/// <summary> /// Called when an event is fired. /// </summary> /// <param name="eventTopic">The event topic.</param> /// <param name="publication">The publication.</param> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> public override void FiringEvent(IEventTopicInfo eventTopic, IPublication publication, object sender, EventArgs e) { base.FiringEvent(eventTopic, publication, sender, e); if (this.Equals(sender)) { return; } lock (this.locker) { if (!this.Topics.Contains(eventTopic.Uri)) { return; } } var message = this.MessageFactory.CreateEventFiredMessage(m => { m.Topic = eventTopic.Uri; m.HandlerRestriction = publication.HandlerRestriction; m.EventArgsType = e.GetType().AssemblyQualifiedName; m.EventArgs = this.Serializer.Serialize(e); m.EventBrokerIdentification = this.HostedEventBrokerIdentification.ToString(CultureInfo.InvariantCulture); m.DistributedEventBrokerIdentification = this.DistributedEventBrokerIdentification; }); this.EventBrokerBus.Publish(message); }
private void InnerChannel_Faulted (object sender, EventArgs e) { // System.Runtime.Remoting.Proxies.__TransparentProxy StandardsChannel = sender as System.Runtime.Remoting.Proxies.__TransparentProxy; Basics.ReportErrorToEventViewer ("WCFStandards.InnerChannel_Faulted", "Es trat folgender Fehler auf:\r\n" + "SenderType = " + sender.GetType ().ToString () + "\r\n" + "ExceptionType = " + e.GetType ().ToString () + "\r\n" + e.ToString ()); // System.ServiceModel.Channels.ServiceChannelProxy StandardsClient. (); }
// Invoked when events fire public static void EventTraceNotifier( int eventIndex, EventArgs e ) { if( (e is LogEventArgs) && ((LogEventArgs)e).MessageType == LogType.Trace ) return; var eventInfo = eventsMap[eventIndex]; StringBuilder sb = new StringBuilder(); bool first = true; foreach( var prop in e.GetType().GetProperties() ) { if( !first ) sb.Append( ", " ); if( prop.Name != prop.PropertyType.Name ) { sb.Append( prop.Name ).Append( '=' ); } object val = prop.GetValue( e, null ); if( val == null ) { sb.Append( "null" ); } else if( val is string ) { sb.AppendFormat( "\"{0}\"", val ); } else { sb.Append( val ); } first = false; } Log( LogType.Trace, "TraceEvent: {0}.{1}( {2} )", eventInfo.DeclaringType.Name, eventInfo.Name, sb.ToString() ); }
static void gen_GEvent(object sender, EventArgs t) { Console.WriteLine(t.GetType()); }