Beispiel #1
0
        public override void DrawRect(CGRect dirtyRect)
        {
            if (!LiteHtmlContainer.Document.HasRendered)
            {
                return;
            }

            var gfxc = NSGraphicsContext.CurrentContext.GraphicsPort;

            gfxc.SaveState();
            var point = ViewportPoint;

            gfxc.TranslateCTM(point.X, point.Y);

            LiteHtmlContainer.CheckViewportChange();

            LiteHtmlContainer.Context = gfxc;
            LiteHtmlContainer.Draw();
            LiteHtmlContainer.Context = null;

            gfxc.RestoreState();

            if (Drawn != null)
            {
                Drawn();
            }
        }
Beispiel #2
0
 public void SetViewport(CGRect viewport)
 {
     if (LiteHtmlContainer.SetViewport(viewport.Location.ToLiteHtmlPoint(), viewport.Size.ToLiteHtmlSize()))
     {
         SetNeedsDisplayInRect(ViewportRect);
     }
 }
Beispiel #3
0
 public void LoadHtml(string html)
 {
     RemoveAllViewElements();
     LiteHtmlContainer.Document.CreateFromString(html);
     LiteHtmlContainer.CheckViewportChange(forceRender: true);
     SetNeedsDisplayInRect(ViewportRect);
 }
Beispiel #4
0
        // If true then a redraw is needed
        bool CheckViewportChange(bool forceRender = false)
        {
            if (forceRender ||
                (int)LiteHtmlContainer.ContextSize.Width != (int)Viewport.Size.Width ||
                (int)LiteHtmlContainer.ContextSize.Height != (int)Viewport.Size.Height)
            {
                LiteHtmlContainer.ContextSize  = Viewport.Size;
                LiteHtmlContainer.ScrollOffset = Viewport.Location.ToLiteHtmlPoint();
                LiteHtmlContainer.Document.OnMediaChanged();
                LiteHtmlContainer.Render();
                return(true);
            }

            if ((int)LiteHtmlContainer.ScrollOffset.Y != (int)Viewport.Location.Y ||
                (int)LiteHtmlContainer.ScrollOffset.X != (int)Viewport.Location.X)
            {
                LiteHtmlContainer.ScrollOffset = Viewport.Location.ToLiteHtmlPoint();
                return(true);
            }

            return(false);
        }
Beispiel #5
0
        void Btn_Activated(object sender, EventArgs e)
        {
            var btn = (LiteHtmlNSButton)sender;

            LiteHtmlContainer.TriggerAnchorClicked(btn.Href);
        }