예제 #1
0
        private void Page_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            Button navigationBackButton = ((FrameworkElement)VisualTreeHelper.GetChild(MainNavigationView, 0)).FindName("NavigationViewBackButton") as Button;
            Thumb  horizontalThumb      = ((FrameworkElement)VisualTreeHelper.GetChild(SliderElement, 0)).FindName("HorizontalThumb") as Thumb;

            if (horizontalThumb != null)
            {
                var interactivityBehaviorCollection = new Microsoft.Xaml.Interactivity.BehaviorCollection();


                var trigger_one = new Microsoft.Xaml.Interactions.Core.EventTriggerBehavior()
                {
                    EventName = "DragStarted"
                };
                var trigger_two = new Microsoft.Xaml.Interactions.Core.EventTriggerBehavior()
                {
                    EventName = "DragDelta"
                };
                var trigger_three = new Microsoft.Xaml.Interactions.Core.EventTriggerBehavior()
                {
                    EventName = "DragCompleted"
                };

                var action_one = new Microsoft.Xaml.Interactions.Core.InvokeCommandAction()
                {
                    Command = _mainVM.ThumbDragStartedCommand
                };
                var action_two = new Microsoft.Xaml.Interactions.Core.InvokeCommandAction()
                {
                    Command = _mainVM.ThumbDragDeltaCommand
                };
                var action_three = new Microsoft.Xaml.Interactions.Core.InvokeCommandAction()
                {
                    Command = _mainVM.ThumbDragCompleteCommand
                };


                trigger_one.Actions.Add(action_one);
                trigger_two.Actions.Add(action_two);
                trigger_three.Actions.Add(action_three);

                interactivityBehaviorCollection.Add(trigger_one);
                interactivityBehaviorCollection.Add(trigger_two);
                interactivityBehaviorCollection.Add(trigger_three);

                interactivityBehaviorCollection.Attach(horizontalThumb);
            }


            if (navigationBackButton != null)
            {
                _mainVM.NavigationViewBackButton            = navigationBackButton;
                _mainVM.NavigationViewBackButton.Visibility = Visibility.Collapsed;
            }

            _messenger.Send <NotificationMessage <Type>, MainViewModel>(new NotificationMessage <Type>(typeof(DefaultView), Core.Enumeration.Message.NOTIFICATION_VIEW_HAS_BEEN_BUILT));
        }
예제 #2
0
        //private void Scroller_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
        //{
        //    if (ContentRoot.Children.Count > 0)
        //    {
        //        if (Scroller.VerticalOffset >= Scroller.ScrollableHeight)
        //        {
        //            var element = ContentRoot.Children
        //            .Where(item => item.Visibility == Visibility.Collapsed)
        //            .FirstOrDefault();

        //            if (element != null)
        //                element.Visibility = Visibility.Visible;
        //        }

        //    }
        //}

        //private UIElement CreateFlipViewChild<T>(T datas)
        //{
        //    FlipView _flipView = new FlipView { HorizontalAlignment = HorizontalAlignment.Stretch };
        //    _flipView.ItemTemplate = Application.Current.Resources["FlipViewItemTemplate"] as DataTemplate;
        //    _flipView.ItemsSource = datas;
        //    _flipView.SelectedIndex = 1;
        //    return _flipView;
        //}
        private void Scroller_Loaded(object sender, RoutedEventArgs e)
        {
            ScrollBar scrollBar = ((FrameworkElement)VisualTreeHelper.GetChild(Scroller, 0)).FindName("VerticalScrollBar") as ScrollBar;

            if (scrollBar != null)
            {
                var trigger = new Microsoft.Xaml.Interactions.Core.EventTriggerBehavior()
                {
                    EventName = "ValueChanged"
                };
                var action = new Microsoft.Xaml.Interactions.Core.InvokeCommandAction()
                {
                    Command = _defaultVM.ScrollerBarValueChangedCommand
                };
                trigger.Actions.Add(action);
                trigger.Attach(scrollBar);

                _defaultVM.ScrollerBar = scrollBar;
            }

            _messenger.Send <NotificationMessage, DefaultViewModel>(new NotificationMessage(Core.Enumeration.Message.NOTIFICATION_VIEW_HAS_BEEN_BUILT));
        }
예제 #3
0
        private async void CastItemPointerEnteredAction(PointerRoutedEventArgs args)
        {
            args.Handled = true;

            var originalSource = args.OriginalSource as FrameworkElement;
            var overlayGrid    = originalSource.FindName("OverlayGrid");

            if (overlayGrid != null)
            {
                var overlayCastcontext = originalSource.DataContext as Cast;
                OverlayedCast = overlayCastcontext;


                var grid = overlayGrid as Grid;

                if (OverlayGrid != null)
                {
                    if (ReferenceEquals(grid, OverlayGrid))
                    {
                        return;
                    }

                    else
                    {
                        OverlayGrid.Visibility = Visibility.Collapsed;
                        var fe       = OverlayGrid as FrameworkElement;
                        var playIcon = fe.FindName("PlaybackPlayButton") as FontIcon;
                        if (playIcon != null)
                        {
                            playIcon.Glyph = "\uE768";
                        }
                    }
                }


                grid.Visibility = Visibility.Visible;
                var frameworkElement = grid as FrameworkElement;

                var playFontIcon = frameworkElement.FindName("PlaybackPlayButton") as FontIcon;
                var loveFontIcon = frameworkElement.FindName("PlaybackLoveButton") as FontIcon;
                var infoFontIcon = frameworkElement.FindName("PlaybackInfoButton") as FontIcon;

                var registeredGrid = _alreadyAttachedBehavior.SingleOrDefault(g => ReferenceEquals(g, grid));
                if (registeredGrid == null)
                {
                    var triggerForLoveIcon = new Microsoft.Xaml.Interactions.Core.EventTriggerBehavior()
                    {
                        EventName = "Tapped"
                    };
                    var triggerForPlayIcon = new Microsoft.Xaml.Interactions.Core.EventTriggerBehavior()
                    {
                        EventName = "Tapped"
                    };

                    var actionForLoveIcon = new Microsoft.Xaml.Interactions.Core.InvokeCommandAction()
                    {
                        Command = PlaybackLoveCommand
                    };
                    var actionForPlayIcon = new Microsoft.Xaml.Interactions.Core.InvokeCommandAction()
                    {
                        Command = PlaybackPlayCommand
                    };

                    triggerForLoveIcon.Actions.Add(actionForLoveIcon);
                    triggerForPlayIcon.Actions.Add(actionForPlayIcon);

                    triggerForLoveIcon.Attach(loveFontIcon);
                    triggerForPlayIcon.Attach(playFontIcon);

                    _alreadyAttachedBehavior.Add(grid);
                }

                var _isLoved = await _dbConn.IsAlreadyExist <Cast>(c => c.Title == OverlayedCast.Title);

                if (_isLoved)
                {
                    var castUpdated = await UpdateCastAsync(OverlayedCast);

                    if (castUpdated)
                    {
                        loveFontIcon.Glyph      = "\uEB52";
                        loveFontIcon.Foreground = new SolidColorBrush(Colors.Orange);
                    }
                }
                else
                {
                    loveFontIcon.Glyph      = "\uEB51";
                    loveFontIcon.Foreground = new SolidColorBrush(Colors.White);
                }
                OverlayGrid = grid;
            }
        }