Exemple #1
0
        private async void Browser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
        {
            if (e.Url.PathAndQuery.Contains("code="))
            {
                var code = e.Url.PathAndQuery.Split('=').Last();

                var client = new HttpClient();

                var parameters = new List <KeyValuePair <string, string> >();

                parameters.Add(new KeyValuePair <string, string>("grant_type", "authorization_code"));
                parameters.Add(new KeyValuePair <string, string>("code", code));
                parameters.Add(new KeyValuePair <string, string>("client_id", clientId));
                parameters.Add(new KeyValuePair <string, string>("client_secret", clientSecret));
                parameters.Add(new KeyValuePair <string, string>("redirect_uri", callbackUrl));

                var content = new FormUrlEncodedContent(parameters);

                var url = "https://api.gab.com/oauth/token";

                var tokenRes = await client.PostAsync(url, content);

                var json = await tokenRes.Content.ReadAsStringAsync();

                var token = JsonConvert.DeserializeObject <Token>(json);

                ((MainWindow)Owner).Token = token;


                this.Close();
            }
        }
Exemple #2
0
        void webBrowserOAuth_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
        {
            FacebookOAuthResult oauthResult;

            if (_fb.TryParseOAuthCallbackUrl(e.Url, out oauthResult))
            {
                if (oauthResult.IsSuccess)
                {
                    AccountFacebook fbAccount = new AccountFacebook();
                    fbAccount.AccessToken = oauthResult.AccessToken;
                    fbAccount.verifyCredentials();
                    if (AppController.Current.AllFacebookAccounts.Where(acc => acc.Id == fbAccount.Id).Count() > 0)
                    {
                        MessageBox.Show("This account already has been authorized with Nymphicus successfully. On some systems there is an auto log in active which prevents Nymphicus from asking about other credentials. Please open Internet Explorer and log off there from Facebook- then try again. This window will be closed now", "Account already authorized", MessageBoxButton.OK);
                        Close();
                        return;
                    }
                    facebookOAuthResult      = oauthResult;
                    fbAccount.TokenExpiresAt = oauthResult.Expires;
                    AppController.Current.AllAccounts.Add(fbAccount);
                    Close();
                    return;
                }
                this.WindowState = System.Windows.WindowState.Normal;
                Show();
            }
            else
            {
                this.WindowState = System.Windows.WindowState.Normal;
                Show();
                oauthResult         = null;
                facebookOAuthResult = oauthResult;
            }
        }
Exemple #3
0
 private void Browser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
 {
     UrlTb.Text            = Browser.Url.ToString();
     Title                 = Browser.DocumentTitle;
     BeforeBtn.Visibility  = Browser.CanGoBack ? Visibility.Visible : Visibility.Collapsed;
     ForwardBtn.Visibility = Browser.CanGoForward ? Visibility.Visible : Visibility.Collapsed;
 }
Exemple #4
0
        private void Webbr_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
        {
            Loading.Visibility = Visibility.Collapsed;

            if (webBrowser.Url != null)
            {
                URL_Label.Content = webBrowser.Url.OriginalString;
            }

            if (webBrowser.CanGoBack)
            {
                Undo.IsEnabled = true;
                Undo.Opacity   = 1f;
            }
            else
            {
                Undo.IsEnabled = false;
                Undo.Opacity   = 0.7f;
            }

            if (webBrowser.CanGoForward)
            {
                Redo.IsEnabled = true;
                Redo.Opacity   = 1f;
            }
            else
            {
                Redo.IsEnabled = false;
                Redo.Opacity   = 0.7f;
            }
        }
        private void wvPrint_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
        {
            var db   = new HospitalDbContext();
            var name = db.Patients.Single(v => v.Id == WaitingList.PatientId).FirstName + @"  " + db.Patients.Single(v => v.Id == WaitingList.PatientId).LastName;

            if (wvPrint.Document != null)
            {
                var patientname = wvPrint.Document.GetElementById("PatientName");
                if (patientname != null)
                {
                    patientname.InnerHtml = name;
                }

                var time = wvPrint.Document.GetElementById("Time");
                if (time != null)
                {
                    time.InnerHtml = WaitingList.Time.Hours + " : " + WaitingList.Time.Minutes;
                }

                var getvalue = WaitingList.Number;
                var num      = getvalue;
                var number   = wvPrint.Document.GetElementById("Number");
                if (number != null)
                {
                    number.InnerHtml = num.ToString();
                }
            }
        }
