Esempio n. 1
0
        public MainWindow()
        {
            InitializeComponent();

            CefSharp.CefSettings settings = new CefSharp.CefSettings()
            {
                //PackLoadingDisabled = true,
            };

            CefSharp.Cef.Initialize(settings);

            myBrowser = new CefSharp.Wpf.ChromiumWebBrowser();
            //myBrowser.Width = browserHolder.Width - 300;
            //myBrowser.Height = browserHolder.Height - 30;
            //myBrowser.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            //myBrowser.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;

            // Seems WebBrowser is fine - it's canvas that's a fixed size. Rescale automatically?
            // http://stackoverflow.com/questions/1664785/resize-html5-canvas-to-fit-window
            myBrowser.Background = new SolidColorBrush(System.Windows.Media.Colors.CadetBlue);

            browserHolder.Children.Add(myBrowser);


            myBrowser.LoadHtml(GetResourceString("SharpFabric.JavaScript.CanvBody.html"), "http://junky/");

            // Initialize fabric.js after the DOM is fully loaded. Not sure whether this is the recommended way to ensure this.
            myBrowser.FrameLoadEnd += delegate
            {
                myBrowser.ExecuteScriptAsync(GetResourceString("SharpFabric.JavaScript.fabric.js"));
                myBrowser.ExecuteScriptAsync(GetResourceString("SharpFabric.JavaScript.qFunctions.js"));
            };

            myBrowser.RegisterJsObject("callbackObj", new CallbackObjectForJs()
            {
                win = this
            });
        }