Esempio n. 1
0
            public WindowMain()
            {
                Browser browser = BrowserFactory.Create();

                browserView = new WPFBrowserView(browser);

                browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e)
                {
                    if (e.IsMainFrame)
                    {
                        DOMDocument document = e.Browser.GetDocument();

                        DOMNode    root      = document.GetElementById("root");
                        DOMNode    textNode  = document.CreateTextNode("Some text");
                        DOMElement paragraph = document.CreateElement("p");
                        paragraph.AppendChild(textNode);
                        root.AppendChild(paragraph);
                    }
                };

                Content = browserView;

                Width        = 1024;
                Height       = 768;
                this.Loaded += WindowMain_Loaded;
            }
Esempio n. 2
0
            public WindowMain()
            {
                Browser browser = BrowserFactory.Create();

                browserView = new WPFBrowserView(browser);

                browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e)
                {
                    if (e.IsMainFrame)
                    {
                        DOMDocument     document  = e.Browser.GetDocument();
                        DOMInputElement firstName = (DOMInputElement)document.GetElementByName("firstName");
                        DOMInputElement lastName  = (DOMInputElement)document.GetElementByName("lastName");
                        DOMInputElement agreement = (DOMInputElement)document.GetElementByName("agreement");
                        firstName.Value   = "John";
                        lastName.Value    = "Doe";
                        agreement.Checked = true;
                    }
                };

                Content = browserView;

                Width        = 1024;
                Height       = 768;
                this.Loaded += WindowMain_Loaded;
            }
Esempio n. 3
0
            public WindowMain()
            {
                layout = new Grid();
                ColumnDefinition gridCol1 = new ColumnDefinition();

                layout.ColumnDefinitions.Add(gridCol1);
                RowDefinition gridRow1 = new RowDefinition();

                gridRow1.Height = new GridLength(45);
                RowDefinition gridRow2 = new RowDefinition();

                layout.RowDefinitions.Add(gridRow1);
                layout.RowDefinitions.Add(gridRow2);

                Content = layout;

                browserView = new WPFBrowserView(BrowserFactory.Create());
                Grid.SetRow(browserView, 1);
                Grid.SetColumn(browserView, 0);

                muteButton = new Button();
                UpdateButtonText(muteButton, browserView.Browser);
                muteButton.Height = 23;
                muteButton.Click += muteButton_Click;
                Grid.SetRow(muteButton, 0);
                Grid.SetColumn(muteButton, 0);

                layout.Children.Add(muteButton);
                layout.Children.Add(browserView);

                Width        = 1024;
                Height       = 768;
                this.Loaded += WindowMain_Loaded;
            }
Esempio n. 4
0
            public WindowMain()
            {
                Browser browser = BrowserFactory.Create();

                //add custom request handler
                var customLoadHandler = new CustomLoadHandler();

                customLoadHandler.CustomResponseEvent += delegate(object sender, CustomResponseEventArgs e)
                {
                    if (e.Url.Contains(@"myscheme://test1"))
                    {
                        browser.Stop();
                        browser.LoadURL(@"http://google.com");
                    }
                };

                browser.LoadHandler = customLoadHandler;

                browserView = new WPFBrowserView(browser);
                Content     = browserView;

                Width        = 1024;
                Height       = 768;
                this.Loaded += WindowMain_Loaded;
            }
Esempio n. 5
0
            public WindowMain()
            {
                BrowserContext browserContext = BrowserContext.DefaultContext;

                Browser browser = BrowserFactory.Create(browserContext);

                browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e)
                {
                    if (e.IsMainFrame)
                    {
                        DOMDocument document = browser.GetDocument();
                        XPathResult result   = document.Evaluate("count(//div)");
                        // If the expression is not a valid XPath expression or the document
                        // element is not available, we'll get an error.
                        if (result.IsError)
                        {
                            Console.WriteLine("Error: " + result.ErrorMessage);
                            return;
                        }

                        // Make sure that result is a number.
                        if (result.IsNumber)
                        {
                            Console.WriteLine("Result: " + result.Number);
                        }
                    }
                };

                browserView = new WPFBrowserView(browser);
                Content     = browserView;

                Width        = 1024;
                Height       = 768;
                this.Loaded += WindowMain_Loaded;
            }
