示例#1
0
        public PresentationSourceFactory(HtmlRenderElementFactory htmlRenderElementFactory, HtmlValueConverter htmlValueConverter, ImageElementContainer imageElementContainer, SvgDefinitionContainer svgDefinitionContainer)
        {
            this.htmlRenderElementFactory = htmlRenderElementFactory;
            this.htmlValueConverter       = htmlValueConverter;
            this.imageElementContainer    = imageElementContainer;
            this.svgDefinitionContainer   = svgDefinitionContainer;

            presentationSources = new List <PresentationSource>();
        }
示例#2
0
        public WebApplicationHost()
        {
            RenderQueue                   renderQueue                   = new RenderQueue();
            HtmlValueConverter            htmlValueConverter            = new HtmlValueConverter();
            SvgValueConverter             svgValueConverter             = new SvgValueConverter();
            SvgDefinitionContainer        svgDefinitionContainer        = new SvgDefinitionContainer(renderQueue);
            ImageElementContainer         imageElementContainer         = new ImageElementContainer();
            EmbeddedResourceObjectFactory embeddedResourceObjectFactory = new EmbeddedResourceObjectFactory(htmlValueConverter);

            HtmlRenderElementFactory htmlRenderElementFactory = new HtmlRenderElementFactory(renderQueue, htmlValueConverter, imageElementContainer, embeddedResourceObjectFactory, svgValueConverter, svgDefinitionContainer);

            PresentationSourceFactory = new PresentationSourceFactory(htmlRenderElementFactory, htmlValueConverter, imageElementContainer, svgDefinitionContainer);
            TaskScheduler             = new TaskScheduler();
            TextMeasurementService    = new TextMeasurementService(htmlValueConverter);
        }
示例#3
0
        public PresentationSource(
            UIElement rootElement,
            HtmlRenderElementFactory htmlRenderElementFactory,
            HtmlValueConverter converter,
            ImageElementContainer imageElementContainer,
            SvgDefinitionContainer svgDefinitionContainer)
        {
            // TODO: Set SynchronizationContext so that all messages get flushed when async callbacks get completed
            this.RootElement = rootElement;
            this.converter   = converter;

            RootElement.IsRootElement = true;

            MouseDevice    = new MouseDevice(this);
            KeyboardDevice = new KeyboardDevice(this);

            MouseDevice.CursorChanged += (sender, e) => Window.Body.SetHtmlStyleProperty("cursor", converter.ToCursorString(MouseDevice.Cursor, htmlRenderElementFactory));
            Window.Body.SetHtmlStyleProperty("cursor", converter.ToCursorString(MouseDevice.Cursor, htmlRenderElementFactory));
            Window.SetApplicationListener(this);

            var dimensions = SetRootElementSize();

            ((FrameworkElement)RootElement).Arrange(new Rect(dimensions.width, dimensions.height));

            IHtmlRenderElement renderElement = ((IHtmlRenderElement)RootElement.GetRenderElement(htmlRenderElementFactory));

            renderElement.Load();

            Window.Body.SetHtmlStyleProperty("overflow", "hidden");
            Window.Body.AppendChild(imageElementContainer.HtmlElement);
            Window.Body.AppendChild(svgDefinitionContainer.HtmlElement);
            Window.Body.AppendChild(renderElement.HtmlElement);

            MouseDevice.Activate();
            KeyboardDevice.Activate();
        }
示例#4
0
        public PresentationSource(UIElement rootElement, HtmlRenderElementFactory htmlRenderElementFactory, HtmlValueConverter converter, ImageElementContainer imageElementContainer, SvgDefinitionContainer svgDefinitionContainer)
        {
            this.RootElement = rootElement;
            this.converter   = converter;

            RootElement.IsRootElement = true;

            MouseDevice    = new MouseDevice(this);
            KeyboardDevice = new KeyboardDevice(this);

            window = Bridge.Html5.Window.Instance;

            MouseDevice.CursorChanged += (sender, e) => Bridge.Html5.Window.Document.Body.SetHtmlStyleProperty("cursor", converter.ToCursorString(MouseDevice.Cursor, htmlRenderElementFactory));
            Bridge.Html5.Window.Document.Body.SetHtmlStyleProperty("cursor", converter.ToCursorString(MouseDevice.Cursor, htmlRenderElementFactory));

            Bridge.Html5.Window.OnKeyDown     = OnKeyDown;
            Bridge.Html5.Window.OnKeyUp       = OnKeyUp;
            Bridge.Html5.Window.OnKeyPress    = PreventKeyboardHandled;
            Bridge.Html5.Window.OnMouseMove   = OnMouseMove;
            Bridge.Html5.Window.OnMouseDown   = OnMouseDown;
            Bridge.Html5.Window.OnMouseUp     = OnMouseUp;
            Bridge.Html5.Window.OnScroll      = OnMouseWheel;
            Bridge.Html5.Window.OnFocus       = e => MouseDevice.Activate();
            Bridge.Html5.Window.OnBlur        = e => MouseDevice.Deactivate();
            Bridge.Html5.Window.OnResize      = e => SetRootElementSize();
            Bridge.Html5.Window.OnClick       = PreventMouseHandled;
            Bridge.Html5.Window.OnContextMenu = PreventMouseHandled;
            Bridge.Html5.Window.AddEventListener("ondblclick", PreventMouseHandled);
            Bridge.Html5.Window.AddEventListener("wheel", OnMouseWheel);

            SetRootElementSize();
            ((FrameworkElement)RootElement).Arrange(new Rect(window.InnerWidth, window.InnerHeight));

            IHtmlRenderElement renderElement = ((IHtmlRenderElement)RootElement.GetRenderElement(htmlRenderElementFactory));

            renderElement.Load();

            Bridge.Html5.Window.Document.Body.Style.Overflow = Overflow.Hidden;
            Bridge.Html5.Window.Document.Body.AppendChild(imageElementContainer.HtmlElement);
            Bridge.Html5.Window.Document.Body.AppendChild(svgDefinitionContainer.HtmlElement);
            Bridge.Html5.Window.Document.Body.AppendChild(renderElement.HtmlElement);

            MouseDevice.Activate();
            KeyboardDevice.Activate();
        }