예제 #1
1
      /// <summary/>
      protected internal override TimeSpan DefineTimeline(ParallelTimeline parentTimeline, TimeSpan parentOffset) {
         var timeline = new DoubleAnimation();
         var trigger  = new PropertyTrigger((DependencyObject)Target, Property, Values);
         timeline.CurrentTimeInvalidated += (sender, e) => trigger.Tick((Clock)sender);

         parentTimeline.Children.Add(timeline);
         if (!RepeatCount.HasValue) {
            RepeatCount = Values.Length;
            var totalDuration = DefineTimelineCore(timeline, parentOffset);
            RepeatCount = null;
            return totalDuration;
         } else {
            return DefineTimelineCore(timeline, parentOffset);
         }
      }
예제 #2
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;
            }
        }
        public void ShouldFireTriggersOnPropertyChanged()
        {
            PropertyTrigger trigger = new PropertyTrigger()
            {
                PropertyName = "HorizontalAlignment"
            };

            MockAction action = new MockAction();
            trigger.Actions.Add(action);
            FrameworkElement element = new FrameworkElement();

            System.Windows.Interactivity.TriggerCollection triggers = Interaction.GetTriggers(element);
            triggers.Add(trigger);

            element.HorizontalAlignment = HorizontalAlignment.Left;

            Assert.IsTrue(action.hasExecuted);
            Assert.IsTrue(action.IsAttached);
        }
예제 #4
0
        public void ShouldFireTriggersOnPropertyChanged()
        {
            PropertyTrigger trigger = new PropertyTrigger()
            {
                PropertyName = "HorizontalAlignment"
            };

            MockAction action = new MockAction();

            trigger.Actions.Add(action);
            FrameworkElement element = new FrameworkElement();

            System.Windows.Interactivity.TriggerCollection triggers = Interaction.GetTriggers(element);
            triggers.Add(trigger);

            element.HorizontalAlignment = HorizontalAlignment.Left;

            Assert.IsTrue(action.hasExecuted);
            Assert.IsTrue(action.IsAttached);
        }