/// <summary>
        /// 事件响应
        /// </summary>
        public static DelegateHandler <TEvent> On <TEvent>(this FrameworkElement uiElement, string description, LogEnum logType, Action <TEvent> action)
            where TEvent : IEvent
        {
            if (uiElement.Resources == null)
            {
                uiElement.Resources = new ResourceDictionary();
            }
            List <IDelegateHandler> contextHandlers = (List <IDelegateHandler>)uiElement.Resources["ntminer_contextHandlers"];

            if (contextHandlers == null)
            {
                contextHandlers = new List <IDelegateHandler>();
                uiElement.Resources.Add("ntminer_contextHandlers", contextHandlers);
                uiElement.Unloaded += UiElement_Unloaded;
            }
            return(VirtualRoot.Path(description, logType, action).AddToCollection(contextHandlers));
        }
Exemple #2
0
        /// <summary>
        /// 事件响应
        /// </summary>
        public static void On <TEvent>(this Window window, string description, LogEnum logType, Action <TEvent> action)
            where TEvent : IEvent
        {
            if (Design.IsInDesignMode)
            {
                return;
            }
            if (window.Resources == null)
            {
                window.Resources = new ResourceDictionary();
            }
            List <IDelegateHandler> contextHandlers = (List <IDelegateHandler>)window.Resources["ntminer_contextHandlers"];

            if (contextHandlers == null)
            {
                contextHandlers = new List <IDelegateHandler>();
                window.Resources.Add("ntminer_contextHandlers", contextHandlers);
                window.Closed += UiElement_Closed;;
            }
            VirtualRoot.Path(description, logType, action).AddToCollection(contextHandlers);
        }
Exemple #3
0
 /// <summary>
 /// 事件响应
 /// </summary>
 private static DelegateHandler <TEvent> On <TEvent>(string description, LogEnum logType, Action <TEvent> action)
     where TEvent : IEvent
 {
     return(VirtualRoot.Path(description, logType, action).AddToCollection(_contextHandlers));
 }
Exemple #4
0
 /// <summary>
 /// 命令窗口。使用该方法的代码行应将前两个参数放在第一行以方便vs查找引用时展示出参数信息
 /// </summary>
 private static DelegateHandler <TCmd> Window <TCmd>(string description, LogEnum logType, Action <TCmd> action)
     where TCmd : ICmd
 {
     return(VirtualRoot.Path(description, logType, action).AddToCollection(_contextHandlers));
 }