コード例 #1
0
ファイル: GUI.cs プロジェクト: Gokimster/WebBrowser
 //dynamically add an item to the favourites drop down menu given a Favourite
 public void addFavToMenu(Favourite f)
 {
     ContainerControl cc = new ContainerControl();
     cc.BackColor = Color.WhiteSmoke;
     ToolStripControlHost c = new ToolStripControlHost(cc);
     Button b = new Button();
     b.Parent = cc;
     initRemoveFavButton(b);
     b.Click += (s, e) => { favMenu.DropDownItems.Remove(c);favs.removeFavourite(f); };
     TextBox temp = new TextBox();
     temp.Text = f.name;
     temp.Click += (s, e) => { initNewTab(f.url); };
     temp.Parent = cc;
     temp.Left = b.Size.Width;
     temp.Left = (int)Math.Floor((float)temp.Left * 1.3f);
     initFavBox(temp);
     Button t = new Button();
     t.Text = f.url;
     t.Parent = cc;
     initMenuButton(t);
     t.Top = temp.Height>b.Height?temp.Height :b.Height;
     t.Top = (int)Math.Floor((float)t.Top * 1.1f);
     t.Left = temp.Left;
     t.Enabled = false;
     Button eb = new Button();
     eb.Parent = cc;
     eb.Left = temp.Left + temp.Size.Width;
     eb.Click += (s, e) => editButtonClick(temp, eb, f);
     initEditButton(eb);
     favMenu.DropDownItems.Add(c);
 }
コード例 #2
0
ファイル: GUI.cs プロジェクト: Gokimster/WebBrowser
 //make favourite name editable and change the button to a confirm button
 private void editButtonClick(TextBox temp, Button eb, Favourite f)
 {
     temp.ReadOnly = false;
     eb.Text       = "S";
     eb.ForeColor  = Color.Green;
     eb.Click     += (s, e) => confirmEditClick(temp, eb, f);
 }
コード例 #3
0
ファイル: GUI.cs プロジェクト: Gokimster/WebBrowser
 //save changes to favourite name and change the button back to the edit button
 private void confirmEditClick(TextBox temp, Button eb, Favourite f)
 {
     temp.ReadOnly = true;
     eb.Text       = "E";
     eb.ForeColor  = Color.Blue;
     favs.changeFavName(f, temp.Text);
     eb.Click += (s, e) => editButtonClick(temp, eb, f);
 }
コード例 #4
0
ファイル: Favourites.cs プロジェクト: Gokimster/WebBrowser
 //----------------------------------------//
 //----------Methods-----------------------//
 //----------------------------------------//
 //creates a new favourite given a url and a name and adds it to the dictionary and to file
 public void addFavourite(string url, string name)
 {
     //using a random int as the key because we are also using this as an id in the xml file
     Random rnd = new Random();
     int i;
     do {
         i = rnd.Next();
     } while (favs.ContainsKey(i));
     Favourite temp = new Favourite(url, name);
     favs.Add(i, temp);
     addFavToFile(i, temp);
 }
コード例 #5
0
ファイル: Favourites.cs プロジェクト: Gokimster/WebBrowser
 //remove a favourite from the lists and from file
 public void removeFavourite(Favourite f)
 {
     foreach(var fav in favs.Where(kvp => kvp.Value.Equals(f)).ToList())
     {
         favs.Remove(fav.Key);
         var favourites = from el in xmlElem.Elements("Favourite")
                         where (int)el.Element("Id") == fav.Key
                         select el;
         foreach(XElement xel in favourites)
         {
             xel.Remove();
         }
     }
     xmlElem.Save(fileName);
 }
コード例 #6
0
ファイル: Favourites.cs プロジェクト: Gokimster/WebBrowser
 //change a favourites name to a given name in the dictionary and in file
 public void changeFavName(Favourite f, string name)
 {
     foreach (var fav in favs.Where(kvp => kvp.Value.Equals(f)).ToList())
     {
         fav.Value.name = name;
         var favourites = from el in xmlElem.Elements("Favourite")
                          where (int)el.Element("Id") == fav.Key
                          select el;
         foreach (XElement xel in favourites)
         {
             xel.SetElementValue("Name", name);
         }
     }
     xmlElem.Save(fileName);
 }
コード例 #7
0
ファイル: Favourites.cs プロジェクト: Gokimster/WebBrowser
 //change a favourites name to a given name in the dictionary and in file
 public void changeFavName(Favourite f, string name)
 {
     foreach (var fav in favs.Where(kvp => kvp.Value.Equals(f)).ToList())
     {
         fav.Value.name = name;
         var favourites = from el in xmlElem.Elements("Favourite")
                          where (int)el.Element("Id") == fav.Key
                          select el;
         foreach (XElement xel in favourites)
         {
             xel.SetElementValue("Name", name);
         }
     }
     xmlElem.Save(fileName);
 }
