Exemple #1
0
        private TreeNode CreateNodeFromBookData(Book b)
        {
            TreeNode node = new TreeNode(b.Title);
            (node.Nodes.Add("ID: " + b.BookID) as TreeNode).Tag = "ID";
            (node.Nodes.Add("Author: " + b.Author) as TreeNode).Tag = "Author";
            (node.Nodes.Add("Pages: " + b.Pages) as TreeNode).Tag = "Pages";
            (node.Nodes.Add("Publication Date: " + b.PublishedDate.ToShortDateString()) as TreeNode).Tag = "PublicationDate";
            (node.Nodes.Add("Category: " + b.Category) as TreeNode).Tag = "Category";

            if (!b.IsDirectory)
                (node.Nodes.Add("FileName: " + b.FileName) as TreeNode).Tag = "FileName";

            if (b.IsDirectory)
            {
                (node.Nodes.Add("Directory: " + b.DirectoryName) as TreeNode).Tag = "Directory";
                TreeNode node2 = new TreeNode("Files");
                foreach (string file in b.Files)
                {
                    node2.Nodes.Add(file);

                }
                node.Nodes.Add(node2);

            }

            return node;
        }
Exemple #2
0
        private void testpropgrid_Load(object sender, EventArgs e)
        {
            //propgridobject obj = new propgridobject();
            //obj.Name = "usman";
            //obj.Property1 = "prop1";
            //obj.Title = "title";
            //obj.Property2 = "prop2";
            //obj.Property3 = proptype.Ten;

            //propertyGrid1.SelectedObject = obj;

            Book b = new Book();
            propertyGrid1.SelectedObject = b;
        }
Exemple #3
0
        private void _removeBookFromTreeView(Book book)
        {
            foreach (TreeNode node in _findNodeFromID(book.BookID))
                tvBooks.Nodes.Remove(node);

            //TreeNode node = _findNodeFromID(book.BookID);
            //tvBooks.Nodes.Remove(node);
        }
Exemple #4
0
 private void _appendBookToTreeView(Book book)
 {
     this.tvBooks.Nodes.Add(CreateNodeFromBookData(book));
 }
Exemple #5
0
        public void LoadBookListFromFile(string filename)
        {
            if (!BookListExists(filename))
            {
                CreateNewBookListFile(filename);

            }
            XmlDocument doc = new XmlDocument();
            doc.Load(filename);
            XmlNodeList nodelist = doc.GetElementsByTagName("Books");
            foreach (XmlNode node in nodelist)
            {
                XmlNodeList books = node.ChildNodes;
                foreach (XmlNode book in books)
                {

                    Book b = new Book();

                    XmlNode temp;

                    temp = book.SelectSingleNode("Title");
                    if (temp != null) b.Title = temp.InnerText;

                    temp = book.SelectSingleNode("Author");
                    if (temp != null) b.Author = temp.InnerText;

                    temp = book.SelectSingleNode("Category");
                    if (temp != null) b.Category = temp.InnerText;

                    temp = book.SelectSingleNode("Pages");
                    if (temp != null) b.Pages = Convert.ToInt32(temp.InnerText);

                    temp = book.SelectSingleNode("PublishedDate");
                    if (temp != null) b.PublishedDate = temp.InnerText;

                    temp = book.SelectSingleNode("FileName");
                    if (temp != null) b.FileName = _canonicalizePath(temp.InnerText, _pathType.File);

                    temp = book.SelectSingleNode("Directory");
                    if (temp != null)
                    {
                        b.DirectoryName = _canonicalizePath(temp.InnerText, _pathType.Directory);
                        b.IsDirectory = true;
                    }

                    _bookList.Add(b);

                }

            }

            foreach (Book b in _bookList)
            {
                if (b.IsDirectory == true)
                {
                    //_bookMap.Add(Path.GetDirectoryName(b.DirectoryName.ToLower()), b);
                    _bookMap.Add(_canonicalizePath(b.DirectoryName, _pathType.Directory), b);

                }
                else
                {
                    //_bookMap.Add(b.FileName.ToLower(), b);]
                    _bookMap.Add(_canonicalizePath(b.FileName, _pathType.File), b);

                }

            }
        }
Exemple #6
0
 public void AddBook(string title, string author, DateTime publishedDate, int pages, string category, string filename, string dirname, bool isdirectory, string[] filelist)
 {
     Book b = new Book();
     b.Title = title;
     b.Author = author;
     b.Category = category;
     b.Pages = pages;
     b.PublishedDate = publishedDate;
     b.FileName = filename;
     b.DirectoryName = dirname;
     b.IsDirectory = isdirectory;
     b.Files = filelist;
     this.AddBook(b);
 }
Exemple #7
0
 public BookManagerChangeEventArgs(Book b)
 {
     _book = b;
 }
Exemple #8
0
 private void _removeBookFromMap(Book book)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Exemple #9
0
 private void _addBookToMap(Book book)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Exemple #10
0
 public void AddBook(Book b)
 {
     BookAdded(this, new BookManagerChangeEventArgs(coll.AddBook(b)));
 }
Exemple #11
0
 public CollectionChangeEventArgs(Book b)
 {
     _book = b;
 }
Exemple #12
0
 public Book AddBook(Book b)
 {
     _books.Add(b);
     this.BookAdded(this, new CollectionChangeEventArgs(b));
     return b;
 }