Ejemplo n.º 1
0
 /// <summary>
 /// Logs the user in or out
 /// </summary>
 /// <param name="sender">The actionButton that was clicked</param>
 /// <param name="e">The routed event arguments</param>
 private void Login_Click(object sender, RoutedEventArgs e)
 {
     if (Login.Content.ToString() == "Log In")
     {
         Status.Visibility           = Visibility.Collapsed;
         Login.Visibility            = Visibility.Collapsed;
         UserPicContainer.Visibility = Visibility.Collapsed;
         BlankUser.Text        = "";
         WebBrowser.Visibility = Visibility.Visible;
         WebBrowser.Focus(FocusState.Programmatic);
         WebBrowser.Navigate(RequestHandler.GetAuthorizationUri());
     }
     else if (Login.Content.ToString() == "Log Out")
     {
         UserPic.ImageSource = new BitmapImage();
         BlankUser.Text      = "\uE77B";
         Status.Text         = loggedOutText;
         Login.Content       = "Log In";
         RequestHandler.ClearTokens();
         if (MainPage.yourMusicPage != null)
         {
             MainPage.yourMusicPage.ClearPlaylists();
         }
     }
     if (App.mainPage != null)
     {
         App.mainPage.UpdateUserUI();
     }
 }
Ejemplo n.º 2
0
 private void sendMessageToBrowser(string message)
 {
     browser.Focus();
     ChatBoxLine.Focus();
     ChatBoxLine.SetAttribute("Value", message);
     SendKeys.Send("{ENTER}");
 }
Ejemplo n.º 3
0
        }//删除节点

        #endregion

        #region webBrowser Edit
        private void BoldButton1_Click(object sender, EventArgs e)
        {
            WebBrowser a = (WebBrowser)TabControl.SelectedTab.Controls[0];

            a.Document.ExecCommand("Bold", false, null);
            a.Focus();
        }
Ejemplo n.º 4
0
        private void InsertPictureButton_Click(object sender, EventArgs e)
        {
            WebBrowser a = (WebBrowser)TabControl.SelectedTab.Controls[0];

            a.Document.ExecCommand("InsertImage", false, null);
            a.Focus();
        }
Ejemplo n.º 5
0
        private void JustifyRightButton_Click(object sender, EventArgs e)
        {
            WebBrowser a = (WebBrowser)TabControl.SelectedTab.Controls[0];

            a.Document.ExecCommand("JustifyRight", false, null);
            a.Focus();
        }
Ejemplo n.º 6
0
        public ViewPlan(string pdf)
        {
            web = new WebBrowser {
                Dock = DockStyle.Fill,
            };
            web.Navigate(pdf + "#toolbar=0&navpanes=1&scrollbar=1");

            button = new CommandButton(Resources.Close)
            {
                Location = new Point(5, 1),
                TabStop  = false,
            };
            prev = new CommandButton(">")
            {
                Location = new Point((Screen.PrimaryScreen.Bounds.Width - CommandButton.DefaultWidth - 5), 1),
                TabStop  = false,
            };
            next = new CommandButton("<")
            {
                Location = new Point((Screen.PrimaryScreen.Bounds.Width - CommandButton.DefaultWidth - 5) - prev.Width, 1),
                TabStop  = false,
            };

            button.Click += (s, e) => { this.Close(); };
            prev.Click   += (s, e) => {
                web.Focus();
                Application.DoEvents();
                SendKeys.Send("{PGUP}");
            };
            next.Click += (s, e) => {
                web.Focus();
                Application.DoEvents();
                SendKeys.Send("{PGDN}");
            };

            panel = new Panel {
                Dock   = DockStyle.Bottom,
                Height = CommandButton.DefaultHeight + 2,
            };
            panel.Controls.Add(button);
            panel.Controls.Add(prev);
            panel.Controls.Add(next);

            this.Controls.Add(panel);
            //this.Controls.Add(pic);
            this.Controls.Add(web);
        }
