Пример #1
0
        private object poker_add_page(string url = "")
        {
            TabPage ex_tab = new TabPage();

            ex_tab.Text       = "Loading..";
            ex_tab.ImageIndex = 0;

            ExtendedWebBrowser ex_browser = new ExtendedWebBrowser();

            ex_browser.Name   = "ex";
            ex_browser.Parent = ex_tab;
            ex_browser.Dock   = DockStyle.Fill;
            ex_browser.ScriptErrorsSuppressed = true;
            ex_browser.Navigated         += new System.Windows.Forms.WebBrowserNavigatedEventHandler(this.pk_browser_Navigated);
            ex_browser.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.pk_browser_DocumentCompleted);
            ex_browser.NewWindow2        += new EventHandler <NewWindow2EventArgs>(pk_browser_NewWindow2);
            ex_browser.StatusTextChanged += new System.EventHandler(this.wb_StatusTextChanged);

            Program.log(ex_browser.Version.ToString());

            if (url != string.Empty)
            {
                ex_browser.Navigate(url);
            }

            this.pk_tab.TabPages.Add(ex_tab);

            return(ex_browser.Application);
        }
Пример #2
0
        public static async Task TryGetImage(string url, Action <Bitmap> callback)
        {
            Debug.WriteLine("Waiting " + url);
            await semaphore.WaitAsync();

            Debug.WriteLine("Access " + url);

            browser = new ExtendedWebBrowser
            {
                Dock = DockStyle.Fill,
                ScriptErrorsSuppressed = true
            };
            browser.PageLoaded += (s, e) =>
            {
                try
                {
                    urlText.Text = e.Url.ToString();
                    if (HasCaptcha())
                    {
                        if (MessageBox.Show("Captcha detected! Please solve it to load pages from this website.", "Captcha") == DialogResult.OK)
                        {
                            ShowPreview();
                        }
                    }
                    else
                    {
                        var images = browser.Document.Images;
                        if (images.Count > 0)
                        {
                            var el = images[0];
                            var d  = browser.Dock;
                            var en = browser.ScrollBarsEnabled;
                            browser.Dock = DockStyle.None;
                            browser.ScrollBarsEnabled   = false;
                            browser.Document.Body.Style = "overflow:hidden";
                            browser.Size = el.ClientRectangle.Size + new Size(50, 50);
                            Bitmap temp = new Bitmap(browser.Width, browser.Height);
                            browser.DrawToBitmap(temp, new Rectangle(0, 0, temp.Width, temp.Height));
                            Bitmap   bmp = new Bitmap(temp.Width - 50, temp.Height - 60);
                            Graphics gfx = Graphics.FromImage(bmp);
                            gfx.DrawImage(temp, new Rectangle(0, 0, bmp.Width, bmp.Height), new Rectangle(10, 20, bmp.Width, bmp.Height), GraphicsUnit.Pixel);
                            gfx.Dispose();
                            //string path = Path.GetTempFileName();
                            //bmp.Save(path);
                            browser.Dock = d;
                            browser.ScrollBarsEnabled = en;
                            callback(bmp);
                        }
                    }
                }
                finally
                {
                    semaphore.Release();
                    Debug.WriteLine("Done " + url);
                    callback(null);
                }
            };
            browser.Navigate(url);
        }
Пример #3
0
        public static async Task GetImageURLs(string url, Action <string, Size> callback)
        {
            Debug.WriteLine("Waiting " + url);
            await semaphore.WaitAsync();

            Debug.WriteLine("Access " + url);

            browser = new ExtendedWebBrowser
            {
                Dock = DockStyle.Fill,
                ScriptErrorsSuppressed = true
            };
            browser.PageLoaded += (s, e) =>
            {
                try
                {
                    urlText.Text = e.Url.ToString();
                    HashSet <string> urls = new HashSet <string>();
                    if (HasCaptcha())
                    {
                        if (MessageBox.Show("Captcha detected! Please solve it to load pages from this website.", "Captcha") == DialogResult.OK)
                        {
                            ShowPreview();
                        }
                    }

                    foreach (HtmlElement el in browser.Document.Images)
                    {
                        string imgUrl = el.GetAttribute("src");
                        if (imgUrl == string.Empty)
                        {
                            imgUrl = el.GetAttribute("data-src");
                        }
                        if (imgUrl != string.Empty && !urls.Contains(imgUrl))
                        {
                            if (imgUrl.Contains("w_auto"))
                            {
                                imgUrl = imgUrl.Replace("w_auto", "w_800");
                            }
                            urls.Add(imgUrl);
                            callback(imgUrl, el.ClientRectangle.Size);
                        }
                    }
                }
                finally
                {
                    semaphore.Release();
                    Debug.WriteLine("Done " + url);
                    callback(null, new Size(0, 0));
                }
            };
            browser.Navigate(url);
        }
