private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            Controller = new VideoPlayerMainController(this);
            LoadingPanel = new LoadingPanel.LoadingPanel
            {
                IsProgressVisible = false,
                ColorScheme =
                {
                    StatusTextColor = new SolidColorBrush(ColorConverter.FromHex("#FFffffff")),
                    BackgroundColor = new SolidColorBrush(Colors.Black),
                    BackgroundOpacity = 0,
                    LoadingColor1 = ColorConverter.FromHex("#FF777777"),
                    LoadingColor2 = ColorConverter.FromHex("#FF111111"),
                    OverlayWidth = 400,
                    OverlayHeight = 260
                },
                Opacity = 0.5
            };
            MediaElementControl.MainUI = this;
            SliderControl.Remote = this;
            VolumeControl.Remote = this;
            PlayControl.Remote = this;
            UrlControl.Remote = this;
            ControlsPanel.Opacity = 0.0;
            VolumeControl.SetVolume(0.5);

            JavaScriptBridge jsBridge = new JavaScriptBridge(Controller);
            HtmlPage.RegisterScriptableObject("glymaVideoPlayerBridge", jsBridge);

            Controller.Initialised();
        }
        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            Controller   = new VideoPlayerMainController(this);
            LoadingPanel = new LoadingPanel.LoadingPanel
            {
                IsProgressVisible = false,
                ColorScheme       =
                {
                    StatusTextColor   = new SolidColorBrush(ColorConverter.FromHex("#FFffffff")),
                    BackgroundColor   = new SolidColorBrush(Colors.Black),
                    BackgroundOpacity =                                                        0,
                    LoadingColor1     = ColorConverter.FromHex("#FF777777"),
                    LoadingColor2     = ColorConverter.FromHex("#FF111111"),
                    OverlayWidth      =                                                      400,
                    OverlayHeight     = 260
                },
                Opacity = 0.5
            };
            MediaElementControl.MainUI = this;
            SliderControl.Remote       = this;
            VolumeControl.Remote       = this;
            PlayControl.Remote         = this;
            UrlControl.Remote          = this;
            ControlsPanel.Opacity      = 0.0;
            VolumeControl.SetVolume(0.5);

            JavaScriptBridge jsBridge = new JavaScriptBridge(Controller);

            HtmlPage.RegisterScriptableObject("glymaVideoPlayerBridge", jsBridge);

            Controller.Initialised();
        }
Esempio n. 3
0
        public WebViewModel(IGitHubService gitHubService, BrowserManager browserManager, JavaScriptBridge javaScriptBridge)
        {
            _gitHubService    = gitHubService;
            _browserManager   = browserManager;
            _javaScriptBridge = javaScriptBridge;

            _browserManager.Initialize();
            InitializeIpcConnection();
            CheckForUpdates();
        }
Esempio n. 4
0
        public WebView(WebViewModel viewModel, JavaScriptBridge javaScriptBridge)
        {
            DataContext = viewModel;
            InitializeComponent();

            // After the bridge receives a message that triggers loading of a new url, we need to set the focus out of the
            // cefsharp browser. Otherwise a nasty bug occurs making the cefsharp embedded browser unable to set
            // the :focus meta tag.
            javaScriptBridge.OnNavigationEventReceived += sender =>
            {
                Application.Current.Dispatcher.Invoke(() => { Ghost.Focus(); });
            };
        }