Esempio n. 6
0
            public WindowMain()
            {
                layout = new Grid();
                ColumnDefinition gridCol1 = new ColumnDefinition();

                layout.ColumnDefinitions.Add(gridCol1);
                RowDefinition gridRow1 = new RowDefinition();

                gridRow1.Height = new GridLength(45);
                RowDefinition gridRow2 = new RowDefinition();

                gridRow2.Height = new GridLength(45);
                RowDefinition gridRow3 = new RowDefinition();

                layout.RowDefinitions.Add(gridRow1);
                layout.RowDefinitions.Add(gridRow2);
                layout.RowDefinitions.Add(gridRow3);


                Content = layout;

                enLanguageButton         = new Button();
                enLanguageButton.Content = "English";
                enLanguageButton.Height  = 23;
                enLanguageButton.Click  += enLanguageButton_Click;
                Grid.SetRow(enLanguageButton, 0);
                Grid.SetColumn(enLanguageButton, 0);

                frLanguageButton         = new Button();
                frLanguageButton.Content = "French";
                frLanguageButton.Height  = 23;
                frLanguageButton.Click  += frLanguageButton_Click;
                Grid.SetRow(frLanguageButton, 1);
                Grid.SetColumn(frLanguageButton, 0);


                Browser browser = BrowserFactory.Create();

                browserView = new WPFBrowserView(browser);
                browser.ContextMenuHandler = new MyContextMenuHandler((FrameworkElement)browserView, browser);

                // Enable SpellChecker service.
                browser.Context.SpellCheckerService.Enabled = true;
                // Configure SpellChecker's language.
                browser.Context.SpellCheckerService.Language = "en-US";

                Grid.SetRow(browserView, 2);
                Grid.SetColumn(browserView, 0);

                layout.Children.Add(enLanguageButton);
                layout.Children.Add(frLanguageButton);
                layout.Children.Add(browserView);

                Width        = 1024;
                Height       = 768;
                this.Loaded += WindowMain_Loaded;
            }
Esempio n. 7
0
        private void AboutDemo()
        {
            Window      aboutDemo       = new Window();
            String      strVersion      = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            BrowserView browserViewDemo = new WPFBrowserView(BrowserFactory.Create(BrowserType.HEAVYWEIGHT));

            aboutDemo.Width       = 380;
            aboutDemo.Height      = 300;
            aboutDemo.Title       = "About Demo";
            aboutDemo.ResizeMode  = ResizeMode.NoResize;
            aboutDemo.WindowStyle = WindowStyle.SingleBorderWindow;
            aboutDemo.Topmost     = true;
            aboutDemo.Content     = browserViewDemo;

            string textAboutDemo = "<br>" + "<html><font face='Arial' size='2'>" +
                                   "<font size='5'>DotNetBrowser Demo</font><br><br>" +
                                   "<b>Version " + strVersion + "</b><br><br>" +
                                   "<base target='_blank'>" +

                                   "This application is created for demonstration purposes only.<br>" +
                                   "&copy; 2017 TeamDev Ltd. All rights reserved.<br><br>" +

                                   "Powered by <a color='#3d82f8' href='https://www.teamdev.com/dotnetbrowser' " +
                                   "style='text-decoration:none'>DotNetBrowser</a>. See " +
                                   "<a color='#3d82f8' href='https://www.teamdev.com/dotnetbrowser-licence-agreement' " +
                                   "style='text-decoration:none'>terms of use.</a><br>" +

                                   "Based on <a color='#3d82f8' href='http://www.chromium.org/' " +
                                   "style='text-decoration:none'>Chromium project</a>. " +
                                   "See <a color='#3d82f8' " +
                                   "href='http://dotnetbrowser-support.teamdev.com/documentation/open-source-components-licences' " +
                                   "style='text-decoration:none'>full list</a> of Chromium<br>components, " +
                                   "used in the current DotNetBrowser version.<br><br>" +

                                   "This demo uses WebKit project under LGPL.<br>" +

                                   "See licence text " +
                                   "<a color='#3d82f8' href='https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html' " +
                                   "style='text-decoration:none'>LGPL v.2</a> and " +
                                   "<a color='#3d82f8' href='https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' " +
                                   "style='text-decoration:none'>LGPL v.2.1</a></font></html>";

            browserViewDemo.Browser.LoadHTML(textAboutDemo);
            aboutDemo.Owner = Window.GetWindow((FrameworkElement)browserView);
            aboutDemo.WindowStartupLocation = WindowStartupLocation.CenterOwner;

            aboutDemo.Closing += delegate
            {
                if (!browserViewDemo.Browser.IsDisposed())
                {
                    browserViewDemo.Browser.Dispose();
                    browserViewDemo.Dispose();
                }
            };

            aboutDemo.ShowDialog();
        }
        protected async System.Threading.Tasks.Task InitializeWpfViewAsync()
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            _browserView = new WPFBrowserView(browser);

