Пример #1
0
        private void LoadPropertyTriggers(XmlNode objNode,
                                          Screen objScr)
        {
            Debug.Assert(null != objNode && null != objScr);
            if (!objNode.HasChildNodes)
            {
                return;
            }

            XmlAttribute targetAttri   = objNode.Attributes[UIServiceCfgDefines.s_TargetAttri];
            XmlAttribute propertyAttri = objNode.Attributes[UIServiceCfgDefines.s_PropertyAttri];
            XmlAttribute valueAttri    = objNode.Attributes[UIServiceCfgDefines.s_ValueAttri];

            if (null == targetAttri ||
                null == propertyAttri ||
                null == valueAttri ||
                string.IsNullOrEmpty(targetAttri.Value) ||
                string.IsNullOrEmpty(propertyAttri.Value) ||
                string.IsNullOrEmpty(valueAttri.Value))
            {
                return;
            }

            PropertyTrigger propTrigger = new PropertyTrigger(objScr,
                                                              targetAttri.Value,
                                                              propertyAttri.Value,
                                                              valueAttri.Value);

            if (!propTrigger.Initialize(objNode))
            {
                propTrigger = null;
                return;
            }
            LoadAllActions(propTrigger, objNode);

            //XmlAttribute bubbleEventAttri = objNode.Attributes[UIServiceCfgDefines.s_bubbleEventAttri];
            //if (null != bubbleEventAttri &&
            //     !string.IsNullOrEmpty(bubbleEventAttri.Value))
            //{
            //    int temp = 0;
            //    if (int.TryParse(bubbleEventAttri.Value, out temp))
            //    {
            //        propTrigger.BubbleEvent = temp == 0 ? false : true;
            //    }
            //}

            if (!propTrigger.Empty)
            {
                objScr.AddTrigger(propTrigger);
            }
            else
            {
                propTrigger = null;
            }
        }
Пример #2
0
        private void LoadEventTrigger(XmlNode objNode,
                                      Screen objScr)
        {
            Debug.Assert(null != objNode && null != objScr);
            if (!objNode.HasChildNodes)
            {
                return;
            }

            XmlAttribute conditionAttri = objNode.Attributes[UIServiceCfgDefines.s_ConditionAttri];

            if (null == conditionAttri ||
                string.IsNullOrEmpty(conditionAttri.Value))
            {
                return;
            }

            try
            {
                EventTrigger trigger = new EventTrigger(objScr, conditionAttri.Value);
                if (!trigger.Initialize(objNode))
                {
                    trigger = null;
                    return;
                }
                //load all actions
                LoadAllActions(trigger, objNode);

                //XmlAttribute bubbleEventAttri = objNode.Attributes[UIServiceCfgDefines.s_bubbleEventAttri];
                //if (null != bubbleEventAttri &&
                //     !string.IsNullOrEmpty(bubbleEventAttri.Value))
                //{
                //    int temp = 0;
                //    if (int.TryParse(bubbleEventAttri.Value, out temp))
                //    {
                //        trigger.BubbleEvent = temp == 0 ? false : true;
                //    }
                //}

                if (!trigger.Empty)
                {
                    objScr.AddTrigger(trigger);
                }
                else
                {
                    trigger = null;
                }
            }
            catch (System.Exception ex)
            {
                Log.UIService.LogError("Failed to load triggers", ex);
            }
        }