private void CBForward_Click(object sender, RoutedEventArgs e)
 {
     if (WView.CanGoForward)
     {
         WView.GoForward();
     }
 }
Example #2
0
        public WebViewPage(string value, bool isLogin = false, int eventId = 0)
        {
            InitializeComponent();

            this.isLogin = isLogin;
            this.eventId = eventId;

            if (!isLogin)
            {
                ToolbarItems.Add(new ToolbarItem("Compartilhar", Other.Other.GetImage("Share"), () =>
                {
                    CrossShare.Current.ShareLink((WView.Source as UrlWebViewSource).Url, "", AppResources.AppName);
                }));
            }

            if (Device.OS == TargetPlatform.iOS)
            {
                ToolbarItems.Add(new ToolbarItem("Mais", "More.png", async() =>
                {
                    string action = "";

                    if (this.isLogin)
                    {
                        action = await DisplayActionSheet("Menu", "Cancelar", null, "Voltar", "Avançar", "Recarregar");
                    }
                    else
                    {
                        action = await DisplayActionSheet("Menu", "Cancelar", null, "Voltar", "Avançar", "Recarregar", "Abrir no navegador");
                    }

                    if (action != null)
                    {
                        if (action.Equals("Voltar"))
                        {
                            if (WView.CanGoBack)
                            {
                                WView.GoBack();
                            }
                        }
                        else if (action.Equals("Avançar"))
                        {
                            if (WView.CanGoForward)
                            {
                                WView.GoForward();
                            }
                        }
                        else if (action.Equals("Recarregar"))
                        {
                            WView.Source = (WView.Source as UrlWebViewSource).Url;
                        }
                        else if (action.Equals("Abrir no navegador"))
                        {
                            Other.Other.OpenSite((WView.Source as UrlWebViewSource).Url, this);
                        }
                    }
                }));
            }
            else
            {
                ToolbarItems.Add(new ToolbarItem("Voltar", null, () =>
                {
                    if (WView.CanGoBack)
                    {
                        WView.GoBack();
                    }
                }, ToolbarItemOrder.Secondary));

                ToolbarItems.Add(new ToolbarItem("Avançar", null, () =>
                {
                    if (WView.CanGoForward)
                    {
                        WView.GoForward();
                    }
                }, ToolbarItemOrder.Secondary));

                ToolbarItems.Add(new ToolbarItem("Recarregar", null, () =>
                {
                    WView.Source = (WView.Source as UrlWebViewSource).Url;
                }, ToolbarItemOrder.Secondary));

                if (!isLogin)
                {
                    ToolbarItems.Add(new ToolbarItem("Abrir no navegador", null, () =>
                    {
                        Other.Other.OpenSite((WView.Source as UrlWebViewSource).Url, this);
                    }, ToolbarItemOrder.Secondary));
                }
            }

            WView.Source      = value;
            WView.Navigating += WView_Navigating;
        }