Exemple #1
0
        /// <summary>
        /// Starts an animation to a particular value on the specified dependency property.
        /// You can pass in an event handler to call when the animation has completed.
        /// </summary>
        /// <param name="pAnimatableElement">The gui element to animate.</param>
        /// <param name="pDependencyProperty">The dependency property to animate.</param>
        /// <param name="pToValue">The final value of the dependency property.</param>
        /// <param name="pAnimationDurationSeconds">The animation duration.</param>
        /// <param name="pCompletedEvent">The callback executed when the animation ended.</param>
        public static void StartAnimation(UIElement pAnimatableElement, DependencyProperty pDependencyProperty, double pToValue, double pAnimationDurationSeconds, EventHandler pCompletedEvent)
        {
            double lFromValue = (double)pAnimatableElement.GetValue(pDependencyProperty);

            DoubleAnimation lAnimation = new DoubleAnimation();
            lAnimation.From = lFromValue;
            lAnimation.To = pToValue;
            lAnimation.Duration = TimeSpan.FromSeconds(pAnimationDurationSeconds);

            lAnimation.Completed += delegate(object pSender, EventArgs pEventArgs)
            {
                //
                // When the animation has completed bake final value of the animation
                // into the property.
                //
                pAnimatableElement.SetValue(pDependencyProperty, pAnimatableElement.GetValue(pDependencyProperty));
                CancelAnimation(pAnimatableElement, pDependencyProperty);

                if (pCompletedEvent != null)
                {
                    pCompletedEvent(pSender, pEventArgs);
                }
            };

            lAnimation.Freeze();

            pAnimatableElement.BeginAnimation(pDependencyProperty, lAnimation);
        }
        /// <summary>
        /// Starts an animation to a particular value on the specified dependency property.
        /// You can pass in an event handler to call when the animation has completed.
        /// </summary>
        public static void StartAnimation(UIElement animationElement, DependencyProperty dependencyProperty, double toValue, double animationDurationSeconds, EventHandler completedEvent)
        {
            if (animationElement == null)
            {
                throw new ArgumentNullResourceException("animationElement", Resources.General_Given_Parameter_Cannot_Be_Null);
            }

            var fromValue = (double)animationElement.GetValue(dependencyProperty);

            var animation = new DoubleAnimation { From = fromValue, To = toValue, Duration = TimeSpan.FromSeconds(animationDurationSeconds) };

            animation.Completed += (sender, e) =>
                                       {
                                           // When the animation has completed bake final value of the animation
                                           // into the property.
                                           animationElement.SetValue(dependencyProperty, animationElement.GetValue(dependencyProperty));
                                           CancelAnimation(animationElement, dependencyProperty);

                                           if (completedEvent != null)
                                           {
                                               completedEvent(sender, e);
                                           }
                                       };

            animation.Freeze();

            animationElement.BeginAnimation(dependencyProperty, animation);
        }
        /// <summary>
        /// Starts an animation to a particular value on the specified dependency property.
        /// You can pass in an event handler to call when the animation has completed.
        /// </summary>
        public static void StartAnimation(UIElement animatableElement, DependencyProperty dependencyProperty, double toValue, double animationDurationSeconds, EventHandler completedEvent)
        {
            double fromValue = (double)animatableElement.GetValue(dependencyProperty);

            DoubleAnimation animation = new DoubleAnimation();
            animation.From = fromValue;
            animation.To = toValue;
            animation.Duration = TimeSpan.FromSeconds(animationDurationSeconds);

            animation.Completed += delegate(object sender, EventArgs e)
            {
                //
                // When the animation has completed bake final value of the animation
                // into the property.
                //
                animatableElement.SetValue(dependencyProperty, animatableElement.GetValue(dependencyProperty));
                CancelAnimation(animatableElement, dependencyProperty);

                if (completedEvent != null)
                {
                    completedEvent(sender, e);
                }
            };

            animation.Freeze();

            animatableElement.BeginAnimation(dependencyProperty, animation);
        }
        public static GroupRecord GetGroupRecordInfo(UIElement element)
        {
            if (element == null)
                return null;

            return (GroupRecord)element.GetValue(GroupRecordInfoProperty);
        }
        /// <summary>
        ///   Gets the command bindings.
        /// </summary>
        /// 
        public static CommandBindingCollection GetCommandBindings(UIElement element)
        {
            if (element == null)
                return null;

            return (CommandBindingCollection)element.GetValue(RegisterCommandBindingsProperty);
        }
 public static bool GetIsEdit(UIElement uiElement)
 {
     if (uiElement == null)
     {
         throw new ArgumentNullException("uiElement");
     }
     return (bool)uiElement.GetValue(IsEditProperty);
 }
 /// <summary>
 /// Gets the
 /// <see cref="T:Microsoft.Phone.Controls.NavigationTransition"/>s
 /// of
 /// <see cref="M:Microsoft.Phone.Controls.TransitionService.NavigationOutTransitionProperty"/>
 /// for a
 /// <see cref="T:System.Windows.UIElement"/>.
 /// </summary>
 /// <param name="element">The <see cref="T:System.Windows.UIElement"/>.</param>
 /// <returns>The </returns>
 public static NavigationOutTransition GetNavigationOutTransition(UIElement element)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     return (NavigationOutTransition)element.GetValue(NavigationOutTransitionProperty);
 }
        public static ListSortDirection? GetSortDirection(UIElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            return (ListSortDirection?)element.GetValue(SortDirectionProperty);
        }
		public static IInputElement GetFocusedChild(UIElement element)
		{
			if (element == null)
				throw new ArgumentNullException("element");
			WeakReference r = (WeakReference)element.GetValue(FocusedChildProperty);
			if (r != null)
				return (IInputElement)r.Target;
			else
				return null;
		}
