예제 #1
0
        private static void OnToggleButtonMouseLeave(object sender, RoutedEventArgs e)
        {
            var button           = sender as ToggleButton;
            var hoverBackground  = GetHoverBackground(button);
            var hoverForeground  = GetHoverForeground(button);
            var hoverBorderBrush = GetHoverBorderBrush(button);

            var list = new List <DependencyProperty>();

            if (hoverBackground != null)
            {
                list.Add(ToggleButton.BackgroundProperty);
            }
            if (hoverForeground != null)
            {
                list.Add(ToggleButton.ForegroundProperty);
            }
            if (hoverBorderBrush != null)
            {
                list.Add(ToggleButton.BorderBrushProperty);
            }
            if (list.Any())
            {
                UIElementUtils.BeginStoryboard(button, list);
            }
        }
예제 #2
0
        private static void OnMenuItemMouseEnter(object sender, MouseEventArgs e)
        {
            var menuItem   = (MenuItem)sender;
            var isTopLevel = menuItem.Role == MenuItemRole.TopLevelHeader || menuItem.Role == MenuItemRole.TopLevelItem;

            var dic              = new Dictionary <DependencyProperty, Brush>();
            var hoverBackground  = isTopLevel ? GetTopLevelItemHoverBackground(menuItem) : GetSubmenuItemHoverBackground(menuItem);
            var hoverForeground  = isTopLevel ? GetTopLevelItemHoverForeground(menuItem) : GetSubmenuItemHoverForeground(menuItem);
            var hoverBorderBrush = isTopLevel ? GetTopLevelItemHoverBorderBrush(menuItem) : GetSubmenuItemHoverBorderBrush(menuItem);

            if (hoverBackground != null)
            {
                dic.Add(MenuItem.BackgroundProperty, hoverBackground);
            }
            if (hoverForeground != null)
            {
                dic.Add(MenuItem.ForegroundProperty, hoverForeground);
            }
            if (hoverBorderBrush != null)
            {
                dic.Add(MenuItem.BorderBrushProperty, hoverBorderBrush);
            }
            if (dic.Any())
            {
                UIElementUtils.BeginStoryboard(menuItem, dic);
            }
        }
예제 #3
0
        private static void OnToggleButtonMouseEnter(object sender, RoutedEventArgs e)
        {
            var button           = sender as ToggleButton;
            var hoverBackground  = GetHoverBackground(button);
            var hoverForeground  = GetHoverForeground(button);
            var hoverBorderBrush = GetHoverBorderBrush(button);

            var dic = new Dictionary <DependencyProperty, Brush>();

            if (hoverBackground != null)
            {
                dic.Add(ToggleButton.BackgroundProperty, hoverBackground);
            }
            if (hoverForeground != null)
            {
                dic.Add(ToggleButton.ForegroundProperty, hoverForeground);
            }
            if (hoverBorderBrush != null)
            {
                dic.Add(ToggleButton.BorderBrushProperty, hoverBorderBrush);
            }
            if (dic.Any())
            {
                UIElementUtils.BeginStoryboard(button, dic);
            }
        }
예제 #4
0
        private Storyboard CreateMarbleStoryboard()
        {
            var storyboard = new Storyboard();
            var anima      = UIElementUtils.CreateAnimation(
                new Thickness(0),
                new Thickness(_boundingWidth - _textWidth, 0, 0, 0),
                AnimationBeginTime,
                AnimationDuration,
                AnimationEase);

            Storyboard.SetTarget(anima, _textBlock);
            Storyboard.SetTargetProperty(anima, new PropertyPath(TextBlock.MarginProperty));

            var totalMs = AnimationDuration.TotalMilliseconds + AnimationInterval.TotalMilliseconds;

            var animaReverse = UIElementUtils.CreateAnimation((Thickness?)null,
                                                              null,
                                                              TimeSpan.FromMilliseconds(totalMs),
                                                              AnimationDuration,
                                                              AnimationEase);

            Storyboard.SetTarget(animaReverse, _textBlock);
            Storyboard.SetTargetProperty(animaReverse, new PropertyPath(TextBlock.MarginProperty));

            storyboard.Children.Add(anima);
            storyboard.Children.Add(animaReverse);

            return(storyboard);
        }