Ejemplo n.º 7
0
 private void NavigateToSite(object sender, EventArgs E)
 {
     browse.Navigate(url.Text);
     this.Controls.Remove(browse);
     this.Controls.Add(browse);
     browse.Focus();
     this.Text = browse.DocumentTitle + " - BTP Browser";
 }
Ejemplo n.º 8
0
        public StudentGuide()
        {
            web = new WebBrowser {
                Dock = DockStyle.Fill,
            };
            var path = Application.StartupPath + @"\Pdf\StudentGuide.pdf?toolbar=0&navpanes=0&scrollbar=0";

            web.Navigate(path);

            Footer footer = new Footer(Resources.Back, "<", ">");

            footer.SetCallback(0, (s, e) => { this.Close(); });
            footer.SetCallback(1, (s, e) => { web.Focus(); SendKeys.Send("{PGDN}"); });
            footer.SetCallback(2, (s, e) => { web.Focus(); SendKeys.Send("{PGDN}"); });

            Controls.Add(footer);
            Controls.Add(web);
        }
Ejemplo n.º 9
0
        public void Navigate(String url, Boolean addToHistoryList)
        {
            if (!String.IsNullOrEmpty(url))
            {
                _browser.Navigate(url);
                _browser.Focus();

                _addToHistoryList = addToHistoryList;
            }
        }
Ejemplo n.º 10
0
 internal void Enter()
 {
     if (!mayCreateActivity())
     {
         return;
     }
     Log.Info("Enter " + currentActivity);
     updateSystemStatus();
     updateBusinessRelative();
     switchTimeTick();
     clearClickNum();
     startPageTimer();
     mWebBrowser.Invoke((MethodInvoker) delegate()
     {
         mWebBrowser.Focus();
         mWebBrowser.Focus();
         mWebBrowser.Document.Focus();
         Activity.Enter(currentActivity);
     });
 }
Ejemplo n.º 11
0
        private void Window_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (iViewer != null)
            {
                iViewer.Dispose();
                iViewer = null;
            }

            if (IsVisible)
            {
                iViewer = new ViewerBrowser(WebBrowser, iServer.PresentationUri);
                WebBrowser.Focus();
            }
        }
Ejemplo n.º 12
0
        private void WorkaroundForm_Load(object sender, EventArgs e)
        {
            this.SuspendLayout();
            this.Location        = new Point(0, 0);
            this.Dock            = DockStyle.Fill;
            this.FormBorderStyle = FormBorderStyle.None;
            WebBrowser webBrowser = new WebBrowser();

            this.Controls.Add(webBrowser);
            webBrowser.Location = new Point(0, 0);
            webBrowser.Dock     = DockStyle.Fill;
            this.ResumeLayout();
            webBrowser.Focus();
            webBrowser.Navigate(new System.Uri("https://bing.com"));
        }
Ejemplo n.º 13
0
        public ConfigurationWindow(Icon aIcon, string aTitle, Server aServer)
        {
            InitializeComponent();

            WebBrowser.Focus();

            iServer = aServer;

            MemoryStream iconStream = new MemoryStream();

            aIcon.Save(iconStream);
            iconStream.Seek(0, SeekOrigin.Begin);
            Icon = BitmapFrame.Create(iconStream);

            Title = aTitle;
            //Background = new SolidColorBrush(System.Windows.Media.Colors.Black);
        }