Exemple #6
0
        private void webBrowser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
        {
            // This can only be set once the WebBrowser control is shown, it will throw a COM exception otherwise.
            webBrowser.AllowWebBrowserDrop = false;

            webBrowser.Navigated -= webBrowser_Navigated;
        }
Exemple #7
0
        private void browser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
        {
            this.addressTextBox.Text = e.Url.ToString();

            if (this.addressTextBox.Text.StartsWith("https://www.facebook.com/connect/login_success.html"))
            {
                string   queryString = e.Url.Fragment;
                string[] parameters  = queryString.Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries);

                foreach (string parameter in parameters)
                {
                    List <string> parameterList = parameter.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries).ToList();

                    if (parameterList.ElementAt(0).Equals("#access_token"))
                    {
                        AccessToken = parameterList.ElementAt(1);
                    }
                    else if (parameterList.ElementAt(0).Equals("expires_in"))
                    {
                        ExpiresIn = parameterList.ElementAt(1);
                    }
                }

                this.Close();
            }
        }
 public void WebBrowser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
 {
     // Queue the files to be deleted at shutdown (otherwise, View Source doesn't work)
     if (e.Url.IsFile)
     {
         filesToDeleteOnExit.Add(e.Url.LocalPath);
     }
 }
Exemple #9
0
        void webBrowser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
        {
            //FieldInfo fiComWebBrowser = typeof(WebBrowser).GetField("_axIWebBrowser2", BindingFlags.Instance | BindingFlags.NonPublic);
            //if (fiComWebBrowser == null) return;

            //object objComWebBrowser = fiComWebBrowser.GetValue(webBrowser);
            //if (objComWebBrowser == null) return;

            //objComWebBrowser.GetType().InvokeMember("Silent", BindingFlags.SetProperty, null, objComWebBrowser, new object[] { true });
        }
Exemple #10
0
 private void OnVisualEditorDocumentNavigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
 {
     VisualEditor.Document.ContextMenuShowing += this.OnDocumentContextMenuShowing;
     htmldoc = new HtmlDocument(VisualEditor.Document);
     //((IHTMLDocument2)VisualEditor.Document.DomDocument).designMode = "ON";
     SetStylesheet();
     SetInitialContent();
     VisualEditor.Document.Body.SetAttribute("contenteditable", "true");
     VisualEditor.Document.Focus();
 }
        private void Browser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
        {
            var browser = sender as WebBrowser;

            return;


            //var html = await HttpUtils.HttpRequestStringAsync(new HttpRequestSettings()
            //{
            //    UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36",
            //    Url = url
            //});
        }