예제 #5
0
        private static void OnMenuItemMouseLeave(object sender, MouseEventArgs e)
        {
            var menuItem   = (MenuItem)sender;
            var isTopLevel = menuItem.Role == MenuItemRole.TopLevelHeader || menuItem.Role == MenuItemRole.TopLevelItem;

            var hoverBackground  = isTopLevel ? GetTopLevelItemHoverBackground(menuItem) : GetSubmenuItemHoverBackground(menuItem);
            var hoverForeground  = isTopLevel ? GetTopLevelItemHoverForeground(menuItem) : GetSubmenuItemHoverForeground(menuItem);
            var hoverBorderBrush = isTopLevel ? GetTopLevelItemHoverBorderBrush(menuItem) : GetSubmenuItemHoverBorderBrush(menuItem);

            var list = new List <DependencyProperty>();

            if (hoverBackground != null)
            {
                list.Add(MenuItem.BackgroundProperty);
            }
            if (hoverForeground != null)
            {
                list.Add(MenuItem.ForegroundProperty);
            }
            if (hoverBorderBrush != null)
            {
                list.Add(MenuItem.BorderBrushProperty);
            }
            if (list.Any())
            {
                UIElementUtils.BeginStoryboard(menuItem, list);
            }
        }
예제 #6
0
        static GridCellSplitter()
        {
            Brush.Freeze();

            UIElementUtils.OverrideFocusable <GridCellSplitter <TGridCellPresenter, TGridCellPanel, TGridCellCollection, TGridCell, TGridCellSplitter, TGridCellColumnController, TGridCellColumn> >(false);
            ControlUtils.OverrideIsTabStop <GridCellSplitter <TGridCellPresenter, TGridCellPanel, TGridCellCollection, TGridCell, TGridCellSplitter, TGridCellColumnController, TGridCellColumn> >(false);
            FrameworkElementUtils.OverrideVisualStyle <GridCellSplitter <TGridCellPresenter, TGridCellPanel, TGridCellCollection, TGridCell, TGridCellSplitter, TGridCellColumnController, TGridCellColumn> >(null);
        }
예제 #7
0
 protected override void OnContentTemplateChanged(DataTemplate oldContentTemplate, DataTemplate newContentTemplate)
 {
     base.OnContentTemplateChanged(oldContentTemplate, newContentTemplate);
     Dispatcher.BeginInvoke(new Action(() =>
     {
         var adorner   = UIElementUtils.GetVisualChild <AdornerDecorator>(this);
         var presenter = UIElementUtils.GetVisualChild <ContentPresenter>(adorner);
         _control      = newContentTemplate?.FindName("PART_Control", presenter) as MessageBoxXControl;
         if (_control != null)
         {
             _control.OnTemplatedChanged -= Control_OnTemplatedChanged;
             _control.OnTemplatedChanged += Control_OnTemplatedChanged;
         }
     }), DispatcherPriority.Loaded);
 }
예제 #8
0
        private Storyboard CreateBarrageStoryboard()
        {
            var storyboard = new Storyboard();

            var anima = UIElementUtils.CreateAnimation(new Thickness(_boundingWidth, 0, 0, 0),
                                                       new Thickness(-_textWidth, 0, 0, 0),
                                                       AnimationBeginTime,
                                                       AnimationDuration,
                                                       AnimationEase);

            Storyboard.SetTarget(anima, _textBlock);
            Storyboard.SetTargetProperty(anima, new PropertyPath(TextBlock.MarginProperty));
            storyboard.Children.Add(anima);
            return(storyboard);
        }
예제 #9
0
        private void UpdateRoller()
        {
            if (RenderSize.Height == 0)
            {
                return;
            }

            var offset = RenderSize.Height / 2;

            if (Items.Count > 0)
            {
                if (SelectedIndex < 0)
                {
                    var firstItem = GetItem(0) as UIElement;
                    if (firstItem != null)
                    {
                        offset += firstItem.RenderSize.Height / 2;
                    }
                }
                for (var i = 0; i <= SelectedIndex; i++)
                {
                    var targetItem = GetItem(i) as UIElement;
                    if (targetItem != null)
                    {
                        if (SelectedIndex == i)
                        {
                            offset -= targetItem.RenderSize.Height / 2;
                        }
                        else
                        {
                            offset -= targetItem.RenderSize.Height;
                        }
                    }
                }
                if (IsLoaded)
                {
                    UIElementUtils.BeginAnimation(_stkPanel, StackPanel.MarginProperty, new Thickness(0, offset, 0, 0), AnimationDuration, AnimationEase, false);
                }
                else
                {
                    _stkPanel.Margin = new Thickness(0, offset, 0, 0);
                }
            }
        }
예제 #10
0
        private void BeginArrangeAnimation()
        {
            BeginAnimation(PercentProperty, null);
            foreach (UIElement child in InternalChildren)
            {
                var currentOffset = GetCurrentOffset(child);
                if (!double.IsNaN(currentOffset))
                {
                    SetLastOffset(child, GetCurrentOffset(child));
                }
            }
            var animation = new DoubleAnimation()
            {
                From           = 0,
                To             = 100,
                Duration       = AnimationDuration,
                EasingFunction = UIElementUtils.CreateEasingFunction(AnimationEase),
            };

            BeginAnimation(PercentProperty, animation);
        }
