Inheritance: System.Windows.Media.Animation.PointAnimation
Example #1
0
        private void FloatingContainerLoaded(object sender, RoutedEventArgs e) {
            if (_fe.StartSize.HasValue) {
                _svi.SetBinding(WidthProperty,
                    new Binding {Source = _fe.StartSize.Value, Path = new PropertyPath("Width")});
                _svi.SetBinding(HeightProperty,
                    new Binding {Source = _fe.StartSize.Value, Path = new PropertyPath("Height")});
                //_svi.Width = _fe.StartSize.Value.Width;
                //_svi.Height = _fe.StartSize.Value.Height;
            }
            else {
                _svi.SetBinding(WidthProperty, new Binding {Source = _fe.Width, Path = new PropertyPath("Width")});
                _svi.SetBinding(HeightProperty, new Binding {Source = _fe.Height, Path = new PropertyPath("Height")});
                //if (_fe.Width > 0) _svi.Width = _fe.Width;
                //if (_fe.Height > 0) _svi.Height = _fe.Height;
            }

            if (_fe.OriginPosition.HasValue || _fe.OriginSize.HasValue) {
                var d = new Duration(_fe.AnimationSpeed);
                if (_fe.StartPosition != null) {
                    var pa = new StopHoldPointAnimation(_fe.StartPosition.Value, d, _svi, ScatterContentControlBase.CenterProperty) {
                            FillBehavior = FillBehavior.Stop,
                            From = _fe.OriginPosition
                        };
                    _svi.BeginAnimation(ScatterContentControlBase.CenterProperty, pa);
                }

                if (_fe.OriginSize.HasValue) {
                    var wa = new StopHoldDoubleAnimation(_fe.StartSize.Value.Width, d, _svi, WidthProperty)
                    {FillBehavior = FillBehavior.Stop, From = _fe.OriginSize.Value.Width};
                    _svi.BeginAnimation(WidthProperty, wa);

                    var ha = new StopHoldDoubleAnimation(_fe.StartSize.Value.Height, d, _svi, HeightProperty)
                    {FillBehavior = FillBehavior.Stop, From = _fe.OriginSize.Value.Height};
                    _svi.BeginAnimation(HeightProperty, ha);
                }
            }
            else {
                if (_fe.StartPosition.HasValue) _svi.Center = _fe.StartPosition.Value;
            }

            if (_fe.StartOrientation.HasValue) _svi.Orientation = _fe.StartOrientation.Value;

            //if (_fe.StartSize.HasValue)
            //{
            //  _svi.Width = _fe.StartSize.Value.Width;
            //  _svi.Height = _fe.StartSize.Value.Height;
            //}
            //else
            //{
            //  if (_fe.Width > 0) _svi.Width = _fe.Width;
            //  if (_fe.Height > 0) _svi.Height = _fe.Height;
            //}

            try {
                if (_fe.MinSize.HasValue) {
                    if (!double.IsNaN(_fe.MinSize.Value.Width)) _svi.MinWidth = _fe.MinSize.Value.Width;
                    if (!double.IsNaN(_fe.MinSize.Value.Height)) _svi.MinHeight = _fe.MinSize.Value.Height;
                }

                if (_fe.MaxSize.HasValue) {
                    _svi.MaxWidth = _fe.MaxSize.Value.Width;
                    _svi.MaxHeight = _fe.MaxSize.Value.Height;
                }
            }
            catch (Exception) {
                Logger.Log("FrameworkContainer", "Error setting min/max size", "", Logger.Level.Error);
            }

            _svi.SetBinding(OpacityProperty, new Binding {Source = _fe, Path = new PropertyPath("OpacityNormal")});
        }
Example #2
0
        private void Dock() {
            _fe.Large = false;
            Undocked = false;
            _fe.TriggerClosedEvent();

            if (_fe.StartPosition != null) {
                var spa = new StopHoldPointAnimation(_fe.StartPosition.Value, new Duration(_fe.AnimationSpeed), _svi,
                    ScatterContentControlBase.CenterProperty)
                {FillBehavior = FillBehavior.Stop};
                spa.Completed += SpaCompleted;

                _svi.BeginAnimation(ScatterContentControlBase.CenterProperty, spa);
            }
            if (_fe.StartSize != null) {
                _svi.BeginAnimation(WidthProperty,
                    new StopHoldDoubleAnimation(_fe.StartSize.Value.Width,
                        new Duration(_fe.AnimationSpeed),
                        _svi, WidthProperty) {FillBehavior = FillBehavior.Stop});

                _svi.BeginAnimation(HeightProperty,
                    new StopHoldDoubleAnimation(_fe.StartSize.Value.Height,
                        new Duration(_fe.AnimationSpeed),
                        _svi, HeightProperty));
            }
            if (_svi.Orientation < 180) {
                if (_fe.StartOrientation != null)
                    _svi.BeginAnimation(ScatterContentControlBase.OrientationProperty,
                        new StopHoldDoubleAnimation(_fe.StartOrientation.Value,
                            new Duration(_fe.AnimationSpeed), _svi,
                            ScatterContentControlBase.OrientationProperty)
                        {FillBehavior = FillBehavior.Stop});
            }
            else {
                if (_fe.StartOrientation != null)
                    _svi.BeginAnimation(ScatterContentControlBase.OrientationProperty,
                        new StopHoldDoubleAnimation(_fe.StartOrientation.Value + 360,
                            new Duration(_fe.AnimationSpeed), _svi,
                            ScatterContentControlBase.OrientationProperty)
                        {FillBehavior = FillBehavior.Stop});
            }
        }
Example #3
0
        private void Animate(Point center, double width, double height, double orientation, double duration) {
            var pa = new StopHoldPointAnimation(center,
                new Duration(TimeSpan.FromMilliseconds(duration)),
                _svi, ScatterContentControlBase.CenterProperty);

            _svi.BeginAnimation(ScatterContentControlBase.CenterProperty, pa);

            var wa = new StopHoldDoubleAnimation(width,
                new Duration(TimeSpan.FromMilliseconds(duration)),
                _svi, WidthProperty);

            _svi.BeginAnimation(WidthProperty, wa);

            var ha = new StopHoldDoubleAnimation(height,
                new Duration(TimeSpan.FromMilliseconds(duration)),
                _svi, HeightProperty);

            _svi.BeginAnimation(HeightProperty, ha);

            var oa = new StopHoldDoubleAnimation(orientation,
                new Duration(TimeSpan.FromMilliseconds(duration)),
                _svi, ScatterContentControlBase.OrientationProperty);

            _svi.BeginAnimation(ScatterContentControlBase.OrientationProperty, oa);
        }