Ejemplo n.º 1
0
        // 双击时打开默认文件
        private void listView1_DoubleClick(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count == 1)
            {
                BookAndUser bu = (BookAndUser)(listView1.SelectedItems[0].Tag);
                Book        b  = bu.Book;

                if (b.Files != null)
                {
                    FileViewer.OpenFile(b.File);
                }

                if (bu.UserBook == null)
                {
                    UserBooks ub = JianLiLinq.Default.CreateUserBook(b);
                    ub.BookReadCounts = 1;
                    JianLiLinq.Default.DB.SubmitChanges();
                }
                else
                {
                    bu.UserBook.BookReadCounts++;
                    db.SubmitChanges();
                }
            }
        }
Ejemplo n.º 2
0
        private void SetBooks(Book[] books)
        {
            this.listView1.Items.Clear();

            foreach (Book b in books)
            {
                ListViewItem i = new ListViewItem();
                i.Text = b.BookName;
                BookAndUser bu = new BookAndUser();
                bu.UserBook   = JianLiLinq.Default.GetUserBook(b);
                bu.Book       = b;
                i.Tag         = bu;
                i.ToolTipText = b.BookDesc;
                if (b.BookCover != null)
                {
                    Image bm = BookHelper.BookCoverConvert(b.BookCover);
                    imageList1.Images.Add(bm);
                    i.ImageIndex = imageList1.Images.Count - 1;
                }
                else
                {
                    i.ImageIndex = 0;
                }
                this.listView1.Items.Add(i);
            }
        }
Ejemplo n.º 3
0
        private void BookEditMenuItem_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 1 || listView1.SelectedItems.Count == 0)
            {
                return;
            }

            BookAndUser  bu = (BookAndUser)this.listView1.SelectedItems[0].Tag;
            BookEditForm f  = new BookEditForm();

            BookEditPresent p = new BookEditPresent(bu.UserBook, f);

            f.ShowDialog();

            listView1.SelectedItems[0].ToolTipText = bu.UserBook.Book.BookDesc;
        }
Ejemplo n.º 4
0
        private void ShowKeywordBook(Keywords keywords)
        {
            listView1.Items.Clear();
            // 选出所有的书
            var bs = from bk in keywords.BookKeywords
                     select bk.Book;

            Image image = imageList1.Images[0];

            imageList1.Images.Clear();
            imageList1.Images.Add(image);

            foreach (Book b in bs)
            {
                // 加入用户与书相关的数据
                BookAndUser bu = new BookAndUser();
                bu.Book     = b;
                bu.UserBook = JianLiLinq.Default.GetUserBook(b);

                // 配置ListViewItem
                ListViewItem i = new ListViewItem();
                i.Text = b.BookName;
                i.Tag  = bu;
                string names = "";
                foreach (User u in JianLiLinq.Default.GetBookContributors(b))
                {
                    names = names + u.UserName + "  ";
                }
                i.ToolTipText = "贡献者:" + names + Environment.NewLine + "简介:" + b.BookDesc;
                if (b.BookCover != null)
                {
                    Image bm = Common2.GetBookThumbnailImage(b);
                    imageList1.Images.Add(bm);
                    i.ImageIndex = imageList1.Images.Count - 1;
                }
                else
                {
                    i.ImageIndex = 0;
                }
                //
                this.listView1.Items.Add(i);
            }
            curkeywords = keywords;
        }
Ejemplo n.º 5
0
        private List <BookAndUser> GetSelectedUserBookInfos()
        {
            if (listView1.SelectedItems.Count == 0)
            {
                return(null);
            }

            List <BookAndUser> ubooks = new List <BookAndUser>();

            foreach (ListViewItem item in listView1.SelectedItems)
            {
                BookAndUser ubook = item.Tag as BookAndUser;
                if (ubook != null)
                {
                    ubooks.Add(ubook);
                }
            }
            return(ubooks);
        }
Ejemplo n.º 6
0
        private void PopulateMenu()
        {
            this.VersionsMenuItem.Visible = false;
            this.VersionsMenuItem.DropDownItems.Clear();

            if (this.listView1.SelectedItems.Count != 1)
            {
                return;
            }
            BookAndUser bu = (BookAndUser)this.listView1.SelectedItems[0].Tag;

            JianLi3Data.File[] fs = JianLiLinq.Default.GetBookFiles(bu.Book);

            LoveMenuItem.Checked      = false;
            LikeMenuItem.Checked      = false;
            RegularMenuItem.Checked   = false;
            NoFeelingMenuItem.Checked = false;
            HateMenuItem.Checked      = false;

            if (bu.UserBook != null)
            {
                ShowUserBookRate(bu.UserBook.BookRate);
            }

            if (fs.Count() == 1)
            {
                return;
            }
            else
            {
                this.VersionsMenuItem.Visible = true;
            }

            foreach (JianLi3Data.File f in fs)
            {
                ToolStripMenuItem item = new ToolStripMenuItem();
                item.Tag    = f;
                item.Text   = f.FileVersion;
                item.Click += new EventHandler(item_Click);
                this.VersionsMenuItem.DropDownItems.Add(item);
            }
        }
