Exemple #1
0
        private void SysFavorite_Load(object sender, EventArgs e)
        {
            pictureBox1.Width = pictureBox1.Height = KellWebBrowser.IconWidth;
            KellWebBrowser.Favorites.Sort(new UrlComparer());
            foreach (UrlObject uo in KellWebBrowser.Favorites)
            {
                listBox1.Items.Add(uo);
                if (uo.IsHome)
                {
                    homeIndex = listBox1.Items.Count - 1;
                    home      = uo;
                }
            }
            button3.Enabled   = KellWebBrowser.HistoryUrlList.Count > 0;
            checkBox1.Checked = KellCommon.ReadIni("AppSettings", "NewWindow", KellCommon.IniFile) == "0" ? true : false;
            string search = KellCommon.ReadIni("AppSettings", "Search", KellCommon.IniFile);

            if (!string.IsNullOrEmpty(search))
            {
                int index;
                if (int.TryParse(search[0].ToString(), out index))
                {
                    comboBox1.SelectedIndex = index;
                }
            }
            if (comboBox1.Items.Count == 1 && comboBox1.Items[0] != null && comboBox1.Items[0].ToString() == NoneSearchEngine)
            {
                comboBox1.SelectedIndex = 0;
            }
            loadOver = true;
        }
        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (!finished)
            {
                title  = webBrowser1.DocumentTitle;
                icon   = GetIcon();
                url    = webBrowser1.Url.AbsoluteUri;
                isHome = DnsConvert.ToPunycode(url) == Home;
                toolStripMenuItem1.Enabled = !isHome;

                UrlObject uo;
                if (!accs.ContainsUrl(url, out uo))
                {
                    UrlObject u = new UrlObject(title, url, icon);
                    u.IsHome = isHome;
                    accs.Add(u);
                }

                SaveAccessRecordSyncFav();
                LoadHistoryList();
                access   = accs.GetUrlAccessCount(Url);
                finished = true;
            }
            button8.Enabled = true;
            toolStripProgressBar1.Visible = false;
            OnDocumentCompleted(e);
        }
 public static bool ContainsUrl(this List <UrlObject> urls, string urlString, out UrlObject uo)
 {
     uo = null;
     foreach (UrlObject url in urls)
     {
         if (DnsConvert.ToPunycode(url.Url) == DnsConvert.ToPunycode(urlString.ToLower()))
         {
             uo = url;
             return(true);
         }
     }
     return(false);
 }
Exemple #4
0
 private void button1_Click(object sender, EventArgs e)
 {
     bool save = false;
     UrlObject uo;
     if (KellWebBrowser.Favorites.ContainsUrl(textBox2.Text, out uo))
     {
         if (MessageBox.Show("当前页面已经存在于收藏夹中,确定要覆盖原来的?", "覆盖提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
         {
             uo.Title = textBox1.Text;
             uo.Image = KellWebBrowser.DocumentIcon;
             UrlObject u;
             if (KellWebBrowser.HistoryUrlList.ContainsUrl(textBox2.Text, out u))
             {
                 uo.Access = u.Access;
             }
             if (DnsConvert.ToPunycode(uo.Url) == KellWebBrowser.Home)
                 uo.IsHome = true;
             save = true;
         }
     }
     else
     {
         uo = new UrlObject(textBox1.Text, textBox2.Text, KellWebBrowser.DocumentIcon);
         UrlObject u;
         if (KellWebBrowser.HistoryUrlList.ContainsUrl(textBox2.Text, out u))
         {
             uo.Access = u.Access;
         }
         if (DnsConvert.ToPunycode(uo.Url) == KellWebBrowser.Home)
             uo.IsHome = true;
         KellWebBrowser.Favorites.Add(uo);
         save = true;
     }
     if (save)
     {
         using (FileStream fs = new FileStream(KellWebBrowser.FavFile, FileMode.Create, FileAccess.Write))
         {
             BinaryFormatter bf = new BinaryFormatter();
             bf.Serialize(fs, KellWebBrowser.Favorites);
         }
         MessageBox.Show("当前页面已经成功保存到收藏夹中!");
     }
 }
Exemple #5
0
 private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     numericUpDown1.Enabled = button5.Enabled = button1.Enabled = button2.Enabled = listBox1.SelectedIndex > -1;
     if (listBox1.SelectedIndex > -1)
     {
         UrlObject uo = listBox1.Items[listBox1.SelectedIndex] as UrlObject;
         textBox1.Text = uo.Title;
         textBox2.Text = uo.Url;
         if (uo.Image != null)
         {
             pictureBox1.Image = uo.Image.ToBitmap();
         }
         else
         {
             pictureBox1.Image = null;
         }
         numericUpDown1.Value = uo.Access;
         if (uo.IsHome)
         {
             button5.Enabled = false;
         }
     }
 }
Exemple #6
0
 private void button5_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedIndex > -1)
     {
         KellWebBrowser.Home = DnsConvert.ToPunycode(KellWebBrowser.Favorites[listBox1.SelectedIndex].Url);
         foreach (UrlObject u in KellWebBrowser.Favorites)
         {
             u.IsHome = false;
         }
         KellWebBrowser.Favorites[listBox1.SelectedIndex].IsHome = true;
         foreach (UrlObject u in KellWebBrowser.HistoryUrlList)
         {
             u.IsHome = DnsConvert.ToPunycode(u.Url) == KellWebBrowser.Home;
         }
         listBox1.Items[listBox1.SelectedIndex] = KellWebBrowser.Favorites[listBox1.SelectedIndex];
         if (homeIndex > -1)
         {
             listBox1.Items[homeIndex] = home;
         }
         homeIndex = listBox1.SelectedIndex;
         home      = KellWebBrowser.Favorites[listBox1.SelectedIndex];
         //MessageBox.Show("主页设置完毕!");
     }
 }