#if DEBUG
            Log.Debug(GetDevToolsUrl());
#endif
        }
Esempio n. 9
0
        public MainWindow()
        {
            browserContext = BrowserContext.DefaultContext;
            browser        = BrowserFactory.Create(browserContext);

            browserView = new WPFBrowserView(browser);
            Content     = browserView;

            this.Loaded += MainWindow_Loaded;
        }
Esempio n. 10
0
        private void LicenseChecker_Loaded(object sender, RoutedEventArgs e)
        {
            ToolbarForLicenseChecker.Visibility       = Visibility.Collapsed;
            ButtonContinue.Visibility                 = Visibility.Collapsed;
            ButtonKeyActivation.Visibility            = Visibility.Collapsed;
            ButtonHobbyist.Visibility                 = Visibility.Collapsed;
            ToolbarForLicenseChecker.Visibility       = Visibility.Collapsed;
            ButtonGoToLoginPage.Visibility            = Visibility.Collapsed;
            LicenseCheckerBrowserContainer.Visibility = Visibility.Collapsed;

            BrowserContextParams browserParameters = new BrowserContextParams("data-dir-license")
            {
                StorageType = StorageType.DISK
            };

            BrowserContext browserContext = new BrowserContext(browserParameters);

            Browser = BrowserFactory.Create(browserContext, BrowserType.LIGHTWEIGHT);

            CookiesHelper.LoadCookies(BrowserView, CSHTML5_COOKIES_URL, NAME_FOR_STORING_COOKIES);
            CookiesHelper.LoadMicrosoftCookies(BrowserView, NAME_FOR_STORING_COOKIES);

            BrowserView = new WPFBrowserView(Browser);
            LicenseCheckerBrowserContainer.Child = BrowserView;

            // we check if a commercial key is  activated and we add it to the cookie before loading the login URL
            if (IsCommercialKeyActivated())
            {
                SetKeyGuidAsCookie(); // we set the key guid as a session cookie so the website know we have an activated key
            }
            // we add an handler for browser error (eg: internet down, website down, page not found...)
            Browser.FailLoadingFrameEvent += OnFailLoadingFrameEvent; //To Do: find a better way of managing those error

            Browser.LoadURL(LoginURL);

            Enable = true;

            BrowserView.DocumentLoadedInMainFrameEvent += (s1, e1) =>
            {
                // We use a dispatcher to go back to thread in charge of the UI.
                MainWindow.Dispatcher.BeginInvoke((Action)(() =>
                {
                    //if (_javaScriptExecutionHandler == null)
                    //    _javaScriptExecutionHandler = new JavaScriptExecutionHandler(MainWebBrowser);

                    //dynamic rootElement = _javaScriptExecutionHandler.ExecuteJavaScriptWithResult(@"document.getElementByIdSafe(""cshtml5-root"");");

                    //MessageBox.Show(rootElement.ToString());


                    //todo: verify that we are not on an outside page (eg. Azure Active Directory login page)
                    OnLoaded();
                }), DispatcherPriority.ApplicationIdle);
            };
        }
