コード例 #1
0
        private async Task Load()
        {
            _web.UserInteractionEnabled = false;
            _web.LoadHtmlString("", NSBundle.MainBundle.BundleUrl);

            _activityView.Alpha = 1;
            _activityView.StartAnimating();
            View.Add(_activityView);

            try
            {
                var productData = (await _inAppPurchaseService.RequestProductData(FeaturesService.ProEdition)).Products.FirstOrDefault();
                var enabled     = _featuresService.IsProEnabled;
                var model       = new UpgradeDetailsModel(productData != null ? productData.LocalizedPrice() : null, enabled);

                var content = new UpgradeDetailsRazorView {
                    Model = model
                }.GenerateString();
                _web.LoadHtmlString(content, NSBundle.MainBundle.BundleUrl);
                _web.UserInteractionEnabled = true;
            }
            finally
            {
                UIView.Animate(0.2f, 0, UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.CurveEaseInOut,
                               () => _activityView.Alpha = 0, () =>
                {
                    _activityView.RemoveFromSuperview();
                    _activityView.StopAnimating();
                });
            }
        }
コード例 #2
0
ファイル: LookupTab.cs プロジェクト: xproj2501x/CombatManager
 protected virtual void ShowItem(T item)
 {
     if (CompareItems(item, default(T)))
     {
         webView.LoadHtmlString("", new NSUrl("http://localhost/"));
         _displayItem = item;
     }
     else
     {
         _displayItem = ModifiedItem(item);
         webView.LoadHtmlString(ItemHtml(_displayItem), new NSUrl("http://localhost/"));
     }
 }
コード例 #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            webView = new UIWebView(UIScreen.MainScreen.Bounds);
            View.Add(webView);

            // Intercept URL loading to handle native calls from browser
            webView.ShouldStartLoad += HandleShouldStartLoad;

            // Render the view from the type generated from RazorView.cshtml

            var model = App.Database.GetItems().ToList();
            List <List <Data> > lista = model
                                        .GroupBy(u => u.Group)
                                        .Select(grp => grp.ToList())
                                        .ToList();

            var template = new TodoList()
            {
                Model = lista
            };
            var page = template.GenerateString();

            webView.LoadHtmlString(page, NSBundle.MainBundle.BundleUrl);
        }
コード例 #4
0
        public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path)
        {
            var vc = new WebViewController(this)
            {
                Autorotate = dvc.Autorotate
            };

            web = new UIWebView(UIScreen.MainScreen.Bounds)
            {
                BackgroundColor  = UIColor.White,
                AutoresizingMask = UIViewAutoresizing.All
            };

            // We delete cache and cookies so it does not remember our login information
            DeleteCacheandCookies();


            web.LoadStarted += (webview, e) => {
                NetworkActivity = true;
            };

            web.LoadFinished += (webview, e) => {
                NetworkActivity = false;
                var wb = webview as UIWebView;
                FacebookOAuthResult oauthResult;
                if (!_fb.TryParseOAuthCallbackUrl(new Uri(wb.Request.Url.ToString()), out oauthResult))
                {
                    return;
                }

                if (oauthResult.IsSuccess)
                {
                    // Facebook Granted Token
                    var accessToken = oauthResult.AccessToken;
                    LoginSucceded(accessToken, dvc);
                }
                else
                {
                    // user cancelled login
                    LoginSucceded(string.Empty, dvc);
                }
            };

            web.LoadError += (webview, args) => {
                NetworkActivity = false;
                if (web != null)
                {
                    web.LoadHtmlString(
                        String.Format("<html><center><font size=+5 color='red'>{0}:<br>{1}</font></center></html>",
                                      "An error occurred: ", args.Error.LocalizedDescription), null);
                }
            };
            vc.NavigationItem.Title = Caption;

            vc.View.AutosizesSubviews = true;
            vc.View.AddSubview(web);

            dvc.ActivateController(vc);
            web.LoadRequest(NSUrlRequest.FromUrl(nsUrl));
        }
コード例 #5
0
        bool HandleShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
        {
            var scheme = "hybrid:";

            // If the URL is not our own custom scheme, just let the webView load the URL as usual
            if (request.Url.Scheme != scheme.Replace(":", ""))
            {
                return(true);
            }

            // This handler will treat everything between the protocol and "?"
            // as the method name.  The querystring has all of the parameters.
            var resources  = request.Url.ResourceSpecifier.Split('?');
            var method     = resources [0];
            var parameters = System.Web.HttpUtility.ParseQueryString(resources[1]);             // breaks if ? not present (ie no params)

            if (method == "ListAll")
            {
                var model    = new Lip3Data().MyRecs;
                var template = new DataCorpus()
                {
                    Model = model
                };
                var page = template.GenerateString();
                webView.LoadHtmlString(page, NSBundle.MainBundle.BundleUrl);
            }
            return(false);
        }
コード例 #6
0
        public void Selected(DialogViewController controller, UITableView tableView, object item, NSIndexPath indexPath)
        {
            var frame = UIScreen.MainScreen.Bounds;

            Web = new UIWebView(frame)
            {
                BackgroundColor = UIColor.White, ScalesPageToFit = true, AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
            };
            Web.LoadStarted  += (sender, e) => NetworkActivity = true;
            Web.LoadFinished += (sender, e) => NetworkActivity = false;
            Web.LoadError    += (webview, args) =>
            {
                NetworkActivity = false;
                if (Web != null)
                {
                    Web.LoadHtmlString(String.Format("<html><center><font size=+5 color='red'>An error occurred:<br>{0}</font></center></html>", args.Error.LocalizedDescription), null);
                }
            };

            _WebViewController = new WebViewController(this)
            {
                Autorotate = controller.Autorotate, Title = Caption
            };
            _WebViewController.View.AddSubview(Web);

            controller.ActivateController(_WebViewController, controller);

            var url = new NSUrl(Value.AbsoluteUri);

            Web.LoadRequest(NSUrlRequest.FromUrl(url));
        }
コード例 #7
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            // Creating a new document.
            WordDocument document    = new WordDocument();
            Stream       inputStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.WordtoHTML.doc");

            //Open the Word document to convert
            document.Open(inputStream, FormatType.Doc);
            //Export the Word document to HTML file
            MemoryStream stream     = new MemoryStream();
            HTMLExport   htmlExport = new HTMLExport();

            htmlExport.SaveAsXhtml(document, stream);
            document.Close();
            stream.Position = 0;
            StreamReader reader     = new StreamReader(stream);
            string       htmlString = reader.ReadToEnd();

            isGenerateButtonClicked = true;
            UIWebView webView = new UIWebView(this.Bounds);

            webView.Frame = new CGRect(0, 0, this.Bounds.Width, this.Bounds.Height);
            this.AddSubview(webView);
            webView.LoadHtmlString(htmlString, NSBundle.MainBundle.BundleUrl);
            webView.ScalesPageToFit = false;
        }
コード例 #8
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor);

            // setup our web view
            WebView = new UIWebView( );
            WebView.Layer.AnchorPoint = CGPoint.Empty;
            WebView.BackgroundColor   = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor);
            //WebView.Opaque = false;
            WebView.Delegate = new CustomWebViewDelegate(this);
            WebView.ScrollView.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor);
            WebView.Hidden          = true;
            WebView.ScalesPageToFit = true;
            View.AddSubview(WebView);

            // add an activity indicator
            ActivityIndicator = new UIActivityIndicatorView();
            ActivityIndicator.Layer.AnchorPoint          = CGPoint.Empty;
            ActivityIndicator.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.WhiteLarge;
            ActivityIndicator.StartAnimating( );
            View.AddSubview(ActivityIndicator);

            ActivityIndicator.Hidden = false;

            // begin by preloading a black html page that will cover the screen
            WebView.LoadHtmlString(BlackHtml, null);
        }
コード例 #9
0
        void SegmentValueChanged(object sender, EventArgs e)
        {
            if (_viewSegment.SelectedSegment == 0)
            {
                if (_previewView != null)
                {
                    _previewView.RemoveFromSuperview();
                    _previewView.Dispose();
                    _previewView = null;
                }

                Add(TextView);
                TextView.BecomeFirstResponder();
            }
            else
            {
                if (_previewView == null)
                {
                    _previewView = new UIWebView(this.View.Bounds);
                }

                TextView.RemoveFromSuperview();
                Add(_previewView);

                var markdownService = IoC.Resolve <IMarkdownService>();
                var markdownView    = new MarkdownView()
                {
                    Model = markdownService.Convert(TextView.Text)
                };
                _previewView.LoadHtmlString(markdownView.GenerateString(), null);
            }
        }