Ejemplo n.º 7
0
        private void SetSelectedBookRate(BookRateEnum rate)
        {
            if (this.listView1.SelectedItems.Count != 1)
            {
                return;
            }
            BookAndUser bu = this.listView1.SelectedItems[0].Tag as BookAndUser;

            if (bu.UserBook == null)
            {
                bu.UserBook = JianLiLinq.Default.GetUserBook(bu.Book);
                if (bu.UserBook == null)
                {
                    bu.UserBook = JianLiLinq.Default.CreateUserBook(bu.Book);
                }
            }

            bu.UserBook.BookRate = BookHelper.BookRateConvert(rate);
            JianLiLinq.Default.DB.SubmitChanges();
        }
Ejemplo n.º 8
0
        private void UpdateBookCoverView(int idx)
        {
            if (listView1.Items.Count < idx)
            {
                return;
            }

            BookAndUser b = listView1.Items[idx].Tag as BookAndUser;

            if (b == null)
            {
                return;
            }
            if (b.Book.BookCover == null)
            {
                return;
            }

            Image bm = BookHelper.BookCoverConvert(b.Book.BookCover);

            imageList1.Images.Add(bm);
            this.listView1.Items[idx].ImageIndex = imageList1.Images.Count - 1;
        }
Ejemplo n.º 9
0
        // when mouse down, populate menu
        private void listView1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                // type
                IsBookMenuItem.Checked    = false;
                IsPaperMenuItem.Checked   = false;
                IsDocMenuItem.Checked     = false;
                IsUncheckMenuItem.Checked = false;
                // rate
                LoveMenuItem.Checked               = false;
                LikeMenuItem.Checked               = false;
                regularToolStripMenuItem.Checked   = false;
                noFeelingToolStripMenuItem.Checked = false;
                HateMenuItem1.Checked              = false;
                notRateToolStripMenuItem.Checked   = false;
                ClipboardCopyMenuItem.Visible      = Clipboard.ContainsImage();

                if (this.listView1.SelectedItems.Count == 0)
                {
                    return;
                }
                else if (this.listView1.SelectedItems.Count == 1)
                {
                    BookAndUser ubook = this.listView1.SelectedItems[0].Tag as BookAndUser;

                    if (ubook == null)
                    {
                        return;
                    }
                    Book book = ubook.Book;

                    // book type
                    BookTypeEnum btype = BookHelper.GetBookType(book);

                    switch (btype)
                    {
                    case BookTypeEnum.Book:
                        IsBookMenuItem.Checked = true;
                        break;

                    case BookTypeEnum.Paper:
                        IsPaperMenuItem.Checked = true;
                        break;

                    case BookTypeEnum.Doc:
                        IsDocMenuItem.Checked = true;
                        break;

                    case BookTypeEnum.Uncheck:
                        IsUncheckMenuItem.Checked = true;
                        break;

                    default:
                        IsUncheckMenuItem.Checked = true;
                        break;
                    }

                    UserBooks ubinfo = ubook.UserBook;
                    if (ubinfo == null)
                    {
                        notRateToolStripMenuItem.Checked = true;
                        return;
                    }
                    // book rate
                    BookRateEnum rate = BookHelper.BookRateConvert(ubinfo.BookRate);
                    switch (rate)
                    {
                    case BookRateEnum.Love:
                        LoveMenuItem.Checked = true;
                        break;

                    case BookRateEnum.Like:
                        LikeMenuItem.Checked = true;
                        break;

                    case BookRateEnum.Regular:
                        regularToolStripMenuItem.Checked = true;
                        break;

                    case BookRateEnum.NoFeeling:
                        noFeelingToolStripMenuItem.Checked = true;
                        break;

                    case BookRateEnum.NotLike:
                        HateMenuItem1.Checked = true;
                        break;

                    default:
                        notRateToolStripMenuItem.Checked = true;
                        break;
                    }
                }
                else
                {
                    foreach (ListViewItem item in this.listView1.SelectedItems)
                    {
                    }
                }
            }
        }