Як отримати значок веб-сайту

Автор работы: Пользователь скрыл имя, 26 Апреля 2013 в 17:43, контрольная работа

Описание работы

У цій роботі описується, як створити і реалізувати деякі з особливостей додатку Web Browser, запам'ятовувати Вибрані веб-вузли і використовувати Links Bar, зберігати Історію відвіданих сторінок, пошук в Google або Live Search, зберігати настроювальні параметри, проглядання джерела і властивостей веб-вузла, друк вмісту сторінки, і інші можливості. C# має WebBrowser control, який робить всю роботу з передачі веб-сторінок.

Содержание работы

Вступ 3
Як отримати значок веб-сайту 4
Панель посилань (Links Bar) 4
Історія і Вибране 6
Перегляд джерела 8
Пошук 9
Збереження настроювальних Параметрів 9
Властивості, Друк, Попередній Перегляд, Установки Сторінки, Зберегти Як 11
Вирізати, Копіювати, Вставити, Виділити Все 12
Список літератури 32

Файлы: 1 файл

Web-браузер.doc

— 355.50 Кб (Скачать файл)

        {

            addNewTab();

            getCurrentBrowser().Navigate(adress);

        }

        //open in new window

        private void openInNewWindowToolStripMenuItem_Click(object sender, EventArgs e)

        {

            WBrowser new_form = new WBrowser();

            new_form.Show();

            new_form.getCurrentBrowser().Navigate(adress);

        }

                     /*LINK CONTEXT MENU*/

        //delete link

        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)

        {

            deleteLink();

        }

        //rename link

        private void renameToolStripMenuItem_Click(object sender, EventArgs e)

        {

            renameLink();

        }

                          /*FAVORITES CONTEXT MENU*/

        //delete favorit

        private void deleteToolStripMenuItem1_Click(object sender, EventArgs e)

        {

            deleteFavorit();

        }

        //rename favorit

        private void renameToolStripMenuItem1_Click(object sender, EventArgs e)

        {

            renameFavorit();

        }

          

              /*HISTORY CONTEXT MENU */

 

        private void openToolStripMenuItem3_Click(object sender, EventArgs e)

        {

            getCurrentBrowser().Navigate(historyTreeView.SelectedNode.Text);

        }

 

//delete history

        private void deleteToolStripMenuItem2_Click(object sender, EventArgs e)

        {

            deleteHistory();

        }

//add to favorites

        private void addToFavoritesToolStripMenuItem_Click(object sender, EventArgs e)

        {  

            AddFavorites dlg = new AddFavorites(historyTreeView.SelectedNode.Text);

             DialogResult res = dlg.ShowDialog();

                if (res == DialogResult.OK)

                {

                    if (dlg.favFile == "Favorites")

                        addFavorit(getCurrentBrowser().Url.ToString(), dlg.favName);

                    else addLink(getCurrentBrowser().Url.ToString(), dlg.favName);

                  

                    deleteHistory();

                }

                dlg.Close();

 

               

        }

 

        #endregion

 

        #region FAVORITES WINDOW

 

        private void showFavorites()

        {

            XmlDocument myXml = new XmlDocument();

            TreeNode link = new TreeNode("Links",0,0);

            link.NodeFont =new  Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

            favTreeView.Nodes.Add(link);

 

            if (File.Exists(favXml))

            {

                myXml.Load(favXml);

 

                foreach (XmlElement el in myXml.DocumentElement.ChildNodes)

                {

                    TreeNode node =

                        new TreeNode(el.InnerText,faviconIndex(el.GetAttribute("url")), faviconIndex(el.GetAttribute("url")));

                    node.ToolTipText = el.GetAttribute("url");

                    node.Name = el.GetAttribute("url");

                    node.ContextMenuStrip = favContextMenu;

                    favTreeView.Nodes.Add(node);

                }

 

            }

 

            if (File.Exists(linksXml))

            {

                myXml.Load(linksXml);

 

                foreach (XmlElement el in myXml.DocumentElement.ChildNodes)

                {

                    TreeNode node =

                        new TreeNode(el.InnerText, faviconIndex(el.GetAttribute("url")), faviconIndex(el.GetAttribute("url")));

                    node.ToolTipText = el.GetAttribute("url");

                    node.Name = el.GetAttribute("url");

                    node.ContextMenuStrip = linkContextMenu;

                    favTreeView.Nodes[0].Nodes.Add(node);

                }

 

            }

 

        }

//node click

        void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)

        {

            if (e.Button == MouseButtons.Right)

            {

                favTreeView.SelectedNode = e.Node;

                adress = e.Node.ToolTipText;

                name = e.Node.Text;

            }

            else

                if (e.Node != favTreeView.Nodes[0])

                    getCurrentBrowser().Navigate(e.Node.ToolTipText);

 

        }