コード例 #10
0
        void Handle_ActionsPopoverWillShowPopover(object sender, EventArgs e)
        {
            UIAlertView view = null;

            if (!_ActionsPopoverShown)
            {
                view = new UIAlertView("Loading", "Accessing Database...", new UIAlertViewDelegate(), null, new string[] {});
                view.Show();
                NSRunLoop.Current.RunUntil(NSDate.Now.AddSeconds(.1));
                //show waiting dialog
            }

            UIWebView v = new UIWebView(new CGRect(0, 0, 180, 120));

            v.LoadHtmlString(MonsterHtmlCreator.CreateHtml(_Character.Monster, _Character, true), new NSUrl("http://localhost/"));
            _ActionsPopover.AccessoryView = v;

            List <CharacterActionItem> actions = CharacterActions.GetActions(_Character, _CharacterListView.SelectedCharacter);

            if (!_ActionsPopoverShown)
            {
                view.DismissWithClickedButtonIndex(0, false);
                //hide waiting dialog
                _ActionsPopoverShown = true;
            }
            AddActionItems(actions, _ActionsPopover.Items);
        }
コード例 #11
0
        public CsharpCallJSViewController()
        {
            View.BackgroundColor = UIColor.White;

            UIButton testButton = UIButton.FromType(UIButtonType.RoundedRect);

            testButton.SetTitle("Invoque une fonction javascript", UIControlState.Normal);
            testButton.TouchUpInside += TestButton_TouchUpInside;
            testButton.SizeToFit();

            testButton.Center = View.Center;
            UIWebView webView = new UIWebView(View.Bounds);

            WebView = webView;

            // Recherche du chemin de la ressource
            string htmlPath = NSBundle.MainBundle.PathForResource("content/csharp_call_javascript", "html");
            // Lecture du flux html
            string htmlContents = File.ReadAllText(htmlPath);

            // Chargement de la string de la page html
            webView.LoadHtmlString(htmlContents, null);

            // Ajout du contrôle en tant que sous au contrôleur principal
            View.AddSubviews(webView, testButton);
        }
コード例 #12
0
        public WebElement(string content, string cellKey, bool rawContentLoad)
            : base(string.Empty)
        {
            Key             = new NSString(cellKey);
            _rawContentLoad = rawContentLoad;
            WebView         = new UIWebView();
            WebView.ScrollView.ScrollEnabled = false;
            WebView.ScrollView.Bounces       = false;
            WebView.ShouldStartLoad          = (w, r, n) => ShouldStartLoad(r, n);
            WebView.LoadFinished            += (sender, e) => {
                if (!string.IsNullOrEmpty(_value))
                {
                    LoadContent(_value);
                }
                _isLoaded = true;
            };

            WebView.LoadHtmlString(content, new NSUrl(""));
            HeightChanged = (x) => {
                if (GetImmediateRootElement() != null)
                {
                    GetImmediateRootElement().Reload(this, UITableViewRowAnimation.Fade);
                }
            };
        }
コード例 #13
0
        protected void AddWebView()
        {
//			Font = UIFont.FromName ("OpenSans", 14),
//				TextColor = UIColor.FromRGB (67, 67, 67),
//				TextAlignment = UITextAlignment.Left,
//				BackgroundColor = UIColor.Clear,
//				Text = '<a href="http://mydiem.com/index.cfm?event=main.faq">Help</a><br/><a href="mailto:[email protected]">Email Support</a>',
//				LineBreakMode = UILineBreakMode.WordWrap,
//				Lines = 0
            var style = "<style type='text/css'>body { color: #000000; background-color: transparent; font-family: 'HelveticaNeue-Light', Helvetica, Arial, sans-serif; padding: 20px; } h1, h2, h3, h4, h5, h6 { padding: 0px; margin: 0px; font-style: normal; font-weight: normal; } h2 { font-family: 'HelveticaNeue-Light', Helvetica, Arial, sans-serif; font-size: 24px; font-weight: normal; } h4 { font-size: 16px; } p { font-family: Helvetica, Verdana, Arial, sans-serif; line-height:1.5; font-size: 16px; } .esv-text { padding: 0 0 10px 0; }</style>";
            var html  = style + "<body><h2>Contact</h2><a href='http://mydiem.com/index.cfm?event=main.faq'>Help</a><br/><a href='mailto:[email protected]'>Email Support</a><br/><br/>";

            html += "<h2>Our Story</h2><p>If you've ever sent your child empty-handed to a class party, attended parent/teacher conferences on the wrong day or arrived an hour early for a game, you're not alone. It's not bad parenting, it's bad scheduling and trust us, we've been there too.</p><p>Year after year we would receive paper calendars from our children's schools, get several emails a week, or would be encouraged to visit websites to view upcoming events (sports teams, Boy Scouts/ Girl Scouts, ballet, band and track club all had different sites!). Sometimes we would enter the information into a paper agenda, which couldn't be shared. Or we would type everything into our computer's calendar hoping the information wouldn't change. And, as the school year progressed, updates would take the form of crumpled notes, skimmed over emails and hurried messages from coaches and teachers that didn't always make it to the master calendar. We'd often ask ourselves, \"Why can't school events appear on our smart phones or computer calendar programs?\" or \"If there is a change, couldn't someone update the calendar for us so we don't have to keep track of emails, notes, etc? Then, one day, we stopped wishing and got to work.</p><p>We are parents to three school-age (and very busy) children and now we\'re also the proud parents of MyDiem.com. We're so happy to share this much-needed tool with other busy parents. Hopefully you will find this tool helpful in keeping track of your child's activities.</p>";
            html += "</body>";

            webViewTest = new UIWebView(new RectangleF(0, 0, 320, WhitePaperBible.iOS.UI.Environment.DeviceScreenHeight));
            webViewTest.SizeToFit();
            View.AddSubview(webViewTest);

            webViewTest.Opaque          = false;
            webViewTest.BackgroundColor = UIColor.Clear;
            webViewTest.LoadHtmlString(html, NSUrl.FromString("http://localhost"));

//			DescriptionLabel.ShouldStartLoad = myHandler;
        }
コード例 #14
0
        public static UIViewController HtmlSelected(ApiNode apiNode)
        {
            var vc = new UIViewController();

            var webView = new UIWebView(UIScreen.MainScreen.Bounds)
            {
                BackgroundColor = UIColor.White,
                ScalesPageToFit = false,
                AutoresizingMask = UIViewAutoresizing.All
            };

            var html = apiNode["content"];

            if (apiNode["contentNode"] != null)
            {
                html = apiNode[apiNode["contentNode"]];
            }

            if (html != null && !html.Contains("<html"))
            {
                html = String.Format("<html><head><link href=\"main-style.css\" rel=\"stylesheet\" type=\"text/css\" /></head><body><h1>{0}</h1>{1}</body><html>", apiNode.Title, html);
            }

            if (html != null)
                webView.LoadHtmlString(html, new NSUrl("HtmlContent/", true));

            vc.NavigationItem.Title = apiNode.Title;

            vc.View.AutosizesSubviews = true;
            vc.View.AddSubview(webView);

            return vc;
        }
コード例 #15
0
ファイル: RichContentCell.cs プロジェクト: Zebra/iFactr-iOS
        public void Load()
        {
            NSUrl newUrl = new NSUrl(Environment.CurrentDirectory, true);

            webView.LoadHtmlString(Text.StartsWith("<html>") && Text.EndsWith("</html>") ? Text :
                                   string.Format("<html><body style=\"-webkit-text-size-adjust:none;font-family:{2};color:#{0};margin:15px\">{1}</body></html>", foregroundColor.HexCode.Substring(3), Text, UIDevice.CurrentDevice.CheckSystemVersion(7, 0) ? "helvetica neue" : "helvetica"), newUrl);
        }
コード例 #16
0
        public CombatTab(CombatState state) : base(state)
        {
            _CombatList = new CombatListView();
            //

            AddSubview(_CombatList);
            _PlayerList = new CharacterListView(CombatState, false);
            _PlayerList.CharacterSelectionChanged += HandlePlayerListCharacterSelectionChanged;
            AddSubview(_PlayerList);
            _MonsterList = new CharacterListView(CombatState, true);
            _MonsterList.CharacterSelectionChanged += HandlePlayerListCharacterSelectionChanged;
            AddSubview(_MonsterList);

            _MonsterView = new UIWebView(new CGRect(0, 0, 100, 100));
            _MonsterView.BackgroundColor = UIColor.Brown;
            _MonsterView.LoadHtmlString("<html></html>", new NSUrl("http://localhost/"));

            AddSubview(_MonsterView);

            _DieView = new DieRollerView();
            _DieView._CollpasedChanged += (object sender, EventArgs e) =>
            {
                LayoutSubviews();
            };
            AddSubview(_DieView);

            _CombatList.CombatState = state;
        }