Пример #4
0
 // File -> Open URL
 private void openUrlToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         using (OpenUrlForm ouf = new OpenUrlForm())
         {
             if (ouf.ShowDialog() == DialogResult.OK)
             {
                 ExtendedWebBrowser brw = _windowManager.New(false);
                 brw.Navigate(ouf.Url);
             }
         }
     }
     catch (Exception ex)
     {
         Program.ShowMessageBox("FrmWebBrowser.openUrlToolStripMenuItem_Click", ex);
     }
 }
Пример #5
0
        private void bbBtn_Click(object sender, EventArgs e)
        {
            TabPage NewTabPage = new TabPage();

            ExtendedWebBrowser NewTabBrowser = new ExtendedWebBrowser()
            {
                Parent = NewTabPage,
                Dock = DockStyle.Fill,
                Tag = NewTabPage
            };

            NewTabBrowser.Navigate("http://bb.unist.ac.kr");
            InitializeBrowserEvents(NewTabBrowser);

            tabControl.TabPages.Add(NewTabPage);
            tabControl.SelectedTab = NewTabPage;

            // ExtendedWebBrowser ex = (ExtendedWebBrowser)(tabControl.SelectedTab.Controls[0]);
            // ex.Navigate("http://bb.unist.ac.kr");
        }
Пример #6
0
        // all data in this file are hardcoded
        public void pkh_login(ExtendedWebBrowser browser)
        {
            try
            {
                browser.Navigate("http://zhongbao.10085.cn:18080/module/public/reg/user_login.html");

                while (browser.ReadyState != WebBrowserReadyState.Complete)
                {
                    // TODO: need add timeout
                    Application.DoEvents();
                }

                browser.Document.GetElementById("mobile").Focus();
                browser.Document.GetElementById("mobile").InnerText   = Properties.Settings.Default.PK_DEFAULT_USER;
                browser.Document.GetElementById("password").InnerText = Properties.Settings.Default.PK_DEFAULT_PASS;
                browser.Document.GetElementById("regcheckcode").Focus();
            }
            catch (Exception ex)
            {
            }
        }
Пример #7
0
        private void nightMealBtn_Click(object sender, EventArgs e)
        {
            TabPage NewTabPage = new TabPage();

            ExtendedWebBrowser NewTabBrowser = new ExtendedWebBrowser()
            {
                Parent = NewTabPage,
                Dock = DockStyle.Fill,
                Tag = NewTabPage
            };

            NewTabBrowser.Navigate("https://docs.google.com/spreadsheet/ccc?key=0AiTS2HBKYvZxdEpRVHJ1cXliQVRNUTI1OVQwTzlyTFE&usp=sharing#gid=0");
            InitializeBrowserEvents(NewTabBrowser);

            tabControl.TabPages.Add(NewTabPage);
            tabControl.SelectedTab = NewTabPage;

            // ExtendedWebBrowser ex = (ExtendedWebBrowser)(tabControl.SelectedTab.Controls[0]);
            // ex.Navigate("http://club.cyworld.com/ClubV1/Home.cy/53814181");
        }