Ejemplo n.º 14
0
        private void textEditor_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.S && lastpresses == Key.LeftCtrl)
            {
                lastpresses = Key.V;
                webBrowser.Focus();
                String text = ((TextEditor)sender).Text;
                if (directories[(TextEditor)sender] == "")
                {
                    SaveFileDialog saveFileDialog = new SaveFileDialog();
                    saveFileDialog.Filter = "HTML page (*.html)|*.html";
                    if (saveFileDialog.ShowDialog() == true)
                    {
                        directories[(TextEditor)sender] = saveFileDialog.FileName;
                        File.WriteAllText(saveFileDialog.FileName, text);
                    }
                    else
                    {
                        return;
                    }
                }
                FileStream fs = new FileStream(directories[(TextEditor)sender], FileMode.Create);
                fs.Write(Encoding.UTF8.GetBytes(text), 0, text.Length);
                fs.Close();
                // Uri uri = new Uri(directories[(TextEditor)sender]);

                //webBrowser.Source = uri;
                //webBrowser.NavigateToString(directories[(TextEditor)sender]);
                webBrowser.Navigate(directories[(TextEditor)sender]);
                //webBrowser.Refresh(true);
            }
            if (e.Key == Key.F && lastpresses == Key.LeftCtrl)
            {
                lastpresses = Key.V;
                ICSharpCode.AvalonEdit.Search.SearchPanel sp = ICSharpCode.AvalonEdit.Search.SearchPanel.Install((TextEditor)sender);
            }
            //if (e.Key == Key.Z && lastpresses == Key.LeftCtrl)
            //{
            //    ((TextEditor)sender).Undo();
            //}
            //if (e.Key == Key.Y && lastpresses == Key.LeftCtrl)
            //{
            //    ((TextEditor)sender).Redo();
            //}
            lastpresses = e.Key;
        }
Ejemplo n.º 15
0
        //----------------------------------------------------------
        //函式名稱: tsmi_newpage_Click
        //說明: tabControl [新分頁] CLICK事件
        //參數: 無
        //回傳值: 無
        //----------------------------------------------------------
        private void tsmi_newpage_Click(object sender, EventArgs e)
        {
            if (tabCtrl.TabPages.Count > 10)
            {
                MessageBox.Show("無法再新增新的查詢頁面!", "系統警告");
                return;
            }
            TabPage tp = new TabPage("分頁(" + (tabCtrl.TabPages.Count + 1).ToString() + ")");

            tabCtrl.TabPages.Add(tp);
            tabCtrl.SelectedIndex = tabCtrl.TabPages.Count - 1;
            //WebBrowser----------------------------------
            WebBrowser new_wb = new WebBrowser();

            new_wb.Parent          = tp;
            new_wb.Dock            = DockStyle.Fill;
            new_wb.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.webBrowser_PreviewKeyDown);
            new_wb.Focus();

            //自動連結到複製的網址
            tb_url.Text = Clipboard.GetText();
            bt_refresh_Click(sender, null);
        }
Ejemplo n.º 16
0
        /// ------------------------------------------------------------------------------------
        private void ShowHtmlChart(bool show)
        {
            _pnlGrid.Visible = true;

            if (_htmlVw != null)
            {
                _htmlVw.Visible    = show;
                _chartGrid.Visible = !show;
            }
            else
            {
                _chartGrid.Visible = true;
            }

            if (_htmlVw != null && _htmlVw.Visible)
            {
                _htmlVw.Focus();
            }
            else
            {
                _chartGrid.Focus();
            }
        }
