Ejemplo n.º 1
1
 void wbrMain_ConsoleMessage(object sender, CefSharp.ConsoleMessageEventArgs e)
 {
     Debug.Write(e.Message);
 }
Ejemplo n.º 2
0
        public bool ProcessRequest(CefSharp.IRequest request, ref string mimeType, ref System.IO.Stream stream)
        {
            if(request.Url.StartsWith("sp://"))
            {
                // On windows, we must replace the / with the \
                String URL = request.Url.Replace("sp://", ResourceDirectory).Replace("/", "\\");
                if (URL.EndsWith(".css"))
                {
                    mimeType = "text/css";
                }
                if (URL.EndsWith(".js"))
                {
                    mimeType = "text/javascript";
                }

                String contents = "";
                using (StreamReader sr = new StreamReader(URL))
                {
                    contents = sr.ReadToEnd();

                }
                byte[] bytes = Encoding.UTF8.GetBytes(contents);
                stream = new MemoryStream(bytes);
                return true;

            }
            return false;
        }
Ejemplo n.º 3
0
 void ChromiumBrowser_IsLoadingChanged(object sender, CefSharp.IsLoadingChangedEventArgs e)
 {
     if (!e.IsLoading)
     {
         //this.BeginInvoke((Action)(() => { _webBrowser.InvokeScript("onResize()"); }));
         this.BeginInvoke((Action)(() => { this.Width += 100; this.Height += 100; }));
     }
 }
Ejemplo n.º 4
0
 public bool OnPreKeyEvent(CefSharp.IWebBrowser browserControl, CefSharp.KeyType type, int windowsKeyCode, int nativeKeyCode,
     CefSharp.CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut)
 {
     if (windowsKeyCode == (int)Keys.F12)
     {
         Program.Form.ChromiumBrowser.ShowDevTools();
     }
     return false;
 }
Ejemplo n.º 5
0
        /*
         * Chromium web browser navigation state changed event handler.
         */
        private void chromium_NavStateChanged(object sender, CefSharp.NavStateChangedEventArgs e) {
            // Is the browser ready to load a page as the first page load?
            if(!e.CanGoBack && !e.CanGoForward && e.CanReload) {
                // Load the active team domain address if we have one
                if(Program.IsInitialTeamInitialized) {
                    chromium.Load(Program.ActiveTeamAddress);
                }

                // Unsubscribe the navigation state changed event
                chromium.NavStateChanged -= chromium_NavStateChanged;
            }
        }
Ejemplo n.º 6
0
        /*
         * Chromium web browser frame load end event handler.
         */
        private void chromium_FrameLoadEnd(object sender, CefSharp.FrameLoadEndEventArgs e) {
            // Was the loaded page the first page load?
            if(!e.Url.Contains(AboutBlankPage)) {
                // Remove the browser load overlay from the form
                this.InvokeOnUiThreadIfRequired(() => {
                    browserPanel.Controls["browserLoadOverlay"].Visible = false;
                });

                // Unsubscribe the frame load end event
                chromium.FrameLoadEnd -= chromium_FrameLoadEnd;
            }
        }
Ejemplo n.º 7
0
        bool CefSharp.ISchemeHandler.ProcessRequest(CefSharp.IRequest request, ref string mimeType, ref System.IO.Stream stream)
        {
            if (request.Url.StartsWith("mako://", StringComparison.OrdinalIgnoreCase) && request.Url.EndsWith(".html"))
            {
                WebClient wc = new WebClient();

                String data = wc.DownloadString(request.Url.ToString().Replace("mako://","http://"));

                Program.me.Preprocess(data, "", false, request.Url.ToString());

                stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(Program.me.Output));
                mimeType = "text/html";
                return true;
            }
            return false;
        }
 private void RequestBrowser_LoadingStateChanged(object sender, CefSharp.LoadingStateChangedEventArgs e)
 {
     if (!e.IsLoading)
     {
         Logger.Log("STREAMCLOUD_NAVIGATION", e.Browser.MainFrame.Url);
         if (e.Browser.MainFrame.Url == trueLink)
         {
             if (continued)
             {
                 finalSiteLoaded = true;
                 Logger.Log("STREAMCLOUD_NAVIGATION", "Navigated to the correct link, continued: " + continued);
             }
             else
             {
                 startedWaiting = DateTime.Now.Ticks;
             }
         }
     }
 }