Esempio n. 11
0
        protected async System.Threading.Tasks.Task InitializeWpfViewAsync()
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            _browserView = new WPFBrowserView(browser);
            _browserView.InputBindings.Add(new InputBinding(new StartWorkCommand(_serviceProvider.GetService <ISessionService>()), new KeyChordGesture(ModifierKeys.Shift | ModifierKeys.Control, Key.OemQuestion, Key.W)));

#if DEBUG
            Log.Debug(GetDevToolsUrl());
#endif
        }
Esempio n. 12
0
        public MainWindow()
        {
            InitializeComponent();

            DirectoryService.Set(AppDomain.CurrentDomain.BaseDirectory);

            var webView = new WPFBrowserView();

            webView.FinishLoadingFrameEvent += BrowserView_OnFinishLoadingFrameEvent;
            BrowserGrid.Children.Add((UIElement)webView.GetComponent());
            webView.Browser.LoadURL("https://en.bitefight.gameforge.com/game");
        }
Esempio n. 13
0
        public MainWindow()
        {
            BrowserPreferences.SetUserAgent("Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1");
            InitializeComponent();

            browser     = BrowserFactory.Create();
            browserView = new WPFBrowserView(browser);
            mainLayout.Children.Add(browserView);

            browser.UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1";

            browserView.Browser.LoadURL("kirksey.helpdocsonline.com");
        }
Esempio n. 14
0
 public static void ClearCookies(WPFBrowserView wpfBrowserView, string registryName = null)
 {
     if (!string.IsNullOrEmpty(registryName))
     {
         RegistryHelpers.DeleteSetting(registryName + "_" + MICROSOFT_COOKIES_URL);
     }
     if (wpfBrowserView.Browser != null && wpfBrowserView.Browser.CookieStorage != null)
     {
         int numberOfDeletedCookies = wpfBrowserView.Browser.CookieStorage.DeleteAll();
         wpfBrowserView.Browser.CookieStorage.Save();
         MessageBox.Show(numberOfDeletedCookies.ToString() + " cookies have been deleted.");
     }
 }
Esempio n. 15
0
 public static void SaveCookies(WPFBrowserView wpfBrowserView, string url, string registryName)
 {
     // we register cookies with a specific url into registries
     if (url != null && wpfBrowserView.Browser != null && wpfBrowserView.Browser.CookieStorage != null)
     {
         List <DotNetBrowser.Cookie> cookiesList     = wpfBrowserView.Browser.CookieStorage.GetAllCookies(url);
         List <CookieData>           cookiesDataList = new List <CookieData>();
         foreach (var cookie in cookiesList)
         {
             cookiesDataList.Add(new CookieData(cookie, url));
         }
         string cookiesAsString = Serializer.Save <List <CookieData> >(cookiesDataList);
         RegistryHelpers.SaveSetting(registryName + "_" + url, cookiesAsString);
     }
 }
Esempio n. 16
0
        public WindowMain()
        {
            BrowserContext browserContext = BrowserContext.DefaultContext;
            Browser        browser        = BrowserFactory.Create(browserContext);

            //add custom request handler
            browser.Context.NetworkService.CertificateVerifier = new TestCertificateVerifier();

            browserView = new WPFBrowserView(browser);
            Content     = browserView;

            Width        = 1024;
            Height       = 768;
            this.Loaded += WindowMain_Loaded;
        }
