Ejemplo n.º 1
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     timer.Start( );
     try
     {
         if (App.Program.InputArgu != "")
         {
             BrowserCore.Navigate(App.Program.InputArgu);
         }
         else if (Url != "" && Url != null && Url != ".")
         {
             BrowserCore.Navigate(Url);
         }
         else if (!(Isnew == "false"))
         {
             string PathStart = File.ReadAllText(AppStartupPath + "\\DataBase\\Config.db");
             if (PathStart == "")
             {
                 File.WriteAllText(AppStartupPath + "\\DataBase\\Config.db", "about:blank");
                 BrowserCore.Navigate("about:blank");
             }
             else
             {
                 BrowserCore.Navigate(PathStart);
             }
         }
     }
     catch (Exception)
     {
         this.Close( );
     }
 }
Ejemplo n.º 2
0
        private void Load(object sender, RoutedEventArgs e)
        {
            string str = UrlTextBox.Text;

            if (str == "about:blank")
            {
                BrowserCore.Navigate("about:blank");
                return;
            }
            try
            {
                //处理str
                if (str.Substring(0, 4) != "http" &&
                    str.Substring(0, 4) != "file" &&
                    str.Substring(0, 4) != "ftp" &&
                    str.Contains("."))
                {
                    str = "http://" + str;
                }
                else if (!str.Contains(".") && !str.Contains("C:") && !str.Contains("D:"))
                {
                    str = "https://www.baidu.com/#ie=UTF-8&wd=" + str;
                }
                else if (str.Contains(":\\"))
                {
                    str = "file:///" + str;
                }

                //加载
                try
                {
                    BrowserCore.Navigate(str);
                }
                catch (UriFormatException)
                {
                    if (str.Substring(0, 4) == "http")
                    {
                        try
                        {
                            BrowserCore.Navigate("http://" + str);
                            UrlTextBox.Text = "http://" + str;
                        }
                        catch (Exception) { }
                        return;
                    }
                    label1.Content = "URL错误";
                }
                UrlTextBox.Text = str;
            }
            catch (ArgumentOutOfRangeException)
            {
                Console.WriteLine("OMH");
                BrowserCore.Navigate("https://www.baidu.com/#ie=UTF-8&wd=" + UrlTextBox.Text);
            }
        }
Ejemplo n.º 3
0
 private void Load(object sender, RoutedEventArgs e)
 {
     if (UrlTextBox.Text.ToLower().Contains("easy://"))
     {
         BrowserCore.PraseEasy(UrlTextBox.Text);
     }
     else
     {
         BrowserCore.Navigate(UrlTextBox.Text);
     }
 }
Ejemplo n.º 4
0
 public void OnNewWindow(NewWindowEventArgs e)
 {
     if (BrowserCore.CefInstance.OnlyThis.IsChecked == false)
     {
         NewInstance.StartNewInstance(e.Url);
     }
     else
     {
         BrowserCore.Navigate(e.Url);
     }
 }
Ejemplo n.º 5
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     //throw new Exception( );
     Dispatcher.BeginInvoke((Action) delegate()
     {
         try
         {
             BrowserCore.Navigate(FileApi.GetStartupPath(App.Program.arguments.isNew));
         }
         catch (Exception ex)
         {
             Logger.Log(ex, logType: LogType.Debug, shutWhenFail: true);
         }
     });
 }
Ejemplo n.º 6
0
 private void Cwb_LoadError(object sender, LoadErrorEventArgs e)
 {
     Dispatcher.BeginInvoke((Action) delegate()
     {
         if (e.ErrorCode.ToString() == "NameNotResolved" ||
             e.ErrorCode.ToString() == "AddressUnreachable")
         {
             BrowserCore.Navigate("https://www.baidu.com/s?wd=" + UrlTextBox.Text);
         }
         else if (e.ErrorCode.ToString() != "Aborted")
         {
             BrowserCore.Navigate(FilePath.AppPath + "\\Error.html?errorCode=" + e.ErrorCode + "&errorText=" + e.ErrorText + "&url=" + UrlTextBox.Text);
         }
     });
 }
Ejemplo n.º 7
0
 public void Navigate(string url)
 {
     BrowserCore.Navigate(url);
 }