Ejemplo n.º 9
0
 void browser_LoadCompleted(object sender, CefSharp.LoadCompletedEventArgs url)
 {
     /*
     try
     {
         if (url.Url != "about:blank")
         {
             browser.ExecuteScript("function onChange() {player1.setPlaybackQuality('hd1080');player1.setPlaybackQuality('hd1080');player1.setPlaybackQuality('hd1080');player1.setPlaybackQuality('hd1080');}setTimeout(function(){player1.addEventListener('onStateChange', 'onChange');onChange();}, 1000);");
         }
     }
     catch (Exception e)
     {
         StringBuilder sb = new StringBuilder();
         sb.AppendLine("============================================");
         sb.AppendLine(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString());
         sb.AppendLine("============================================");
         if (e != null)
         {
             sb.AppendLine(e.Message);
             sb.AppendLine(e.StackTrace);
             sb.AppendLine();
         }
         if (e.InnerException != null)
         {
             sb.AppendLine(e.InnerException.Message);
             sb.AppendLine(e.InnerException.StackTrace);
             sb.AppendLine();
         }
         if (e.InnerException.InnerException != null)
         {
             sb.AppendLine(e.InnerException.InnerException.Message);
             sb.AppendLine(e.InnerException.InnerException.StackTrace);
             sb.AppendLine();
         }
         File.AppendAllText("log.txt", sb.ToString());
     }
     */
 }