Esempio n. 17
0
            public WindowMain()
            {
                BrowserContext browserContext = BrowserContext.DefaultContext;

                Browser browser = BrowserFactory.Create(browserContext);

                browser.DialogHandler = new MyDialogHandler(this);

                browserView = new WPFBrowserView(browser);
                Content     = browserView;

                Width        = 1024;
                Height       = 768;
                this.Loaded += WindowMain_Loaded;
            }
Esempio n. 18
0
            public WindowMain()
            {
                BrowserContext browserContext = BrowserContext.DefaultContext;

                browserContext.NetworkService.NetworkDelegate = new SampleNetworkDelegate();

                Browser browser = BrowserFactory.Create(browserContext);

                browserView = new WPFBrowserView(browser);

                Content = browserView;

                Width        = 1024;
                Height       = 768;
                this.Loaded += WindowMain_Loaded;
            }
Esempio n. 19
0
            public WindowMain()
            {
                BrowserContext browserContext = BrowserContext.DefaultContext;

                Browser browser = BrowserFactory.Create(browserContext);

                // Suppress/filter all ajax calls
                browser.Context.NetworkService.ResourceHandler = new TestResourceHandler();

                browserView = new WPFBrowserView(browser);
                Content     = browserView;

                Width        = 1024;
                Height       = 768;
                this.Loaded += WindowMain_Loaded;
            }
Esempio n. 20
0
        public MainWindow()
        {
            // Initialize WPF Application UI.
            InitializeComponent();

            // Create WPF BrowserView component.
            browser     = BrowserFactory.Create();
            browserView = new WPFBrowserView(browser);
            // Embed BrowserView component into main layout.
            mainLayout.Children.Add(browserView);
            browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e)
            {
                if (e.IsMainFrame)
                {
                    int       key      = KeyInterop.VirtualKeyFromKey(Key.H);
                    KeyParams paramers = new KeyParams((VirtualKeyCode)key, 'H');
                    browser.KeyDown(paramers);
                    browser.KeyUp(paramers);

                    key      = KeyInterop.VirtualKeyFromKey(Key.L);
                    paramers = new KeyParams((VirtualKeyCode)key, 'e');
                    browser.KeyDown(paramers);
                    browser.KeyUp(paramers);

                    key      = KeyInterop.VirtualKeyFromKey(Key.L);
                    paramers = new KeyParams((VirtualKeyCode)key, 'l');
                    browser.KeyDown(paramers);
                    browser.KeyUp(paramers);

                    key      = KeyInterop.VirtualKeyFromKey(Key.L);
                    paramers = new KeyParams((VirtualKeyCode)key, 'l');
                    browser.KeyDown(paramers);
                    browser.KeyUp(paramers);

                    key      = KeyInterop.VirtualKeyFromKey(Key.O);
                    paramers = new KeyParams((VirtualKeyCode)key, 'o');
                    browser.KeyDown(paramers);
                    browser.KeyUp(paramers);
                }
            };

            browserView.Browser.LoadHTML(@"<html>
                                            <body>
                                                <input type='text' autofocus></input>
                                            </body>
                                           </html>");
        }
