Chinaunix首页 | 论坛 | 博客
  • 博客访问: 957046
  • 博文数量: 210
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2070
  • 用 户 组: 普通用户
  • 注册时间: 2014-11-19 21:54
文章分类

全部博文(210)

文章存档

2020年(2)

2019年(18)

2018年(27)

2017年(5)

2016年(53)

2015年(88)

2014年(17)

分类: C/C++

2015-11-25 13:48:52


点击(此处)折叠或打开

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;

  5. namespace HJReader
  6. {
  7.     class HJBook
  8.     {
  9.         /*
  10.         书的名字
  11.      书的作者
  12.      书的简介
  13.      书的章节 (可适应多个章节)
  14.      书签(也就是当前读到的位置)
  15.      书的所在的目录
  16.          * */
  17.         public String BookName; // 书的名字
  18.         public String Author; // 书的作者
  19.         public int PagesOfBook; // 这本书有多少页
  20.         public int BookMark; //书签,这本书读到哪里了
  21.         String DirectoryOfBook; //这本书在哪个目录下
  22.         public HJBook(
  23.             String InputName,
  24.             String InputAuthor,
  25.             int Pages,
  26.             int Mark,
  27.             String dir)
  28.         {
  29.             BookName = InputName;
  30.             Author = InputAuthor;
  31.             PagesOfBook = Pages;
  32.             BookMark = Mark;
  33.             DirectoryOfBook = dir;
  34.         }
  35.         public String SetBookName(String inputBookName)
  36.         {
  37.             if (inputBookName!=null)
  38.                 BookName = inputBookName;
  39.             return BookName;
  40.         }
  41.         public String GetBookName()
  42.         {
  43.             return BookName;
  44.         }

  45.         public String SetAuthor(String inputAuthor)
  46.         {
  47.             if (inputAuthor != null)
  48.                 Author = inputAuthor;
  49.             return Author;
  50.         }
  51.         public String GetAuthor()
  52.         {
  53.             return Author;
  54.         }
  55.         public int GetPageNumberOfBook()
  56.         {
  57.             return BookMark;
  58.         }
  59.         public int GotoNextPage()
  60.         {
  61.             BookMark++;
  62.             if (BookMark > PagesOfBook)
  63.                 BookMark = PagesOfBook;
  64.             return BookMark;
  65.         }
  66.         public int GotoPrevPage()
  67.         {
  68.             BookMark--;
  69.             if (BookMark <= 0)
  70.                 BookMark = 1;
  71.             return BookMark;
  72.         }
  73.         public int GotoFirstPage()
  74.         {
  75.             BookMark = 1;
  76.             return BookMark;
  77.         }
  78.         public int GotoLastPage()
  79.         {
  80.             BookMark = PagesOfBook;
  81.             return BookMark;
  82.         }
  83.         // 翻到书的任意一页,输入一个整数,返回一个整数。
  84.         public int GotoAnypage(int PageNumber)
  85.         {
  86.             if (PageNumber <= 0)
  87.                 BookMark = 1;
  88.             else if (PageNumber >= PagesOfBook)
  89.                 BookMark = PagesOfBook;
  90.             else
  91.                 BookMark = PageNumber;
  92.             return BookMark;
  93.         }

  94.         public Uri GetCurrentUri()
  95.         {
  96.               Uri BookPageUrl = new Uri(
  97.                     "file:///D:/c-sharp/HJReader/HJReader/bin/Debug/"
  98.                       + BookMark.ToString() + ".html");
  99.               return BookPageUrl;
  100.         }
  101.     }
  102. }


点击(此处)折叠或打开

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;

  9. namespace HJReader
  10. {
  11.     public partial class HJReader : Form
  12.     {
  13.         HJBook CurrentBook;
  14.         int index = 1;
  15.         public HJReader()
  16.         {
  17.             InitializeComponent();
  18.             CurrentBook = new HJBook(
  19.                 "射雕英雄传",
  20.                 "金庸",
  21.                 12,
  22.                 1,
  23.                 "."
  24.                 );
  25.             LabelBookName.Text = CurrentBook.Author + ":" + CurrentBook.BookName;

  26.             ReaderWeb.Url = new Uri("file:///D:/c-sharp/HJReader/HJReader/bin/Debug/1.html");
  27.            // ReaderWeb.Url = new Uri("");
  28.         }

  29.         private void ExitButton_Click(object sender, EventArgs e)
  30.         {
  31.             MessageBox.Show("即将退出程序");
  32.             this.Close();
  33.         }

  34.         private void NextPage_Click(object sender, EventArgs e)
  35.         {
  36.            
  37.             index = CurrentBook.GotoNextPage();
  38.             
  39.             PageLabel.Text = "当前页是:第" +
  40.                 CurrentBook.BookMark.ToString() + "页";
  41.             this.Text = LabelBookName.Text + "----" + PageLabel.Text;
  42.             ReaderWeb.Url = CurrentBook.GetCurrentUri();
  43.         }

  44.         private void PrevPage_Click(object sender, EventArgs e)
  45.         {
  46.             
  47.             index = CurrentBook.GotoPrevPage();
  48.            
  49.             PageLabel.Text = "当前页是:第" +
  50.                 CurrentBook.BookMark.ToString() + "页";
  51.             this.Text = LabelBookName.Text + "----" + PageLabel.Text;
  52.             ReaderWeb.Url = CurrentBook.GetCurrentUri();
  53.         }

  54.         private void SkipButton_Click(object sender, EventArgs e)
  55.         {
  56.             
  57.             index = CurrentBook.GotoAnypage(int.Parse(SelectPage.Text));
  58.             
  59.             PageLabel.Text = "当前页是:第" +
  60.                index.ToString() + "页";
  61.             this.Text = LabelBookName.Text + "----" + PageLabel.Text;
  62.             ReaderWeb.Url = CurrentBook.GetCurrentUri();
  63.         }

  64.        

  65.        
  66.     }
  67. }

阅读(1835) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~