예제 #11
0
        private Storyboard CreateFadeStoryboard()
        {
            var storyboard = new Storyboard();

            var animaForeground = UIElementUtils.CreateAnimation(null,
                                                                 0,
                                                                 AnimationBeginTime,
                                                                 AnimationDuration,
                                                                 AnimationEase);

            Storyboard.SetTarget(animaForeground, _textBlock);
            Storyboard.SetTargetProperty(animaForeground, new PropertyPath(TextBlock.OpacityProperty));

            var totalMs = AnimationDuration.TotalMilliseconds + AnimationInterval.TotalMilliseconds;

            var animaForegroundReverse = UIElementUtils.CreateAnimation(null,
                                                                        1,
                                                                        TimeSpan.FromMilliseconds(totalMs),
                                                                        AnimationDuration,
                                                                        AnimationEase);

            Storyboard.SetTarget(animaForegroundReverse, _textBlock);
            Storyboard.SetTargetProperty(animaForegroundReverse, new PropertyPath(TextBlock.OpacityProperty));

            var animaString = new StringAnimationUsingKeyFrames();

            animaString.KeyFrames.Add(new DiscreteStringKeyFrame()
            {
                Value   = Text,
                KeyTime = KeyTime.FromTimeSpan(AnimationDuration),
            });
            Storyboard.SetTarget(animaString, _textBlock);
            Storyboard.SetTargetProperty(animaString, new PropertyPath(TextBlock.TextProperty));

            storyboard.Children.Add(animaForeground);
            storyboard.Children.Add(animaForegroundReverse);
            storyboard.Children.Add(animaString);

            return(storyboard);
        }
예제 #12
0
        private static void OnPasswordBoxLostFocus(object sender, RoutedEventArgs e)
        {
            var passwordBox   = sender as PasswordBox;
            var fcBorderBrush = GetFocusedBorderBrush(passwordBox);
            var fcForeground  = GetFocusedForeground(passwordBox);

            if (fcBorderBrush == null && fcForeground == null)
            {
                return;
            }

            var list = new List <DependencyProperty>();

            if (fcBorderBrush != null)
            {
                list.Add(PasswordBox.BorderBrushProperty);
            }
            if (fcForeground != null)
            {
                list.Add(PasswordBox.ForegroundProperty);
            }

            UIElementUtils.BeginStoryboard(passwordBox, list);
        }
예제 #13
0
        private static void OnPasswordBoxGotFocus(object sender, RoutedEventArgs e)
        {
            var passwordBox   = sender as PasswordBox;
            var fcBorderBrush = GetFocusedBorderBrush(passwordBox);
            var fcForeground  = GetFocusedForeground(passwordBox);

            if (fcBorderBrush == null && fcForeground == null)
            {
                return;
            }

            var dic = new Dictionary <DependencyProperty, Brush>();

            if (fcBorderBrush != null)
            {
                dic.Add(PasswordBox.BorderBrushProperty, fcBorderBrush);
            }
            if (fcForeground != null)
            {
                dic.Add(PasswordBox.ForegroundProperty, fcForeground);
            }

            UIElementUtils.BeginStoryboard(passwordBox, dic);
        }