コード例 #17
0
ファイル: HtmlElement.cs プロジェクト: escoz/MonoTouch.MVVM
        public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path)
        {
            var vc = new WebViewController(this)
            {
                Autorotate = dvc.Autorotate
            };

            web = new UIWebView(UIScreen.MainScreen.ApplicationFrame)
            {
                BackgroundColor = UIColor.White, ScalesPageToFit = true, AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
            };
            web.LoadStarted  += delegate { NetworkActivity = true; };
            web.LoadFinished += delegate { NetworkActivity = false; };
            web.LoadError    += (webview, args) =>
            {
                NetworkActivity = false;
                if (web != null)
                {
                    web.LoadHtmlString(String.Format("<html><center><font size=+5 color='red'>An error occurred:<br>{0}</font></center></html>", args.Error.LocalizedDescription), null);
                }
            };
            vc.NavigationItem.Title = Caption;
            vc.View.AddSubview(web);

            dvc.ActivateController(vc, dvc);

            var url = new NSUrl(Value.AbsoluteUri);

            web.LoadRequest(NSUrlRequest.FromUrl(url));
        }
コード例 #18
0
ファイル: Conekta.cs プロジェクト: conekta/conekta-xamarin
        public static void collectDevice()
        {
            string SessionId = Conekta.DeviceFingerPrint ();
            string PublicKey = Conekta.PublicKey;
            string html = "<!DOCTYPE html><html><head></head><body style=\"background: blue;\">";
            html += "<script type=\"text/javascript\" src=\"https://conektaapi.s3.amazonaws.com/v0.5.0/js/conekta.js\" data-conekta-public-key=\"" + PublicKey + "\" data-conekta-session-id=\"" + SessionId + "\"></script>";
            html += "</body></html>";

            string contentPath = Environment.CurrentDirectory;

            #if __IOS__
            UIWebView web = new UIWebView(new RectangleF(new PointF(0,0), new SizeF(0, 0)));
            web.ScalesPageToFit = true;
            web.LoadHtmlString(html, new NSUrl("https://conektaapi.s3.amazonaws.com/v0.5.0/js/conekta.js"));
            Conekta._delegate.View.AddSubview(web);
            #endif

            #if __ANDROID__
            WebView web_view = new WebView(Android.App.Application.Context);
            web_view.Settings.JavaScriptEnabled = true;
            web_view.Settings.AllowContentAccess = true;
            web_view.Settings.DomStorageEnabled = true;
            web_view.LoadDataWithBaseURL(Conekta.UriConektaJs, html, "text/html", "UTF-8", null);
            #endif
        }
コード例 #19
0
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            UIViewController aboutContentVC = new UIViewController();

            aboutContentVC.Title = "About";

            AppDisplayUtil.Instance.SetCurrentPopoverViewSize(new CGSize(320, 465));
            aboutContentVC.View.Frame = new CGRect(0, 0, 320, 465);

            UIWebView webView = new UIWebView();

            webView.Frame           = curViewController.View.Frame;
            webView.BackgroundColor = UIColor.White;
            aboutContentVC.View.AddSubview(webView);

            string aboutContent = "";

            switch (indexPath.LongRow)
            {
            case 0:            //About LexisNexis Red
                aboutContent = SettingsUtil.Instance.GetLexisNexisRedInfo();
                break;

            case 1:            //About LexisNexis Legal and Professional
                aboutContent = SettingsUtil.Instance.GetLexisNexisInfo();
                break;

            case 2:            //Terms and Conditions
                aboutContent = SettingsUtil.Instance.GetTermsAndConditions();
                break;
            }
            webView.LoadHtmlString(aboutContent, NSUrl.FromString(""));

            curViewController.NavigationController.PushViewController(aboutContentVC, true);
        }
コード例 #20
0
		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

			var webFrame = UIScreen.MainScreen.ApplicationFrame;

			_webView = new UIWebView(webFrame) {
				BackgroundColor = UIColor.White,
				ScalesPageToFit = true,
				AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
			};

			_webView.LoadStarted += delegate {
				UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
			};
			_webView.LoadFinished += delegate {
				UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
			};
			_webView.LoadError += (webview, args) => {
				UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
					_webView.LoadHtmlString (String.Format ("<html><center><font size=+5 color='red'>An error occurred:<br>{0}</font></center></html>", args.Error.LocalizedDescription), null);
			};

			View.AddSubview(_webView);

			_webView.LoadRequest(new NSUrlRequest(new NSUrl(ViewModel.Uri)));
		}
コード例 #21
0
        public override void ViewDidLoad()
        {
            const int toolbarHeight = 44;

            base.ViewDidLoad();

            var webViewFrame = this.View.Frame;
            var toolbarFrame = this.View.Frame;

            toolbarFrame.Height = toolbarHeight;

            webViewFrame.Y       = toolbarHeight;
            webViewFrame.Height -= toolbarHeight;

            // Perform any additional setup after loading the view, typically from a nib.
            UIWebView webView = new UIWebView(webViewFrame);

//			YtWebViewDelegate del = new YtWebViewDelegate();
//
//			webView.Delegate = del;
            webView.BackgroundColor = UIColor.Black;

            var doneBarButton = new UIBarButtonItem("Gotowe", UIBarButtonItemStyle.Done, (o, e) =>
            {
                webView.LoadHtmlString("<html></html>", null);
                webView.RemoveFromSuperview();
                DismissModalViewController(true);
            });

            UIBarButtonItem[] items = new UIBarButtonItem[]
            {
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                doneBarButton
            };

            UIToolbar toolbar = new UIToolbar(toolbarFrame);

            toolbar.SetItems(items, false);

            toolbar.BarStyle = UIBarStyle.Black;

            webView.Init();
            webView.LoadHtmlString(_html, null);

            View.Add(webView);
            View.Add(toolbar);
        }
コード例 #22
0
 public override void LoadFailed(UIWebView webView, NSError error)
 {
     NetworkActivity = false;
     if (webView != null)
     {
         webView.LoadHtmlString(String.Format("<html><center><font size=+5 color='red'>An error occurred:<br>{0}</font></center></html>", error.LocalizedDescription), null);
     }
 }
コード例 #23
0
        public void PrintHtml(string html)
        {
            var webview = new UIWebView(new CGRect(0f, 0f, UIApplication.SharedApplication.KeyWindow.Screen.Bounds.Width, UIApplication.SharedApplication.KeyWindow.Screen.Bounds.Height));

            webview.LoadFinished   += _loadFinished;
            webview.ScalesPageToFit = true;
            webview.LoadHtmlString(html, null);
        }
コード例 #24
0
        async Task TestLocalHtmlPageAsync(UIWebView webView)
        {
            // Dossier ou iOS
            string contentDirectory = Path.Combine(NSBundle.MainBundle.BundlePath, "Content/");

            // Flux html à afficher dans la UIWebView
            string html = "<html><body><h1>Hello</h1><br /><span>Voici une page web issue d'une chaîne de caractères.</span></body></html>";

            // Chargement de la string de la page html
            webView.LoadHtmlString(html, new NSUrl(contentDirectory, true));

            await Task.Delay(5000);

            html = "<html><body><h1>Hello</h1><br /> <img src=\"xamarin.png\" alt=\"Xamarin logo\" height=\"200\" width=\"200\"> </body></html>";
            // Chargement de la string de la page html
            webView.LoadHtmlString(html, new NSUrl(contentDirectory, true));
        }
コード例 #25
0
ファイル: ExibitInfoView.cs プロジェクト: rzaitov/LoftGuide
        public void BindToView()
        {
            ExibitInfo info = _controller.GetExibitInfo();

            NSUrl dirUrl = new NSUrl(info.DirPath, true);

            _contentDisplayer.LoadHtmlString(info.HtmlExibitInfo, dirUrl);
        }
コード例 #26
0
ファイル: WebViewController.cs プロジェクト: moostep/Reqqr
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            webView = new UIWebView();
            View.AddSubview(webView);
            webView.LoadHtmlString(response.Body, null);
        }
