private void User_ContextRequested(UIElement sender, ContextRequestedEventArgs args)
        {
            var flyout = new MenuFlyout();

            var element       = sender as FrameworkElement;
            var messageSender = ScrollingHost.ItemFromContainer(element) as MessageSender;

            flyout.Items.Add(new MenuFlyoutItem {
                Text = Strings.Resources.Unblock, Command = ViewModel.UnblockCommand, CommandParameter = messageSender
            });

            if (args.TryGetPosition(sender, out Point point))
            {
                if (point.X < 0 || point.Y < 0)
                {
                    point = new Point(Math.Max(point.X, 0), Math.Max(point.Y, 0));
                }

                flyout.ShowAt(sender, point);
            }
        }
Exemplo n.º 2
0
        private void SetScrollMode(bool enable)
        {
            if (enable)
            {
                ScrollingHost.VerticalScrollMode          = ScrollMode.Auto;
                ScrollingHost.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
                ScrollingHost.ChangeView(null, ScrollingHost.ScrollableHeight - 48, null, false);

                ScrollingInfo.Visibility = Visibility.Visible;
                InfoPanel.Visibility     = Visibility.Collapsed;
            }
            else
            {
                ScrollingHost.ChangeView(null, ScrollingHost.ScrollableHeight, null, true);
                ScrollingHost.VerticalScrollMode          = ScrollMode.Disabled;
                ScrollingHost.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;

                ScrollingInfo.Visibility = Visibility.Collapsed;
                InfoPanel.Visibility     = Visibility.Visible;
            }
        }
Exemplo n.º 3
0
        private async void PanelDoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
        {
            var position = e.GetPosition(Panel);

            if (ScrollingHost.ZoomFactor != 1)
            {
                //ScrollingHost.ZoomToFactor(1);
                ScrollingHost.ChangeView(null, null, 1, true);
            }
            else if (ScrollingHost.ZoomFactor == 1)
            {
                //ScrollingHost.ZoomToFactor(4);

                var dispatcher = Window.Current.CoreWindow.Dispatcher;
                await dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
                {
                    ScrollingHost.ChangeView(position.X, position.Y, 4, true);
                    //ScrollingHost.ScrollToHorizontalOffset(position.X);
                    //ScrollingHost.ScrollToVerticalOffset(position.Y);
                });
            }
        }
Exemplo n.º 4
0
 private void TagsTextBox_SizeChanged(object sender, SizeChangedEventArgs e)
 {
     ScrollingHost.ChangeView(null, ScrollingHost.ScrollableHeight, null);
 }
Exemplo n.º 5
0
 private void ChangeView(int index, bool disableAnimation)
 {
     ScrollingHost.ChangeView(ActualWidth * index, null, null, disableAnimation);
 }
Exemplo n.º 6
0
 private void LayoutRoot_HorizontalSnapPointsChanged(object sender, object e)
 {
     ScrollingHost.HorizontalSnapPointsType = SnapPointsType.None;
     ScrollingHost.ChangeView(LayoutRoot.SnapPointWidth, null, null, true);
     ScrollingHost.HorizontalSnapPointsType = SnapPointsType.MandatorySingle;
 }
 public void Reset()
 {
     ScrollingHost.ChangeView(0, 0, 1, true);
 }
Exemplo n.º 8
0
        private async void Hyperlink_Click(TLTextUrl urlText)
        {
            if (urlText.WebPageId == _webpageId)
            {
                var fragmentStart = urlText.Url.IndexOf('#');
                if (fragmentStart > 0)
                {
                    var name = urlText.Url.Substring(fragmentStart + 1);
                    if (_anchors.TryGetValue(name, out Border anchor))
                    {
                        ScrollingHost.ScrollIntoView(anchor);
                        //anchor.StartBringIntoView();
                        return;

                        if (_scrollingHost == null)
                        {
                            _scrollingHost = ScrollingHost.Descendants <ScrollViewer>().FirstOrDefault() as ScrollViewer;
                        }

                        if (_scrollingHost != null)
                        {
                            var transform = anchor.TransformToVisual(ScrollingHost.ItemsPanelRoot);
                            var position  = transform.TransformPoint(new Point());

                            _scrollingHost.ChangeView(null, Math.Max(0, position.Y - 8), null, false);
                        }
                    }
                }
            }
            else if (urlText.WebPageId != 0)
            {
                var protoService = (MTProtoService)MTProtoService.Current;
                protoService.SendInformativeMessageInternal <TLWebPageBase>("messages.getWebPage", new TLMessagesGetWebPage {
                    Url = urlText.Url, Hash = 0
                },
                                                                            result =>
                {
                    Execute.BeginOnUIThread(() =>
                    {
                        ViewModel.NavigationService.Navigate(typeof(InstantPage), result);
                    });
                },
                                                                            fault =>
                {
                    Debugger.Break();
                });
            }
            else
            {
                var url = urlText.Url;
                if (url.StartsWith("http") == false)
                {
                    url = "http://" + url;
                }

                if (Uri.TryCreate(url, UriKind.Absolute, out Uri uri))
                {
                    if (MessageHelper.IsTelegramUrl(uri))
                    {
                        MessageHelper.HandleTelegramUrl(urlText.Url);
                    }
                    else
                    {
                        await Launcher.LaunchUriAsync(uri);
                    }
                }
            }
        }