Esempio n. 21
0
            public WindowMain()
            {
                layout = new Grid();
                ColumnDefinition gridCol1 = new ColumnDefinition();

                layout.ColumnDefinitions.Add(gridCol1);
                RowDefinition gridRow1 = new RowDefinition();

                gridRow1.Height = new GridLength(45);
                RowDefinition gridRow2 = new RowDefinition();

                gridRow2.Height = new GridLength(45);
                RowDefinition gridRow3 = new RowDefinition();

                layout.RowDefinitions.Add(gridRow1);
                layout.RowDefinitions.Add(gridRow2);
                layout.RowDefinitions.Add(gridRow3);

                Content = layout;

                btnSelectedText         = new Button();
                btnSelectedText.Content = "Get Selected Text";
                btnSelectedText.Height  = 23;
                btnSelectedText.Click  += btnSelectedText_Click;
                Grid.SetRow(btnSelectedText, 0);
                Grid.SetColumn(btnSelectedText, 0);

                btnSelectedHtml         = new Button();
                btnSelectedHtml.Content = "Get Selected HTML";
                btnSelectedHtml.Height  = 23;
                btnSelectedHtml.Click  += btnSelectedHtml_Click;
                Grid.SetRow(btnSelectedHtml, 1);
                Grid.SetColumn(btnSelectedHtml, 0);


                browserView = new WPFBrowserView(BrowserFactory.Create());
                Grid.SetRow(browserView, 2);
                Grid.SetColumn(browserView, 0);

                layout.Children.Add(btnSelectedText);
                layout.Children.Add(btnSelectedHtml);
                layout.Children.Add(browserView);

                Width        = 1024;
                Height       = 768;
                this.Loaded += WindowMain_Loaded;
            }
Esempio n. 22
0
        protected void OnInitialized()
        {
            var switches = DotNetBrowserSwitches.Create(BrowserType);

            BrowserPreferences.SetChromiumSwitches(switches.ToArray());

            _path           = GetOrCreateContextParamsPath();
            _browserContext = new BrowserContext(new BrowserContextParams(_path));

            var browser = BrowserFactory.Create(_browserContext, BrowserType);

            browser.Preferences.AllowDisplayingInsecureContent = false;
            browser.Preferences.AllowRunningInsecureContent    = false;
            browser.Preferences.AllowScriptsToCloseWindows     = false;
            browser.Preferences.ApplicationCacheEnabled        = false;
            browser.Preferences.DatabasesEnabled          = false;
            browser.Preferences.LocalStorageEnabled       = false;
            browser.Preferences.PluginsEnabled            = false;
            browser.Preferences.TransparentBackground     = true;
            browser.Preferences.UnifiedTextcheckerEnabled = false;
            browser.Preferences.WebAudioEnabled           = false;
            browser.ZoomEnabled   = true;
            browser.DialogHandler = this;
            browser.LoadHandler   = this;
            browser.Context.NetworkService.ResourceHandler = this;

            browser.RenderGoneEvent      += Browser_RenderGoneEvent;
            browser.ScriptContextCreated += Browser_ScriptContextCreated;

            _browserView = new WPFBrowserView(browser);
            browser.ConsoleMessageEvent += Browser_ConsoleMessageEvent;

            _browserView.InputBindings.Add(new InputBinding(new BookmarkShortcut1Command(), new KeyChordGesture(ModifierKeys.Shift | ModifierKeys.Control, Key.OemQuestion, Key.D1)));
            _browserView.InputBindings.Add(new InputBinding(new BookmarkShortcut2Command(), new KeyChordGesture(ModifierKeys.Shift | ModifierKeys.Control, Key.OemQuestion, Key.D2)));
            _browserView.InputBindings.Add(new InputBinding(new BookmarkShortcut3Command(), new KeyChordGesture(ModifierKeys.Shift | ModifierKeys.Control, Key.OemQuestion, Key.D3)));
            _browserView.InputBindings.Add(new InputBinding(new BookmarkShortcut4Command(), new KeyChordGesture(ModifierKeys.Shift | ModifierKeys.Control, Key.OemQuestion, Key.D4)));
            _browserView.InputBindings.Add(new InputBinding(new BookmarkShortcut5Command(), new KeyChordGesture(ModifierKeys.Shift | ModifierKeys.Control, Key.OemQuestion, Key.D5)));
            _browserView.InputBindings.Add(new InputBinding(new BookmarkShortcut6Command(), new KeyChordGesture(ModifierKeys.Shift | ModifierKeys.Control, Key.OemQuestion, Key.D6)));
            _browserView.InputBindings.Add(new InputBinding(new BookmarkShortcut7Command(), new KeyChordGesture(ModifierKeys.Shift | ModifierKeys.Control, Key.OemQuestion, Key.D7)));
            _browserView.InputBindings.Add(new InputBinding(new BookmarkShortcut8Command(), new KeyChordGesture(ModifierKeys.Shift | ModifierKeys.Control, Key.OemQuestion, Key.D8)));
            _browserView.InputBindings.Add(new InputBinding(new BookmarkShortcut9Command(), new KeyChordGesture(ModifierKeys.Shift | ModifierKeys.Control, Key.OemQuestion, Key.D9)));

#if DEBUG
            Log.Debug(GetDevToolsUrl());
#endif
        }
