Exemplo n.º 1
0
 private void AssociatedObject_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
 {
     if (PreviewBehavior._isShowingPreview)
     {
         Point            point             = new Point(e.ManipulationOrigin.X, e.ManipulationOrigin.Y);
         UIElement        rootVisual        = Application.Current.RootVisual;
         FrameworkElement newHoveredElement = VisualTreeHelper.FindElementsInHostCoordinates(PreviewBehavior.GetHostCoordinates(e.ManipulationContainer.TransformToVisual(rootVisual).Transform(point)), rootVisual).FirstOrDefault <UIElement>() as FrameworkElement;
         if (newHoveredElement != null)
         {
             BehaviorCollection behaviors1      = Interaction.GetBehaviors((DependencyObject)newHoveredElement);
             PreviewBehavior    previewBehavior = (behaviors1 != null ? behaviors1.FirstOrDefault <Behavior>((Func <Behavior, bool>)(b => b is PreviewBehavior)) : (Behavior)null) as PreviewBehavior;
             if (previewBehavior == null && newHoveredElement.Parent != null)
             {
                 BehaviorCollection behaviors2 = Interaction.GetBehaviors(newHoveredElement.Parent);
                 previewBehavior = (behaviors2 != null ? behaviors2.FirstOrDefault <Behavior>((Func <Behavior, bool>)(b => b is PreviewBehavior)) : (Behavior)null) as PreviewBehavior;
             }
             if (previewBehavior != null)
             {
                 Image       image         = newHoveredElement as Image;
                 BitmapImage originalImage = (image != null ? image.Source : null) as BitmapImage;
                 this.ShowPreview(previewBehavior.PreviewUri, originalImage, previewBehavior.TopOffset);
                 this.SetHoveredElement(newHoveredElement);
             }
         }
         e.Handled = true;
     }
     else
     {
         this.StopTimer();
     }
 }
Exemplo n.º 2
0
        private void SetHoveredElement(FrameworkElement newHoveredElement)
        {
            if (this._hoveredElement == newHoveredElement)
            {
                return;
            }
            List <AnimationInfo> animInfoList = new List <AnimationInfo>();

            if (this._hoveredElement != null)
            {
                animInfoList.AddRange((IEnumerable <AnimationInfo>)PreviewBehavior.CreateAnimations(this._hoveredElement, false));
            }
            this._hoveredElement = newHoveredElement;
            if (this._hoveredElement != null)
            {
                animInfoList.AddRange((IEnumerable <AnimationInfo>)PreviewBehavior.CreateAnimations(this._hoveredElement, true));
            }
            AnimationUtil.AnimateSeveral(animInfoList, new int?(0), null);
        }