コード例 #27
0
            public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
            {
                if (indexPath.Section == 0)
                {
                    var cell = tableView.DequeueReusableCell("BookDetail");
                    if (cell == null)
                    {
                        cell = new UITableViewCell(UITableViewCellStyle.Default, "BookDetail");
                    }

                    foreach (var subview in cell.ContentView.Subviews)
                    {
                        subview.RemoveFromSuperview();
                    }

                    string body = "<html><head><meta name=\"viewport\" content=\"initial-scale=1.0, user-scalable=no\"/></head><body style=\"-webkit-text-size-adjust:none;background:{0};margin:10px 15px 15px;font-family:helvatica,arial,sans-serif;font-size:16;\">{1}</body></html>";
                    string html;
                    if (model.Author == null)
                    {
                        html = "<b>No Information Available</b>";
                    }
                    else
                    {
                        html  = String.Format("<img src='http://images.amazon.com/images/P/{0}.01.ZTZZZZZZ.jpg' align='left' style='max-height:125px;max-width:75px;padding:0px' />", model.ISBN10);
                        html += model.Contributor + "<br/><br/>";
                        html += "<b>Publisher</b>: " + model.Publisher + "<br/>";
                        html += model.Description + "<br/><br/>";
                        html += "<b>List Price</b>: $" + model.Price + "<br/><br/>";
                    }

                    UIWebView view       = new UIWebView(new CGRect(10, 10, 280, 232));
                    UIView    scrollView = view.Subviews.Last();
                    if (scrollView is UIScrollView)
                    {
                        ((UIScrollView)scrollView).ScrollEnabled = false;
                    }

                    view.LoadHtmlString(String.Format(body, "#FFFFFF", html), new NSUrl(Environment.CurrentDirectory, true));

                    cell.ContentView.AddSubview(view);

                    return(cell);
                }
                else
                {
                    var cell = tableView.DequeueReusableCell("BookLink");
                    if (cell == null)
                    {
                        cell = new UITableViewCell(UITableViewCellStyle.Default, "BookLink");
                        cell.SelectionStyle = UITableViewCellSelectionStyle.Blue;
                        cell.Accessory      = UITableViewCellAccessory.DisclosureIndicator;
                    }

                    cell.TextLabel.Text = links[(indexPath.Section - 1) * 2];

                    return(cell);
                }
            }
コード例 #28
0
		private void OnLoadFailed(UIWebView webView, NSError error)
		{
			// Report the error inside the web view.
			var localizedErrorMessage = "An error occured:".Localize ();
			var errorHTML = string.Format ("<!doctype html><html><body><div style=\"width: 100%%; text-align: center; font-size: 36pt;\">{0} {1}</div></body></html>", localizedErrorMessage, error.Description);

			webView.LoadHtmlString (errorHTML, null);
			UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
		}
コード例 #29
0
        private void OnLoadFailed(UIWebView webView, NSError error)
        {
            // Report the error inside the web view.
            var localizedErrorMessage = "An error occured:".Localize();
            var errorHTML             = string.Format("<!doctype html><html><body><div style=\"width: 100%%; text-align: center; font-size: 36pt;\">{0} {1}</div></body></html>", localizedErrorMessage, error.Description);

            webView.LoadHtmlString(errorHTML, null);
            UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
        }
コード例 #30
0
        void UpdateConditionDisplay()
        {
            if (View != null)
            {
                foreach (GradientButton b in ConditionButtons)
                {
                    b.RemoveFromSuperview();
                }


                ConditionButtons.Clear();

                float xLoc = ConditionMargin;
                float yLoc = 79 + ConditionMargin;
                foreach (ActiveCondition c in _Character.Monster.ActiveConditions)
                {
                    GradientButton b = new GradientButton();

                    b.Frame = new CGRect(xLoc, yLoc, ConditionWidth, ConditionHeight);
                    b.SetImage(UIExtensions.GetSmallIcon(c.Condition.Image), UIControlState.Normal);
                    View.AddSubview(b);
                    if (c.Turns != null)
                    {
                        b.SetText(c.Turns.ToString());
                    }
                    b.Data             = c;
                    c.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
                    {
                        if (e.PropertyName == "Turns")
                        {
                            string text = "";
                            if (c.Turns != null)
                            {
                                text = c.Turns.ToString();
                            }
                            b.SetText(text);
                            b.TitleLabel.AdjustsFontSizeToFitWidth = true;
                        }
                    };

                    ButtonStringPopover p = new ButtonStringPopover(b);
                    BuildConditionMenu(p, c);

                    xLoc += ConditionWidth + ConditionMargin;

                    if (xLoc + ConditionWidth > View.Bounds.Width)
                    {
                        xLoc  = ConditionMargin;
                        yLoc += ConditionHeight + ConditionMargin;
                    }
                    UIWebView v = new UIWebView(new CGRect(0, 0, 300, 300));
                    v.LoadHtmlString(ConditionViewController.ConditionHTML(c.Condition), new NSUrl("http://localhost/"));
                    p.AccessoryView = v;
                }
            }
        }
コード例 #31
0
 public override void SetValue(object value)
 {
     if (value != null)
     {
         string html           = (string)value;
         var    MarkDownEngine = new MarkdownDeep.Markdown();
         html = MarkDownEngine.Transform(html);
         webView.LoadHtmlString(html, new Foundation.NSUrl(""));
     }
 }
コード例 #32
0
 public override void ViewWillAppear(bool animated)
 {
     base.ViewWillAppear(animated);
     this.View.BackgroundColor = UIColor.White;
     webView       = new UIWebView(this.View.Bounds);
     webView.Frame = new CGRect(0, 0, this.View.Bounds.Width, this.View.Bounds.Height);
     this.View.AddSubview(webView);
     webView.LoadHtmlString(m_htmlString, NSBundle.MainBundle.BundleUrl);
     webView.ScalesPageToFit = false;
 }
コード例 #33
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            try {
                basedir = Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
                basedir = basedir.Replace("Documents", "Monospace2.app");
                webView.LoadHtmlString(FormatText(), new NSUrl(basedir + "/Sponsors/", true));
            } catch (Exception ex) { Console.WriteLine(ex); }
        }
コード例 #34
0
        public override void ViewDidLoad()
        {
            Title = "Web";
            NavigationController.NavigationBar.Translucent = false;
            var webFrame = UIScreen.MainScreen.ApplicationFrame;

            webFrame.Y      += 25f;
            webFrame.Height -= 40f;

            web = new UIWebView(webFrame)
            {
                BackgroundColor  = UIColor.White,
                ScalesPageToFit  = true,
                AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
            };
            web.LoadStarted += delegate {
                UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
            };
            web.LoadFinished += delegate {
                UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
            };
            web.LoadError += (webview, args) => {
                UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
                web.LoadHtmlString(String.Format("<html><center><font size=+5 color='red'>An error occurred:<br>{0}</font></center></html>", args.Error.LocalizedDescription), null);
            };
            View.AddSubview(web);

            // Delegate = new
            var urlField = new UITextField(new CGRect(20f, 10f, View.Bounds.Width - (20f * 2f), 30f))
            {
                BorderStyle            = UITextBorderStyle.Bezel,
                TextColor              = UIColor.Black,
                Placeholder            = "<enter a URL>",
                Text                   = "http://ios.xamarin.com/",
                BackgroundColor        = UIColor.White,
                AutoresizingMask       = UIViewAutoresizing.FlexibleWidth,
                ReturnKeyType          = UIReturnKeyType.Go,
                KeyboardType           = UIKeyboardType.Url,
                AutocapitalizationType = UITextAutocapitalizationType.None,
                AutocorrectionType     = UITextAutocorrectionType.No,
                ClearButtonMode        = UITextFieldViewMode.Always
            };

            urlField.ShouldReturn = delegate(UITextField field){
                field.ResignFirstResponder();
                web.LoadRequest(NSUrlRequest.FromUrl(new NSUrl(field.Text)));

                return(true);
            };

            View.AddSubview(urlField);

            web.LoadRequest(NSUrlRequest.FromUrl(new NSUrl("http://ios.xamarin.com/")));
        }
コード例 #35
0
		public TriumphatorWebViewController () : base()
		{
			Title = Locale.GetText ("Speisekarte");
			_webView = new UIWebView ();
			_webView.ScalesPageToFit = true;
			//_webView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
			_webView.LoadError += (webview, args) => {
				if (_webView != null)
					_webView.LoadHtmlString (
						String.Format ("<html><center><font color='red'>{0}:<br>{1}</font></center></html>",
						"An error occurred:", args.Error.LocalizedDescription), null);
			};
		}