Exemple #12
0
        private void Wb_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
        {
            string accessCode = GetCodeFormUri(e.Url);

            if (!string.IsNullOrEmpty(accessCode))
            {
                System.Windows.Forms.Form form = ((System.Windows.Forms.WebBrowser)sender).FindForm();
                form.Text         = accessCode;
                form.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            else if (e.Url.Fragment.Contains("access_token="))
            {
            }
        }
Exemple #13
0
        void WebBrowser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
        {
            FacebookOAuthResult oauthResult;
            FacebookClient      _fb = new FacebookClient();

            if (_fb.TryParseOAuthCallbackUrl(e.Url, out oauthResult))
            {
                if (oauthResult.IsSuccess)
                {
                    this.AccessToken = oauthResult.AccessToken;
                    UpdateItems();
                }
            }
        }
 private void webBrowser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
 {
     try
     {
         //this.webBrowser.Document.Window.Error -= new System.Windows.Forms.HtmlElementErrorEventHandler(this.Window_Error);
         this.webBrowser.Document.Window.Error += new System.Windows.Forms.HtmlElementErrorEventHandler(this.Window_Error);
     }
     catch (Exception ex)
     {
         LogManage.WriteLog(this.GetType(), ex);
     }
     finally
     {
     }
 }
Exemple #15
0
        private void ieBrowser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
        {
            countIE++;
            string url   = "";
            string title = "";

            ShowCountMessageIE(countIE);
            string html = ieBrowser.Document.GetElementsByTagName("html")[0].OuterHtml;

            this.Dispatcher.Invoke(() => {
                url   = ieBrowser.Url.ToString();
                title = ieBrowser.Document.Title;
            });
            ShowHtmlIE(html, url, title);
        }
Exemple #16
0
        private void OnVisualEditorDocumentNavigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs /*NavigationEventArgs*/ e)
        {
            VisualEditor.Document.ContextMenuShowing += this.OnDocumentContextMenuShowing;
            htmldoc = new HtmlDocument(VisualEditor.Document);
            //((IHTMLDocument2)VisualEditor.Document.DomDocument).designMode = "ON";
            SetStyleSheets();
            SetInitialContent();
            SetBodyAttributes();

            VisualEditor.Document.Focus();

            //var doc = VisualEditor.Document as HTMLDocument;
            //doc.body.setAttribute("", "");
            //doc.oncontextmenu += this.OnDocumentContextMenuShowing;
        }
 private void WebBrowser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
 {
     try
     {
         VkHelper.CheckEthernet();
         if (!e.Url.ToString().StartsWith("https://oauth.vk.com/blank.html"))
         {
             return;
         }
         AccessToken = e.Url.Fragment.Split('&')[0].Replace("#access_token=", "");
         Close();
     }
     catch (NetworkInformationException)
     {
         System.Windows.Forms.MessageBox.Show(@"Ошибка интернет соединения.");
     }
 }
Exemple #18
0
        void webBrowserAuthorization_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
        {
            //HideScriptErrors(webBrowserAuthorization, true);

            if (!initialLogoutCompleted)
            {
                initialLogoutCompleted = true;
                startAuthorization();
                return;
            }
            else
            {
                if (e != null)
                {
                    if (e.Url.AbsoluteUri.Contains("code="))
                    {
                        complete = true;

                        Model.Authentication.auth_response response = Authentications.parse_authentication_reponse(e.Url.AbsoluteUri);
                        AuthEventArgs eventArgs = new AuthEventArgs();
                        if (response.success)
                        {
                            Model.Authentication.token token = Authentications.get_access_token(response.code, client_id, client_secret, redirect_uri);
                            if (token != null)
                            {
                                eventArgs.success = true;
                                eventArgs.token   = token;
                            }
                            else
                            {
                                eventArgs.error = "Unable to retrieve access token from code";
                            }
                        }
                        else
                        {
                            eventArgs.error = response.error_message;
                        }
                        AuthSuccess(this, eventArgs);
                        Close();
                    }
                }
            }
        }
Exemple #19
0
        private void OnVisualEditorDocumentNavigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
        {
            VisualEditor.Document.ContextMenuShowing += this.OnDocumentContextMenuShowing;
            htmldoc = new HtmlDocument(VisualEditor.Document);
            //((IHTMLDocument2)VisualEditor.Document.DomDocument).designMode = "ON";
            //样式
            if (style != null && VisualEditor.Document != null)
            {
                HTMLDocument    hdoc   = (HTMLDocument)VisualEditor.Document.DomDocument;
                IHTMLStyleSheet hstyle = hdoc.createStyleSheet("", 0);
                hstyle.cssText = style;
            }
            //内容
            if (myBindingContent != null)
            {
                VisualEditor.Document.Body.InnerHtml = myBindingContent;
            }

            VisualEditor.Document.Body.SetAttribute("contenteditable", "true");
            VisualEditor.Document.Focus();
        }
Exemple #20
0
 private void Value_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
 {
     //Url = WebBrowser.Url.OriginalString;
 }
Exemple #21
0
 private void _webBrowser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
 {
     BrowserVisible = true;
 }
Exemple #22
0
 private static void WebBrowser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
 {
     ieAutoResetEvent.Set();
 }
