public CustomAppPage(string app_id, byte[] host_user_address, byte[][] user_addresses, string app_entry_point) { InitializeComponent(); NavigationPage.SetHasNavigationBar(this, false); sessionId = Guid.NewGuid().ToByteArray(); appId = app_id; hostUserAddress = host_user_address; userAddresses = user_addresses; // Load the app entry point var source = new UrlWebViewSource(); source.Url = "file://" + app_entry_point; webView.Source = source; requestReceivedTimestamp = Clock.getTimestamp(); }
public void TestSourceChangedPropagation() { var source = new UrlWebViewSource { Url = "http://www.google.com" }; var web = new WebView { Source = source }; bool signaled = false; web.PropertyChanged += (sender, args) => { if (args.PropertyName == WebView.SourceProperty.PropertyName) { signaled = true; } }; Assert.False(signaled); source.Url = "http://www.xamarin.com"; Assert.True(signaled); }
public TestPage() { var urlSource = new UrlWebViewSource { Url = "https://blog.xamarin.com/", }; wv = new CoreWebView() { Source = urlSource, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; this.ToolbarItems.Add(new ToolbarItem() { Text = "Save", Command = new Command(async(obj) => { //Method 1 //wv.CreatePDF.Invoke((success) => { // var result = success; //}); //Method 2 var success = await wv.CreatePDFAsync(); if (success) { #if __IOS__ DependencyService.Get <IFileReader>().Read(wv.FullPath); #else await this.DisplayAlert("Success", "PDF was successfully printed", "Cancel"); #endif } }) }); this.Content = new StackLayout() { Children = { wv } }; }
public SingleChatPage(Friend fr) { InitializeComponent(); NavigationPage.SetHasNavigationBar(this, false); _webView = webView; Title = fr.nickname; friend = fr; friend.chat_page = this; // Connect to the friend's S2 node friend.searchForRelay(); // Load the platform specific home page url var source = new UrlWebViewSource(); source.Url = string.Format("{0}html/chat.html", DependencyService.Get <IBaseUrl>().Get()); webView.Source = source; }
public WebViewViewModel() { Source = new UrlWebViewSource { Url = DefaultUrl }; GoBack = new Command( canExecute: () => CanGoBack, execute: () => _webView?.GoBack()); GoForward = new Command( canExecute: () => CanGoForward, execute: () => _webView?.GoForward()); Refresh = new Command( execute: () => _webView.Source = (_webView.Source as UrlWebViewSource).Url); OpenInBrowser = new Command( execute: () => Device.OpenUri(new Uri(DefaultUrl))); }
protected override void OnElementChanged(ElementChangedEventArgs <WebView> e) { base.OnElementChanged(e); UrlWebViewSource webview = Element.Source as UrlWebViewSource; if (Element != null && Element.Source != null && Control != null) { Control.SetBackgroundColor(Android.Graphics.Color.Transparent); try { if (!webview.Url.Contains("file:///android_asset/")) { Control.LoadUrl("file:///android_asset/" + webview.Url); } } catch { } Control.VerticalScrollBarEnabled = false; Control.HorizontalScrollBarEnabled = false; } }
/// <summary> /// Initializes a new instance of the SphericalView class. /// </summary> public SphericalView() { InitializeComponent(); string url = "spherical.html"; if (Device.RuntimePlatform != Device.iOS) { url = $"spherical.html?viewMode=None&lang={CultureInfo.CurrentCulture.TwoLetterISOLanguageName}"; } var source = new UrlWebViewSource { Url = DependencyService.Get <IBaseUrl>().GetBase() + url }; Preview.Navigated += Preview_Navigated; Preview.Source = source; //Xamarin.Forms.DualScreen.DualScreenInfo.Current.HingeAngleChanged += Current_HingeAngleChanged; }
public Instruction_Page2() { InitializeComponent(); // Binding Instructions var baseURL = DependencyService.Get <IBaseUrl>().Get(); var url = Application.Current.Properties["Language"].ToString() == "English" ? System.IO.Path.Combine(baseURL, "Html_Instructions/Instruction_Eng2.html"): System.IO.Path.Combine(baseURL, "Html_Instructions/Instruction_SV2.html"); var source = new UrlWebViewSource(); source.Url = url; webView.Source = source; SetControlLanguage(); // Button delegate finishBtn.Clicked += OnFinishClicked; //BindingContext = new AudioPlayerViewModel(DependencyService.Get<IAudioPlayerService>()); //AudioPlayerViewModel.instance = (AudioPlayerViewModel)BindingContext; if (Device.RuntimePlatform == Device.iOS) { webView.HeightRequest = Application.Current.Properties["Language"].ToString() == "English"? 540:720; webView.IsEnabled = false; } }
public MapPage() { try { InitializeComponent(); Title = Application.Current.Properties["Language"].ToString() == "English" ? AppResourceEnglish.Map_Header : AppResourceSweden.Map_Header; var baseURL = DependencyService.Get <IBaseUrl>().Get(); var url = Application.Current.Properties["Language"].ToString() == "English" ? System.IO.Path.Combine(baseURL, "Map.html") : System.IO.Path.Combine(baseURL, "Map_Swedish.html"); var source = new UrlWebViewSource(); source.Url = url; map.Source = source; //var myTimer = new System.Timers.Timer(); myTimer.Elapsed += MyTimer_Elapsed; myTimer.Interval = 10000; myTimer.Enabled = true; this.Disappearing += Map_Disappearing; //DependencyService.Get<IAudioPlayerService>().Stop(); //if (Device.RuntimePlatform == Device.iOS) //{ // //var cookieJar = NSHttpCookieStorage.SharedStorage; // //cookieJar.AcceptPolicy = NSHttpCookieAcceptPolicy.Always; // //foreach (var aCookie in cookieJar.Cookies) // //{ // // cookieJar.DeleteCookie(aCookie); // //} // NSHttpCookieStorage CookieStorage = NSHttpCookieStorage.SharedStorage; // foreach (var cookie in CookieStorage.Cookies) // CookieStorage.DeleteCookie(cookie); //} } catch (Exception ex) { throw ex; } }
public AboutPage() { NavigationPage.SetHasNavigationBar(this, true); Title = "About DCC"; // a URL is easier var source = new UrlWebViewSource(); source.Url = "http://oct2014.desertcodecamp.com/about"; var web = new WebView { }; web.Source = source; Content = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, Children = { web, } }; }
protected override void OnElementChanged(ElementChangedEventArgs <EnhancedWebView> e) { base.OnElementChanged(e); web.Webkit.WebView webView = Control as web.Webkit.WebView; if (Control == null) { webView = new web.Webkit.WebView(_localContext); SetNativeControl(webView); } if (e.OldElement != null) { // ... } if (e.NewElement != null) { Dictionary <string, string> headers = Element.CustomHeaders; webView.Settings.JavaScriptEnabled = true; webView.Settings.BuiltInZoomControls = false; webView.Settings.SetSupportZoom(true); EnhancedWebViewClient webViewClient = new EnhancedWebViewClient(); webViewClient.Username = Element.Username; webViewClient.Password = Element.Password; webViewClient.Headers = headers; webView.SetWebViewClient(webViewClient); if (Element.Source != null) { if (Element.Source.GetType() == typeof(UrlWebViewSource)) { UrlWebViewSource source = Element.Source as UrlWebViewSource; webView.LoadUrl(source.Url, headers); } } } }
/// <summary> /// Initializes a new instance of the <see cref="HelpPage"/> class. /// </summary> public HelpPage() { InitializeComponent(); var lang = CultureInfo.CurrentCulture.TwoLetterISOLanguageName.ToUpperInvariant(); var localized = new[] { "DE", "FR" }; var filename = "about.html"; if (localized.Contains(lang)) { filename = string.Format("about.{0}.html", lang); } var source = new UrlWebViewSource { Url = DependencyService.Get <IBaseUrl>().GetBase() + filename }; WebView.Source = source; WebView.Navigating += WebView_Navigating; }
public async override void OnNavigatedTo(INavigationParameters parameters) { base.OnNavigatedTo(parameters); if (_settings.IsOnline) { IsBusy = true; IsEmailSend = parameters.GetValue <bool>("IsEmailSend"); ExternalId = parameters.GetValue <int>("ExternalId"); IsRegisterButtonShow = (IsEmailSend == false) ? true : false; UrlWebViewSourceObj = new UrlWebViewSource { Url = $"http://ssc.resquark.com/home/ComplaintEmail/{ExternalId}" }; IsBusy = false; } else { IsEmpty = true; EmptyStateTitle = AppAlertMessage.NoInternetConnections; IsBusy = false; } }
public override void OnPageFinished(AWebView view, string url) { if (_renderer.Element == null || url == "file:///android_asset/") { return; } var source = new UrlWebViewSource { Url = url }; _renderer._ignoreSourceChanges = true; ((IElementController)_renderer.Element).SetValueFromRenderer(WebView.SourceProperty, source); _renderer._ignoreSourceChanges = false; var args = new WebNavigatedEventArgs(WebNavigationEvent.NewPage, source, url, _navigationResult); _renderer.Element.SendNavigated(args); _renderer.UpdateCanGoBackForward(); base.OnPageFinished(view, url); }
private void browser_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName.Equals("Source")) { WebView browser = sender as WebView; if (browser != null) { UrlWebViewSource source = browser.Source as UrlWebViewSource; if (source != null) { // https://www.linkedin.com/connect/login_success.html?code=AQCU-FgxysBWTCSnCuqH3b4i1FOHdDwWx6huLDTABcsgPcbj4wufFAoaUmcG55FOSsYUkOCSftQnHbm9lyc7p7eI5lY07QfK4D4banQng3Aup3dFcRK1jUK1-no-d-zS6IC0JQojZAD-guPrqkgt5P1B1ch7Go96XpK3P59PhgqHOvrbE7UzkQLejbcgkzTDBOUtphOFVuHdT_ZcqCuo11Bi945DT210gYp07uZQGKFtflD6TmrFMgu6h-dkmaWELkV3efgFVAGZCqVzsn5S5yEWugE2TCgZTafkbXQ2In8u_6eYPkAzPl9xS5p-R6KxVSA#_=_ if (source.Url.StartsWith(RedirectURL)) { System.Diagnostics.Debug.WriteLine("Login Success"); Uri result = new Uri(source.Url); Dictionary <string, string> queryValues = ParseQueryString(result); AccessCode = queryValues["code"]; Authenticate(); } } } } }
public override void OnPageFinished(global::Android.Webkit.WebView view, string url) { if (_renderer?.Element == null || url == HybridWebViewRenderer.AssetBaseUrl) { return; } var source = new UrlWebViewSource { Url = url }; _renderer.IgnoreSourceChanges = true; _renderer.ElementController.SetValueFromRenderer(HybridWebView.SourceProperty, source); _renderer.IgnoreSourceChanges = false; var args = new WebNavigatedEventArgs(WebNavigationEvent.NewPage, source, url, _navigationResult); _renderer.ElementController.SendNavigated(args); _renderer.UpdateCanGoBackForward(); base.OnPageFinished(view, url); }
public WebViewGallery() { var htmlWebView = new WebView { HeightRequest = 40, //Source = new HtmlWebViewSource {Html ="<html><body><p>This is a WebView!</p></body></html>"} }; var urlWebView = new WebView { VerticalOptions = LayoutOptions.FillAndExpand, //Source = new UrlWebViewSource {Url = "http://xamarin.com/"} }; var htmlSource = new HtmlWebViewSource(); htmlSource.SetBinding(HtmlWebViewSource.HtmlProperty, "HTML"); htmlWebView.Source = htmlSource; var urlSource = new UrlWebViewSource(); urlSource.SetBinding(UrlWebViewSource.UrlProperty, "URL"); urlWebView.Source = urlSource; var viewModel = new ViewModel(); BindingContext = viewModel; Content = new StackLayout { Padding = new Size(20, 20), Children = { htmlWebView, urlWebView } }; }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.WebView> e) { base.OnElementChanged(e); if (e.OldElement == null) { setSettings(Control); Control.SetWebViewClient(new JavascriptWebViewClient($"javascript: {JavaScriptUserId}", BridWebView, this)); //Control.SetWebChromeClient(new HybridWebChromeClient(_context, BridWebView)); } if (e.OldElement != null) { Control.RemoveJavascriptInterface("jsBridge"); var hybridWebView = e.OldElement as HyBridWebView; } if (e.NewElement != null) { Control.AddJavascriptInterface(new JSBridge(_context, this, BridWebView, androidWebView), "jsBridge"); UrlWebViewSource source = e.NewElement.Source as UrlWebViewSource; Control.LoadUrl(source.Url); } }
protected override void OnElementChanged(ElementChangedEventArgs <CustomWebView> e) { base.OnElementChanged(e); Android.Webkit.WebView webView = Control as Android.Webkit.WebView; if (Control == null) { webView = new Android.Webkit.WebView(_localContext); SetNativeControl(webView); } if (e.OldElement != null) { // ... } if (e.NewElement != null) { Dictionary <string, string> headers = new Dictionary <string, string> { ["A-custom-header"] = Element.CustomHeaderValue }; webView.Settings.JavaScriptEnabled = true; webView.Settings.BuiltInZoomControls = true; webView.Settings.SetSupportZoom(true); webView.ScrollBarStyle = ScrollbarStyles.OutsideOverlay; webView.ScrollbarFadingEnabled = false; webView.SetWebViewClient(new CustomWebViewClient(headers)); UrlWebViewSource source = Element.Source as UrlWebViewSource; webView.LoadUrl(source.Url, headers); } }
public WebViewSource generatePage(string html_file_name) { var platform_utils = DependencyService.Get <IPlatformUtils>(); if (Device.RuntimePlatform == Device.Android) { var source = new HtmlWebViewSource(); Stream stream = platform_utils.getAsset(Path.Combine("html", html_file_name)); source.BaseUrl = platform_utils.getAssetsBaseUrl() + "html/"; source.Html = SpixiLocalization.localizeHtml(stream); stream.Close(); stream.Dispose(); return(source); } else { string assets_file_path = Path.Combine(platform_utils.getAssetsPath(), "html", html_file_name); string localized_file_path = Path.Combine(platform_utils.getHtmlPath(), "ll_" + html_file_name); SpixiLocalization.localizeHtml(assets_file_path, localized_file_path); var source = new UrlWebViewSource(); source.Url = platform_utils.getHtmlBaseUrl() + "ll_" + html_file_name; return(source); } }
protected override void OnElementChanged(ElementChangedEventArgs <EnhancedWebView> e) { base.OnElementChanged(e); var webView = Control as WKWebView; if (webView == null) { var config = new WKWebViewConfiguration(); webView = new WKWebView(Frame, config); SetNativeControl(webView); } if (e.OldElement != null) { } if (e.NewElement != null) { UrlWebViewSource source = (Xamarin.Forms.UrlWebViewSource)Element.Source; var webRequest = new NSMutableUrlRequest(new NSUrl(source.Url)); if (Element.CustomHeaders.Count > 0) { foreach (string key in Element.CustomHeaders.Keys) { webRequest[key] = Element.CustomHeaders[key]; } } if (!string.IsNullOrEmpty(Element.Username) && !string.IsNullOrEmpty(Element.Password)) { WebViewDelegate webViewDelegate = new WebViewDelegate(); webViewDelegate.Username = Element.Username; webViewDelegate.Password = Element.Password; webView.NavigationDelegate = webViewDelegate; } Control.LoadRequest(webRequest); } }
//async void OnNextPageClicked(object sender, EventArgs e) //{ // await Navigation.PushAsync(new Instruction_Page3()); //} /// <summary> /// OnFinishClicked Button CLick Event /// </summary> void OnFinishClicked(object sender, EventArgs e) { try { //DependencyService.Get<IAudioPlayerService>().Stop(); //AudioPlayerViewModel.instance._isStopped = true; //AudioPlayerViewModel.instance.CommandText = "Audio Information"; Application.Current.Properties["GotIt"] = true; var baseURL = DependencyService.Get <IBaseUrl>().Get(); var url = Application.Current.Properties["Language"].ToString() == "English" ? System.IO.Path.Combine(baseURL, "Html_Instructions/Instruction_Eng1.html") : System.IO.Path.Combine(baseURL, "Html_Instructions/Instruction_SV1.html"); var source = new UrlWebViewSource(); source.Url = url; webView.Source = source; Application.Current.MainPage = new Polcirkelleden.MainPage(); //Application.Current.MainPage = new MainPage { Detail = new NavigationPage(new MapPage()) }; } catch (Exception ex) { Debug.WriteLine("OnFinishClicked() Exception Page3!!!"); Debug.WriteLine("Exception Description: " + ex); } }
public HomePage() { InitializeComponent(); NavigationPage.SetHasBackButton(this, false); NavigationPage.SetHasNavigationBar(this, false); new Thread(() => { Thread.CurrentThread.IsBackground = true; Node.connectToNetwork(); }).Start(); // Load the platform specific home page url var source = new UrlWebViewSource(); source.Url = string.Format("{0}html/index.html", DependencyService.Get <IBaseUrl>().Get()); webView.Source = source; //CrossLocalNotifications.Current.Show("title", "body",100, DateTime.Now.AddSeconds(10)); handleBackground(); // Navigation.PushAsync(new LockPage(), Config.defaultXamarinAnimations); }
public mapPage() { InitializeComponent(); var web_view = mainWebView; //CrossGeolocator.Current.AllowsBackgroundUpdates = true; var loc = CrossGeolocator.Current; loc.PositionChanged += Current_PositionChanged; //Debug.WriteLine("Position Status: {0}", position.Timestamp); //Debug.WriteLine("Position Latitude: {0}", position.Latitude); //Debug.WriteLine("Position Longitude: {0}", position.Longitude); var source = new UrlWebViewSource { Url = DependencyService.Get <IBaseUrl>().Get() + "/index.html" // = "https://www.digitalussouth.org/" }; web_view.Source = source; web_view.Navigating += async(s, e) => { if (e.Url.StartsWith("https://www.google.com")) { try { var uri = new Uri(e.Url); Device.OpenUri(uri); } catch (Exception) { } e.Cancel = true; } if (e.Url.StartsWith("http://www.scencyclopedia.org")) { try { var uri = new Uri(e.Url); Device.OpenUri(uri); } catch (Exception) { } e.Cancel = true; } if (e.Url.EndsWith("getLoc")) { try { System.Console.WriteLine("location callback"); var locator = CrossGeolocator.Current; var position = await locator.GetPositionAsync();//TimeSpan.FromSeconds(10)); web_view.Eval(string.Format("updateMap({0}, {1}, {2})", position.Latitude, position.Longitude, position.Accuracy)); } catch (Exception) { } e.Cancel = true; } if (!loc.IsListening) { await loc.StartListeningAsync(TimeSpan.FromSeconds(1), 10); } }; void Current_PositionChanged(object sender, Plugin.Geolocator.Abstractions.PositionEventArgs e) { System.Console.WriteLine("position changed"); var position = e.Position; web_view.Eval(string.Format("updateMap({0}, {1}, {2})", position.Latitude, position.Longitude, position.Accuracy)); } }
public override void DecidePolicy(WKWebView webView, WKNavigationAction navigationAction, Action <WKNavigationActionPolicy> decisionHandler) { //Should not happen if (_blazorWebViewForms == null) { decisionHandler(WKNavigationActionPolicy.Cancel); } else { var navEvent = WebNavigationEvent.NewPage; var navigationType = navigationAction.NavigationType; switch (navigationType) { case WKNavigationType.LinkActivated: navEvent = WebNavigationEvent.NewPage; break; case WKNavigationType.FormSubmitted: navEvent = WebNavigationEvent.NewPage; break; case WKNavigationType.BackForward: navEvent = _renderer._lastBackForwardEvent; break; case WKNavigationType.Reload: navEvent = WebNavigationEvent.Refresh; break; case WKNavigationType.FormResubmitted: navEvent = WebNavigationEvent.NewPage; break; case WKNavigationType.Other: navEvent = WebNavigationEvent.NewPage; break; } _lastEvent = navEvent; var request = navigationAction.Request; var lastUrl = request.Url.ToString(); WebViewSource source; if (_renderer.Element != null && _renderer.Element.Source != null) { source = _renderer.Element.Source; } else { source = new UrlWebViewSource() { Url = lastUrl }; } var args = new WebNavigatingEventArgs(navEvent, source, lastUrl); _blazorWebViewForms.SendNavigating(args); _renderer.UpdateCanGoBackForward(); decisionHandler(args.Cancel ? WKNavigationActionPolicy.Cancel : WKNavigationActionPolicy.Allow); } }
/// <summary> /// Set Language of specific controls on page /// </summary> void SetControlLanguage() { // Tabbed Page Title Title = Application.Current.Properties["Language"].ToString() == "English" ? AppResourceEnglish.Animal_Header : AppResourceSweden.Animal_Header; lblReindeerHeader.Text = Application.Current.Properties["Language"].ToString() == "English" ? AppResourceEnglish.Aminal_TitleA : AppResourceSweden.Aminal_TitleA; lblTaigaHeader.Text = Application.Current.Properties["Language"].ToString() == "English" ? AppResourceEnglish.Aminal_TitleB : AppResourceSweden.Aminal_TitleB; lblBirchPolyporeHeader.Text = Application.Current.Properties["Language"].ToString() == "English" ? AppResourceEnglish.Aminal_TitleC : AppResourceSweden.Aminal_TitleC; lblBlackHeader.Text = Application.Current.Properties["Language"].ToString() == "English" ? AppResourceEnglish.Aminal_TitleD : AppResourceSweden.Aminal_TitleD; lblBearHeader.Text = Application.Current.Properties["Language"].ToString() == "English" ? AppResourceEnglish.Aminal_TitleE : AppResourceSweden.Aminal_TitleE; lblFreshwaterHeader.Text = Application.Current.Properties["Language"].ToString() == "English" ? AppResourceEnglish.Aminal_TitleF : AppResourceSweden.Aminal_TitleF; lblSiberianHeader.Text = Application.Current.Properties["Language"].ToString() == "English" ? AppResourceEnglish.Aminal_TitleG : AppResourceSweden.Aminal_TitleG; if (Device.RuntimePlatform == Device.iOS) { lblBearHeader.IsVisible = false; lblFreshwaterHeader.IsVisible = false; lblSiberianHeader.IsVisible = false; bearWebView.HeightRequest = 500; Bear.Title = Application.Current.Properties["Language"].ToString() == "English" ? AppResourceEnglish.Aminal_TitleE : AppResourceSweden.Aminal_TitleE; Freshwater.Title = Application.Current.Properties["Language"].ToString() == "English" ? AppResourceEnglish.Aminal_TitleF : AppResourceSweden.Aminal_TitleF; Siberian.Title = Application.Current.Properties["Language"].ToString() == "English" ? AppResourceEnglish.Aminal_TitleG : AppResourceSweden.Aminal_TitleG; } else { lblBearHeader.IsVisible = true; lblFreshwaterHeader.IsVisible = true; lblSiberianHeader.IsVisible = true; } Reindeer.Icon = "reindeernew.png"; Taiga.Icon = "forest.png"; BirchPolypore.Icon = "birch.png"; Black.Icon = "grouse.png"; Bear.Icon = "bearnew.png"; Freshwater.Icon = "clam.png"; Siberian.Icon = "bird.png"; //baseURL = DependencyService.Get<IBaseUrl>().Get(); // Reindeer Data var source = new UrlWebViewSource(); source.Url = Application.Current.Properties["Language"].ToString() == "English" ? System.IO.Path.Combine(baseURL, "Nature_Html/Reindeer_Eng.html") : System.IO.Path.Combine(baseURL, "Nature_Html/Reindeer_SV.html"); reindeerWebView.Source = source; // BirchPolypore Data var source1 = new UrlWebViewSource(); source1.Url = Application.Current.Properties["Language"].ToString() == "English" ? System.IO.Path.Combine(baseURL, "Nature_Html/BirchPolypore_Eng.html") : System.IO.Path.Combine(baseURL, "Nature_Html/BirchPolypore_SV.html"); birchWebView.Source = source1; // Black Grouse And Wood Grouse Data var source2 = new UrlWebViewSource(); source2.Url = Application.Current.Properties["Language"].ToString() == "English" ? System.IO.Path.Combine(baseURL, "Nature_Html/BlackGrouse_Eng.html") : System.IO.Path.Combine(baseURL, "Nature_Html/BlackGrouse_SV.html"); blackWebView.Source = source2; // Bear - Brunbjörn Data var source3 = new UrlWebViewSource(); source3.Url = Application.Current.Properties["Language"].ToString() == "English" ? System.IO.Path.Combine(baseURL, "Nature_Html/Bear_Eng.html") : System.IO.Path.Combine(baseURL, "Nature_Html/Bear_SV.html"); bearWebView.Source = source3; //Fresh Water Mussel Audio var source4 = new UrlWebViewSource(); source4.Url = Application.Current.Properties["Language"].ToString() == "English" ? System.IO.Path.Combine(baseURL, "Nature_Html/Freshwater_Eng.html") : System.IO.Path.Combine(baseURL, "Nature_Html/Freshwater_SV.html"); freshWaterWebView.Source = source4; //freshWaterWebView.IsEnabled = false; //Taiga Audio var source5 = new UrlWebViewSource(); source5.Url = Application.Current.Properties["Language"].ToString() == "English" ? System.IO.Path.Combine(baseURL, "Nature_Html/Taiga_Eng.html") : System.IO.Path.Combine(baseURL, "Nature_Html/Taiga_SV.html"); taigaWebView.Source = source5; //taigaWebView.IsEnabled = false; //Siberian Jay Audio var source6 = new UrlWebViewSource(); source6.Url = Application.Current.Properties["Language"].ToString() == "English" ? System.IO.Path.Combine(baseURL, "Nature_Html/Siberian_Eng.html") : System.IO.Path.Combine(baseURL, "Nature_Html/Siberian_SV.html"); siberianWebView.Source = source6; //siberianWebView.IsEnabled = false; // Contect Pages Label text //lblTaiga.Text = Application.Current.Properties["Language"].ToString() == "English" ? AppResourceEnglish.Animal_Taiga : AppResourceSweden.Animal_Taiga; //lblFreshWater.Text = Application.Current.Properties["Language"].ToString() == "English" ? AppResourceEnglish.Animal_FreshWater : AppResourceSweden.Animal_FreshWater; //lblSiberian.Text = Application.Current.Properties["Language"].ToString() == "English" ? AppResourceEnglish.Animal_Siberian : AppResourceSweden.Animal_Siberian; }
private async Task LoadMintForm() { //OneDrive //UrlAssest = "https://mayasofting-my.sharepoint.com/personal/german_ramirez_mayasoft_com_co/_layouts/15/download.aspx?SourceUrl=%2Fpersonal%2Fgerman%5Framirez%5Fmayasoft%5Fcom%5Fco%2FDocuments%2FMint%20Grading%2Fform%5Fassets12%2E0%2Ezip"; //string formUrl = "https://mayasofting-my.sharepoint.com/personal/german_ramirez_mayasoft_com_co/_layouts/15/download.aspx?SourceUrl=%2Fpersonal%2Fgerman%5Framirez%5Fmayasoft%5Fcom%5Fco%2FDocuments%2FMint%20Grading%2FHtmlForm%2Etxt"; //GoogleDrive UrlAssest = "https://qa.mint-online.com/trunk/form-assets/form-assets.zip"; string formUrl = "https://doc-0c-8o-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/0iioeec6d25ln64vs5tts9k2flrf59d9/1523023200000/03041252391972702159/*/1cZd-vjvQaCiMHU-xt-wV5Ktz1JsiHDMg?e=download"; const string apiVersion = "12.1"; const string templateName = "MintFormTemplateApp.html"; const string formName = "index.html"; const string formText = "HtmlForm.txt"; string pathTemplate = Path.Combine(apiVersion, "template-form-app", templateName); string pathForm = Path.Combine(apiVersion, "template-form-app", formName); //string pathForm = Path.Combine(apiVersion, "template-form-app", "HtmlForm.txt"); //string pathForm = Path.Combine(apiVersion, "template-form-app", "Json.txt"); FileManager.DeleteFolder(apiVersion); if (!FileManager.ExistsFolder(apiVersion)) { await FileManager.DownloadFile(UrlAssest, apiVersion + ".zip"); //Get Resouces from URL } //await FileManager.DownloadFile(formUrl, pathForm); // - - - - - - - - - - - - - - - - - - - - - - //if (FileManager.ExistsFile(pathForm)) { //string jsonText = FileManager.LoadText(pathForm); //JObject json = JObject.Parse(jsonText); //MintRenderForm render = JsonConvert.DeserializeObject<MintRenderForm>(jsonText); //} //foreach (string directoryPath in FileManager.GetDirectories()) //{ // System.Diagnostics.Debug.WriteLine("Directorio : " + directoryPath); //} // - - - - - - - - - - - - - - - - - - - - - - //Read files with Resources string templateHTML = FileManager.LoadText(pathTemplate); string formHTML = FileManager.LoadText(formText, true); //string formHTML = render.html; templateHTML = templateHTML.Replace("@-FORM-CONTENT-@", formHTML); FileManager.SaveText(pathForm, templateHTML); //Read file from internal storage //string baseUrl = string.Empty; //string formHtml = FileManager.LoadText(pathForm); //baseUrl = FileManager.GetAppBaseUrl(); // --> Path source = 11.0/js/... --- OK //baseUrl = Path.Combine(FileManager.GetAppBaseUrl(), apiVersion) + "/"; // --> Path source = css/ //baseUrl = Path.Combine(FileManager.GetAppBaseUrl(), apiVersion, "template-form-app") + "/"; // --> Path source = ../css/ //Using HTMLWebViewSource //HtmlWebViewSource.BaseUrl = baseUrl; //HtmlWebViewSource.Html = formHtml; //Using URLWebViewSource //Create new instance "UrlWebViewSource" to refresh WebView if URL inicial = "". UrlWebViewSource = new UrlWebViewSource(); UrlWebViewSource.Url = Path.Combine(FileManager.GetAppBaseUrl(), apiVersion, "template-form-app", formName); // - - - - - - - - - - - - - - - - - - - - - - //await EvaluateJavascript("console.log('JS launched through Eval function.')"); }
public WebView() { HorizontalOptions = LayoutOptions.Fill; VerticalOptions = LayoutOptions.Fill; #region members = new Dictionary <string, Variable> { { "Width", new FVariable { ongetvalue = () => new Gnumber(Width), onsetvalue = (value) => { WidthRequest = Convert.ToDouble(value); return(0); } } }, { "Height", new FVariable { ongetvalue = () => new Gnumber(Height), onsetvalue = (value) => { HeightRequest = Convert.ToDouble(value); return(0); } } }, { "Horizontal", new FVariable { ongetvalue = () => new Gstring(HorizontalOptions.ToString()), onsetvalue = (value) => { if (value.ToString() == "center") { HorizontalOptions = LayoutOptions.Center; } else if (value.ToString() == "left") { HorizontalOptions = LayoutOptions.Start; } else if (value.ToString() == "right") { HorizontalOptions = LayoutOptions.End; } else if (value.ToString() == "stretch") { HorizontalOptions = LayoutOptions.Fill; } return(0); } } }, { "Vertical", new FVariable { ongetvalue = () => new Gstring(VerticalOptions.ToString()), onsetvalue = (value) => { if (value.ToString() == "center") { VerticalOptions = LayoutOptions.Center; } else if (value.ToString() == "bottom") { VerticalOptions = LayoutOptions.End; } else if (value.ToString() == "stretch") { VerticalOptions = LayoutOptions.Fill; } else if (value.ToString() == "top") { VerticalOptions = LayoutOptions.Start; } return(0); } } }, { "Margin", new FVariable { ongetvalue = () => new Glist { new Variable(Margin.Left), new Variable(Margin.Top), new Variable(Margin.Right), new Variable(Margin.Bottom) }, onsetvalue = (value) => { var list = value.IGetCSValue() as Glist; Margin = new Thickness( Convert.ToDouble(list[0].value), Convert.ToDouble(list[1].value), Convert.ToDouble(list[2].value), Convert.ToDouble(list[3].value) ); return(0); } } }, { "Visibility", new FVariable { ongetvalue = () => { string s = "null"; switch (IsVisible) { case true: s = "visiable"; break; case false: s = "gone"; break; } return(new Gstring(s)); }, onsetvalue = (value) => { if (value.ToString() == "gone") { IsVisible = false; } else if (value.ToString() == "hidden") { IsVisible = false; } else if (value.ToString() == "visible") { IsVisible = true; } return(0); } } }, { "Url", new FVariable { ongetvalue = () => new Gstring(this.Source.ToString()), onsetvalue = (value) => { var path = value.ToString(); if (GIInfo.Platform == "Mac_Xamarin") { path = path.Replace("\\", "/"); } Source = new UrlWebViewSource { Url = path }; return(0); } } }, { "InvokeJS", new Variable(new MFunction(invokejs, this)) } }; parent = new GTXAM.Control(this); #endregion }