コード例 #36
0
        // We use MonoTouch.Dialog to visually represent the parsed json data
        // http://docs.xamarin.com/guides/ios/user_interface/monotouch.dialog/
        public WeatherViewController(RootObject json)
            : base(null, true)
        {
            var item = json.Query.Results.Channel.Item;

            Root = new RootElement ("Weather in Boston, MA") {
                new Section (item.Title) {
                    new StyledStringElement ("Latitude", item.Lat, UITableViewCellStyle.Subtitle),
                    new StyledStringElement ("Longitude", item.Lon, UITableViewCellStyle.Subtitle),
                    new RootElement ("Current Condition") {
                        new Section () {
                            new StyledStringElement ("Code", item.Condition.Code, UITableViewCellStyle.Subtitle),
                            new StyledStringElement ("Date", item.Condition.Date, UITableViewCellStyle.Subtitle),
                            new StyledStringElement ("Temp", item.Condition.Temp, UITableViewCellStyle.Subtitle),
                            new StyledStringElement ("Text", item.Condition.Text, UITableViewCellStyle.Subtitle)
                        }
                    },
                    new RootElement ("Forecast") {
                        item.Forecast.Where (f => f != null).Select (f => {
                            return new Section (f.Day + ", " + f.Date) {
                                new StyledStringElement ("Code", f.Code, UITableViewCellStyle.Subtitle),
                                new StyledStringElement ("High", f.High, UITableViewCellStyle.Subtitle),
                                new StyledStringElement ("Low", f.Low, UITableViewCellStyle.Subtitle),
                                new StyledStringElement ("Text", f.Text, UITableViewCellStyle.Subtitle)
                            };
                        })
                    },
                    new HtmlElement ("Link to site", item.Link),
                    new StringElement ("Description", ()=> {
                        var webViewController = new UIViewController ();
                        var webView = new UIWebView (View.Frame);
                        webView.LoadHtmlString (item.Description, null);
                        webViewController.View.Add (webView);
                        NavigationController.PushViewController (webViewController, true);
                    }),
                    new RootElement ("Guid") {
                        new Section () {
                            new StyledStringElement ("IsPermaLink", item.Guid.IsPermaLink, UITableViewCellStyle.Subtitle),
                            new StyledStringElement ("Content", item.Guid.Content, UITableViewCellStyle.Subtitle)
                        }
                    }
                },
                new Section () {
                    new RootElement ("Show Parsed Json") {
                        new Section () {
                            new MultilineElement (json.Dump ())
                        }
                    }
                }
            };
        }
コード例 #37
0
		public override void ViewDidLoad ()
		{
			Title = "Web";
			NavigationController.NavigationBar.Translucent = false;
			var webFrame = UIScreen.MainScreen.ApplicationFrame;
			webFrame.Y += 25f;
			webFrame.Height -= 40f;

			web = new UIWebView (webFrame) {
				BackgroundColor = UIColor.White,
				ScalesPageToFit = true,
				AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
			};
			web.LoadStarted += delegate {
				UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
			};
			web.LoadFinished += delegate {
				UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
			};
			web.LoadError += (webview, args) => {
				UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
				web.LoadHtmlString (String.Format ("<html><center><font size=+5 color='red'>An error occurred:<br>{0}</font></center></html>", args.Error.LocalizedDescription), null);
			};
			View.AddSubview (web);

			// Delegate = new
			var urlField = new UITextField (new CGRect (20f, 10f, View.Bounds.Width - (20f * 2f), 30f)){
				BorderStyle = UITextBorderStyle.Bezel,
				TextColor = UIColor.Black,
				Placeholder = "<enter a URL>",
				Text = "http://ios.xamarin.com/",
				BackgroundColor = UIColor.White,
				AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
				ReturnKeyType = UIReturnKeyType.Go,
				KeyboardType = UIKeyboardType.Url,
				AutocapitalizationType = UITextAutocapitalizationType.None,
				AutocorrectionType = UITextAutocorrectionType.No,
				ClearButtonMode = UITextFieldViewMode.Always
			};

			urlField.ShouldReturn = delegate (UITextField field){
				field.ResignFirstResponder ();
				web.LoadRequest (NSUrlRequest.FromUrl (new NSUrl (field.Text)));

				return true;
			};

			View.AddSubview (urlField);

			web.LoadRequest (NSUrlRequest.FromUrl (new NSUrl ("http://ios.xamarin.com/")));
		}
コード例 #38
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            Title = "Tips";
            View.BackgroundColor = UIColor.GroupTableViewBackgroundColor;

            ReadHelpHtml();

            _webView = new UIWebView();
            _webView.Frame = new RectangleF(0, 0, 320, 480);
            _webView.LoadHtmlString(_tipsHtml, new NSUrl("/"));
            _webView.BackgroundColor = UIColor.Clear;
            _webView.Opaque = false;
            View.AddSubview(_webView);
        }
コード例 #39
0
        /// <summary>
        /// Configures the UIWebView when the view loads.
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = _category.Name;
            View.BackgroundColor = UIColor.GroupTableViewBackgroundColor;

            string html = ReplaceTokens();
            _webView = new UIWebView();
            _webView.Frame = new RectangleF(0, 0, 320, 480);
            _webView.LoadHtmlString(html, new NSUrl("/"));
            _webView.BackgroundColor = UIColor.Clear;
            _webView.Opaque = false;
            View.AddSubview(_webView);
        }
コード例 #40
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			webView = new UIWebView (UIScreen.MainScreen.Bounds);
			View.Add (webView);

			// Intercept URL loading to handle native calls from browser
			webView.ShouldStartLoad += HandleShouldStartLoad;

			// Render the view from the type generated from RazorView.cshtml

			var model = App.Database.GetItems ().ToList ();
			var template = new TodoList () { Model = model };
			var page = template.GenerateString ();
			webView.LoadHtmlString (page, NSBundle.MainBundle.BundleUrl);
		}
コード例 #41
0
ファイル: iosController.cs プロジェクト: hadasii/soundycon
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();
                // Perform any additional setup after loading the view, typically from a nib.
                webView = new UIWebView(UIScreen.MainScreen.Bounds);
                View.Add(webView);

                // Intercept URL loading to handle native calls from browser
                //webView.ShouldStartLoad += HandleShouldStartLoad;

                // Render the view from the type generated from RazorView.cshtml

                //var model = App.Database.GetItems().ToList();
            var template = new MainPage(); //new RazorView() ;
                var page = template.GenerateString();
                webView.LoadHtmlString(page, NSBundle.MainBundle.BundleUrl);
        }
コード例 #42
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            webView = new UIWebView { ScalesPageToFit = true };

            webView.LoadStarted += delegate {
                UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
            };
            webView.LoadFinished += delegate {
                UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
            };

            webView.LoadHtmlString(FormatText(), new NSUrl());
            webView.SizeToFit();
            webView.Frame = new RectangleF (0, 0, this.View.Frame.Width, this.View.Frame.Height - 44);
            this.View.AddSubview(webView);
        }
コード例 #43
0
ファイル: CustomHtmlElement.cs プロジェクト: 21Off/21Off
		public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path)
		{
			tableView.DeselectRow (path, true);
			
			//base.Selected (dvc, tableView, path);
			
			var evc = new EmptyViewController(()=>
			{
				nav.PopViewControllerAnimated(true);
			}, Caption);			
			
			var vc = new WebViewController (this) {
				Autorotate = dvc.Autorotate
			};
			var web = new UIWebView (UIScreen.MainScreen.ApplicationFrame){
				BackgroundColor = UIColor.White,
				ScalesPageToFit = true,
				AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
			};
			web.LoadStarted += delegate {
				NetworkActivity = true;
				var indicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.White);
				vc.NavigationItem.RightBarButtonItem = new UIBarButtonItem(indicator);
				indicator.StartAnimating();
			};
			web.LoadFinished += delegate {
				NetworkActivity = false;
				vc.NavigationItem.RightBarButtonItem = null;
			};
			web.LoadError += (webview, args) => {
				NetworkActivity = false;
				vc.NavigationItem.RightBarButtonItem = null;
				if (web != null)
					web.LoadHtmlString (String.Format ("<html><center><font size=+5 color='red'>An error occurred:<br>{0}</font></center></html>", args.Error.LocalizedDescription), null);
			};
			vc.NavigationItem.Title = Caption;
			vc.View.AddSubview (web);
			//vc.View.Frame = new RectangleF(0, 41 , 320, 480 - 41);
			
			evc.Add(vc.View);
			nav.PushViewController(evc, true);
			
			web.LoadRequest (NSUrlRequest.FromUrl (new NSUrl (Url)));
		}