Exemple #10
0
        /// <summary>
        /// Gets the value of the Menu attached property from a given DependencyObject. 
        /// </summary>
        /// <param name="control">The element from which to read the property value.</param>
        /// <returns>The value of the Menu attached property.</returns>
        public static Menu GetContextMenu(UIElement control)
        {
            // preconditions

            Argument.IsNotNull("control", control);

            // implementation

            return control.GetValue(ContextMenuProperty) as Menu;
        }
Exemple #11
0
 public static MouseActionCollection GetMouseActions(UIElement element)
 {
     return (MouseActionCollection)element.GetValue(MouseActionsProperty);
 }
Exemple #12
0
 public static int GetIsMouseOverDelay(UIElement element)
 {
     return (int)element.GetValue(IsMouseOverDelayProperty);
 }
Exemple #13
0
 public static bool GetIgnoreMouseIsOver(UIElement element)
 {
     return (bool)element.GetValue(IgnoreMouseIsOverProperty);
 }
Exemple #14
0
 public static bool GetIgnoreIsMouseDown(UIElement element)
 {
     return (bool)element.GetValue(IgnoreIsMouseDownProperty);
 }
Exemple #15
0
 public static bool GetHasImage(System.Windows.UIElement element)
 {
     return((bool)element.GetValue(HasImageProperty));
 }
Exemple #16
0
 public static ICommand GetPreviewDropCommand(UIElement obj)
 {
     return (ICommand)obj.GetValue(PreviewDropCommandProperty);
 }
 public static ICommand GetOnDrop(UIElement element)
 {
     return (ICommand)element.GetValue(OnDropProperty);
 }
 public static ICommand GetMouseDownCommand(UIElement element)
 {
     return (ICommand)element.GetValue(MouseDownCommandProperty);
 }
Exemple #19
0
 public static Action<bool> GetMouseIsOver(UIElement element)
 {
     return (Action<bool>)element.GetValue(MouseIsOverProperty);
 }
Exemple #20
0
 public static bool? GetMouseClicktoggleBool(UIElement element)
 {
     return (bool?)element.GetValue(MouseClicktoggleBoolProperty);
 }
Exemple #21
0
 public static string GetImageSource(System.Windows.UIElement element)
 {
     return((string)element.GetValue(ImageSourceProperty));
 }
Exemple #22
0
 public static ICommand GetMouseDoubleClick(UIElement element)
 {
     return (ICommand)element.GetValue(MouseDoubleClickProperty);
 }
 public static InputBindingCollection GetInputBindings( UIElement element )
 {
     return ( InputBindingCollection )element.GetValue( InputBindingsProperty );
 }
Exemple #24
0
 public static Action<Point> GetMouseMove(UIElement element)
 {
     return (Action<Point>) element.GetValue(MouseMoveProperty);
 }
Exemple #25
0
 public static string GetHint(System.Windows.UIElement element)
 {
     return((string)element.GetValue(HintProperty));
 }
 public static string GetDropDataType(UIElement element)
 {
     return (string)element.GetValue(DropDataTypeProperty);
 }
Exemple #27
0
 public static Action<int> GetMouseScroll(UIElement element)
 {
     return (Action<int>)element.GetValue(MouseScrollProperty);
 }
 public static object GetParameter(UIElement element)
 {
     return element.GetValue(OnParameterProperty);
 }
Exemple #29
0
 public static ICommand GetMouseScrollUp(UIElement element)
 {
     return (ICommand)element.GetValue(MouseScrollUpProperty);
 }
 //public static bool GetMyProperty(DependencyObject obj)
 public static bool GetIsLoadingPropertyAttached(UIElement element)
 {
     return (bool)element.GetValue(IsLoadingPropertyAttachedProperty);
 }
Exemple #31
0
 public static MouseButton GetMouseUpButton(UIElement element)
 {
     return (MouseButton)element.GetValue(MouseUpButtonProperty);
 }
Exemple #32
0
 public static bool GetMyInitialized(UIElement element)
 {
     return (bool)element.GetValue(MyInitializedProperty);
 }
Exemple #33
0
 private static DispatcherTimer GetIsMouseOverDispatcherTimer(UIElement element)
 {
     return (DispatcherTimer)element.GetValue(IsMouseOverDispatcherTimerProperty);
 }