Exemple #23
0
        void wb_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
        {
            var wb    = sender as WebBrowserEx;
            var model = wb.CurrentTabItem;

            if (model != null && model.SearchBar.Address == null)
            {
                return;
            }

            if (model != null && model.WebBrowser.Url != null)
            {
                bool redirectToBlockedPageInfo = false;
                if (model.SearchBar.Address != wb.Url.AbsoluteUri)
                {
                    string secureIP          = "";
                    bool   isValid           = ValidateDNSEntrySecureServer(wb.Url, out secureIP);
                    bool   isTrustedByComodo = true;
                    if (!string.IsNullOrEmpty(secureIP) && !isValid)
                    {
                        //we create request by IP resolved by Comodo DNS
                        //if it resolves to problematic IP we can redirect browser somewhere...
                        if (!checkedSiteDict.ContainsKey(wb.Url.DnsSafeHost))
                        {
                            isTrustedByComodo = IsTrustedByComodo("http://" + secureIP);
                            isValid           = isTrustedByComodo;
                            checkedSiteDict.Add(wb.Url.DnsSafeHost, isTrustedByComodo);
                        }
                        else
                        {
                            isValid           = checkedSiteDict[wb.Url.DnsSafeHost];
                            isTrustedByComodo = checkedSiteDict[wb.Url.DnsSafeHost];
                        }
                    }
                    if (isValid)
                    {
                        wb.CurrentTabItem.SearchBar.IPBySecureDNS = secureIP;
                        wb.CurrentTabItem.SearchBar.AddressVerificationByDNSVisibility = System.Windows.Visibility.Collapsed;
                    }
                    else
                    {
                        redirectToBlockedPageInfo = true;
                        wb.CurrentTabItem.SearchBar.IPBySecureDNS = secureIP;
                        wb.CurrentTabItem.SearchBar.AddressVerificationByDNSVisibility = System.Windows.Visibility.Visible;
                    }
                }
                if (redirectToBlockedPageInfo)
                {
                    wb.Navigate(DefaultProperties.PasswordBossBlockedSiteUrl);
                }
                else
                {
                    model.SearchBar.Address = wb.Url.AbsoluteUri; //e.Url.AbsoluteUri;
                }


                if (model != null)
                {
                    if (model.CanGoBack != model.WebBrowser.CanGoBack)
                    {
                        model.CanGoBack = model.WebBrowser.CanGoBack;
                    }
                    if (model.CanGoForward != model.WebBrowser.CanGoForward)
                    {
                        model.CanGoForward = model.WebBrowser.CanGoForward;
                    }
                }
            }

            RemoveForbiddenElements(wb);
        }
Exemple #24
0
        void webBrowserAuthorization_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
        {
            if (!initialLogoutCompleted)
            {
                initialLogoutCompleted = true;
                startAuthorization();
                return;
            }
            else
            {
                if (e != null)
                {
                    if (e.Url.AbsoluteUri.Contains("code="))
                    {
                        complete = true;

                        Helper.Response response  = Helper.SendGetRequest(e.Url.AbsoluteUri);
                        AuthEventArgs   eventArgs = new AuthEventArgs();
                        if (!string.IsNullOrEmpty(response.Content))
                        {
                            if (!response.Content.StartsWith("ERROR:::"))
                            {
                                eventArgs.accessToken = response.Content;
                                eventArgs.success     = true;
                                AuthSuccess(this, eventArgs);
                                Close();
                                return;
                            }
                            else
                            {
                                eventArgs.error = response.Content.Substring(8);
                            }
                        }
                        else
                        {
                            eventArgs.error = "Null response";
                        }
                        AuthSuccess(this, eventArgs);
                        Close();
                    }

                    if (e.Url != null)
                    {
                        if (e.Url.AbsoluteUri.Contains("#access_token="))
                        {
                            AuthEventArgs eventArgs = new AuthEventArgs();
                            complete = true;

                            string regexParams = "#access_token=(.*?)[&|\\?]";

                            Regex regex = new Regex(regexParams);

                            Match match = regex.Match(e.Url.AbsoluteUri);

                            string accessToken = "";
                            if (match.Success)
                            {
                                accessToken           = match.Groups[1].Value;
                                eventArgs.success     = true;
                                eventArgs.accessToken = accessToken;
                                eventArgs.error       = "";
                            }
                            else
                            {
                                eventArgs.error = "Parsing error on access token";
                            }

                            AuthSuccess(this, eventArgs);
                            Close();
                        }
                    }
                }
            }
        }