Exemplo n.º 9
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            return;

            var scrollViewer = ScrollingHost.GetScrollViewer();

            if (scrollViewer == null)
            {
                return;
            }

            var properties = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(scrollViewer);
            var header     = ElementCompositionPreview.GetElementVisual(HeaderPanel);
            var info       = ElementCompositionPreview.GetElementVisual(ScrollingInfo);

            var photo    = ElementCompositionPreview.GetElementVisual(Photo);
            var title    = ElementCompositionPreview.GetElementVisual(LabelTitle);
            var subtitle = ElementCompositionPreview.GetElementVisual(Subtitle);
            var action   = ElementCompositionPreview.GetElementVisual(SendMessage);

            if (ApiInformation.IsMethodPresent("Windows.UI.Composition.Compositor", "CreateLinearGradientBrush"))
            {
                var overlay  = photo.Compositor.CreateSpriteVisual();
                var gradient = overlay.Compositor.CreateLinearGradientBrush();
                gradient.ColorStops.Add(overlay.Compositor.CreateColorGradientStop(0, ((SolidColorBrush)App.Current.Resources["PageHeaderBackgroundBrush"]).Color));
                gradient.ColorStops.Add(overlay.Compositor.CreateColorGradientStop(1, ((SolidColorBrush)App.Current.Resources["PageSubHeaderBackgroundBrush"]).Color));
                gradient.StartPoint = new Vector2();
                gradient.EndPoint   = new Vector2(0, 1);
                overlay.Brush       = gradient;
                overlay.Size        = new Vector2((float)HeaderOverlay.ActualWidth, (float)HeaderOverlay.ActualHeight);

                HeaderOverlay.SizeChanged += (s, args) =>
                {
                    overlay.Size = args.NewSize.ToVector2();
                };

                ElementCompositionPreview.SetElementChildVisual(HeaderOverlay, overlay);

                var animOverlay = header.Compositor.CreateExpressionAnimation("Min(76, -Min(scrollViewer.Translation.Y, 0)) / 38");
                animOverlay.SetReferenceParameter("scrollViewer", properties);

                overlay.StartAnimation("Scale.Y", animOverlay);
            }

            var animClip = header.Compositor.CreateExpressionAnimation("Min(76, -Min(scrollViewer.Translation.Y, 0))");

            animClip.SetReferenceParameter("scrollViewer", properties);

            header.Clip = header.Compositor.CreateInsetClip(0, -32, -12, 0);
            header.Clip.StartAnimation("BottomInset", animClip);


            var animPhotoOffsetY = header.Compositor.CreateExpressionAnimation("-(Min(76, -Min(scrollViewer.Translation.Y, 0)) / 76 * 41)");

            animPhotoOffsetY.SetReferenceParameter("scrollViewer", properties);

            var animPhotoOffsetX = header.Compositor.CreateExpressionAnimation("Min(76, -Min(scrollViewer.Translation.Y, 0)) / 76 * 28");

            animPhotoOffsetX.SetReferenceParameter("scrollViewer", properties);

            var animPhotoScale = header.Compositor.CreateExpressionAnimation("1 -(Min(76, -Min(scrollViewer.Translation.Y, 0)) / 76 * (34 / 64))");

            animPhotoScale.SetReferenceParameter("scrollViewer", properties);

            photo.StartAnimation("Offset.Y", animPhotoOffsetY);
            photo.StartAnimation("Offset.X", animPhotoOffsetX);
            photo.StartAnimation("Scale.X", animPhotoScale);
            photo.StartAnimation("Scale.Y", animPhotoScale);


            var animTitleY = header.Compositor.CreateExpressionAnimation("-(Min(76, -Min(scrollViewer.Translation.Y, 0)) / 76 * 58)");

            animTitleY.SetReferenceParameter("scrollViewer", properties);

            var animTitleX = header.Compositor.CreateExpressionAnimation("-(Min(76, -Min(scrollViewer.Translation.Y, 0)) / 76 * 6)");

            animTitleX.SetReferenceParameter("scrollViewer", properties);

            title.StartAnimation("Offset.Y", animTitleY);
            title.StartAnimation("Offset.X", animTitleX);
            subtitle.StartAnimation("Offset.Y", animTitleY);
            subtitle.StartAnimation("Offset.X", animTitleX);


            var animInfoY = header.Compositor.CreateExpressionAnimation("-(Min(76, -Min(scrollViewer.Translation.Y, 0)) / 76 * 40)");

            animInfoY.SetReferenceParameter("scrollViewer", properties);

            var animOpacity = header.Compositor.CreateExpressionAnimation("1 -(Min(76, -Min(scrollViewer.Translation.Y, 0)) / 76)");

            animOpacity.SetReferenceParameter("scrollViewer", properties);

            info.StartAnimation("Offset.Y", animInfoY);
            info.StartAnimation("Opacity", animOpacity);

            action.CenterPoint = new Vector3(18);
            action.StartAnimation("Opacity", animOpacity);
            action.StartAnimation("Scale.X", animOpacity);
            action.StartAnimation("Scale.Y", animOpacity);
        }
 public ScrollViewer GetScrollViewer()
 {
     return(ScrollingHost.GetScrollViewer());
 }