//show history in tree wiew

        private void showHistory()

        {

            historyTreeView.Nodes.Clear();

            XmlDocument myXml = new XmlDocument();

 

            if (File.Exists(historyXml))

            {

                myXml.Load(historyXml);

                DateTime now=DateTime.Now;

                if (comboBox1.Text.Equals("Ordered Visited Today"))

                {

                    historyTreeView.ShowRootLines = false;

                    foreach (XmlElement el in myXml.DocumentElement.ChildNodes)

                    {

                         DateTime d=DateTime.Parse(el.GetAttribute("lastVisited"),currentCulture);

                       

                        if (!(d.Date==now.Date)) return;

 

                        TreeNode node =

                            new TreeNode(el.GetAttribute("url"), 3, 3);

                        node.ToolTipText = el.GetAttribute("url") + "\nLast Visited: " + el.GetAttribute("lastVisited") + "\nTimes Visited: " + el.GetAttribute("times");

                        node.Name = el.GetAttribute("url");

                        node.ContextMenuStrip = histContextMenu;

                        historyTreeView.Nodes.Add(node);

                    }

 

                }

              

           if (comboBox1.Text.Equals("View By Site"))

           {

              historyTreeView.ShowRootLines = true;

              foreach(XmlElement el in myXml.DocumentElement.ChildNodes)

              { Uri site=new Uri(el.GetAttribute("url"));

                 

                  if(!historyTreeView.Nodes.ContainsKey(site.Host.ToString()))

                      historyTreeView.Nodes.Add(site.Host.ToString(),site.Host.ToString(),0,0);

                   TreeNode node =new TreeNode(el.GetAttribute("url"), 3, 3);

                    node.ToolTipText = el.GetAttribute("url") + "\nLast Visited: " + el.GetAttribute("lastVisited") + "\nTimes Visited: " + el.GetAttribute("times");

                    node.Name = el.GetAttribute("url");

                    node.ContextMenuStrip = histContextMenu;

                    historyTreeView.Nodes[site.Host.ToString()].Nodes.Add(node);

               }

 

           }

 

           if (comboBox1.Text.Equals("View by Date"))

           { 

               historyTreeView.ShowRootLines = true;

               historyTreeView.Nodes.Add("2 Weeks Ago","2 Weeks Ago",2,2);

               historyTreeView.Nodes.Add("Last Week","Last Week",2,2);

               historyTreeView.Nodes.Add("This Week","This Week",2,2);

               historyTreeView.Nodes.Add("Yesterday","Yesterday",2,2);

               historyTreeView.Nodes.Add("Today","Today",2,2);

               foreach (XmlElement el in myXml.DocumentElement.ChildNodes)

               {

                  DateTime d=DateTime.Parse(el.GetAttribute("lastVisited"),currentCulture);

                 

                   TreeNode node = new TreeNode(el.GetAttribute("url"), 3, 3);

                   node.ToolTipText = el.GetAttribute("url") + "\nLast Visited: " + el.GetAttribute("lastVisited") + "\nTimes Visited: " + el.GetAttribute("times");

                   node.Name = el.GetAttribute("url");

                   node.ContextMenuStrip = histContextMenu;

 

                   if (d.Date==now.Date)

                       historyTreeView.Nodes[4].Nodes.Add(node);

                   else

                       if (d.AddDays(1).ToShortDateString().Equals(now.ToShortDateString()))

                           historyTreeView.Nodes[3].Nodes.Add(node);

                       else

                           if (d.AddDays(7) > now)

                               historyTreeView.Nodes[2].Nodes.Add(node);

                           else

                               if (d.AddDays(14) > now)

                                   historyTreeView.Nodes[1].Nodes.Add(node);

                               else

                                   if (d.AddDays(21) > now)

                                       historyTreeView.Nodes[0].Nodes.Add(node);

                                      else

                                       if (d.AddDays(22) > now)

                                           myXml.DocumentElement.RemoveChild(el);

               }

           }

         }

           

           

        }

//history nodes click

        private void historyTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)

        {

            if (e.Button == MouseButtons.Right)

            {

                historyTreeView.SelectedNode = e.Node;

                adress = e.Node.Text;

            }

            else

                if (!comboBox1.Text.Equals("Ordered Visited Today"))

                {

                    if (!historyTreeView.Nodes.Contains(e.Node))

                        getCurrentBrowser().Navigate(e.Node.Text);

                }

                else

                    getCurrentBrowser().Navigate(e.Node.Text);

        }

 