Ejemplo n.º 10
0
        private void Cwb_StatusMessage(object sender, CefSharp.StatusMessageEventArgs e)
        {
            try
            {
                lblStatusText.Text = e.Value.ToString();
                ConsoleMessageEventArgs cmea = new ConsoleMessageEventArgs(e.Value.ToString(), "Internal", 0);
                ConsoleMessageEvent(this, cmea);
            }
            catch (Exception)
            {

                throw;
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 浏览器加载完毕后事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        async void WebBrowser_FrameLoadEnd(object sender, CefSharp.FrameLoadEndEventArgs e)
        {
            string result = await this.WebBrowser.GetTextAsync();

            Application.Current.Dispatcher.Invoke(new Action(delegate
            {
                this.IsWaiting = false;
                this.WebBrowser.Focus();
                if (result.IndexOf('{') == 0)
                {
                    this.CheckData(result);
                }
            }));
        }
Ejemplo n.º 12
0
 public bool OnKeyEvent(CefSharp.IWebBrowser browserControl, CefSharp.KeyType type, int windowsKeyCode, CefSharp.CefEventFlags modifiers, bool isSystemKey)
 {
     return false;
 }
Ejemplo n.º 13
0
 public void OnDownloadUpdated(IBrowser browser, CefSharp.DownloadItem downloadItem, IDownloadItemCallback callback)
 {
 }
Ejemplo n.º 14
0
 private void B_login_FrameLoadEnd(object sender, CefSharp.FrameLoadEndEventArgs e)
 {
     page_loaded = true;
     Console.WriteLine("Hello from the other side!");
     if (Wizard_Position == 1 && !has_injected) {
         //User is waiting for us.
         Login();
     }
     else if (first_step_passed) {
         try {
             Inject();
         }
         catch { MessageBox.Show("Unexpected Error Occurred :-/", "Truffle"); /*Meh. Better safe than sorry.*/ }
     }
 }
Ejemplo n.º 15
0
        public bool ProcessRequest(CefSharp.IRequest request, ref string mimeType, ref System.IO.Stream stream)
        {
            if (request.Url.StartsWith("entify://"))
            {
                request.Url = request.Url.Substring("entify://".Length);
                string[] fragments = request.Url.Split('/');
                String bundle = fragments[0];
                String path = ENTIFY_APPS_DIR + Path.DirectorySeparatorChar + bundle + Path.DirectorySeparatorChar + String.Join(Path.DirectorySeparatorChar.ToString(), fragments, 1, fragments.Length - 1);
                if (!File.Exists(path))
                {
                    path = ENTIFY_LOCAL_APPS_DIR + Path.DirectorySeparatorChar + bundle + Path.DirectorySeparatorChar + String.Join(Path.DirectorySeparatorChar.ToString(), fragments, 1, fragments.Length - 1);
                }
                if (File.Exists(path))
                {
                    FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
                    byte[] bytes = new byte[fs.Length];
                    fs.Read(bytes, 0, bytes.Length);
                    MemoryStream ms = new MemoryStream(bytes, 0, bytes.Length);
                    fs.Close();
                    stream = ms;
                    mimeType = GetMimeType(path);
                    if (mimeType == "text/css")
                    {
                        StreamReader sr = new StreamReader(ms);
                        var css = sr.ReadToEnd();
                        css = css.Replace("{{primary_color}}", ColorTranslator.ToHtml(Program.form1.BackColor));
                        css = css.Replace("{{primary_color|rgb}}", String.Format("%s,%s,%s", Program.form1.BackColor.R, Program.form1.BackColor.G, Program.form1.BackColor.B));
                        css = css.Replace("{{hue}}", Math.Round(Program.form1.BackColor.GetHue()).ToString());
                        css = css.Replace("{{sat}}", Math.Round(Program.form1.BackColor.GetSaturation() * 100).ToString());
                        css = css.Replace("{{bright}}", Math.Round(Program.form1.BackColor.GetBrightness() * 100).ToString());
                        var f = DotlessConfiguration.GetDefault();
                        css = TransformToCss(css, "a.tmp");

                        MemoryStream ms2 = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(css), false);
                        stream = ms2;
                    }
                    if (mimeType == "application/javascript")
                    {
                        return true;
                    }
                    if (mimeType == "text/html")
                    {
                        StreamReader sr = new StreamReader(ms);
                        var css = sr.ReadToEnd();
                        css = css.Replace("{% header %}", LoadResource("entify://resources/header.html"));
                        css = css.Replace("{{primary_color}}", ColorTranslator.ToHtml(Program.form1.BackColor));
                        css = css.Replace("{{primary_color|rgb}}", String.Format("%s,%s,%s", Program.form1.BackColor.R, Program.form1.BackColor.G, Program.form1.BackColor.B));
                        css = css.Replace("{{hue}}", Math.Round(Program.form1.BackColor.GetHue()).ToString());
                        css = css.Replace("{{sat}}", Math.Round(Program.form1.BackColor.GetSaturation() * 100).ToString());
                        css = css.Replace("{{bright}}", Math.Round(Program.form1.BackColor.GetBrightness() * 100).ToString());
                        css = css.Replace("{{theme}}", Properties.Settings.Default.Theme);
                        //var f = DotlessConfiguration.GetDefault();
                        // css = TransformToCss(css, "a.tmp");

                        MemoryStream ms2 = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(css), false);
                        stream = ms2;
                    }
                    if (request.Url.EndsWith(".xml")) // Assume spider view
                    {
                        StreamReader sr = new StreamReader(ms);

                        IScriptEngine scripting = SpiderView.Runtime;
                        IPreprocessor preprocessor = SpiderView.Preprocessor;

                        // Read raw data

                        // Extract
                        var shtml = SpiderView.Process(LoadResource(request.Url));
                        mimeType = "text/html";
                        MemoryStream ms2 = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(shtml), false);
                        stream = ms2;
                    }
                    return true;
                }
            }
            return false;
        }
Ejemplo n.º 16
0
 public void OnBeforeDownload(IBrowser browser, CefSharp.DownloadItem downloadItem, IBeforeDownloadCallback callback)
 {
     Dispatcher.BeginInvoke((Action)(() =>
     {
         mainWindow.Downloads1.AddDownload(downloadItem.Url, Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), downloadItem.SuggestedFileName);
         mainWindow.Downloads1.Visibility = Visibility.Visible;
     }));
 }
