Exemplo n.º 1
0
        private void Preview_ImageOpened(object sender, RoutedEventArgs e)
        {
            var viewModel = ViewModel;

            if (viewModel == null)
            {
                return;
            }

            var image = sender as GalleryContentView;

            if (image.Item != viewModel.FirstItem)
            {
                return;
            }

            var item = image.Item;

            if (item == null)
            {
                return;
            }

            ScrollingHost.Opacity = 0;
            Preview.Opacity       = 1;

            var container = GetContainer(0);

            var animation = ConnectedAnimationService.GetForCurrentView().GetAnimation("FullScreenPicture");

            if (animation != null)
            {
                animation.Configuration = new BasicConnectedAnimationConfiguration();

                _layer.StartAnimation("Opacity", CreateScalarAnimation(0, 1));
                _bottom.StartAnimation("Opacity", CreateScalarAnimation(0, 1));

                if (animation.TryStart(image.Presenter))
                {
                    void handler(ConnectedAnimation s, object args)
                    {
                        animation.Completed -= handler;

                        Transport.Show();
                        ScrollingHost.Opacity = 1;
                        Preview.Opacity       = 0;

                        if (item.IsVideo && container != null)
                        {
                            Play(container.Presenter, item, item.GetFile());
                        }
                    }

                    animation.Completed += handler;

                    return;
                }
            }

            _layer.Opacity = 1;

            Transport.Show();
            ScrollingHost.Opacity = 1;
            Preview.Opacity       = 0;

            if (item.IsVideo && container != null)
            {
                Play(container.Presenter, item, item.GetFile());
            }
        }
Exemplo n.º 2
0
 internal void PrepareConnectedAnimation()
 {
     OnPrepareConnectedAnimation(ConnectedAnimationService.GetForCurrentView());
 }
 public void SetAnimation()
 {
     ConnectedAnimationService.GetForCurrentView()?.PrepareToAnimate(SpotlightViewModel.ImageGalleryAnimationClose, _image);
 }
        private void Frame_Navigated(object sender, Windows.UI.Xaml.Navigation.NavigationEventArgs e)
        {
            var navigatedPage = (sender as Frame).Content as Page;

            if (navigatedPage == null)
            {
                return;
            }

            void loadedHandler(object s, RoutedEventArgs args)
            {
                var page = s as Page;

                page.Loaded -= loadedHandler;

                object parameter;

                if (e.NavigationMode == Windows.UI.Xaml.Navigation.NavigationMode.Back)
                {
                    var sourcePage = (sender as Frame).ForwardStack.LastOrDefault();
                    parameter = sourcePage?.Parameter;
                }
                else
                {
                    parameter = e.Parameter;
                }

                var cas = ConnectedAnimationService.GetForCurrentView();

                var connectedAnimationsProps     = Connected.GetPageConnectedAnimationProperties(page);
                var coordinatedAnimationElements = Connected.GetPageCoordinatedAnimationElements(page);

                foreach (var props in connectedAnimationsProps.Values)
                {
                    var connectedAnimation = cas.GetAnimation(props.Key);
                    var animationHandled   = false;
                    if (connectedAnimation != null)
                    {
                        if (props.IsListAnimation && parameter != null && ApiInformationHelper.IsCreatorsUpdateOrAbove)
                        {
                            foreach (var listAnimProperty in props.ListAnimProperties)
                            {
                                if (listAnimProperty.ListViewBase.ItemsSource is IEnumerable <object> items && items.Contains(parameter))
                                {
                                    listAnimProperty.ListViewBase.ScrollIntoView(parameter);

                                    // give time to the UI thread to scroll the list
                                    var t = listAnimProperty.ListViewBase.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
                                    {
                                        try
                                        {
                                            var success = await listAnimProperty.ListViewBase.TryStartConnectedAnimationAsync(connectedAnimation, parameter, listAnimProperty.ElementName);
                                        }
                                        catch (Exception)
                                        {
                                            connectedAnimation.Cancel();
                                        }
                                    });

                                    animationHandled = true;
                                }
                            }
                        }
                        else if (!props.IsListAnimation)
                        {
                            if (ApiInformationHelper.IsCreatorsUpdateOrAbove && coordinatedAnimationElements.TryGetValue(props.Element, out var coordinatedElements))
                            {
                                connectedAnimation.TryStart(props.Element, coordinatedElements);
                            }
                            else
                            {
                                connectedAnimation.TryStart(props.Element);
                            }

                            animationHandled = true;
                        }
                    }

                    if (_previousPageConnectedAnimationProps.ContainsKey(props.Key) && animationHandled)
                    {
                        _previousPageConnectedAnimationProps.Remove(props.Key);
                    }
                }

                // if there are animations that were prepared on previous page but no elements on this page have the same key - cancel
                foreach (var previousProps in _previousPageConnectedAnimationProps)
                {
                    var connectedAnimation = cas.GetAnimation(previousProps.Key);
                    connectedAnimation?.Cancel();
                }

                _previousPageConnectedAnimationProps.Clear();
            }

            navigatedPage.Loaded += loadedHandler;
        }