Пример #8
0
        private void nateClubBtn_Click(object sender, EventArgs e)
        {
            TabPage NewTabPage = new TabPage();

            ExtendedWebBrowser NewTabBrowser = new ExtendedWebBrowser()
            {
                Parent = NewTabPage,
                Dock = DockStyle.Fill,
                Tag = NewTabPage
            };

            NewTabBrowser.Navigate("http://club.cyworld.com/ClubV1/Home.cy/53814181");
            // NewTabBrowser.Navigate("http://xo.nate.com/Notfound.sk?redirect=http://club.cyworld.com/uniallstar&cpurl=www_ndr.nate.com%2flogin&viewnid=null&viewcid=null&flag=Y&e_url=http://www.nate.com/&mode=");
            InitializeBrowserEvents(NewTabBrowser);

            tabControl.TabPages.Add(NewTabPage);
            tabControl.SelectedTab = NewTabPage;

            // ExtendedWebBrowser ex = (ExtendedWebBrowser)(tabControl.SelectedTab.Controls[0]);
            // ex.Navigate("http://club.cyworld.com/ClubV1/Home.cy/53814181");
        }
Пример #9
0
        private void epBtn_Click(object sender, EventArgs e)
        {
            TabPage NewTabPage = new TabPage();

            ExtendedWebBrowser NewTabBrowser = new ExtendedWebBrowser()
            {
                Parent = NewTabPage,
                Dock = DockStyle.Fill,
                Tag = NewTabPage
            };

            NewTabBrowser.Navigate("http://portal.unist.ac.kr/EP/tmaxsso/runSAPEP.jsp");
            InitializeBrowserEvents(NewTabBrowser);

            tabControl.TabPages.Add(NewTabPage);
            tabControl.SelectedTab = NewTabPage;

            // ExtendedWebBrowser ex = (ExtendedWebBrowser)(tabControl.SelectedTab.Controls[0]);
            // ex.Navigate("http://portal.unist.ac.kr/EP/web/portal/jsp/EP_Default1.jsp");
        }
Пример #10
0
        private void calendarBtn_Click(object sender, EventArgs e)
        {
            TabPage NewTabPage = new TabPage();

            ExtendedWebBrowser NewTabBrowser = new ExtendedWebBrowser()
            {
                Parent = NewTabPage,
                Dock = DockStyle.Fill,
                Tag = NewTabPage
            };

            NewTabBrowser.Navigate("https://www.google.com/calendar/embed?src=anr9a4cbgv3os8ac5i8fg6fqic%40group.calendar.google.com&ctz=Asia/Seoul");
            InitializeBrowserEvents(NewTabBrowser);

            tabControl.TabPages.Add(NewTabPage);
            tabControl.SelectedTab = NewTabPage;

            // ExtendedWebBrowser ex = (ExtendedWebBrowser)(tabControl.SelectedTab.Controls[0]);
            // ex.Navigate("http://club.cyworld.com/ClubV1/Home.cy/53814181");
        }
Пример #11
0
        private void InitGameTab()
        {
            if (tabControlLeft == null)
            {
                return;
            }

            if (tabControlLeft.TabPages.Count == 0)
            {
                return;
            }

            var tabPage = tabControlLeft.TabPages[0];

            tabPage.Text = AppVars.Profile.UserNick;
            TabClass tabClass;

            if (tabPage.Tag == null)
            {
                tabClass = new TabClass {
                    MyType = TabType.Game, WB = browserGame
                };
                tabPage.Tag = tabClass;
            }

            browserGame.BeforeNewWindow   -= wbTab_BeforeNewWindow;
            browserGame.BeforeNavigate    -= browserGame_BeforeNavigate;
            browserGame.DocumentCompleted -= browserGame_DocumentCompleted;

            panelGame.Controls.Remove(browserGame);
            browserGame.Dispose();
            browserGame = null;
            CookiesManager.ClearGame();

            browserGame = new ExtendedWebBrowser
            {
                Dock = DockStyle.Fill,
                Name = "browserGame",
                ScriptErrorsSuppressed = true,
                TabIndex           = 0,
                ObjectForScripting = new ScriptManager()
            };

            browserGame.BeforeNewWindow   += wbTab_BeforeNewWindow;
            browserGame.BeforeNavigate    += browserGame_BeforeNavigate;
            browserGame.DocumentCompleted += browserGame_DocumentCompleted;

            panelGame.Controls.Add(browserGame);
            tabClass             = (TabClass)tabPage.Tag;
            tabClass.WB          = browserGame;
            tabPage.Tag          = tabClass;
            buttonGameScreen.Tag = browserGame;

            var url = HelperConverters.AddressEncode(string.Concat("http://www.neverlands.ru/pinfo.cgi?", "Мастер Создатель"));

            browserGame.Navigate(url);
            while (browserGame != null && !browserGame.IsDisposed && browserGame.ReadyState != WebBrowserReadyState.Complete)
            {
                Application.DoEvents();
            }

            if (browserGame != null && !browserGame.IsDisposed)
            {
                browserGame.Navigate(Resources.AddressNeverlands);
                while (browserGame != null && !browserGame.IsDisposed &&
                       browserGame.ReadyState != WebBrowserReadyState.Complete)
                {
                    Application.DoEvents();
                }

                if (browserGame != null && !browserGame.IsDisposed)
                {
                    browserGame.Navigate(Resources.AddressNeverlands);
                }
            }
        }