Ejemplo n.º 17
0
        private void TryToSubmitLoginForm()
        {
            HtmlElement LoginForm = WebBrowser.Document.GetElementById("loginForm");

            if (LoginForm != null)
            {
                HtmlElement UsernameInput = WebBrowser.Document.GetElementById("username100");
                if (UsernameInput != null)
                {
                    HtmlElement PasswordInput = WebBrowser.Document.GetElementById("password");
                    if (PasswordInput != null)
                    {
                        var Buttons = LoginForm.GetElementsByTagName("button");
                        foreach (HtmlElement Button in Buttons)
                        {
                            if (Button.InnerText.Trim().ToLower() == "login")
                            {
                                // Have all the inputs we need, try injecting the username and password
                                WebBrowser.Focus();

                                UsernameInput.Focus();
                                SendKeys.SendWait(_CardNumber);

                                PasswordInput.Focus();
                                SendKeys.SendWait(_Password);

                                Button.InvokeMember("click");

                                _ScraperState = ScraperState.WaitingForAccountInformation;
                                return;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 18
0
        private void WebBrowser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
        {
            if (!e.Uri.ToString().ToLower().Contains("tableeditor.html"))
            {
                return;
            }

            var json = BaseBrowserInterop.SerializeObject(TableData);

            WebBrowser.Focus();

            try
            {
                JavaScriptCallbacks = new TableEditorJavaScriptCallbacks(this);
                var inst = WebBrowser.InvokeScript("InitializeInterop", JavaScriptCallbacks, json);

                Interop = new TableEditorDotnetInterop(inst);
            }
            catch
            {
                mmApp.Model.Window.ShowStatusError("Unable to open table editor. Unable to navigate to editor template.");
                this.Close();
            }
        }
Ejemplo n.º 19
0
 public void Navigate(string URL)
 {
     wb.Navigate(URL);
     wb.Focus();
 }
Ejemplo n.º 20
0
 private void zoomIn_Click(object sender, EventArgs e)
 {
     // zoom in
     _wBrowser.Focus();
     SendKeys.Send("^{ADD}");
 }
Ejemplo n.º 21
0
 private void Search_OnEnter(object sender, EnterEventArgs e)
 {
     Navigate(e.Source);
     WebBrowser.Focus(FocusState.Pointer);
 }
        public void share(WebBrowser wb)
        {
            try
            {
                if (link0 == 0)
                {
                    Invoke(new Action(() => links0 = wb.Document.GetElementsByTagName("a")));
                }
                link0 = 1;
                //cmnd = "a";
                shr1 : if (shrset == 0)
                {
                    //  Invoke(new Action(() => timer1.Start()));
                    //Thread.Sleep(1000);
                    Invoke(new Action(() => wb.Focus()));
                    // Invoke(new Action(() => richTextBox1.Text += "clicking share button" + Environment.NewLine));
                    foreach (HtmlElement link in links0)
                    {
                        string l = link.GetAttribute("className");
                        if (!string.IsNullOrEmpty(l))
                        {
                            if (l.Equals("share_action_link"))
                            {
                                link.Focus();
                                Thread.Sleep(300);
                                System.Windows.Forms.SendKeys.SendWait("{Enter}");
                                // Invoke(new Action(() => richTextBox1.Text += "Share button" + Environment.NewLine));
                                shrset = 1;
                                break;
                            }
                        }
                    }
                }
                cmnd = "span";
                if (link1 == 0)
                {
                    Invoke(new Action(() => links1 = wb.Document.GetElementsByTagName("span")));
                }
                link1 = 1;
                // Invoke(new Action(() => timer1.Start()));
                //  Invoke(new Action(() => richTextBox1.Text += "clicking Share" + Environment.NewLine));
                //run = true;
                //while (run)
                //{

                //}

                foreach (HtmlElement link in links1)
                {
                    if (!string.IsNullOrEmpty(link.InnerText) && link.InnerText.Equals("Share…"))
                    {
                        link.InvokeMember("Click");
                        // Invoke(new Action(() => richTextBox1.Text += "clicked Share" + Environment.NewLine));
                        done = 1;
                        break;
                    }
                }
                if (done == 0)
                {
                    goto shr1;
                }
                else
                {
                    done = 0;
                }


shr2:
                //  run = true;
                Thread.Sleep(5000);
                if (link2 == 0)
                {
                    Invoke(new Action(() => links2 = wb.Document.GetElementsByTagName("span")));
                }
                link2 = 1;
                // Invoke(new Action(() => timer1.Start()));
                Thread.Sleep(500);
                //while (run)
                //{

                //}
                // Invoke(new Action(() => richTextBox1.Text += "clicking Timeline button" + Environment.NewLine));
                foreach (HtmlElement link in links2)
                {
                    if (!string.IsNullOrEmpty(link.InnerText))
                    {
                        if (string.Equals(link.InnerText, "On your own Timeline") && link.TabIndex == 0)
                        {
                            System.Windows.Forms.SendKeys.SendWait("+{Tab}");
                            Thread.Sleep(200);
                            System.Windows.Forms.SendKeys.SendWait("{Enter}");
                            Thread.Sleep(200);
                            System.Windows.Forms.SendKeys.SendWait("{Down}");
                            Thread.Sleep(200);
                            System.Windows.Forms.SendKeys.SendWait("{Down}");
                            Thread.Sleep(200);
                            System.Windows.Forms.SendKeys.SendWait("{Enter}");
                            Thread.Sleep(200);
                            done = 1;
                            //  Invoke(new Action(() => richTextBox1.Text += "Clicked Timeline button  " + link.TabIndex + "::" + link.TagName + Environment.NewLine));
                            break;
                        }
                    }
                }

                if (done == 0)
                {
                    goto shr2;
                }
                else
                {
                    done = 0;
                }
                run = true;


                // Invoke(new Action(() => label1.Text = "33"));
                //Invoke(new Action(() => timer1.Start()));
                //run = true;
                //while (run)
                //{

                //}
                //Invoke(new Action(() => richTextBox1.Text += "Clicking Group" + Environment.NewLine));
                //foreach (HtmlElement link in links)
                //{
                //    if (!string.IsNullOrEmpty(link.InnerText))
                //    {
                //        if (link.InnerText.Equals("In a group"))
                //        {
                //            Invoke(new Action(() => wb.Focus()));
                //            link.InvokeMember("Click");
                //            Invoke(new Action(() => richTextBox1.Text += "clicked group" + Environment.NewLine));
                //            break;
                //        }
                //    }
                //}
                //Invoke(new Action(() => label1.Text = "44"));

                run = true;

                Invoke(new Action(() => InvokeOnClick(button2, EventArgs.Empty)));

                //imp_code(i);

                while (run)
                {
                }

                Invoke(new Action(() => label1.Text = "5"));
shr3:
                run = true;
                if (link3 == 0)
                {
                    Invoke(new Action(() => links3 = wb.Document.GetElementsByTagName("li")));
                }
                link3 = 1;
                //Invoke(new Action(() => timer3.Start()));
                //while (run)
                //{

                //}
                Thread.Sleep(1000);
                //  Invoke(new Action(() => wb.Focus()));
                //  Invoke(new Action(() => richTextBox1.Text += "Clicking selected group" + Environment.NewLine));
                foreach (HtmlElement link in links3)
                {
                    string l = link.GetAttribute("title");
                    if (!string.IsNullOrEmpty(l))
                    {
                        if (string.Equals(l, dataGridView1.Rows[i].Cells[0].Value.ToString()))
                        {
                            System.Windows.Forms.SendKeys.SendWait("{Enter}");

                            Thread.Sleep(300);
                            System.Windows.Forms.SendKeys.SendWait("{Enter}");
                            shared = true;
                            done   = 1;

                            Thread.Sleep(3500);
                            break;
                        }
                        else
                        {
                            System.Windows.Forms.SendKeys.SendWait("{Down}");
                        }
                    }
                }

                if (done == 0)
                {
                    goto shr3;
                }
                else
                {
                    done = 0;
                }

                run = true;

                if (shared)
                {
                    shared = false;
                    Invoke(new Action(() => dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.LightGreen));
                    Invoke(new Action(() => dataGridView1.Rows[i].Cells[1].Value             = "Post Shared"));
                    // Invoke(new Action(() => richTextBox1.Text += "Shared" + Environment.NewLine));
                }
                else
                {
                    Invoke(new Action(() => dataGridView1.Rows[i].DefaultCellStyle.ForeColor = Color.White));
                    Invoke(new Action(() => dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Brown));
                    Invoke(new Action(() => dataGridView1.Rows[i].Cells[1].Value             = "Issue detected"));
                }


                // Invoke(new Action(() => richTextBox1.Text += ""));
                if (wbvisible == 1)
                {
                    wbvisible = 2;
                }
                else
                {
                    wbvisible = 1;
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.ToString());

                run = true;
            }
        }
Ejemplo n.º 23
0
 public void CaptureFocus()
 {
     _browser.Focus();
 }
Ejemplo n.º 24
0
 // Those work for me but wonder if they are reliable. There are other ways:
 // http://stackoverflow.com/questions/738232/zoom-in-on-a-web-page-using-webbrowser-net-control
 private void ViewZoomIn_Click(object sender, EventArgs e)
 {
     _webBrowser.Focus();
     SendKeys.Send("^{+}"); // [CTRL]+[+]
 }