Exemplo n.º 5
0
 protected virtual void OnPrepareConnectedAnimation(ConnectedAnimationService service)
 {
 }
        public MainPage()
        {
            InitializeComponent();

            //ApplicationView.PreferredLaunchViewSize = new Size(1440, 936);
            //ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;

            CustomizeTitleBar();
            void CustomizeTitleBar()
            {
                var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;

                // Draw into the title bar.
                coreTitleBar.ExtendViewIntoTitleBar = true;
                DraggableAppTitleBarArea.Height     = coreTitleBar.Height;

                // Set a draggable region.
                Window.Current.SetTitleBar(DraggableAppTitleBarArea);

                coreTitleBar.LayoutMetricsChanged += (s, args) =>
                {
                    DraggableAppTitleBarArea.Height = s.Height;
                };

                coreTitleBar.IsVisibleChanged += (s, args) =>
                {
                    DraggableAppTitleBarArea.Visibility = s.IsVisible ? Visibility.Visible : Visibility.Collapsed;
                };

                // Remove the solid-colored backgrounds behind the caption controls and system back button.
                var viewTitleBar = ApplicationView.GetForCurrentView().TitleBar;

                viewTitleBar.ButtonBackgroundColor         = Colors.Transparent;
                viewTitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
                viewTitleBar.ButtonForegroundColor         = Color.FromArgb(255, 4, 119, 191);
            }

            ConnectedAnimationService.GetForCurrentView().DefaultDuration = TimeSpan.FromMilliseconds(400);

            if (MainNav.MenuItems[0] is WinUI.NavigationViewItemBase item)
            {
                MainNav.SelectedItem = item;
                NavigateToPage(item.Tag);
            }

            Window.Current.SizeChanged += async(s, e) =>
            {
                await Task.Delay(1200);

                var isSpanned = ApplicationView.GetForCurrentView().ViewMode == ApplicationViewMode.Spanning;
                if (isSpanned)
                {
                    Logo.GoToDualScreenState();
                }
                else
                {
                    Logo.GoToSingleScreenState();
                }
            };

            Loaded += async(s, e) =>
            {
                var titleBarHeight = CoreApplication.GetCurrentView().TitleBar.Height;
                MainNav.Padding = new Thickness(0, titleBarHeight, 0, 0);

                Logo.Start();

                _sensor = await HingeAngleSensor.GetDefaultAsync();

                if (_sensor != null)
                {
                    _sensor.ReportThresholdInDegrees = _sensor.MinReportThresholdInDegrees;

                    _sensor.ReadingChanged += OnSensorReadingChanged;
                    var current = (await _sensor.GetCurrentReadingAsync()).AngleInDegrees;
                }

                async void OnSensorReadingChanged(HingeAngleSensor sender, HingeAngleSensorReadingChangedEventArgs args)
                {
                    // Event is invoked from a different thread.
                    await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
                    {
                        double angle = 0.0;

                        if (args.Reading.AngleInDegrees <= 180)
                        {
                            angle = args.Reading.AngleInDegrees / 2 - 90;
                        }
                        else
                        {
                            angle = (args.Reading.AngleInDegrees - 180) * 2;
                        }

                        Logo.SetAngle(angle);
                    });
                }
            };
        }
Exemplo n.º 7
0
        private void Preview_ImageOpened(object sender, RoutedEventArgs e)
        {
            var viewModel = ViewModel;

            if (viewModel == null)
            {
                return;
            }

            var image = sender as GalleryContentView;

            if (image.Item != viewModel.FirstItem)
            {
                return;
            }

            var item = image.Item as GalleryContent;

            if (item == null)
            {
                return;
            }

            ScrollingHost.Opacity = 0;
            Preview.Opacity       = 1;

            var container = GetContainer(0);

            var animation = ConnectedAnimationService.GetForCurrentView().GetAnimation("FullScreenPicture");

            if (animation != null)
            {
                if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Media.Animation.ConnectedAnimation", "Configuration"))
                {
                    animation.Configuration = new BasicConnectedAnimationConfiguration();
                }

                _layer.StartAnimation("Opacity", CreateScalarAnimation(0, 1));

                if (animation.TryStart(image.Presenter))
                {
                    TypedEventHandler <ConnectedAnimation, object> handler = null;
                    handler = (s, args) =>
                    {
                        animation.Completed -= handler;

                        Transport.Show();
                        ScrollingHost.Opacity = 1;
                        Preview.Opacity       = 0;

                        if (item.IsVideo && container != null)
                        {
                            Play(container.Presenter, item, item.GetFile());
                        }
                    };

                    animation.Completed += handler;

                    return;
                }
            }

            _layer.Opacity = 1;

            Transport.Show();
            ScrollingHost.Opacity = 1;
            Preview.Opacity       = 0;

            if (item.IsVideo && container != null)
            {
                Play(container.Presenter, item, item.GetFile());
            }
        }
Exemplo n.º 8
0
 protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
 {
     ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("InitToWaitingRoomTextBlockConnectedAnimation", TextBlock_UserName);
 }