Esempio n. 23
0
            public WindowMain()
            {
                layout = new Grid();
                ColumnDefinition gridCol1 = new ColumnDefinition();

                layout.ColumnDefinitions.Add(gridCol1);
                RowDefinition gridRow1 = new RowDefinition();

                gridRow1.Height = new GridLength(45);
                RowDefinition gridRow2 = new RowDefinition();

                layout.RowDefinitions.Add(gridRow1);
                layout.RowDefinitions.Add(gridRow2);


                Content = layout;

                btnCloseNotification         = new Button();
                btnCloseNotification.Content = "Close";
                btnCloseNotification.Height  = 23;
                btnCloseNotification.Click  += btnCloseNotification_Click;
                Grid.SetRow(btnCloseNotification, 0);
                Grid.SetColumn(btnCloseNotification, 0);

                Browser browser = BrowserFactory.Create();

                browser.PermissionHandler = new MyPermissionHandler();
                browser.Context.NotificationService.NotificationHandler = new MyNotificationHandler((NotificationEventArgs e) =>
                {
                    notification = e.Notification;
                    ShowNotification(notification);
                });

                browserView = new WPFBrowserView(browser);

                Grid.SetRow(browserView, 2);
                Grid.SetColumn(browserView, 0);

                layout.Children.Add(btnCloseNotification);
                layout.Children.Add(browserView);

                Width        = 1024;
                Height       = 768;
                this.Loaded += WindowMain_Loaded;
            }
Esempio n. 24
0
        public static void SetCustomCookies(WPFBrowserView wpfBrowserView, IList <CookieData> cookies)
        {
            if (cookies == null)
            {
                return;
            }

            foreach (CookieData data in cookies)
            {
                if (data.session)
                {
                    wpfBrowserView.Browser.CookieStorage.SetSessionCookie(data.url, data.name, data.value, data.domain, data.path, data.secure, data.httpOnly);
                }
                else
                {
                    wpfBrowserView.Browser.CookieStorage.SetCookie(data.url, data.name, data.value, data.domain, data.path, data.expirationTime, data.secure, data.httpOnly);
                }
            }
        }
Esempio n. 25
0
            public WindowMain()
            {
                BrowserContext browserContext = BrowserContext.DefaultContext;

                Browser browser = BrowserFactory.Create(browserContext);

                browser.RenderGoneEvent += delegate(object sender, RenderEventArgs e)
                {
                    // Restore Browser instance by loading the same URL
                    browser.LoadURL(e.Browser.URL);
                };

                browserView = new WPFBrowserView(browser);
                Content     = browserView;

                Width        = 1024;
                Height       = 768;
                this.Loaded += WindowMain_Loaded;
            }