コード例 #44
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();
            // no XIB !
            webView = new UIWebView()
            {
                ScalesPageToFit = false
            };
            webView.LoadHtmlString(FormatText(), new NSUrl());

            // Set the web view to fit the width of the app.
            webView.SizeToFit();

            // Reposition and resize the receiver
            webView.Frame = new RectangleF (0, 0, this.View.Bounds.Width, this.View.Bounds.Height);

            // Add the table view as a subview
            this.View.AddSubview(webView);
        }
コード例 #45
0
ファイル: BusStopViewController.cs プロジェクト: runegri/MuPP
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            _view = new UIView();
            _view.BackgroundColor = UIColor.GroupTableViewBackgroundColor;

            UILabel label = new UILabel();
            label.Text = _stopInfo.StopName;
            label.BackgroundColor = UIColor.GroupTableViewBackgroundColor;
            label.SizeToFit();
            label.Frame = new RectangleF(10,0, 300, 40);

            _view.Add(label);

            UIButton button = UIButton.FromType(UIButtonType.RoundedRect);
            button.SetTitle("Legg til i favoritter", UIControlState.Normal);;

            button.Frame = new RectangleF(10, 120, 150, 50);

            _view.Add(button);

            _view.SizeToFit();

            button.TouchUpInside += delegate {
                _busStopRepository.AddFavorite(_stopInfo);
            };

            webView = new UIWebView { ScalesPageToFit = false };

            webView.LoadHtmlString (FormatText (), new NSUrl ());

            // Set the web view to fit the width of the app.
            webView.SizeToFit ();

            // Reposition and resize the receiver
            _view.Frame = new RectangleF (0, 0, this.View.Bounds.Width, this.View.Bounds.Height);

            // Add the table view as a subview
            this.View.AddSubview (_view);
        }
コード例 #46
0
        public override void ViewDidLoad()
        {
            Title = "Information";
            base.ViewDidLoad ();

            UIImageView imageView = new UIImageView();
            imageView.Image = UIImage.FromFile("Assets/Images/defaultbg.png");
            imageView.Frame = new System.Drawing.RectangleF(0,0,320,480);
            View.AddSubview(imageView);

            _webView = new UIWebView();
            _webView.Alpha = 0; // no white flashing
            _webView.BackgroundColor = UIColor.Clear;
            _webView.Opaque = false;
            _webView.Delegate = new DefaultWebDelegate();
            _webView.Frame = new System.Drawing.RectangleF(0, 0, 320, 480);
            _webView.LoadHtmlString(HtmlTemplate.InformationTemplate, new NSUrl("/"));

            View.AddSubview(_webView);
            View.BringSubviewToFront(_webView);
        }
コード例 #47
0
		public async override void LoadView ()
		{
			base.LoadView ();

			Reader reader = new Reader();
			Article article;

			try
			{
				article = await reader.Read(new Uri(_url));
				var webView = new UIWebView (View.Frame);
				webView.LoadHtmlString(article.Content, new NSUrl(_url));

				Add(webView);
			}
			catch (ReadException exc)
			{
				// handle exception
			}

		}
コード例 #48
0
ファイル: WebElement.cs プロジェクト: jsuo/CodeBucket
        public WebElement (string content, string cellKey, bool rawContentLoad) 
            : base (string.Empty)
        {
            Key = new NSString(cellKey);
            _rawContentLoad = rawContentLoad;
            WebView = new UIWebView();
            WebView.ScrollView.ScrollEnabled = false;
            WebView.ScrollView.Bounces = false;
            WebView.ShouldStartLoad = (w, r, n) => ShouldStartLoad(r, n);
            WebView.LoadFinished += (sender, e) => {
                if (!string.IsNullOrEmpty(_value))
                    LoadContent(_value);
                _isLoaded = true;
            };

            WebView.LoadHtmlString(content, new NSUrl(""));
            HeightChanged = (x) => {
                if (GetImmediateRootElement() != null)
                    GetImmediateRootElement().Reload(this, UITableViewRowAnimation.Fade);
            };
        }
コード例 #49
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();
            // no XIB !
            webView = new UIWebView()
            {
                ScalesPageToFit = false
            };

            basedir = Environment.GetFolderPath (System.Environment.SpecialFolder.Personal);
            basedir = basedir.Replace("Documents", "PDC09.app");

            webView.LoadHtmlString(FormatText(), null);//new NSUrl(basedir+"/Sponsors/", true));

            // Set the web view to fit the width of the app.
            webView.SizeToFit();

            // Reposition and resize the receiver
            webView.Frame = new RectangleF (0, 0, this.View.Frame.Width, this.View.Frame.Height-90);

            // Add the table view as a subview
            this.View.AddSubview(webView);
        }
コード例 #50
0
        public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path)
        {
            int i = 0;
            var vc = new UIViewController()
            {
                //Autorotate = dvc.Autorotate
            };

            webView = new UIWebView(UIScreen.MainScreen.Bounds)
            {
                BackgroundColor = UIColor.White,
                ScalesPageToFit = true,
                AutoresizingMask = UIViewAutoresizing.All
            };

            webView.LoadHtmlString(html, new NSUrl("HtmlContent", true));

            vc.NavigationItem.Title = Caption;

            vc.View.AutosizesSubviews = true;
            vc.View.AddSubview(webView);

            dvc.ActivateController(vc);
        }
コード例 #51
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			this.NavigationController.NavigationBar.SetTitleTextAttributes (
				new UITextAttributes () { TextColor = UIColor.Red}
			);

			this.NavigationController.NavigationBar.TintColor = UIColor.Red;

			this.View.BackgroundColor = UIColor.White;
			webView = new UIWebView (new RectangleF (0, 0, this.View.Frame.Size.Width, this.View.Frame.Size.Height));
			webView.Delegate = new WebViewDelegate ();

			webView.AutosizesSubviews = true;
			webView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;

			this.View.Add (webView);

			webView.ScalesPageToFit = true;
			string html = article.CommentsAsHtml ();
			webView.LoadHtmlString (html, null);

		}
コード例 #52
0
        public override void ViewDidLoad()
        {
            try {
                webView = new UIWebView();
                webView.ScrollView.Bounces = false;
                Add(webView);

                webView.ShouldStartLoad += delegate(UIWebView v, NSUrlRequest request, UIWebViewNavigationType navigationType) {
                    if (navigationType == UIWebViewNavigationType.LinkClicked)
                    {
                        var c = new WebBrowserController(request.Url.AbsoluteString);
                        NavigationController.PushViewController(c, true);
                        return false;
                    }

                    return true;
                };

                webView.LoadHtmlString(_user.about_me, new NSUrl("http://" + Config.CurrentSite.api_site_parameter));
            }
            catch (Exception ex) {
                this.UnhandledError(ex);
            }
        }
コード例 #53
0
		public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path)
		{
			var vc = new WebViewController (this) {
				Autorotate = dvc.Autorotate
			};

			web = new UIWebView (UIScreen.MainScreen.Bounds) {
				BackgroundColor = UIColor.White,
				AutoresizingMask = UIViewAutoresizing.All
			};

			// We delete cache and cookies so it does not remember our login information
			DeleteCacheandCookies ();


			web.LoadStarted += (webview, e) => {
				NetworkActivity = true;
			};

			web.LoadFinished += (webview, e) =>  {
				NetworkActivity = false;
				var wb = webview as UIWebView;
				FacebookOAuthResult oauthResult;
				if (!_fb.TryParseOAuthCallbackUrl (new Uri (wb.Request.Url.ToString()), out oauthResult))
				{
					return;
				}
				
				if (oauthResult.IsSuccess)
				{
					// Facebook Granted Token
					var accessToken = oauthResult.AccessToken;
					LoginSucceded(accessToken, dvc);
				}
				else
				{
					// user cancelled login
					LoginSucceded(string.Empty, dvc);
				}
			};

			web.LoadError += (webview, args) => {
				NetworkActivity = false;
				if (web != null)
					web.LoadHtmlString (
						String.Format ("<html><center><font size=+5 color='red'>{0}:<br>{1}</font></center></html>",
					               "An error occurred: ", args.Error.LocalizedDescription), null);
			};
			vc.NavigationItem.Title = Caption;
			
			vc.View.AutosizesSubviews = true;
			vc.View.AddSubview (web);

			dvc.ActivateController (vc);
			web.LoadRequest (NSUrlRequest.FromUrl (nsUrl));
		}