Exemple #25
0
 private void OnNavigated(object sender,
                          System.Windows.Forms.WebBrowserNavigatedEventArgs arg)
 {
     //  Log.UIService.LogDebugFormat("On navigated Url[{0}]", arg.Url);
 }
Exemple #26
0
 static void webBrowser_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e)
 {
     _navigated = true;
 }
Exemple #27
0
        /// <summary>
        /// 網頁載入完成後,才載入GIF
        /// </summary>
        private void Img_web_Navigated(object sender123, System.Windows.Forms.WebBrowserNavigatedEventArgs e123)
        {
            C_滑鼠偵測_滾動.MouseWheel += C_滑鼠偵測_滾動_MouseWheel;
            //M.w_web.MouseWheel += C_滑鼠偵測_滾動_MouseWheel;

            /*
             * M.w_web.MouseWheel += (sernder, e) => {
             *  MessageBox.Show("" + e.Delta);
             * };*/

            //web的選單
            M.img_web.Document.ContextMenuShowing += (object sender, System.Windows.Forms.HtmlElementEventArgs e) => {
                M.func_開啟右鍵選單();
            };



            //雙擊web 全螢幕 用的全域變數
            DateTime time_雙擊web全螢幕 = DateTime.Now;//

            System.Drawing.Point point_雙擊web全螢幕 = M.fun_取得滑鼠();


            //讓web也能拖曳視窗
            M.img_web.Document.MouseDown += ((sender2, e2) => {
                M.img_web.Document.Focus();

                if (e2.MouseButtonsPressed == System.Windows.Forms.MouseButtons.Left)
                {
                    //雙擊web 全螢幕
                    if (((TimeSpan)(DateTime.Now - time_雙擊web全螢幕)).TotalMilliseconds < 400)  //連點低於400毫秒
                    {
                        if (M.grid_換頁按鈕_下.Visibility == Visibility.Visible &&
                            M.fun_取得滑鼠().Y > M.PointToScreen(new Point(0, 0)).Y + M.Height - 100 &&
                            M.fun_取得滑鼠().Y < M.PointToScreen(new Point(0, 0)).Y + M.Height - 20 &&
                            M.fun_取得滑鼠().X > M.PointToScreen(new Point(0, 0)).X + 20 &&
                            M.fun_取得滑鼠().X < M.PointToScreen(new Point(0, 0)).X + M.ActualWidth - 20)
                        {
                            return;
                        }

                        if (point_雙擊web全螢幕 == M.fun_取得滑鼠())//同一個點
                        {
                            if (M.WindowState != WindowState.Maximized)
                            {
                                M.WindowState = WindowState.Maximized;
                            }
                            else
                            {
                                M.WindowState = WindowState.Normal;
                            }
                        }
                        time_雙擊web全螢幕 = DateTime.Now.AddHours(-5);//避免連點3下又跑回來
                    }
                    else
                    {
                        time_雙擊web全螢幕 = DateTime.Now;
                    }
                    point_雙擊web全螢幕 = M.fun_取得滑鼠();


                    try {
                        if (M.fun_判斷滑鼠是否在右下角())  //讓右下角可以拖曳改變視窗大小
                        {
                            if (M.WindowState != WindowState.Maximized)
                            {
                                M.c_視窗改變大小.ResizeWindow(ResizeDirection.BottomRight);
                            }
                        }
                        else
                        {
                            //如果網頁沒有捲軸,就拖曳視窗
                            String x = (String)M.img_web.Document.InvokeScript("fun_bool_movie", new Object[] { });//用js判斷目前是否有捲軸
                            if (x.ToString().Equals("true"))
                            {
                                if (M.WindowState != WindowState.Maximized)        //不是全螢幕
                                {
                                    M.c_視窗改變大小.ResizeWindow(ResizeDirection.Move); //拖曳視窗
                                }
                            }
                        }
                    } catch { }
                }
            });



            //延遲載入,避免GIF無法顯示
            new Thread(() => {
                Thread.Sleep(1);
                C_adapter.fun_UI執行緒(() => {
                    M.c_set.fun_套用setting設定();
                    M.fun_載入圖片或資料夾(path);
                });
            }).Start();
        }