Exemplo n.º 9
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (e.NavigationMode == NavigationMode.Back)
            {
                // 滚动到之前的地方
                ThreadPoolTimer DelayTimer = ThreadPoolTimer.CreateTimer(async(source) =>
                {
                    await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
                    {
                        var transform = gridView.TransformToVisual(ScrollPage);
                        var point     = transform.TransformPoint(new Point(0, 0));
                        if (point.Y != 0)
                        {
                            var y = point.Y + ScrollPage.VerticalOffset;
                            if (y < 200)
                            {
                                y += 200;
                            }
                            ScrollPage.ChangeView(null, y - 200, null, true);
                        }
                    });
                }, TimeSpan.FromSeconds(0.1));
                ChangeBG();
                MovieImage.Source = ImageCacheService.GetImage(TimeAPIService.CurrentDetail.Image);
                await ViewModel.LoadAnimationAsync();
            }
            else
            {
                var data = e.Parameter as MovieItemDetail;
                if (data != null && data.ID == null)
                {
                    DisplayDeleteFileDialog();
                    return;
                }
                if (data == null)
                {
                    data = JsonConvert.DeserializeObject <MovieItemDetail>((e.Parameter as JObject).ToString());
                }
                AddData(data);
                MovieImage.Source = ImageCacheService.GetImage(data.Image); // new BitmapImage(new Uri(data.Image));
                ConnectedAnimation imageAnimation = ConnectedAnimationService.GetForCurrentView().GetAnimation("Image");
                if (imageAnimation != null)
                {
                    imageAnimation.TryStart(MovieImage);
                }

                // History Add
                string[] types = data.MovieType.Split(new char[] { ' ' });
                foreach (string type in types)
                {
                    if (type.Length != 0)
                    {
                        Singleton <MyCollectViewModel> .Instance.HistoryAdd(type);
                    }
                }
                Singleton <MyCollectViewModel> .Instance.SaveHistory();
            }
            collectionButton();
            Singleton <SuspendAndResumeService> .Instance.OnBackgroundEntering += Instance_OnBackgroundEntering;
        }
Exemplo n.º 10
0
 protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
 {
     base.OnNavigatingFrom(e);
     ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("animation2", DetailTopPanel);
 }
Exemplo n.º 11
0
 private async void SchoolLogo_Click(object sender, RoutedEventArgs e)
 {
     ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("ForwardConnectedAnimation", SchoolLogo);
     var schoolDialog = new SchoolsDialog();
     await schoolDialog.ShowAsync();
 }
Exemplo n.º 12
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("MainStackPanel", MainStackPanel);
     Frame.Navigate(typeof(MenuPage));
 }
Exemplo n.º 13
0
 private void UIElement_OnTapped(object sender, TappedRoutedEventArgs e)
 {
     ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("SongListExpand", ImageContainer);
     ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("SongListExpandAcrylic", GridInfo);
     Common.BaseFrame.Navigate(typeof(SongListDetail), playList, new DrillInNavigationTransitionInfo());
 }
 private void Button_Tapped(object sender, TappedRoutedEventArgs e)
 {
     ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("cat", Cat);
     this.Frame.Navigate(typeof(MainPage));
 }
Exemplo n.º 15
0
 private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
 {
     ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("Image", SourveImage);
     this.Frame.Navigate(typeof(Page2), SourveImage.Source);
 }
Exemplo n.º 16
0
 public static void PrepAnimation(string name, UIElement elem)
 => ConnectedAnimationService.GetForCurrentView().PrepareToAnimate(name, elem);
Exemplo n.º 17
0
 private void OnSaveClicked(object sender, RoutedEventArgs e)
 {
     ConnectedAnimationService.GetForCurrentView().PrepareToAnimate(Constants.ConnectedAnimationKey, CoverImage);
 }
Exemplo n.º 18
0
 protected override void OnNavigatedFrom(NavigationEventArgs e)
 {
     base.OnNavigatedFrom(e);
     ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("DetailToInvoice", InvoiceDetailsHeader);
 }
Exemplo n.º 19
0
        protected override void OnBackRequestedOverride(object sender, HandledEventArgs e)
        {
            if (!_wasFullScreen)
            {
                ApplicationView.GetForCurrentView().ExitFullScreenMode();
            }

            if (ViewModel != null)
            {
                ViewModel.Aggregator.Unsubscribe(this);

                ViewModel.Delegate = null;
                ViewModel.Items.CollectionChanged -= OnCollectionChanged;

                Bindings.StopTracking();
            }

            //var container = GetContainer(0);
            //var root = container.Presenter;
            if (ViewModel != null && ViewModel.SelectedItem == ViewModel.FirstItem && _closing != null)
            {
                ScrollingHost.Opacity = 0;
                Preview.Opacity       = 1;

                var root = Preview.Presenter;

                var animation = ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("FullScreenPicture", root);
                if (animation != null)
                {
                    if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Media.Animation.ConnectedAnimation", "Configuration"))
                    {
                        animation.Configuration = new BasicConnectedAnimationConfiguration();
                    }

                    var element = _closing();
                    if (element.ActualWidth > 0 && animation.TryStart(element))
                    {
                        TypedEventHandler <ConnectedAnimation, object> handler = null;
                        handler = (s, args) =>
                        {
                            animation.Completed -= handler;
                            Hide();
                        };

                        animation.Completed += handler;
                    }
                    else
                    {
                        Hide();
                    }
                }
                else
                {
                    Hide();
                }
            }
            else
            {
                var batch = _layout.Compositor.CreateScopedBatch(CompositionBatchTypes.Animation);

                _layout.StartAnimation("Offset.Y", CreateScalarAnimation(_layout.Offset.Y, (float)ActualHeight));

                batch.End();
                batch.Completed += (s, args) =>
                {
                    ScrollingHost.Opacity = 0;
                    Preview.Opacity       = 1;

                    Hide();
                };
            }

            _layer.StartAnimation("Opacity", CreateScalarAnimation(1, 0));

            if (Transport.IsVisible)
            {
                Transport.Hide();
            }

            Unload();
            Dispose();

            e.Handled = true;
        }