Esempio n. 5
0
        public Form1()
        {
            InitializeComponent();

            // Initialize the product repository
            _productRepository = new ProductRepository();

            // Initialize the JavaScriptBridge
            _javaScriptBridge = JavaScriptBridge.CreateAndStart(webView1, Constants.PermittedOrigin);
            _javaScriptBridge.AddScriptingHandler("GetAllProducts", @params => _productRepository.GetProducts());
            _javaScriptBridge.AddScriptingHandler("GetProduct", @params =>
            {
                // Since these are coming from JavaScript, take extra care to validate the parameters
                if (@params != null && @params.Count == 1 && @params.ContainsKey("name"))
                {
                    var name = @params["name"]?.ToString();
                    if (!string.IsNullOrEmpty(name))
                    {
                        return(_productRepository.GetProductByName(name));
                    }
                }

                throw new ArgumentException("Unexpected parameters");
            });

            webView1.DOMContentLoaded += (o, e) => Text = webView1.DocumentTitle;

            // This is a custom text writer trace listener to send diagnostic data to the webview log
            Trace.Listeners.Add(new WebViewTraceListener(webView1));

            // When the page loads push the product data to the page and bind with JavaScript showData function
            webView1.NavigationCompleted += (o, e) =>
            {
                if (o is IWebView wv)
                {
                    // Get the products and push to JavaScript function "showData"
                    var products = new ProductRepository().GetProducts();
                    wv.InvokeScriptFunctionAsync("showData", products);
                }
            };

            // Perform the navigation as you normally would. This could either by through the Source property,
            // or through one of the navigation methods.
            //
            // Using the method to navigate to local content for our example
            webView1.NavigateToLocal("/Example.html");
        }
Esempio n. 6
0
        /// <summary>
        /// Constructor for the main window control. Data context viewmodel is injected into constructor parameters.
        /// </summary>
        /// <param name="viewModel">The view model of the main window control.</param>
        /// <param name="javaScriptBridge">The java script bridge.</param>
        public MainWindowView(MainWindowViewModel viewModel, JavaScriptBridge javaScriptBridge)
        {
            DataContext = viewModel;

            // We have to set layout here, as the layout in wpf doesn't work with bindings at runtime.
            Width    = viewModel.Width;
            MinWidth = viewModel.MinWidth;
            Height   = viewModel.Height;
            Top      = viewModel.Top;
            Left     = viewModel.Left;

            InitializeComponent();

            javaScriptBridge.OnAppForegroundRequestReceived += sender =>
            {
                Application.Current.Dispatcher.Invoke(Activate);
            };
        }
Esempio n. 7
0
        public MainWindow()
        {
            InitializeComponent();

            // Initialize the product repository
            _productRepository = new ProductRepository();

            // Initialize the JavaScriptBridge
            _javaScriptBridge = JavaScriptBridge.CreateAndStart(WebView, Constants.PermittedOrigin);
            _javaScriptBridge.AddScriptingHandler("GetAllProducts", @params => _productRepository.GetProducts());
            _javaScriptBridge.AddScriptingHandler("GetProduct", @params =>
            {
                // Since these are coming from JavaScript, take extra care to validate the parameters
                if (@params != null && @params.Count == 1 && @params.ContainsKey("name"))
                {
                    var name = @params["name"]?.ToString();
                    if (!string.IsNullOrEmpty(name))
                    {
                        return(_productRepository.GetProductByName(name));
                    }
                }

                throw new ArgumentException("Unexpected parameters");
            });

            WebView.DOMContentLoaded += (o, e) => Title = WebView.DocumentTitle;

            // This is a custom text writer trace listener to send diagnostic data to the webview log
            Trace.Listeners.Add(new WebViewTraceListener(WebView));


            // When the page loads push the product data to the page and bind with JavaScript showData function
            WebView.NavigationCompleted += (o, e) =>
            {
                if (o is IWebView wv)
                {
                    // Get the products and push to JavaScript function "showData"
                    var products = new ProductRepository().GetProducts();
                    wv.InvokeScriptFunctionAsync("showData", products);
                }
            };
        }
Esempio n. 8
0
        public SectionViewPage(bool primary)
            : base()
        {
            this.alreadyInitialized = false;
            this.isPrimary          = primary;
            this.Content            = new Grid();
            this.webView            = new WebView();
            this.jsbridge           = new JavaScriptBridge(this.webView, Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher);
            this.progressRing       = new ProgressRing();

            Grid grid = this.Content as Grid;

            Grid.SetColumn(this.webView, 1);
            Grid.SetRow(this.webView, 1);
            grid.Children.Add(this.webView);
            grid.Children.Add(this.progressRing);

            this.NavigationCacheMode = NavigationCacheMode.Disabled;
            this.initBultinHandlers();
        }
Esempio n. 9
0
 public BcfierJavascriptInterop(JavaScriptBridge javaScriptBridge)
 {
     _javaScriptBridge = javaScriptBridge;
 }