コード例 #1
0
        //static void Main(string[] args)
        //{
        //}
        public static void Main(String[] args)
        {
            Console.WriteLine("Started....");

            WebView wv = WebCore.CreateWebView(1024, 600);

            wv.Source = new Uri("https://accounts.google.com/");

            FrameEventHandler handler = null;

            handler = (s, e) =>
            {
                if (e.IsMainFrame)
                {
                    // we have finished loading main page,
                    // let's unhook ourselves
                    wv.LoadingFrameComplete -= handler;

                    LoginAndTakeScreenShot(wv);
                }
            };

            wv.LoadingFrameComplete += handler;

            WebCore.Run();
        }
コード例 #2
0
        private static void LoginAndTakeScreenShot(WebView wv)
        {
            dynamic document = (JSObject)wv.ExecuteJavascriptWithResult("document");

            using (document)
            {
                //Works
                var tbox = document.getElementById("Email");
                tbox.value = "*****@*****.**";

                //Works
                var pbox = document.getElementById("Passwd");
                pbox.value = "**********";

                FrameEventHandler handler = null;
                handler = (sender, args) =>
                {
                    if (args.IsMainFrame)
                    {
                        wv.LoadingFrameComplete -= handler;

                        BitmapSurface surface = (BitmapSurface)wv.Surface;
                        surface.SaveToPNG("result.png", true);
                        System.Diagnostics.Process.Start("result.png");

                        WebCore.Shutdown();
                    }
                };

                wv.LoadingFrameComplete += handler;

                var sbox = document.getElementById("signIn");
                sbox.click();
            }
        }
コード例 #3
0
        public static async Task <bool> WaitPageLoadComplete(this IWebView view, Action TriggerPageChangeAction, int timeOutSec = 0, CancellationToken ct = new CancellationToken())
        {
            SemaphoreSlim     signal     = new SemaphoreSlim(0, 1);
            bool              result     = false;
            FrameEventHandler frameEvent = (o, e) =>
            {
                if (e.IsMainFrame)
                {
                    result = true;

                    signal.Release();
                }
            };

            view.LoadingFrameComplete += frameEvent;

            TriggerPageChangeAction.Invoke();

            if (timeOutSec > 0)
            {
                await signal.WaitAsync(TimeSpan.FromSeconds(timeOutSec), ct);
            }
            else
            {
                await signal.WaitAsync(ct);
            }
            view.LoadingFrameComplete -= frameEvent;
            return(result);
        }
コード例 #4
0
        public void SetHtml(string content)
        {
            if (Application.Current == null)
            {
                return;
            }
            Application.Current.Dispatcher.BeginInvoke(new Action(() =>
            {
                Html = content;
                if (wb == null)
                {
                    return;
                }

                wb.CacheMode = new BitmapCache();
                FrameEventHandler webControlOnLoadCompleted = null;
                webControlOnLoadCompleted = (sender, args) =>
                {
                    if (args.IsMainFrame)
                    {
                        wb.LoadingFrameComplete -= webControlOnLoadCompleted;
                        WbProcentualZoom();
                        wb.CacheMode         = null;
                        awesomiumInitialised = true;
                    }
                };
                wb.LoadingFrameComplete += webControlOnLoadCompleted;
                wb.LoadHTML(content);
            }));
        }
コード例 #5
0
ファイル: GuiTest.cs プロジェクト: zedr0n/testJS
        private void doTest(FrameEventHandler handler)
        {
            List <Exception> exceptions = new List <Exception>();
            var newWindowThread         = new Thread(() =>
            {
                // Create and show the Window
                _window = new Backend.MainWindow();

                _window.Closed += (s, e) =>
                                  Dispatcher.CurrentDispatcher.BeginInvokeShutdown(DispatcherPriority.Background);

                // Close the window after initialisation finished
                _window.webControl.LoadingFrameComplete += (s, e) =>
                {
                    try
                    {
                        handler.Invoke(s, e);
                    }
                    catch (Exception ex)
                    {
                        exceptions.Add(ex);
                        _window.Close();
                    }
                    _window.Close();
                };

                _window.Show();
                // Start the Dispatcher Processing
                Dispatcher.Run();
            });

            // Set the apartment state
            newWindowThread.SetApartmentState(ApartmentState.STA);
            // Make the thread a background thread
            newWindowThread.IsBackground = true;
            // Start the thread
            newWindowThread.Start();
            // Wait for thread to finish before completing test
            newWindowThread.Join();

            foreach (Exception ex in exceptions)
            {
                throw ex;
            }
        }