Exemplo n.º 20
0
        //check
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            //PenInputToggle.IsChecked = false;
            //FrontInk.IsHitTestVisible = false;
            //FrontText.IsHitTestVisible = true;
            //BackText.IsHitTestVisible = true;
            //BackInk.IsHitTestVisible = false;
            //InputMethod.Visibility = Visibility.Collapsed;
            Inputindicator.Symbol = Symbol.Edit;
            FrontInk.InkPresenter.InputDeviceTypes = CoreInputDeviceTypes.Pen;
            BackInk.InkPresenter.InputDeviceTypes  = CoreInputDeviceTypes.Pen;
            if (CardPage.showFront)
            {
                CardPage.togle.Content   = "Showing front";
                CardPage.togle.IsChecked = true;
            }
            else
            {
                CardPage.togle.Content   = "Showing back";
                CardPage.togle.IsChecked = false;
            }
            FrontGrid.ItemsSource = App.viewModel.cards;
            BackGrid.ItemsSource  = App.viewModel.cards;
            resetVisibility();
            FrontInk.InkPresenter.StrokeContainer.Clear();
            BackInk.InkPresenter.StrokeContainer.Clear();
            await getCard(true);
            await getCard(false);
            await getInk(true);
            await getInk(false);

            FrontRESIZE.Background = new SolidColorBrush(CardPage.selected.Background);
            BackRESIZE.Background  = new SolidColorBrush(CardPage.selected.Background);
            FrontText.FontSize     = CardPage.selected.FrontFontSize;
            BackText.FontSize      = CardPage.selected.BackFontSize;
            colorindicator.Fill    = new SolidColorBrush(CardPage.selected.Background);
            FrontText.Foreground   = new SolidColorBrush(CardPage.selected.TextColor);
            BackText.Foreground    = new SolidColorBrush(CardPage.selected.TextColor);

            FrontGrid.IsMultiSelectCheckBoxEnabled = false;
            BackGrid.IsMultiSelectCheckBoxEnabled  = false;
            FrontGrid.SelectionMode      = ListViewSelectionMode.Single;
            BackGrid.SelectionMode       = ListViewSelectionMode.Single;
            FrontGrid.IsItemClickEnabled = true;
            BackGrid.IsItemClickEnabled  = true;
            FrontGrid.SelectedItem       = CardPage.selected;
            BackGrid.SelectedItem        = CardPage.selected;
            ConnectedAnimation animation = ConnectedAnimationService.GetForCurrentView().GetAnimation("OpenCard");

            if (CardPage.showFront)
            {
                front.Visibility = Visibility.Visible;
                back.Visibility  = Visibility.Collapsed;
            }
            else
            {
                front.Visibility = Visibility.Collapsed;
                back.Visibility  = Visibility.Visible;
            }

            if (animation != null)
            {
                animation.TryStart(RootGrid);
            }
            if (front.Visibility == Visibility.Visible)
            {
                fb.Text = "Front";
                FrontInkBar.Visibility = Visibility.Visible;
                BackInkBar.Visibility  = Visibility.Collapsed;
                fontsize.Content       = "" + CardPage.selected.FrontFontSize;
            }
            else if (back.Visibility == Visibility.Visible)
            {
                fb.Text = "Back";
                BackInkBar.Visibility  = Visibility.Visible;
                FrontInkBar.Visibility = Visibility.Collapsed;
                fontsize.Content       = "" + CardPage.selected.BackFontSize;
            }

            var i = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                FrontGrid.ScrollIntoView(FrontGrid.SelectedItem, ScrollIntoViewAlignment.Leading);
                BackGrid.ScrollIntoView(BackGrid.SelectedItem, ScrollIntoViewAlignment.Leading);
            });
        }
Exemplo n.º 21
0
 protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
 {
     ConnectedAnimationService.GetForCurrentView()
     .PrepareToAnimate("forwardAnimation", extendedSplashImage);
 }
