Beispiel #1
0
        public ReactView(bool usePreloadedWebView = true)
        {
            if (usePreloadedWebView)
            {
                view = CreateReactViewInstance();
            }
            else
            {
                view = new ReactViewRender(false);
            }
            SetResourceReference(StyleProperty, typeof(ReactView)); // force styles to be inherited, must be called after view is created otherwise view might be null
            Content = view;
            Dispatcher.BeginInvoke(DispatcherPriority.Send, (Action)(() => {
                if (!view.IsDisposing)
                {
                    if (EnableHotReload)
                    {
                        view.EnableHotReload(Source);
                    }
                    view.LoadComponent(this);
                }
            }));

            FocusManager.SetIsFocusScope(this, true);
            FocusManager.SetFocusedElement(this, view.FocusableElement);
        }
Beispiel #2
0
        private static ReactViewRender CreateReactViewInstance()
        {
            var result = cachedView;

            cachedView = null;
            Application.Current.Dispatcher.BeginInvoke((Action)(() => {
                if (cachedView == null && !Application.Current.Dispatcher.HasShutdownStarted)
                {
                    cachedView = new ReactViewRender();
                    if (window == null)
                    {
                        window = new Window()
                        {
                            ShowActivated = false,
                            WindowStyle = WindowStyle.None,
                            ShowInTaskbar = false,
                            Visibility = Visibility.Hidden,
                            Width = 50,
                            Height = 50,
                            Top = int.MinValue,
                            Left = int.MinValue,
                            IsEnabled = false,
                            Title = "ReactViewRender Background Window"
                        };
                        window.Closed += (o, e) => {
                            cachedView?.Dispose();
                            cachedView = null;
                        };
                        window.Show();
                    }
                    window.Content = cachedView;
                }
            }), DispatcherPriority.Background);
            return(result ?? new ReactViewRender());
        }
 public InternalWebView(ReactViewRender owner, bool preloadBrowser)
 {
     this.owner         = owner;
     IsSecurityDisabled = true; // must be set before InitializeBrowser
     if (preloadBrowser)
     {
         InitializeBrowser();
     }
 }
Beispiel #4
0
        private static ReactViewRender CreateReactViewInstance()
        {
            var result = cachedView;

            cachedView = null;
            Application.Current.Dispatcher.BeginInvoke((Action)(() => {
                if (cachedView == null && !Application.Current.Dispatcher.HasShutdownStarted)
                {
                    cachedView = new ReactViewRender(true);
                }
            }), DispatcherPriority.Background);
            return(result ?? new ReactViewRender(true));
        }
Beispiel #5
0
 public ReactView(bool usePreloadedWebView = true)
 {
     if (usePreloadedWebView)
     {
         view = CreateReactViewInstance();
     }
     else
     {
         view = new ReactViewRender();
     }
     SetResourceReference(StyleProperty, typeof(ReactView)); // force styles to be inherited, must be called after view is created otherwise view might be null
     Content = view;
     Dispatcher.BeginInvoke(DispatcherPriority.Send, (Action)(() => {
         if (EnableHotReload)
         {
             view.EnableHotReload(Source);
         }
         view.LoadComponent(JavascriptSource, JavascriptName, CreateNativeObject());
     }));
 }
Beispiel #6
0
 public InternalWebView(ReactViewRender owner)
 {
     this.owner = owner;
 }