Ejemplo n.º 17
0
 private void JwPlayerControl_IsBrowserInitializedChanged(object sender, CefSharp.IsBrowserInitializedChangedEventArgs e)
 {
     if (e.IsBrowserInitialized)
     {
         if (fileToPlay != null && titleToPlay != null)
         {
             //TODO Find better solution to wait for the about:blank page to 'load' since it prevents my Load in DisplayHtml.
             Task.Delay(500).ContinueWith(t =>
             {
                 Play(fileToPlay, titleToPlay);
                 titleToPlay = fileToPlay = null;
             });
         }
     }
 }
 private void Browser_ConsoleMessage(object sender, CefSharp.ConsoleMessageEventArgs e)
 {
     System.Diagnostics.Debug.WriteLine("CEF ({0}): {1}", e.Line, e.Message);
 }
Ejemplo n.º 19
0
 void WebBrowser_FrameLoadStart(object sender, CefSharp.FrameLoadStartEventArgs e)
 {
     Application.Current.Dispatcher.Invoke(new Action(delegate
     {
         this.IsWaiting = true;
     }));
 }
Ejemplo n.º 20
0
        private void Cwb_ConsoleMessage(object sender, CefSharp.ConsoleMessageEventArgs e)
        {
            try
            {
                if (ConsoleMessageEvent != null)
                {
                    //TODO: Need to fix this so we can send a string and not the ConsoleMessageEventArgs
                    ConsoleMessageEvent(this, e);
                }
            }
            catch (Exception)
            {

                throw;
            }
            // Raise an Event for frmMain log
        }
Ejemplo n.º 21
0
 void wbControl_AddressChanged(object sender, CefSharp.AddressChangedEventArgs e)
 {
     var js = "Address Changed to '+" + e.Address + ")";
     //showMessage(js);
 }
Ejemplo n.º 22
0
        private void Cwb_NavStateChanged(object sender, CefSharp.NavStateChangedEventArgs e)
        {
            try
            {
                if (e.IsLoading)
                    lblStatusText.Text = "Loading";
            }
            catch (Exception)
            {

                throw;
            }
        }
Ejemplo n.º 23
0
        private void Cwb_LoadError(object sender, CefSharp.LoadErrorEventArgs e)
        {
            try
            {
                lblStatusCode.Text = e.ErrorCode.ToString();
            }
            catch (Exception)
            {

                throw;
            }
        }
Ejemplo n.º 24
0
 void wbControl_FrameLoadStart(object sender, CefSharp.FrameLoadStartEventArgs e)
 {
     var js = "Frame Load Start for '+" + e.Url + "";
     //showMessage(js);
 }
Ejemplo n.º 25
0
 public void OnBeforeDownload(IBrowser browser, CefSharp.DownloadItem downloadItem,
     IBeforeDownloadCallback callback)
 {
     Dispatcher.BeginInvoke((Action) (() =>
     {
         mainWindow.Downloads1.AddDownload(downloadItem.Url,
             Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),
             downloadItem.SuggestedFileName);
         if (mainWindow.Downloads1.ActualHeight.Equals(0))
         {
             double height = 0;
             if (!mainWindow.Downloads1.ItemsCount.Equals(0))
             {
                 height = mainWindow.Downloads1.MarginTop + 50 +
                          mainWindow.Downloads1.Items.Count*mainWindow.Downloads1.ItemHeight;
             }
             else
             {
                 height = mainWindow.Downloads1.MarginTop + 50;
             }
             mainWindow.Downloads1.Visibility = Visibility.Visible;
             StaticFunctions.AnimateScale(0, 0, 250, height, mainWindow.Downloads1, 0.2);
             StaticFunctions.AnimateFade(0, 1, mainWindow.Downloads1, 0.2, mainWindow.Downloads1.RefreshDownloads);
         }
     }));
 }