Exemplo n.º 22
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                var frameState = SuspensionManager.SessionStateForFrame(this.Frame);


                if (this.Frame.CanGoForward && frameState.ContainsKey("Page-" + (this.Frame.BackStackDepth + 1)))
                {
                    // Jump to the pivot where user left
                    if (frameState.ContainsKey("Page-" + (this.Frame.BackStackDepth)))
                    {
                        var thisPageParameters = frameState["Page-" + (this.Frame.BackStackDepth)] as IDictionary <string, object>;
                        if (thisPageParameters.ContainsKey("Tab") && MainPivot.SelectedIndex != (int)(thisPageParameters["Tab"]))
                        {
                            // Work around to disable to pivot turning animation by changing the index twice
                            MainPivot.SelectedIndex = (MainPivot.SelectedIndex + 2) % 4;
                            MainPivot.SelectedIndex = (MainPivot.SelectedIndex + 1) % 4;
                            MainPivot.SelectedIndex = (int)(thisPageParameters["Tab"]);

                            //MainPivot.UpdateLayout();
                        }
                    }



                    // Jump to the page item if this is a back button action
                    var lastPageParameters = frameState["Page-" + (this.Frame.BackStackDepth + 1)] as IDictionary <string, object>;
                    if (lastPageParameters.ContainsKey("Index") && lastPageParameters.ContainsKey("PostId"))
                    {
                        var index  = (int)lastPageParameters["Index"];
                        var postId = (int)lastPageParameters["PostId"];


                        if (this.HomeViewModel.SelectedViewIndex == 0)
                        {
                            // Pre-fall creator has different image loading order
                            // unable to share same connected animation code without breaking the UI
                            if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 5))
                            {
                                var post = FeatureView.FeatureViewModel.TopToday.First(o => o.Id == postId);
                                if (post != null && FeatureView.FeatureViewModel.TopToday.IndexOf(post) != -1)
                                {
                                    // Start the animation
                                    ConnectedAnimation animation = ConnectedAnimationService.GetForCurrentView().GetAnimation("PreviewImage");
                                    if (animation != null)
                                    {
                                        FeatureView.UpdateLayout();
                                        var button = this.FeatureView.GetTopTodayButton(FeatureView.FeatureViewModel.TopToday.IndexOf(post)) as Button;
                                        var image  = ((UIElement)((Border)button.Content).Child) as ImageCropper;
                                        animation.TryStart(image.ImageInside);
                                    }
                                }
                            }
                        }
                        else if (this.HomeViewModel.SelectedViewIndex == 1 || this.HomeViewModel.SelectedViewIndex == 2)
                        {
                            JustifiedWrapPanel panel = null;
                            if (this.HomeViewModel.SelectedViewIndex == 1)
                            {
                                // Navigating back from a search result image
                                panel = BrowsePanel;
                            }
                            else if (this.HomeViewModel.SelectedViewIndex == 2)
                            {
                                // Navigating back from a favorite image
                                panel = FavoritePanel;
                            }

                            // Scroll into the index of last opened page
                            panel.ScrollIntoView((panel.ItemsSource as IList)[index], ScrollIntoViewAlignment.Default);
                            panel.UpdateLayout();



                            // Pre-fall creator has different image loading order
                            // unable to share same connected animation code without breaking the UI
                            if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 5))
                            {
                                // Start the animation
                                ConnectedAnimation animation = ConnectedAnimationService.GetForCurrentView().GetAnimation("PreviewImage");
                                if (animation != null)
                                {
                                    if (panel.ContainerFromIndex(index) is ContentControl container)
                                    {
                                        var root  = (FrameworkElement)container.ContentTemplateRoot;
                                        var image = (UIElement)root.FindName("PreviewImage");
                                        animation.TryStart(image);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 23
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            Debug.Assert(e.Parameter != null, "e.Parameter != null");
            base.OnNavigatedTo(e);
            var reset   = e.NavigationMode == NavigationMode.New;
            var restore = e.NavigationMode == NavigationMode.Back;

            this.ViewModel = GalleryVM.GetVM((long)e.Parameter);
            var idx = this.ViewModel.View.CurrentPosition;

            this.ViewModel.View.IsCurrentPositionLocked = false;
            if (reset)
            {
                changeViewTo(false, true);

                this.gv.ScrollIntoView(this.ViewModel.Gallery.First());

                if (this.ViewModel.Gallery.Comments.IsLoaded)
                {
                    this.lv_Comments.ScrollIntoView(this.lv_Comments.Items.FirstOrDefault());
                }
                else
                {
                    void handler(object s, System.ComponentModel.PropertyChangedEventArgs args)
                    {
                        var sender = (ExClient.Galleries.Commenting.CommentCollection)s;

                        if (string.IsNullOrEmpty(args.PropertyName) || args.PropertyName == nameof(sender.IsLoaded))
                        {
                            sender.PropertyChanged -= handler;
                            if (!sender.IsEmpty)
                            {
                                this.lv_Comments.ScrollIntoView(sender[0]);
                            }
                        }
                    }

                    this.ViewModel.Gallery.Comments.PropertyChanged += handler;
                }

                this.lv_Torrents.ScrollIntoView(this.lv_Torrents.Items.FirstOrDefault());

                await Task.Delay(33);

                this.pv.Focus(FocusState.Programmatic);
                this.pv.SelectedIndex = 0;
            }
            else if (restore)
            {
                var animation = ConnectedAnimationService.GetForCurrentView().GetAnimation("ImageAnimation");
                changeViewTo(true, true);
                if (this.ViewModel.View.CurrentItem is null)
                {
                    this.ViewModel.View.MoveCurrentToFirst();
                    idx = 0;
                }
                this.gv.ScrollIntoView(this.ViewModel.View.CurrentItem, ScrollIntoViewAlignment.Leading);
                await Dispatcher.Yield(CoreDispatcherPriority.Low);

                var container = (Control)this.gv.ContainerFromIndex(idx);
                if (container != null && this.pv.SelectedIndex == 0)
                {
                    container.Focus(FocusState.Programmatic);
                }
                if (animation != null)
                {
                    if (this.pv.SelectedIndex == 0 && container != null)
                    {
                        await this.gv.TryStartConnectedAnimationAsync(animation, this.ViewModel.View.CurrentItem, "Image");
                    }
                    else
                    {
                        animation.Cancel();
                    }
                }
                await Dispatcher.YieldIdle();

                container = (Control)this.gv.ContainerFromIndex(idx);
                if (container != null && this.pv.SelectedIndex == 0)
                {
                    container.Focus(FocusState.Programmatic);
                }
            }
        }
Exemplo n.º 24
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            MainVM = e.Parameter as MainViewModel;
            if (!MainVM.DetailViewModel.Animate)
            {
                //Wave 1st
                var animGroup1 = _compositor.CreateAnimationGroup();
                var fadeIn1    = _compositor.CreateScalarKeyFrameAnimation();
                fadeIn1.Target   = "Opacity";
                fadeIn1.Duration = TimeSpan.FromMilliseconds(500);
                fadeIn1.InsertKeyFrame(0, 0);
                fadeIn1.InsertKeyFrame(1, 1);
                fadeIn1.DelayTime = TimeSpan.FromMilliseconds(400);
                var offSet1 = _compositor.CreateVector3KeyFrameAnimation();
                offSet1.Target   = "Translation";
                offSet1.Duration = TimeSpan.FromMilliseconds(400);
                offSet1.InsertKeyFrame(0f, new Vector3(-10, 0, 0));
                offSet1.InsertKeyFrame(1f, new Vector3(0, 0, 0));
                offSet1.DelayTime = TimeSpan.FromMilliseconds(400);

                animGroup1.Add(fadeIn1);
                animGroup1.Add(offSet1);

                //Wave 2nd
                var animGroup2 = _compositor.CreateAnimationGroup();
                var fadeIn2    = _compositor.CreateScalarKeyFrameAnimation();
                fadeIn2.Target   = "Opacity";
                fadeIn2.Duration = TimeSpan.FromMilliseconds(500);
                fadeIn2.InsertKeyFrame(0, 0);
                fadeIn2.InsertKeyFrame(1, 1);
                fadeIn2.DelayTime = TimeSpan.FromMilliseconds(650);
                var offSet2 = _compositor.CreateVector3KeyFrameAnimation();
                offSet2.Target   = "Translation";
                offSet2.Duration = TimeSpan.FromMilliseconds(400);
                offSet2.InsertKeyFrame(0f, new Vector3(-10, 0, 0));
                offSet2.InsertKeyFrame(1f, new Vector3(0, 0, 0));
                offSet2.DelayTime = TimeSpan.FromMilliseconds(550);
                animGroup2.Add(fadeIn2);
                animGroup2.Add(offSet2);


                //Wave 3rd
                var animGroup3 = _compositor.CreateAnimationGroup();
                var fadeIn3    = _compositor.CreateScalarKeyFrameAnimation();
                fadeIn3.Target   = "Opacity";
                fadeIn3.Duration = TimeSpan.FromMilliseconds(500);
                fadeIn3.InsertKeyFrame(0, 0);
                fadeIn3.InsertKeyFrame(1, 1);
                fadeIn3.DelayTime = TimeSpan.FromMilliseconds(800);
                var offSet3 = _compositor.CreateVector3KeyFrameAnimation();
                offSet3.Target   = "Translation";
                offSet3.Duration = TimeSpan.FromMilliseconds(400);
                offSet3.InsertKeyFrame(0f, new Vector3(-10, 0, 0));
                offSet3.InsertKeyFrame(1f, new Vector3(0, 0, 0));
                offSet3.DelayTime = TimeSpan.FromMilliseconds(700);
                animGroup3.Add(fadeIn3);
                animGroup3.Add(offSet3);


                var fadeOut = _compositor.CreateScalarKeyFrameAnimation();
                fadeOut.Target    = "Opacity";
                fadeOut.Duration  = TimeSpan.FromMilliseconds(500);
                fadeOut.DelayTime = TimeSpan.FromMilliseconds(500);
                fadeOut.InsertKeyFrame(0, 1);
                fadeOut.InsertKeyFrame(1, 0);

                ElementCompositionPreview.SetImplicitShowAnimation(PlayButton, animGroup2);
                ElementCompositionPreview.SetImplicitShowAnimation(AddToButton, animGroup2);
                ElementCompositionPreview.SetImplicitShowAnimation(ExitButton, animGroup1);
                ElementCompositionPreview.SetImplicitShowAnimation(list, animGroup3);
                ElementCompositionPreview.SetImplicitShowAnimation(AlbumYearTextBlock, animGroup1);
                ElementCompositionPreview.SetImplicitShowAnimation(AlbumNameTextBlock, animGroup1);
                ElementCompositionPreview.SetImplicitShowAnimation(TitleTextBlock, animGroup1);


                ElementCompositionPreview.SetImplicitHideAnimation(PlayButton, fadeOut);
                ElementCompositionPreview.SetImplicitHideAnimation(AddToButton, fadeOut);
                ElementCompositionPreview.SetImplicitHideAnimation(ExitButton, fadeOut);
                ElementCompositionPreview.SetImplicitHideAnimation(list, fadeOut);
                ElementCompositionPreview.SetImplicitHideAnimation(AlbumYearTextBlock, fadeOut);
                ElementCompositionPreview.SetImplicitHideAnimation(AlbumNameTextBlock, fadeOut);
                ElementCompositionPreview.SetImplicitHideAnimation(TitleTextBlock, fadeOut);
            }
            else
            {
                _playButtonVisual.Opacity         = 1f;
                _addToButtonVisual.Opacity        = 1f;
                _exitButtonVisual.Opacity         = 1f;
                _musicListVisual.Opacity          = 1f;
                _albumNameTextBlockVisual.Opacity = 1f;
                _albumYearTextBlockVisual.Opacity = 1f;
                _titleTextBlockVisual.Opacity     = 1f;
            }
            base.OnNavigatedTo(e);

            animation = ConnectedAnimationService.GetForCurrentView().GetAnimation("ca1");
            if (animation != null)
            {
                animation.TryStart(ThumbnailImage);
            }
        }
Exemplo n.º 25
0
 protected virtual void OnUsingConnectedAnimation(ConnectedAnimationService service)
 {
 }
Exemplo n.º 26
0
 public void RequestGoBack()
 {
     ConnectedAnimationService.GetForCurrentView().PrepareToAnimate(Consts.AlbumItemConnectedAnimation + "_1", Title);
     ConnectedAnimationService.GetForCurrentView().PrepareToAnimate(Consts.AlbumItemConnectedAnimation + "_2", Image);
     LibraryPage.Current.GoBack();
 }
Exemplo n.º 27
0
 internal void UsingConnectedAnimation()
 {
     OnUsingConnectedAnimation(ConnectedAnimationService.GetForCurrentView());
 }
Exemplo n.º 28
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            ConnectedAnimation imageAnimation =
                ConnectedAnimationService.GetForCurrentView().GetAnimation("avatar");

            if (App.navImageCache != null)
            {
                AvatarFull.ImageSource = App.navImageCache;
                App.navImageCache      = null;
                navFromFlyout          = true;
            }



            if (imageAnimation != null)
            {
                imageAnimation.TryStart(FullAvatar);
            }

            //Windows.UI.Color? color = (await App.getUserColor((e.Parameter as User)));

            //UserAccent = new SolidColorBrush(color.HasValue ? color.Value : (Windows.UI.Color)App.Current.Resources["BlurpleColor"]);

            bool loadviaRest = true;

            if (e.Parameter is User)
            {
                profile      = new DiscordAPI.SharedModels.UserProfile();
                profile.user = (User)e.Parameter;
                if (profile.user.Bot)
                {
                    grid.VerticalAlignment = VerticalAlignment.Center;
                }

                userid = profile.user.Id;
            }
            else if (e.Parameter is string)
            {
                userid  = (e.Parameter as string);
                profile = await RESTCalls.GetUserProfile(e.Parameter as string);

                loadviaRest = false;
            }
            else
            {
                CloseButton_Click(null, null);
                return;
            }
            if (LocalState.Friends.ContainsKey(profile.user.Id))
            {
                profile.Friend = LocalState.Friends[profile.user.Id];
            }
            else
            {
                profile.Friend = null;
            }

            if (LocalState.PresenceDict.ContainsKey(userid))
            {
                if (LocalState.PresenceDict[userid].Status != null && LocalState.PresenceDict[userid].Status != "invisible")
                {
                    rectangle.Fill = (SolidColorBrush)App.Current.Resources[LocalState.PresenceDict[userid].Status];
                }
                else if (LocalState.PresenceDict[userid].Status == "invisible")
                {
                    rectangle.Fill = (SolidColorBrush)App.Current.Resources["offline"];
                }
            }
            else
            {
                rectangle.Fill = (SolidColorBrush)App.Current.Resources["offline"];
            }

            if (userid == LocalState.CurrentUser.Id)
            {
                AccountSettings.Visibility = Visibility.Visible;
            }
            else
            {
                AccountSettings.Visibility = Visibility.Collapsed;
            }


            if (LocalState.PresenceDict.ContainsKey(profile.user.Id))
            {
                if (LocalState.PresenceDict[profile.user.Id].Game != null)
                {
                    richPresence.GameContent = LocalState.PresenceDict[profile.user.Id].Game;
                }
                else
                {
                    richPresence.Visibility = Visibility.Collapsed;
                }
            }
            else
            {
                richPresence.Visibility = Visibility.Collapsed;
            }
            UpdateBorderColor();

            username.Text = profile.user.Username;
            username.Fade(1, 400);
            discriminator.Text = "#" + profile.user.Discriminator;
            discriminator.Fade(0.4f, 800);

            if (profile.Friend != null)
            {
                SwitchFriendValues(profile.Friend.Type);
            }
            else if (profile.user.Id == LocalState.CurrentUser.Id)
            {
            }
            else if (profile.user.Bot)
            {
                SendMessageLink.Visibility = Visibility.Visible;
                Block.Visibility           = Visibility.Visible;
                loadviaRest             = false;
                BotIndicator.Visibility = Visibility.Visible;
            }
            else
            {
                sendFriendRequest.Visibility = Visibility.Visible;
                SendMessageLink.Visibility   = Visibility.Visible;
                Block.Visibility             = Visibility.Visible;
                BotIndicator.Visibility      = Visibility.Collapsed;
            }


            if (LocalState.Notes.ContainsKey(profile.user.Id))
            {
                NoteBox.Text = LocalState.Notes[profile.user.Id];
            }

            GatewayManager.Gateway.UserNoteUpdated     += Gateway_UserNoteUpdated;
            GatewayManager.Gateway.PresenceUpdated     += Gateway_PresenceUpdated;
            GatewayManager.Gateway.RelationShipAdded   += Gateway_RelationshipAdded;
            GatewayManager.Gateway.RelationShipUpdated += Gateway_RelationshipUpdated;
            GatewayManager.Gateway.RelationShipRemoved += Gateway_RelationshipRemoved;

            //  BackgroundGrid.Blur(8, 0).Start();
            base.OnNavigatedTo(e);



            switch (profile.user.Flags)
            {
            case 1:
            {
                var img = new Image()
                {
                    MaxHeight = 28,
                    Source    = new BitmapImage(new Uri("ms-appx:///Assets/DiscordBadges/staff.png")),
                    Opacity   = 0
                };
                ToolTipService.SetToolTip(img, App.GetString("/Dialogs/FlagDiscordStaff").ToUpper());
                BadgePanel.Children.Add(img);
                img.Fade(1).Start();
                break;
            }

            case 2:
            {
                var img = new Image()
                {
                    MaxHeight = 28,
                    Source    = new BitmapImage(new Uri("ms-appx:///Assets/DiscordBadges/partner.png")),
                    Opacity   = 0
                };
                ToolTipService.SetToolTip(img, App.GetString("/Dialogs/FlagDiscordPartner").ToUpper());
                BadgePanel.Children.Add(img);
                img.Fade(1).Start();
                break;
            }

            case 4:
            {
                var img = new Image()
                {
                    MaxHeight = 28,
                    Source    = new BitmapImage(new Uri("ms-appx:///Assets/DiscordBadges/hypesquad.png")),
                    Opacity   = 0
                };
                ToolTipService.SetToolTip(img, App.GetString("/Dialogs/FlagHypesquad"));
                BadgePanel.Children.Add(img);
                img.Fade(1).Start();
                break;
            }
            }
            if (profile.user.Id == "109338686889476096")
            {
                ViewStats.Visibility = Visibility.Visible;
            }



            var imageurl = Common.AvatarUri(profile.user.Avatar, profile.user.Id);

            SetupComposition(imageurl);
            var image = new BitmapImage(imageurl);

            if (!navFromFlyout)
            {
                AvatarFull.ImageSource = image;
            }
            //  AvatarBlurred.Source = image;

            if (profile.user.Avatar != null)
            {
                AvatarBG.Fill = Common.GetSolidColorBrush("#00000000");
            }
            else
            {
                AvatarBG.Fill = Common.DiscriminatorColor(profile.user.Discriminator);
            }


            if (profile.user.Bot)
            {
                return;
            }
            if (loadviaRest)
            {
                profile = await RESTCalls.GetUserProfile(profile.user.Id);
            }
            try
            {
                if (profile.PremiumSince.HasValue)
                {
                    var img = new Image()
                    {
                        MaxHeight = 28,
                        Source    = new BitmapImage(new Uri("ms-appx:///Assets/DiscordBadges/nitro.png")),
                        Opacity   = 0
                    };
                    ToolTipService.SetToolTip(img, App.GetString("/Main/PremiumMemberSince") + " " + Common.HumanizeDate(profile.PremiumSince.Value, null));
                    BadgePanel.Children.Add(img);
                    img.Fade(1.2f);
                }

                if (profile.connected_accounts != null)
                {
                    for (int i = 0; i < profile.connected_accounts.Count(); i++)
                    {
                        var    element  = profile.connected_accounts.ElementAt(i);
                        string themeExt = "";
                        if (element.Type.ToLower() == "steam")
                        {
                            if (App.Current.RequestedTheme == ApplicationTheme.Dark)
                            {
                                themeExt = "_light";
                            }
                            else
                            {
                                themeExt = "_dark";
                            }
                        }
                        element.ImagePath = "/Assets/ConnectionLogos/" + element.Type.ToLower() + themeExt + ".png";
                        Connections.Items.Add(element);
                    }
                }

                if (profile.MutualGuilds != null)
                {
                    for (int i = 0; i < profile.MutualGuilds.Count(); i++)
                    {
                        var element = profile.MutualGuilds.ElementAt(i);
                        if (!LocalState.Guilds.ContainsKey(element.Id))
                        {
                            continue;
                        }
                        element.Name      = LocalState.Guilds[element.Id].Raw.Name;
                        element.ImagePath = "https://discordapp.com/api/guilds/" + LocalState.Guilds[element.Id].Raw.Id + "/icons/" + LocalState.Guilds[element.Id].Raw.Icon + ".jpg";

                        if (element.Nick != null)
                        {
                            element.NickVisibility = Visibility.Visible;
                        }
                        else
                        {
                            element.NickVisibility = Visibility.Collapsed;
                        }

                        MutualGuilds.Items.Add(element);
                    }
                    if (MutualGuilds.Items.Count > 0)
                    {
                        commonServerPanel.Visibility = Visibility.Visible;
                        commonserverHeader.Fade(1, 300, 0).Start();
                    }
                }
            }
            catch
            {
            }

            if (profile?.user?.Id != null)
            {
                IEnumerable <SharedFriend> relationships = await RESTCalls.GetUserRelationShips(profile.user.Id);

                int relationshipcount = relationships.Count();

                if (relationshipcount == 0)
                {
                    return;
                }

                commonFriendPanel.Visibility = Visibility.Visible;
                commonfriendHeader.Fade(1, 300, 0).Start();
                for (int i = 0; i < relationshipcount; i++)
                {
                    var relationship = relationships.ElementAt(i);
                    relationship.Discriminator = "#" + relationship.Discriminator;
                    if (relationship.Avatar != null)
                    {
                        relationship.ImagePath = "https://cdn.discordapp.com/avatars/" + relationship.Id + "/" + relationship.Avatar + ".png";
                    }
                    else
                    {
                        relationship.ImagePath = "ms-appx:///Assets/DiscordIcon-old.png";
                    }

                    MutualFriends.Items.Add(relationship);
                }


                //var contact = await Managers.ContactManager.GetContact(profile.user.Id);
                //if (contact != null)
                //{
                //    if (contact.FullName != profile.user.Username + "#" + profile.user.Discriminator)
                //    {
                //        Name.Text = contact.FullName;
                //        Seperate.Visibility = Visibility.Visible;
                //    }
                //}
            }
        }
Exemplo n.º 29
0
 protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
 {
     base.OnNavigatingFrom(e);
     ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("backAnimation", Image);
 }
Exemplo n.º 30
0
 public ConnectedAnimation Prepare()
 {
     return(ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("Crop", m_imageViewer));
 }