コード例 #6
0
ファイル: GuiTest.cs プロジェクト: zedr0n/testJS
        private void doTest(FrameEventHandler handler)
        {
            List<Exception> exceptions = new List<Exception>();
            var newWindowThread = new Thread(() =>
            {
                // Create and show the Window
                _window = new Backend.MainWindow();

                _window.Closed += (s, e) =>
                    Dispatcher.CurrentDispatcher.BeginInvokeShutdown(DispatcherPriority.Background);

                // Close the window after initialisation finished
                _window.webControl.LoadingFrameComplete += (s, e) =>
                {
                    try
                    {
                        handler.Invoke(s, e);
                    }
                    catch (Exception ex)
                    {
                        exceptions.Add(ex);
                        _window.Close();
                    }
                    _window.Close();
                };

                _window.Show();
                // Start the Dispatcher Processing
                Dispatcher.Run();
            });

            // Set the apartment state
            newWindowThread.SetApartmentState(ApartmentState.STA);
            // Make the thread a background thread
            newWindowThread.IsBackground = true;
            // Start the thread
            newWindowThread.Start();
            // Wait for thread to finish before completing test
            newWindowThread.Join();

            foreach (Exception ex in exceptions)
                throw ex;
        }
コード例 #7
0
    public async Task Navigate(String url)
    {
        Debug.WriteLine("Navigating");
        TaskCompletionSource <bool> tcs     = new TaskCompletionSource <bool>();
        FrameEventHandler           handler = (sender, args) =>
        {
            Debug.WriteLine(args.Url);
            if (!_webView.IsNavigating && !_webView.IsLoading)
            {
                tcs.SetResult(true);
            }
        };

        _webView.LoadingFrameComplete += handler;
        _synchronizationContext.Send(SetWebViewSource, url);
        await tcs.Task;

        _webView.LoadingFrameComplete -= handler;
        Debug.WriteLine("Done");
    }
コード例 #8
0
ファイル: ProgrammMethods.cs プロジェクト: deff83/botADBTC
        public Task <EventArgs> WaitForLoadingComplete(CancellationToken token)
        {
            var tcs = new TaskCompletionSource <EventArgs>();
            FrameEventHandler handler = ((sender, e) =>
            {
                if (!(sender as WebControl).IsLoading)
                {
                    result = "DONE";
                    tcs.TrySetResult(e);
                }
            }
                                         );
            var registration = token.Register(() => { result = "CANCELLED"; tcs.TrySetCanceled(); });

            webControlnow.LoadingFrameComplete += handler;

            tcs.Task.ContinueWith(_ =>
            {
                webControlnow.LoadingFrameComplete -= handler;
                registration.Dispose();
            }, TaskContinuationOptions.ExecuteSynchronously);

            return(tcs.Task);
        }
コード例 #9
0
 public static extern bool SendMessage(IntPtr hWnd, int wMsg, short wParam, FrameEventHandler lParam);
コード例 #10
0
		public static extern Handle Construct(
			FrameEventHandler frameStarted, 
			FrameEventHandler frameEnded, 
			FrameEventHandler frameRenderingQueued);
コード例 #11
0
ファイル: Camera.cs プロジェクト: windygu/SuperBoy
 public static extern bool SendMessage(IntPtr hWnd, int wMsg, short wParam, FrameEventHandler lParam);
コード例 #12
0
 public static bool capSetCallbackOnFrame(IntPtr lwnd, FrameEventHandler fpProc)
 {
     return SendMessage(lwnd, WM_CAP_SET_CALLBACK_FRAME, 0, fpProc);
 }
コード例 #13
0
 [DllImport("User32.dll")] public static extern bool SendMessage(IntPtr hWnd, int wMsg, short wParam, FrameEventHandler lParam);