//fav panel visible change

        private void favoritesPanel_VisibleChanged(object sender, EventArgs e)

        {

            if (favoritesPanel.Visible == true)

            {

                showFavorites();

                showHistory();

            }

            else

            {

                favTreeView.Nodes.Clear();

                historyTreeView.Nodes.Clear();

            }

        }

 

        private void comboBox1_SelectedValueChanged(object sender, EventArgs e)

        {

            showHistory();

        }

 

        #endregion

 

        #region FAVORITS

        /*FAVORITES*/

 

        //add to favorits

        private void addToFavoritsToolStripMenuItem_Click(object sender, EventArgs e)

        {

            if (getCurrentBrowser().Url != null)

            {

                AddFavorites dlg = new AddFavorites(getCurrentBrowser().Url.ToString());

                DialogResult res = dlg.ShowDialog();

 

                if (res == DialogResult.OK)

                {

                    if (dlg.favFile == "Favorites")

                        addFavorit(getCurrentBrowser().Url.ToString(), dlg.favName);

                    else addLink(getCurrentBrowser().Url.ToString(), dlg.favName);

                }

                dlg.Close();

            }

        }

        //add to favorits bar

        private void addToFavoritsBarToolStripMenuItem_Click(object sender, EventArgs e)

        {

            addLink(getCurrentBrowser().Url.ToString(), getCurrentBrowser().Url.ToString());

        }

        //organize favorites

        private void organizeFavoritsToolStripMenuItem_Click(object sender, EventArgs e)

        {

            (new OrganizeFavorites(favTreeView, linkBar,linkContextMenu,favContextMenu)).ShowDialog();

        }

 

        //show favorites in menu

        private void favoritesToolStripMenuItem_DropDownOpening(object sender, EventArgs e)

        {

            XmlDocument myXml = new XmlDocument();

            myXml.Load(favXml);

 

            for (int i = favoritesToolStripMenuItem.DropDownItems.Count - 1; i > 5; i--)

            {

                favoritesToolStripMenuItem.DropDownItems.RemoveAt(i);

            }

            foreach (XmlElement el in myXml.DocumentElement.ChildNodes)

            {

                ToolStripMenuItem item = new ToolStripMenuItem(el.InnerText, getFavicon(el.GetAttribute("url")), fav_Click);

                item.ToolTipText = el.GetAttribute("url");

                favoritesToolStripMenuItem.DropDownItems.Add(item);

            }

        }

        //show links in menu

        private void linksMenuItem_DropDownOpening(object sender, EventArgs e)

        {

            XmlDocument myXml = new XmlDocument();

            myXml.Load(linksXml);

            linksMenuItem.DropDownItems.Clear();

            foreach (XmlElement el in myXml.DocumentElement.ChildNodes)

            {  

                ToolStripMenuItem item = new ToolStripMenuItem(el.InnerText,getFavicon(el.GetAttribute("url")), fav_Click);

                item.ToolTipText = el.GetAttribute("url");

                linksMenuItem.DropDownItems.Add(item);

            }

        }

        private void fav_Click(object sender, EventArgs e)

        {

            ToolStripMenuItem m = (ToolStripMenuItem)sender;

            getCurrentBrowser().Navigate(m.ToolTipText);

        }

        #endregion

 

        #region FILE

        /*FILE*/

 

        //new tab

        private void newTabToolStripMenuItem_Click(object sender, EventArgs e)

        {

            addNewTab();

        }

        //duplicate tab

        private void duplicateTabToolStripMenuItem_Click(object sender, EventArgs e)

        {

            if (getCurrentBrowser().Url != null)

            {

                Uri dup_url = getCurrentBrowser().Url;

                addNewTab();

                getCurrentBrowser().Url = dup_url;

 

            }

            else addNewTab();

        }

        //new window

        private void newWindowToolStripMenuItem_Click(object sender, EventArgs e)

        {

            (new WBrowser()).Show();

 

        }

        //close tab

        private void closeTabToolStripMenuItem_Click(object sender, EventArgs e)

        {

            closeTab();

        }

        //open

        private void openToolStripMenuItem_Click(object sender, EventArgs e)

        {

            (new Open(getCurrentBrowser())).Show();

        }

        //page setup

        private void pageSetupToolStripMenuItem_Click(object sender, EventArgs e)

        {

            getCurrentBrowser().ShowPageSetupDialog();

        }

        //save as

        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)

        {

            getCurrentBrowser().ShowSaveAsDialog();

        }

        //print

        private void printToolStripMenuItem_Click(object sender, EventArgs e)

        {

            getCurrentBrowser().ShowPrintDialog();

 

        }

        //print preview

        private void printPreviewToolStripMenuItem_Click(object sender, EventArgs e)

        {

            getCurrentBrowser().ShowPrintPreviewDialog();

        }

        //properties

        private void propertiesToolStripMenuItem_Click(object sender, EventArgs e)

        {

            getCurrentBrowser().ShowPropertiesDialog();

        }

        //send page by email

        private void pageByEmailToolStripMenuItem_Click(object sender, EventArgs e)

        {

            //getCurrentBrowser().Navigate("https://login.yahoo.com/config/login_verify2?&.src=ym");

            Process.Start("msimn.exe");

        }

        //send link by email

        private void linkByEmailToolStripMenuItem_Click(object sender, EventArgs e)

        {

           // getCurrentBrowser().Navigate("https://login.yahoo.com/config/login_verify2?&.src=ym");

            Process.Start("msimn.exe");

        }

 

 

        #endregion

 

        #region EDIT

        /*EDIT*/

        //cut

        private void cutToolStripMenuItem_Click(object sender, EventArgs e)

        {

            getCurrentBrowser().Document.ExecCommand("Cut", false, null);

 

        }

        //copy

        private void copyToolStripMenuItem_Click(object sender, EventArgs e)

Информация о работе Як отримати значок веб-сайту