Beispiel #1
0
        /// <summary>
        /// 更新UI使用的数据
        /// </summary>
        /// <param name="uiMsg">数据</param>
        public void SendMessage(UIMessageData uiMsg)
        {
            //所有的消息会被派发给子窗口
//            var keys = subWindowsMap.Keys.ToList();
//            for (int i = 0; i < keys.Count; i++)
//            {
//                var k = keys[i];
//                subWindowsMap[k].SendMessage(uiMsg);
//            }

            foreach (var subWin in subWindowsMap.Values)
            {
                subWin.SendMessage(uiMsg);
            }

            //TODO: 执行完Invoke会导致 map的堆栈出问题,
            MethodInfo method = null;
            var        key    = uiMsg.Name.GetHashCode();
            bool       flag   = this.callbackMap.TryGetValue(key, out method);

            if (flag)
            {
                method.Invoke(this, new object[] { uiMsg });
            }
        }
Beispiel #2
0
        /// <summary>
        /// 更新UI使用的数据
        /// </summary>
        /// <param name="messageData">数据</param>
        public void SendMessage(UIMessageData messageData)
        {
            Action <UIMessageData> action = null;
            var key = messageData.Name.GetHashCode();

            callbackMap.TryGetValue(key, out action);
            if (action != null)
            {
                action(messageData);
            }
            //所有的消息会被派发给子窗口
            if (subWindowsMap.Count > 0)
            {
                foreach (var value in subWindowsMap.Values)
                {
                    var uimassage = value as IUIMessage;
                    if (uimassage != null)
                    {
                        uimassage.SendMessage(messageData);
                    }
                }
            }
        }
        /// <summary>
        /// 更新UI使用的数据
        /// </summary>
        /// <param name="uiMsg">数据</param>
        public void SendMessage(UIMessageData uiMsg)
        {
            MethodInfo method = null;
            var        key    = uiMsg.Name.GetHashCode();

            if (callbackMap.TryGetValue(key, out method))
            {
                method.Invoke(this, new object[] { uiMsg });
            }

            //所有的消息会被派发给子窗口
            //TODO: 这里用foreach会出bug,ILR的堆栈过深的原因
            var keys = subWindowsMap.Keys.ToList();

            for (int i = 0; i < keys.Count; i++)
            {
                subWindowsMap[keys[i]].SendMessage(uiMsg);
            }
//            foreach (var subWin in subWindowsMap.Values)
//            {
//                subWin.SendMessage(uiMsg);
//            }
        }
Beispiel #4
0
        /// <summary>
        /// 外部推送ui数据
        /// </summary>
        /// <param name="uiIndex"></param>
        /// <param name="uiMsg"></param>
        public void SendMessage(Enum index, UIMessageData uiMsg)
        {
            var     uiIndex = index.GetHashCode();
            IWindow win;

            if (windowMap.TryGetValue(uiIndex, out win))
            {
                win.SendMessage(uiMsg);
                return;
            }

            //存入缓存
            List <UIMessageData> list = null;

            uiDataCacheMap.TryGetValue(uiIndex, out list);
            //
            if (list == null)
            {
                list = new List <UIMessageData>();
                uiDataCacheMap[uiIndex] = list;
            }

            list.Add(uiMsg);
        }
        /// <summary>
        /// 外部推送ui数据
        /// </summary>
        /// <param name="uiIndex"></param>
        /// <param name="messageData"></param>
        public void SendMessage(Enum index, UIMessageData messageData)
        {
            var uiIndex = index.GetHashCode();

            if (windowMap.ContainsKey(uiIndex))
            {
                var ui = windowMap[uiIndex];
                ui.SendMessage(messageData);
                return;
            }

            //存入缓存
            List <UIMessageData> list = null;

            uiDataCacheMap.TryGetValue(uiIndex, out list);
            //
            if (list == null)
            {
                list = new List <UIMessageData>();
                uiDataCacheMap[uiIndex] = list;
            }

            list.Add(messageData);
        }