コード例 #54
0
ファイル: VideoCell.cs プロジェクト: bpug/LbkIos
		private void Initialize ()
		{
			this.webview = new UIWebView (new RectangleF (PIC_XPAD, PIC_YPAD, PIC_SIZE, PIC_SIZE));
			this.webview.ScalesPageToFit = true;
			this.webview.AutoresizingMask = UIViewAutoresizing.None;
			this.webview.LoadFinished += (sender, e) => {
				_btnYoutube = this.webview.FirstOrDefault<UIButton> ();
				/* Autoplay
					if (_btnYoutube != null) {
						_btnYoutube.SendActionForControlEvents (UIControlEvent.TouchUpInside);
					}
					*/
			};
			webview.LoadStarted += delegate {
				Util.PushNetworkActive ();
			};
			webview.LoadFinished += delegate {
				Util.PopNetworkActive ();
			};
			webview.LoadError += (web, args) => {
				Util.PopNetworkActive ();
				if (webview != null)
					webview.LoadHtmlString (
						String.Format ("<html><center><font color='red'>{0}:<br>{1}</font></center></html>",
						"An error occurred:", args.Error.LocalizedDescription), null);
			};
			
			UpdateCell (Video);
			
			ContentView.Add (this.webview);
		}
コード例 #55
0
ファイル: UsageAgreement.cs プロジェクト: dkme/moooyo
        public static UIView GetAgreementView(float viewWidth, float viewHeight)
        {
            UIView View = new UIView(new RectangleF((viewWidth - 290) / 2, 25, 290, 450));
            View.BackgroundColor = UIColor.Clear;

            UIImageView backImageView = new UIImageView(new RectangleF(0, 0, 290, 450));
            backImageView.Image = AGREEMENTBACKIMAGE;
            backImageView.BackgroundColor = UIColor.Clear;

            UILabel titleLable = new UILabel(new RectangleF(20, 12, 100, 20));
            titleLable.TextAlignment = UITextAlignment.Left;
            titleLable.TextColor = UIColor.FromRGB(200, 20, 30);
            titleLable.Font = UIFont.FromName(FONTFAMILY, 16);
            titleLable.BackgroundColor = UIColor.Clear;
            titleLable.Text = "使用协议";

            UIWebView textView = new UIWebView(new RectangleF(22, 50, 247, 330));
            textView.LoadHtmlString(html, new NSUrl(NSBundle.MainBundle.BundlePath, true));
            textView.BackgroundColor = UIColor.FromRGB(250, 250, 250);

            UIButton button = new UIButton(new RectangleF(15, 385 , 257, 50));
            button.SetImage(AGREEMENTBUTTONOUT, UIControlState.Normal);
            button.AdjustsImageWhenHighlighted = false;
            UILabel buttonTitle = new UILabel(new RectangleF(100, 0, 60, 50));
            buttonTitle.Text = "确定";
            buttonTitle.Font = UIFont.FromName(FONTFAMILY, 18);
            buttonTitle.TextColor = UIColor.FromRGB(255, 255, 255);
            buttonTitle.BackgroundColor = UIColor.Clear;
            buttonTitle.TextAlignment = UITextAlignment.Center;
            button.Add(buttonTitle);
            button.TouchUpInside += (sender, e) =>
            {
                button.SetImage(AGREEMENTBUTTONIN, UIControlState.Normal);
                CloseAgreement();
            };
            button.TouchDown += (sender, e) =>
            {
                button.SetImage(AGREEMENTBUTTONIN, UIControlState.Normal);
            };
            button.TouchDragInside += (sender, e) =>
            {
                button.SetImage(AGREEMENTBUTTONOUT, UIControlState.Normal);
            };

            View.Add(backImageView);
            View.Add(titleLable);
            View.Add(textView);
            View.Add(button);

            return View;
        }
コード例 #56
0
ファイル: IPhoneNet.cs プロジェクト: jioe/appverse-mobile
        private void OpenBrowserOnThread(object browserCommandObject)
        {
            BrowserCommand browserCommand = (BrowserCommand)browserCommandObject;

            UIApplication.SharedApplication.InvokeOnMainThread (delegate {

                IPhoneUIViewController contentController = new IPhoneUIViewController(browserCommand.Title, browserCommand.ButtonText);

                UIWebView webView = new UIWebView();
                webView.ScalesPageToFit = true;
                webView.LoadStarted+= delegate (object sender, EventArgs e) {
                    UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
                };
                webView.LoadFinished+=delegate (object sender, EventArgs e) {
                    UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;

                    // stop notify loading masks if any
                    INotification notificationService = (INotification)IPhoneServiceLocator.GetInstance ().GetService ("notify");
                    notificationService.StopNotifyLoading();
                };
                contentController.AddInnerView(webView);

                IPhoneServiceLocator.CurrentDelegate.MainUIViewController ().PresentModalViewController(contentController, true);
                IPhoneServiceLocator.CurrentDelegate.SetMainUIViewControllerAsTopController(false);
                if(browserCommand.Url!=null && browserCommand.Url.Length>0) {
                    NSUrl nsUrl = new NSUrl (browserCommand.Url);
                    NSUrlRequest  nsUrlRequest = new NSUrlRequest(nsUrl,NSUrlRequestCachePolicy.ReloadRevalidatingCacheData, 120.0);
                    webView.LoadRequest(nsUrlRequest);
                } else if(browserCommand.Html!=null && browserCommand.Html.Length>0) {
                    webView.LoadHtmlString(browserCommand.Html, new NSUrl("/"));
                }

            });
        }
コード例 #57
0
ファイル: Elements.cs プロジェクト: mauropm/Monospace11
        public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path)
        {
            var vc = new WebViewController (this) {
                Autorotate = dvc.Autorotate
            };
            web = new UIWebView (UIScreen.MainScreen.ApplicationFrame){
                BackgroundColor = UIColor.White,
                ScalesPageToFit = true,
                AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
            };
            web.LoadStarted += delegate {
                NetworkActivity = true;
            };
            web.LoadFinished += delegate {
                NetworkActivity = false;
            };
            web.LoadError += (webview, args) => {
                NetworkActivity = false;
                if (web != null)
                    web.LoadHtmlString (String.Format ("<html><center><font size=+5 color='red'>An error occurred:<br>{0}</font></center></html>", args.Error.LocalizedDescription), null);
            };
            vc.NavigationItem.Title = Caption;
            vc.View.AddSubview (web);

            dvc.ActivateController (vc);
            web.LoadRequest (NSUrlRequest.FromUrl (nsUrl));
        }
コード例 #58
0
		bool HandleShouldStartLoad (UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType) {
			var scheme = "hybrid:";
			// If the URL is not our own custom scheme, just let the webView load the URL as usual
			if (request.Url.Scheme != scheme.Replace(":", ""))
				return true;

			// This handler will treat everything between the protocol and "?"
			// as the method name.  The querystring has all of the parameters.
			var resources = request.Url.ResourceSpecifier.Split('?');
			var method = resources [0];
			var parameters = System.Web.HttpUtility.ParseQueryString(resources[1]); // breaks if ? not present (ie no params)

			if (method == "") {
				var template = new TodoView () { Model = new TodoItem() };
				var page = template.GenerateString ();
				webView.LoadHtmlString (page, NSBundle.MainBundle.BundleUrl);
			}
			else if (method == "ViewTask") {
				var id = parameters ["todoid"];
				var model = App.Database.GetItem (Convert.ToInt32 (id));
				var template = new TodoView () { Model = model };
				var page = template.GenerateString ();
				webView.LoadHtmlString (page, NSBundle.MainBundle.BundleUrl);
			} else if (method == "TweetAll") {
				var todos = App.Database.GetItemsNotDone ();
				var totweet = "";
				foreach (var t in todos)
					totweet += t.Name + ",";
				if (totweet == "")
					totweet = "there are no tasks to tweet";
				else 
					totweet = "Still do to:" + totweet;
				var tweetController = new TWTweetComposeViewController ();
				tweetController.SetInitialText (totweet); 
				PresentViewController (tweetController, true, null);
			} else if (method == "TextAll") {
				if (MFMessageComposeViewController.CanSendText) {

					var todos = App.Database.GetItemsNotDone ();
					var totext = "";
					foreach (var t in todos)
						totext += t.Name + ",";
					if (totext == "")
						totext = "there are no tasks to text";

					MFMessageComposeViewController message =
						new MFMessageComposeViewController ();
					message.Finished += (sender, e) => {
						e.Controller.DismissViewController (true, null);
					};
					//message.Recipients = new string[] { receiver };
					message.Body = totext;
					PresentViewController (message, true, null);
				} else {
					new UIAlertView ("Sorry", "Cannot text from this device", null, "OK", null).Show ();
				}
			} else if (method == "TodoView") {
				// the editing form
				var button = parameters ["Button"];
				if (button == "Save") {
					var id = parameters ["id"];
					var name = parameters ["name"];
					var notes = parameters ["notes"];
					var done = parameters ["done"];

					var todo = new TodoItem {
						ID = Convert.ToInt32 (id),
						Name = name,
						Notes = notes,
						Done = (done == "on")
					};

					App.Database.SaveItem (todo);
					NavigationController.PopToRootViewController (true);

				} else if (button == "Delete") {
					var id = parameters ["id"];

					App.Database.DeleteItem (Convert.ToInt32 (id));
					NavigationController.PopToRootViewController (true);

				} else if (button == "Cancel") {
					NavigationController.PopToRootViewController (true);

				} else if (button == "Speak") {
					var name = parameters ["name"];
					var notes = parameters ["notes"];
					Speech.Speak (name + " " + notes);
				}
			}
			return false;
		}