Esempio n. 26
0
        public static Tab CreateTab(String url)
        {
            Browser     browser     = BrowserFactory.Create(BrowserType);
            BrowserView browserView = new WPFBrowserView(browser);

            browser.DialogHandler      = new WPFDefaultDialogHandler((UIElement)browserView);
            browser.DownloadHandler    = new WPFDefaultDownloadHandler((UIElement)browserView);
            browser.ContextMenuHandler = new WPFDefaultContextMenuHandler((FrameworkElement)browserView, true);
            browser.Preferences.FireKeyboardEventsEnabled = false;
            browser.Preferences.FireMouseEventsEnabled    = false;

            TabContent tabContent = new TabContent(browserView);

            TabCaption tabCaption = new TabCaption();

            tabCaption.SetTitle("about:blank");

            browserView.Browser.LoadURL(url);
            return(new Tab(tabCaption, tabContent));
        }
        public bool TryRefresh(Assembly entryPointAssembly, XamlPropertiesPane xamlPropertiesPane, WPFBrowserView webControl, Rectangle highlightElement)
        {
            int nbTreeViewElements;

            _xamlPropertiesPane       = xamlPropertiesPane;
            _webControl               = webControl;
            _rectangleUsedToHighlight = highlightElement;
            _hasBeenFullyExpanded     = false;

            var isSuccess = XamlInspectionHelper.TryInitializeTreeView(this.TreeViewForXamlInspection, entryPointAssembly, out nbTreeViewElements);

            if (isSuccess)
            {
                this.NumberTreeViewElement.Text = "Element count: " + nbTreeViewElements;
            }
            else
            {
                this.NumberTreeViewElement.Text = "";
            }
            return(isSuccess);
        }
Esempio n. 28
0
        public static void LoadCookies(WPFBrowserView wpfBrowserView, string url, string registryName)
        {
            // we search for cookies with a specific url into registries
            string cookiesAsString = RegistryHelpers.GetSetting(registryName + "_" + url, null);

            if (cookiesAsString != null)
            {
                List <CookieData> cookiesList = Serializer.Load <List <CookieData> >(cookiesAsString);
                foreach (var cookie in cookiesList)
                {
                    if (cookie.session)
                    {
                        wpfBrowserView.Browser.CookieStorage.SetSessionCookie(cookie.url, cookie.name, cookie.value, cookie.domain, cookie.path, cookie.secure, cookie.httpOnly);
                    }
                    else
                    {
                        wpfBrowserView.Browser.CookieStorage.SetCookie(cookie.url, cookie.name, cookie.value, cookie.domain, cookie.path, cookie.expirationTime, cookie.secure, cookie.httpOnly);
                    }
                }
            }
        }
Esempio n. 29
0
            public WindowMain()
            {
                Browser browser = BrowserFactory.Create();

                browserView = new WPFBrowserView(browser);

                Content = browserView;

                Width        = 1024;
                Height       = 768;
                this.Loaded += WindowMain_Loaded;

                browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e)
                {
                    if (e.IsMainFrame)
                    {
                        // Get HTML of each frame on the web page
                        PrintFrameHierarhy(browser, BrowserFrameID.MAIN_FRAME_ID);
                    }
                };
            }
Esempio n. 30
0
            public WindowMain()
            {
                Browser browser = BrowserFactory.Create();

                browserView = new WPFBrowserView(browser);

                browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e)
                {
                    if (e.IsMainFrame)
                    {
                        DOMDocument document = e.Browser.GetDocument();

                        var myEvent = browser.CreateEvent("MyEvent");

                        DOMNode root = document.GetElementById("root");

                        DOMEventHandler domEvent = delegate(object s, DOMEventArgs evt)
                        {
                            if (evt.EventType == myEvent.EventType)
                            {
                                DOMNode    textNode  = document.CreateTextNode("Some text");
                                DOMElement paragraph = document.CreateElement("p");
                                paragraph.AppendChild(textNode);
                                root.AppendChild(paragraph);
                            }
                        };

                        root.AddEventListener(myEvent, domEvent, false);

                        Thread.Sleep(3000);
                        root.DispatchEvent(myEvent);
                    }
                };

                Content = browserView;

                Width        = 1024;
                Height       = 768;
                this.Loaded += WindowMain_Loaded;
            }