예제 #14
0
        private void Tore(int oldIndex, int newIndex, bool useAnimate)
        {
            if (!IsInitialized)
            {
                return;
            }
            var totalCount = Children.Count;

            if (oldIndex < 0 || newIndex < 0 || oldIndex > totalCount || newIndex > totalCount)
            {
                return;
            }
            var isUpward = newIndex > oldIndex;

            var oldChild = Children[oldIndex];
            var newChild = Children[newIndex];

            newChild.Opacity               = 0;
            newChild.IsHitTestVisible      = true;
            oldChild.RenderTransformOrigin = new Point(0.5, 0.5);
            newChild.RenderTransformOrigin = new Point(0.5, 0.5);

            switch (Animation)
            {
            case StickyAnimation.Scale:
                var oldScale = new ScaleTransform()
                {
                    ScaleX = 1, ScaleY = 1
                };
                var newScale = new ScaleTransform()
                {
                    ScaleX = isUpward ? 1.5 : 0.75, ScaleY = isUpward ? 1.5 : 0.75
                };

                oldChild.RenderTransform  = oldScale;
                oldChild.IsHitTestVisible = false;
                newChild.RenderTransform  = newScale;

                UIElementUtils.BeginAnimation(oldScale, ScaleTransform.ScaleXProperty, isUpward ? 0.75 : 1.5, AnimationDuration, AnimationEase);
                UIElementUtils.BeginAnimation(oldScale, ScaleTransform.ScaleYProperty, isUpward ? 0.75 : 1.5, AnimationDuration, AnimationEase);
                UIElementUtils.BeginAnimation(oldChild, OpacityProperty, 0, AnimationDuration, AnimationEase);
                UIElementUtils.BeginAnimation(newScale, ScaleTransform.ScaleXProperty, 1, AnimationDuration, AnimationEase);
                UIElementUtils.BeginAnimation(newScale, ScaleTransform.ScaleYProperty, 1, AnimationDuration, AnimationEase);
                UIElementUtils.BeginAnimation(newChild, OpacityProperty, 1, AnimationDuration, AnimationEase);
                break;

            case StickyAnimation.Slide:
                if (isUpward)
                {
                    var oldTranslate = new TranslateTransform()
                    {
                        X = 0
                    };
                    oldChild.RenderTransform = oldTranslate;
                    UIElementUtils.BeginAnimation(oldTranslate, TranslateTransform.XProperty, -ActualWidth, AnimationDuration, AnimationEase);
                    UIElementUtils.BeginAnimation(newChild, OpacityProperty, 1, AnimationDuration, AnimationEase);
                }
                else
                {
                    var newTranslate = new TranslateTransform()
                    {
                        X = -ActualWidth
                    };
                    newChild.RenderTransform  = newTranslate;
                    oldChild.IsHitTestVisible = false;
                    UIElementUtils.BeginAnimation(newTranslate, TranslateTransform.XProperty, 0, AnimationDuration, AnimationEase);
                    UIElementUtils.BeginAnimation(newChild, OpacityProperty, 1, AnimationDuration, AnimationEase);
                    UIElementUtils.BeginAnimation(oldChild, OpacityProperty, 0, AnimationDuration, AnimationEase);
                }
                break;
            }
        }
예제 #15
0
 static PropertyViewControl()
 {
     DefaultStyleKeyHelper.OverrideStyleKey <PropertyViewControl>();
     UIElementUtils.OverrideFocusable <PropertyViewControl>(false);
 }
예제 #16
0
        private void UpdateState()
        {
            if (!IsInitialized)
            {
                return;
            }
            switch (ContentPlacement)
            {
            case DrawerPlacement.Left:
            case DrawerPlacement.Right:
                if (double.IsNaN(MaxWidth))
                {
                    throw new Exception("Drawer Exception : value of MaxWidth property can not be Auto.");
                }
                if (!IsLoaded || AnimationDuration.TotalMilliseconds == 0)
                {
                    if (IsOpen)
                    {
                        if (!double.IsInfinity(MaxWidth))
                        {
                            Width = MaxWidth;
                        }
                    }
                    else
                    {
                        Width = 0;
                    }
                }
                else
                {
                    if (IsOpen)
                    {
                        if (double.IsNaN(Width))
                        {
                            Width = ActualWidth;
                        }
                        UIElementUtils.BeginAnimation(this, WidthProperty, MaxWidth, AnimationDuration, AnimationEase);
                    }
                    else
                    {
                        if (double.IsNaN(Width))
                        {
                            Width = ActualWidth;
                        }
                        UIElementUtils.BeginAnimation(this, WidthProperty, 0, AnimationDuration, AnimationEase);
                    }
                }
                break;

            case DrawerPlacement.Top:
            case DrawerPlacement.Bottom:
                if (double.IsNaN(MaxWidth))
                {
                    throw new Exception("Drawer Exception : value of MaxHeight property can not be Auto.");
                }
                if (!IsLoaded || AnimationDuration.TotalMilliseconds == 0)
                {
                    if (IsOpen)
                    {
                        if (!double.IsInfinity(MaxHeight))
                        {
                            Height = MaxHeight;
                        }
                    }
                    else
                    {
                        Height = 0;
                    }
                }
                else
                {
                    if (IsOpen)
                    {
                        if (double.IsNaN(Height))
                        {
                            Height = ActualHeight;
                        }
                        UIElementUtils.BeginAnimation(this, HeightProperty, MaxHeight, AnimationDuration, AnimationEase);
                    }
                    else
                    {
                        if (double.IsNaN(Height))
                        {
                            Height = ActualHeight;
                        }
                        UIElementUtils.BeginAnimation(this, HeightProperty, 0, AnimationDuration, AnimationEase);
                    }
                }
                break;
            }
        }
예제 #17
0
 static ScrollBarThumb()
 {
     DefaultStyleKeyHelper.OverrideStyleKey <ScrollBarThumb>();
     UIElementUtils.OverrideFocusable <ScrollBarThumb>(false);
 }