コード例 #8
0
ファイル: Favourites.cs プロジェクト: Gokimster/WebBrowser
 //remove a favourite from the lists and from file
 public void removeFavourite(Favourite f)
 {
     foreach (var fav in favs.Where(kvp => kvp.Value.Equals(f)).ToList())
     {
         favs.Remove(fav.Key);
         var favourites = from el in xmlElem.Elements("Favourite")
                          where (int)el.Element("Id") == fav.Key
                          select el;
         foreach (XElement xel in favourites)
         {
             xel.Remove();
         }
     }
     xmlElem.Save(fileName);
 }
コード例 #9
0
ファイル: Favourites.cs プロジェクト: Gokimster/WebBrowser
        //----------------------------------------//
        //----------Methods-----------------------//
        //----------------------------------------//

        //creates a new favourite given a url and a name and adds it to the dictionary and to file
        public void addFavourite(string url, string name)
        {
            //using a random int as the key because we are also using this as an id in the xml file
            Random rnd = new Random();
            int    i;

            do
            {
                i = rnd.Next();
            } while (favs.ContainsKey(i));
            Favourite temp = new Favourite(url, name);

            favs.Add(i, temp);
            addFavToFile(i, temp);
        }
コード例 #10
0
ファイル: GUI.cs プロジェクト: Gokimster/WebBrowser
        //dynamically add an item to the favourites drop down menu given a Favourite
        public void addFavToMenu(Favourite f)
        {
            ContainerControl cc = new ContainerControl();

            cc.BackColor = Color.WhiteSmoke;
            ToolStripControlHost c = new ToolStripControlHost(cc);
            Button b = new Button();

            b.Parent = cc;
            initRemoveFavButton(b);
            b.Click += (s, e) => { favMenu.DropDownItems.Remove(c); favs.removeFavourite(f); };
            TextBox temp = new TextBox();

            temp.Text   = f.name;
            temp.Click += (s, e) => { initNewTab(f.url); };
            temp.Parent = cc;
            temp.Left   = b.Size.Width;
            temp.Left   = (int)Math.Floor((float)temp.Left * 1.3f);
            initFavBox(temp);
            Button t = new Button();

            t.Text   = f.url;
            t.Parent = cc;
            initMenuButton(t);
            t.Top     = temp.Height > b.Height?temp.Height :b.Height;
            t.Top     = (int)Math.Floor((float)t.Top * 1.1f);
            t.Left    = temp.Left;
            t.Enabled = false;
            Button eb = new Button();

            eb.Parent = cc;
            eb.Left   = temp.Left + temp.Size.Width;
            eb.Click += (s, e) => editButtonClick(temp, eb, f);
            initEditButton(eb);
            favMenu.DropDownItems.Add(c);
        }
コード例 #11
0
 //add a favourite page to the favourites menu
 private void addFavToMenu(Favourite f)
 {
     ((GUI)this.ParentForm).addFavToMenu(f);
 }
コード例 #12
0
ファイル: Favourites.cs プロジェクト: Gokimster/WebBrowser
 //add a new favourite to file with a given id
 private void addFavToFile(int id, Favourite f)
 {
     xmlElem.Add(new XElement("Favourite", new XElement("Id", id), new XElement("Url", f.url), new XElement("Name", f.name)));
     xmlElem.Save(fileName);
 }
コード例 #13
0
ファイル: Favourites.cs プロジェクト: Gokimster/WebBrowser
 //add a new favourite to file with a given id
 private void addFavToFile(int id, Favourite f)
 {
     xmlElem.Add(new XElement("Favourite", new XElement("Id", id), new XElement("Url", f.url), new XElement("Name", f.name)));
     xmlElem.Save(fileName);
 }
コード例 #14
0
ファイル: WebTab.cs プロジェクト: Gokimster/WebBrowser
 //add a favourite page to the favourites menu
 private void addFavToMenu(Favourite f)
 {
     ((GUI)this.ParentForm).addFavToMenu(f);
 }
コード例 #15
0
ファイル: GUI.cs プロジェクト: Gokimster/WebBrowser
 //make favourite name editable and change the button to a confirm button
 private void editButtonClick(TextBox temp, Button eb, Favourite f)
 {
     temp.ReadOnly = false;
     eb.Text = "S";
     eb.ForeColor = Color.Green;
     eb.Click += (s, e) => confirmEditClick(temp, eb, f);
 }
コード例 #16
0
ファイル: GUI.cs プロジェクト: Gokimster/WebBrowser
 //save changes to favourite name and change the button back to the edit button
 private void confirmEditClick(TextBox temp, Button eb, Favourite f)
 {
     temp.ReadOnly = true;
     eb.Text = "E";
     eb.ForeColor = Color.Blue;
     favs.changeFavName(f, temp.Text);
     eb.Click += (s, e) => editButtonClick(temp, eb, f);
 }