Пример #12
0
        private void InitGameTab()
        {
            try
            {
                if (AppVars.MainForm != null)
                {
                    AppVars.MainForm.BeginInvoke(
                        new UpdateTexLogDelegate(AppVars.MainForm.UpdateTexLog),
                        new object[] { "InitGameTab()" });
                }
            }
            catch (InvalidOperationException)
            {
            }

            if (tabControlLeft == null)
            {
                return;
            }

            if (tabControlLeft.TabPages.Count == 0)
            {
                return;
            }

            var tabPage = tabControlLeft.TabPages[0];

            tabPage.Text = AppVars.Profile.UserNick;
            TabClass tabClass;

            if (tabPage.Tag == null)
            {
                tabClass = new TabClass {
                    MyType = TabType.Game, WB = browserGame
                };
                tabPage.Tag = tabClass;
            }

            browserGame.BeforeNewWindow   -= wbTab_BeforeNewWindow;
            browserGame.BeforeNavigate    -= browserGame_BeforeNavigate;
            browserGame.DocumentCompleted -= browserGame_DocumentCompleted;

            panelGame.Controls.Remove(browserGame);
            browserGame.Dispose();
            browserGame = null;
            CookiesManager.ClearGame();

            browserGame = new ExtendedWebBrowser
            {
                Dock = DockStyle.Fill,
                Name = "browserGame",
                ScriptErrorsSuppressed = true,
                TabIndex           = 0,
                ObjectForScripting = new ScriptManager()
            };

            browserGame.BeforeNewWindow   += wbTab_BeforeNewWindow;
            browserGame.BeforeNavigate    += browserGame_BeforeNavigate;
            browserGame.DocumentCompleted += browserGame_DocumentCompleted;

            panelGame.Controls.Add(browserGame);
            tabClass             = (TabClass)tabPage.Tag;
            tabClass.WB          = browserGame;
            tabPage.Tag          = tabClass;
            buttonGameScreen.Tag = browserGame;

            /*
             * var encnick = HelperConverters.NickEncode("Мастер Создатель");
             * var url = $"http://www.neverlands.ru/pinfo.cgi?{encnick}";
             * browserGame.Navigate(url);
             * while (browserGame != null && !browserGame.IsDisposed && browserGame.ReadyState != WebBrowserReadyState.Complete)
             *  Application.DoEvents();
             *
             */

            if (browserGame != null && !browserGame.IsDisposed)
            {
                browserGame.Navigate(Resources.AddressNeverlands);

                try
                {
                    if (AppVars.MainForm != null)
                    {
                        AppVars.MainForm.BeginInvoke(
                            new UpdateTexLogDelegate(AppVars.MainForm.UpdateTexLog),
                            new object[] { $"browserGame.Navigate({Resources.AddressNeverlands})" });
                    }
                }
                catch (InvalidOperationException)
                {
                }

                while (browserGame != null && !browserGame.IsDisposed &&
                       browserGame.ReadyState != WebBrowserReadyState.Complete)
                {
                    Application.DoEvents();
                }

                /*
                 * if (browserGame != null && !browserGame.IsDisposed)
                 *  browserGame.Navigate(Resources.AddressNeverlands);
                 */
            }
        }