Example #1
0
        public static UIViewElement CreateHtmlViewElement(string caption, string value, UITextAlignment alignment)
        {
            var html = Regex.Replace(value, @"((http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?)", "<a href='$1'>$1</a>", RegexOptions.Compiled);
            var style = @"<style type='text/css'>body { color: #000; background-color:#e0e0e0; font-family: Helvetica, Arial, sans-serif; font-size:16px; float:" + ((alignment == UITextAlignment.Left) ? "left" : "right") + "; }</style>";
            html = "<html><head>" + style + "</head><body>" + html + "</body>";
            Console.Out.WriteLine("Parsed html: {0}", html);

            var web = new AdvancedWebView();
            web.LoadHtmlString(html, null);

            var size = web.StringSize(html,
                                      UIFont.SystemFontOfSize(10),
                                      new SizeF(UIScreen.MainScreen.Bounds.Width - 20, 2000),
                                      UILineBreakMode.WordWrap);
            float width = size.Width;
            float height = size.Height;
            web.Bounds = new RectangleF(0, 0, width, height);
            web.Center = new PointF(width/2, height/2);

            return new AdvancedUIViewElement(caption, web, false);
        }
Example #2
0
        public static AdvancedWebView CreateHtmlView(string webFilePath, float width, float height)
        {
            NSUrl webFile = NSUrl.FromFilename (webFilePath);
            NSUrlRequest request = new NSUrlRequest (webFile);

            AdvancedWebView web = new AdvancedWebView();
            web.LoadRequest (request);
            web.ScalesPageToFit = false;
            web.SizeToFit ();
            web.Bounds = new RectangleF (0, 0, width, height);
            web.AutoresizingMask = UIViewAutoresizing.FlexibleRightMargin | UIViewAutoresizing.FlexibleBottomMargin;
            web.Center = new PointF(width/2+5, height/2+5);
            return web;
        }