static Delegate[] GetClosingEventInvocationList(Window target) { Delegate[] PaintEventInvocationList = null; var ParenTWindow = target; if (ParenTWindow == null) { return(PaintEventInvocationList); } string PaintEventKeyName = "EventClosing"; PropertyInfo FormEventProperty; // 窗体事件属性信息 EventHandlerList FormEventPropertyInstance; // 窗体事件属性对象 FieldInfo PaintEventKeyField; // Paint事件对应的键值字段信息 Object PaintEventKeyInstance; // Paint事件对应的键值对象 Delegate PaintEventDelegate; Type FormType = typeof(System.Windows.Controls.Control); Type BaeTypeOfPaintEvent = typeof(System.Windows.Controls.Control); FormEventProperty = FormType.GetProperty("Events", BindingFlags.Instance | BindingFlags.NonPublic); FormEventPropertyInstance = FormEventProperty.GetValue(ParenTWindow, null) as EventHandlerList; PaintEventKeyField = BaeTypeOfPaintEvent.GetField(PaintEventKeyName, BindingFlags.Static | BindingFlags.NonPublic); PaintEventKeyInstance = PaintEventKeyField.GetValue(ParenTWindow); PaintEventDelegate = FormEventPropertyInstance[PaintEventKeyInstance]; if (PaintEventDelegate != null) { PaintEventInvocationList = PaintEventDelegate.GetInvocationList(); } return(PaintEventInvocationList); }
protected Delegate[] GetPaintEventInvocationList() { Delegate[] PaintEventInvocationList = null; Control ParentForm = this.Parent as Control; if (ParentForm == null) { return(PaintEventInvocationList); } string PaintEventKeyName = "EventPaint"; PropertyInfo FormEventProperty; // 窗体事件属性信息 EventHandlerList FormEventPropertyInstance; // 窗体事件属性对象 FieldInfo PaintEventKeyField; // Paint事件对应的键值字段信息 Object PaintEventKeyInstance; // Paint事件对应的键值对象 Delegate PaintEventDelegate; Type FormType = typeof(Control); Type BaeTypeOfPaintEvent = typeof(Control); FormEventProperty = FormType.GetProperty("Events", BindingFlags.Instance | BindingFlags.NonPublic); FormEventPropertyInstance = FormEventProperty.GetValue(ParentForm, null) as EventHandlerList; PaintEventKeyField = BaeTypeOfPaintEvent.GetField(PaintEventKeyName, BindingFlags.Static | BindingFlags.NonPublic); PaintEventKeyInstance = PaintEventKeyField.GetValue(ParentForm); PaintEventDelegate = FormEventPropertyInstance[PaintEventKeyInstance]; if (PaintEventDelegate != null) { PaintEventInvocationList = PaintEventDelegate.GetInvocationList(); } return(PaintEventInvocationList); }