コード例 #1
0
 private void StartKeyFrame(ObjectKeyFrame keyFrame)
 {
     if (keyFrame != null)
     {
         _keyFramesToObjectTimers[keyFrame].Start();
     }
 }
コード例 #2
0
 private void ApplyLastKeyFrame(object sender, EventArgs e)
 {
     if (!_cancelledAnimation)
     {
         ObjectKeyFrame lastKeyFrame = _keyFrames[_resolvedKeyFrames.GetNextKeyFrameIndex(_keyFrames.Count - 1)];
         ApplyKeyFrame(lastKeyFrame);
     }
 }
コード例 #3
0
        void UpdateThumbColor()
        {
            if (Control == null)
            {
                return;
            }

            var grid = Control.GetFirstDescendant <Windows.UI.Xaml.Controls.Grid>();

            if (grid == null)
            {
                return;
            }

            ObjectKeyFrame frame = Windows.UI.Xaml.VisualStateManager.GetVisualStateGroups(grid)
                                   .First(g => g.Name == "CommonStates")
                                   .States.First(s => s.Name == "PointerOver")
                                   .Storyboard.Children.OfType <ObjectAnimationUsingKeyFrames>().First(
                t => Storyboard.GetTargetName(t) == "SwitchKnobOn" &&
                Storyboard.GetTargetProperty(t) == "Fill")
                                   .KeyFrames.First();

            if (_originalThumbOnBrush == null)
            {
                _originalThumbOnBrush = (Brush)frame.Value;
            }

            if (!Element.ThumbColor.IsDefault)
            {
                frame.Value = new SolidColorBrush(Element.ThumbColor.ToWindowsColor())
                {
                    Opacity = _originalThumbOnBrush.Opacity
                }
            }
            ;
            else
            {
                frame.Value = _originalThumbOnBrush;
            }

            var thumb = (Ellipse)grid.FindName("SwitchKnobOn");

            if (_originalThumbOnBrush == null)
            {
                _originalThumbOnBrush = thumb.Fill;
            }

            if (!Element.ThumbColor.IsDefault)
            {
                thumb.Fill = new SolidColorBrush(Element.ThumbColor.ToWindowsColor());
            }
            else
            {
                thumb.Fill = _originalThumbOnBrush;
            }
        }
コード例 #4
0
 private void InitializeKeyFramesSet()
 {
     _resolvedKeyFrames       = new INTERNAL_ResolvedKeyFramesEntries <ObjectKeyFrame>(_keyFrames);
     _keyFramesToObjectTimers = new Dictionary <ObjectKeyFrame, NullableTimer>();
     for (int i = 0; i < KeyFrames.Count; i++)
     {
         int            keyFrameIndex = _resolvedKeyFrames.GetNextKeyFrameIndex(i);
         ObjectKeyFrame keyFrame      = KeyFrames[keyFrameIndex];
         NullableTimer  timer         = new NullableTimer(keyFrame.KeyTime.TimeSpan - (i > 0 ? KeyFrames[_resolvedKeyFrames.GetNextKeyFrameIndex(i - 1)].KeyTime.TimeSpan : TimeSpan.Zero));
         timer.Completed += ApplyNextKeyFrame;
         _keyFramesToObjectTimers.Add(keyFrame, timer);
     }
     _appliedKeyFramesCount = 0;
 }
コード例 #5
0
        private void ApplyKeyFrame(ObjectKeyFrame keyFrame)
        {
            object value = keyFrame.Value;

            if (value is string && _propDp.PropertyType != typeof(string))
            {
                if (_propDp.PropertyType.IsEnum)
                {
                    value = Enum.Parse(_propDp.PropertyType, (string)value);
                }
                else
                {
                    value = DotNetForHtml5.Core.TypeFromStringConverters.ConvertFromInvariantString(_propDp.PropertyType, (string)value);
                }
            }

            object castedValue = DynamicCast(value, _propDp.PropertyType);

            AnimationHelpers.ApplyValue(_propertyContainer, _targetProperty, castedValue, _parameters.IsVisualStateChange);
        }
コード例 #6
0
ファイル: ObjectComponents.cs プロジェクト: jjg0519/OA
        private static ObjectKeyFrame CreateColorKeyFrmas(KeyFrames <Object> Model)
        {
            ObjectKeyFrame frame = null;

            switch (Model.Type)
            {
            case KeyFramesType.Spline: break;

            case KeyFramesType.Linear: break;

            case KeyFramesType.Easing: break;

            case KeyFramesType.Discrete: frame = new DiscreteObjectKeyFrame(); break;

            default: break;
            }
            frame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(Model.KeyTime));
            frame.Value   = Model.Value;
            return(frame);
        }
コード例 #7
0
        private void ApplyKeyFrame(DependencyObject target, IterationParameters parameters, PropertyPath propertyPath, Type propertyType, ObjectKeyFrame keyFrame, DispatcherTimer timer)
        {
            if (timer != null)
            {
                timer.Stop();
            }
            _keyFramesToObjectTimers.Remove(keyFrame);
            object value = keyFrame.Value;

            if (value is string && propertyType != typeof(string))
            {
                if (propertyType.IsEnum)
                {
                    value = Enum.Parse(propertyType, (string)value);
                }
                else
                {
                    //we convert the value from the given string:
                    value = DotNetForHtml5.Core.TypeFromStringConverters.ConvertFromInvariantString(propertyType, (string)value);
                }
            }

            var castedValue = DynamicCast(value, propertyType); //Note: we put this line here because the Xaml could use a Color gotten from a StaticResource (which was therefore not converted to a SolidColorbrush by the compiler in the .g.cs file) and led to a wrong type set in a property (Color value in a property of type Brush).

            if (parameters.IsVisualStateChange)
            {
                propertyPath.INTERNAL_PropertySetVisualState(target, castedValue);
            }
            else
            {
                propertyPath.INTERNAL_PropertySetLocalValue(target, castedValue);
            }

            CheckTimeLineEndAndRaiseCompletedEvent(parameters);

            //----------------------------------------
            //todo:clone required ?
            //----------------------------------------
        }
コード例 #8
0
        public void GotoFrame(int index)
        {
            ObjectKeyFrame frame = this._animation.KeyFrames[index];

            this._clockController.Seek(frame.KeyTime.TimeSpan, TimeSeekOrigin.BeginTime);
        }