コード例 #1
0
        /// <summary>
        /// 执行事件
        /// </summary>
        /// <param name="target"></param>
        /// <param name="text"></param>
        private static void InvokeEvent(IControl target, string text)
        {
            EventDecoder            ed        = new EventDecoder();
            List <DecoderOfControl> listEvent = ed.DecodeEvent(text);

            foreach (DecoderOfControl docObj in listEvent)
            {
                try
                {
                    SetCurrentControlList(target);
                    int ctrlIndex = CurrentControlList.FindIndex
                                        (p => (p as FrameworkElement).Name.Equals(ConfigManagerSection.ControlNamePrefix + docObj.CtrlId.ToString()));
                    if (ctrlIndex == -1 && !docObj.Type.Equals(EventType.SqlType))
                    {
                        return;
                    }
                    else
                    {
                        CallMethodByPropertyName(CurrentControlList[ctrlIndex], docObj);
                    }
                }
                catch
                {
                    MessageBox.Show("执行事件出错--" + text);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 直接执行事件
        /// </summary>
        /// <param name="text"></param>
        /// <param name="ic"></param>
        public static void CallEventDerectly(string text, IControl ic)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }
            SetCurrentControlList(ic);
            EventDecoder            ed        = new EventDecoder();
            List <DecoderOfControl> listEvent = ed.DecodeEvent(text);

            foreach (DecoderOfControl docObj in listEvent)
            {
                SetCurrentControlList(ic);
                ExcuteOneEvent(docObj, ic);
            }
        }