コード例 #59
0
ファイル: MissionView.cs プロジェクト: rootdevelop/Sunny
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
			
            
            if (((MissionViewModel)ViewModel).Mission.LiveStream)
            {
                chatView.Hidden = false;
                messageField.Hidden = false;
                sendButton.Hidden = false;
                
                firstTitle.Hidden = true;
                secondTitle.Hidden = true;
                imageView.Hidden = true;
                
                var streamingUri = ((MissionViewModel)ViewModel).LiveStreamViewModel.LiveStreamUrl;
                
                _asset = AVAsset.FromUrl(NSUrl.FromString(streamingUri));
                _playerItem = new AVPlayerItem(_asset);
                
                _player = new AVPlayer(_playerItem);

                _playerLayer = AVPlayerLayer.FromPlayer(_player);
                _playerLayer.Frame = new RectangleF(21, 88, 602, 311);
                View.Layer.AddSublayer(_playerLayer);
                _player.Play();
                
                ((MissionViewModel)ViewModel).LiveStreamViewModel.UserName = "******";
                
                chatView.Text = "";
                
                var previousText = string.Empty;
                
                SunnySocket.MessageReceivedAsyncCallback = (string name, string message) =>
                InvokeOnMainThread(() =>
                {
                    if (message != previousText)
                    {
                        chatView.Text = name + " - " + message + "\n" + chatView.Text;
                        chatView.Font = UIFont.FromName("HelveticaNeue-Bold", 15);
                        chatView.TextColor = UIColor.FromRGBA(0.027f, 0.102f, 0.389f, 1.000f);
                        previousText = message;
                    }
                });
                
                messageField.ShouldReturn += (x) =>
                {
                    ((MissionViewModel)ViewModel).LiveStreamViewModel.SendMessageCommand.Execute(null); 
                    return true;
                };
                    
                var set = this.CreateBindingSet<MissionView, MissionViewModel>();
                set.Bind(title).To(vm => vm.Mission.Name);
                set.Bind(messageField).To(vm => vm.LiveStreamViewModel.Message);
                set.Bind(backButton).To("GoBackCommand"); 
                set.Bind(sendButton).To("LiveStreamViewModel.SendMessageCommand"); 
                set.Apply();
                
                messageField.BecomeFirstResponder();
            }
            else
            {
                chatView.Hidden = true;
                messageField.Hidden = true;
                sendButton.Hidden = true;
                
                var imageBorder = new UIButton(UIButtonType.System);
                imageBorder.Frame = new RectangleF(imageView.Frame.X - 1, imageView.Frame.Y - 1, imageView.Frame.Width + 2, imageView.Frame.Height + 2);
                imageBorder.BackgroundColor = UIColor.Clear;
                imageBorder.Layer.BorderColor = UIColor.FromRGBA(0.631f, 0.816f, 0.922f, 1.000f).CGColor;
                imageBorder.Layer.CornerRadius = 4;
                imageBorder.Layer.BorderWidth = 1;
                View.AddSubview(imageBorder);
            
                var webview = new UIWebView();
                webview.Frame = new RectangleF(450, 87, 554, 681);
            
                var webviewBorder = new UIButton(UIButtonType.System);
                webviewBorder.Frame = new RectangleF(webview.Frame.X - 1, webview.Frame.Y - 1, webview.Frame.Width + 2, webview.Frame.Height + 2);
                webviewBorder.BackgroundColor = UIColor.Clear;
                webviewBorder.Layer.BorderColor = UIColor.FromRGBA(0.631f, 0.816f, 0.922f, 1.000f).CGColor;
                webviewBorder.Layer.CornerRadius = 4;
                webviewBorder.Layer.BorderWidth = 1;
                View.AddSubview(webviewBorder);
            
                View.AddSubview(webview);
            
                var newsButton = new UIButton(UIButtonType.System);
                newsButton.Frame = new RectangleF(21, 485, 360, 60);
                newsButton.BackgroundColor = UIColor.Clear;
                newsButton.Layer.BorderColor = UIColor.FromRGBA(0.631f, 0.816f, 0.922f, 1.000f).CGColor;
                newsButton.Layer.CornerRadius = 4;
                newsButton.Layer.BorderWidth = 1;
                View.AddSubview(newsButton);

       
                var notifyButton = new UIButton(UIButtonType.System);
                notifyButton.Frame = new RectangleF(21, 605, 360, 60);
                notifyButton.BackgroundColor = UIColor.Clear;
                notifyButton.Layer.BorderColor = UIColor.FromRGBA(0.631f, 0.816f, 0.922f, 1.000f).CGColor;
                notifyButton.Layer.CornerRadius = 4;
                notifyButton.Layer.BorderWidth = 1;
                View.AddSubview(notifyButton);

                notifyButton.TouchUpInside += (sender, e) =>
                {
                    notifyButton.Enabled = false;
                    new UIAlertView("Thank you", "You'll receive a notification when we go fly fly (or boom boom)", null, "Ok").Show();
                };
            
                var imageViewLoader = new MvxImageViewLoader(() => this.imageView);
                        
                var set = this.CreateBindingSet<MissionView, MissionViewModel>();
                set.Bind(imageViewLoader).To(vm => vm.Mission.ImageUri);
                set.Bind(title).To(vm => vm.Mission.Name);
                set.Bind(newsButton).To("ShowMissionNewsOverviewCommand");
                set.Bind(notifyButton).To("InitPushCommand"); 
                set.Bind(backButton).To("GoBackCommand"); 
                set.Apply();
            
                var html = ((MissionViewModel)ViewModel).Mission.Text;
                webview.LoadHtmlString(html, null);     
            
                webview.ShouldStartLoad += shouldStartLoad; 
            }
                   
        }
コード例 #60
0
		public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path)
		{
			int i = 0;
			var vc = new WebViewController (this) {
				Autorotate = dvc.Autorotate
			};

			web = new UIWebView (UIScreen.MainScreen.Bounds) {
				BackgroundColor = UIColor.White,
				ScalesPageToFit = true,
				AutoresizingMask = UIViewAutoresizing.All
			};
			web.LoadStarted += delegate {
				// this is called several times and only one UIActivityIndicatorView is needed
				if (i++ == 0) {
					var indicator = new UIActivityIndicatorView (UIActivityIndicatorViewStyle.White);
					vc.NavigationItem.RightBarButtonItem = new UIBarButtonItem (indicator);
					indicator.StartAnimating ();
				}
				NetworkActivity = true;
			};
			web.LoadFinished += delegate {
				if (--i == 0) {
					// we stopped loading, remove indicator and dispose of UIWebView
					vc.NavigationItem.RightBarButtonItem = null;
					web.StopLoading ();
					web.Dispose ();
				}
				NetworkActivity = false;
			};
			web.LoadError += (webview, args) => {
				NetworkActivity = false;
				vc.NavigationItem.RightBarButtonItem = null;
				if (web != null)
					web.LoadHtmlString (
						String.Format ("<html><center><font size=+5 color='red'>{0}:<br>{1}</font></center></html>",
						"An error occurred:".GetText (), args.Error.LocalizedDescription), null);
			};
			vc.NavigationItem.Title = Caption;
			
			vc.View.AutosizesSubviews = true;
			vc.View.AddSubview (web);
			
			dvc.ActivateController (vc);
			web.LoadRequest (NSUrlRequest.FromUrl (nsUrl));
		}