/// <summary> /// 获取养肥区 /// </summary> void GetFatten() { List <Book> books = DataFetch.GetBooks(true); FattenArea.ItemsSource = null; FattenArea.ItemsSource = books; }
/// <summary> /// 养肥区更新 /// </summary> private void UpdateFatten() { Thread thread = new Thread(new ThreadStart(delegate { List <Book> books = DataFetch.GetBooks(true); foreach (Book book in books) { book.FattenNumber = DataFetch.GetListCount(book) - (int)book.Read; if (book.FattenNumber >= config.FattenNumber) { this.Dispatcher.Invoke(new Action(() => { new Tips("《" + book.Name + "》已经养肥,请尽情享用~").Show(); })); } } this.Dispatcher.Invoke(new Action(() => { if ((bool)BoolFertilizingArea.IsChecked) { FattenArea.ItemsSource = books; } })); })); thread.IsBackground = true; thread.Start(); }
/// <summary> /// 确定更换书源 /// </summary> private void SureSource_Click(object sender, RoutedEventArgs e) { //MessageBox.Show(((MenuItem)sender).Tag.ToString()); Book book = SourceChange.SelectedItem as Book; if (book != null && book is Book) { if (!DataFetch.UpdateBookSource(book)) { new Tips("更换失败~").Show(); } else { //更换书籍后,重新刷新全部书籍信息 //获取所有书籍 this.DataContext = DataFetch.GetBooks(); //启动时更新书籍 Update(); } //清空已有的部分数据 SourceChange.ItemsSource = null; SourceChange.Items.Clear(); buffer.Visibility = Visibility.Hidden; SourceChange.Visibility = Visibility.Collapsed; bookshelf.Visibility = Visibility.Visible; } }
/// <summary> /// 加入养肥区 /// </summary> private void ItemFatten_Click(object sender, RoutedEventArgs e) { int id = Convert.ToInt32(((MenuItem)sender).Tag); DataFetch.Add_MoveOut(id, true); //获取所有书籍 this.DataContext = DataFetch.GetBooks(); }
/// <summary> /// 关闭事件 /// </summary> private void BeforeClosing(object sender, EventArgs e) { if (mainWindow != null && !WindowsShow) { mainWindow.Visibility = Visibility.Visible; //获取所有书籍 mainWindow.DataContext = DataFetch.GetBooks(); } }
/// <summary> /// 删除书籍 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Delete_Click(object sender, RoutedEventArgs e) { //获取书籍ID int Id = Convert.ToInt32(((MenuItem)sender).Tag); Book book = DataFetch.GetBook(Id); if (MessageBox.Show("确定要删除《" + book.Name + "》? 本操作不可以逆转,请谨慎操作~", "提示", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.Yes) { DataFetch.DeleteBook(Id); this.DataContext = DataFetch.GetBooks(); } }
/// <summary> /// 移出养肥区 /// </summary> private void MoveOut_Click(object sender, RoutedEventArgs e) { Book book = FattenArea.SelectedItem as Book; if (book != null && book is Book) { DataFetch.Add_MoveOut((int)book.Id, false); //获取所有书籍 this.DataContext = DataFetch.GetBooks(); UpdateFatten(); } }
public MainWindow() { InitializeComponent(); string path = AppDomain.CurrentDomain.BaseDirectory; //this.Icon = BitmapFrame.Create(new Uri(path + "Resources/favicon.ico")); //获取配置项 config = ConfigReadWrite.GetConfig(); //添加书源 lb = DataFetch.GetBookSources(); //绑定书源 BookSourceName.ItemsSource = lb; BookSourceName.Text = config.SourceStation; //this.BookSourceName.SelectedIndex = 0; //获取所有书籍 this.DataContext = DataFetch.GetBooks(); //启动时更新书籍 Update(); //启动时更新养肥区 UpdateFatten(); //字体 Typeface.ItemsSource = Tool.GetTypeface(); Typeface.Text = config.Typeface; //绑定字体大小 TypefaceSize.ItemsSource = config.GetTypefaceSize; TypefaceSize.Text = config.FontSize.ToString(); //绑定主题 theme.ItemsSource = config.GetTheme; theme.Text = config.Theme; //绑定书源 SourceStation.ItemsSource = lb; SourceStation.Text = config.SourceStation; //禁用养肥区 fatten.IsEnabled = false; about.Text = "本软件只是娱乐之作,所有数据来源皆来自于网络,如果有侵犯到他人的权益,请于我进行联系,我会第一时间删除源站,谢谢合作!\n\n本软件默认有两个源:笔趣阁、追书网,用户可以自定义增加更多的源站,如果你有更好的源站,可以推荐给我,我会第一时间集成进去。\n\n本软件初始发布于吾爱破解,如果你在使用的过程中有发现BUG或者其他不合理的地方,请进行留言。本软件只作用于学习研究,请在下载内24小时内删除本软件。"; }
/// <summary> /// 加入书架 /// </summary> private void JoinBookshelves_Click(object sender, RoutedEventArgs e) { Book book = SearchList.SelectedItem as Book; if (book != null && book is Book) { if (DataFetch.BookAdd(book)) { new Tips("添加成功!").Show(); //获取所有书籍 this.DataContext = DataFetch.GetBooks(); } } }
/// <summary> /// 加入养肥区 /// </summary> private void ItemFatten_Click(object sender, RoutedEventArgs e) { int id = Convert.ToInt32(((MenuItem)sender).Tag); DataFetch.Add_MoveOut(id, true); //获取所有书籍 this.DataContext = DataFetch.GetBooks(); if (FertilizingArea.Visibility == Visibility.Visible) { //更新养肥区界面 GetFatten(); } }
/// <summary> /// 刷新数据 /// </summary> public void RefreshData() { //添加书源 lb = DataFetch.GetBookSources(); lb.Add(new BookSource { Id = -5, Title = "全部搜索" }); //绑定书源 BookSourceName.ItemsSource = lb; BookSourceName.Text = config.SourceStation; //获取所有书籍 this.DataContext = DataFetch.GetBooks(); //启动时更新书籍 Update(); //启动时更新养肥区 UpdateFatten(); }