// Show page fro the position public void LoadScene() { BookSource Cache = DataContext as BookSource; Handler = Cache.GetCurrentHandler(); PreparePage(); }
public async void add_Book(object sender, ItemClickEventArgs e) { var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; String uniqueId = "book" + localSettings.Values["bookCount"].ToString(); PhotoItem selImage = (PhotoItem)e.ClickedItem; String imageName = selImage.Name; StorageFolder imageFolder = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFolderAsync(selImage.Loc.Replace("/", "\\")); StorageFile storageFile = await imageFolder.GetFileAsync(imageName); imageFolder = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFolderAsync("thumbs"); await storageFile.CopyAsync(imageFolder, uniqueId + ".jpg"); var books = new Book(compositelocal["uniqueid"].ToString(), compositelocal["title"].ToString(), compositelocal["author"].ToString(), compositelocal["image"].ToString(), compositelocal["location"].ToString()); BookSource.AddBookAsync(books); if (localSettings.Containers.ContainsKey("booksContainer")) { localSettings.Containers["booksContainer"].Values[uniqueId] = compositelocal; int count = (int)localSettings.Values["bookCount"]; localSettings.Values["bookCount"] = ++count; } //this.Add.IsEnabled = true; this.imageGrid.Visibility = Windows.UI.Xaml.Visibility.Collapsed; this.imageGridViewText.Text = ""; BookPhotos.Photos.Clear(); //this.pbar.IsIndeterminate = false; storageFile = null; }
/// <summary> /// 更新书源 /// </summary> /// <param name="bookSource"></param> /// <returns></returns> public static bool SourceUpdate(BookSource bookSource) { string sql = "update BookSource set 'Title'='" + bookSource.Title + "','Url'='" + bookSource.Url + "','SearchUrl'='" + bookSource.SearchUrl + "','AddressRangeRegular'='" + bookSource.AddressRangeRegular + "','AddressCuttingRegular'='" + bookSource.AddressCuttingRegular + "','AddressRegular'='" + bookSource.AddressRegular + "','BookNameRegular'='" + bookSource.BookNameRegular + "','AuthorRegular'='" + bookSource.AuthorRegular + "','UpdateRegular'='" + bookSource.UpdateRegular + "','NewestRegular'='" + bookSource.NewestRegular + "','DetailsRegular'='" + bookSource.DetailsRegular + "','StateRegular'='" + bookSource.StateRegular + "','DirectoryScopeRegular'='" + bookSource.DirectoryScopeRegular + "','DirectoryCuttingRegular'='" + bookSource.DirectoryCuttingRegular + "','DirectoryTieleRegular'='" + bookSource.DirectoryTieleRegular + "','DirectoryUrlRegular'='" + bookSource.DirectoryUrlRegular + "','ContentTitleRegular'='" + bookSource.ContentTitleRegular + "','ContentRegular'='" + bookSource.ContentRegular + "','ImageRegular'='" + bookSource.ImageRegular + "' where Id=" + bookSource.Id; //TempData.UpdateBookSourceS(); return((SQLiteDBHelper.ExecuteNonQuery(sql, null) <= 0) ? false : true); }
public void AddNewSource_NewSourceToBeAdded_ReturnOneMoreToBeCount() { // Arrange var service = new BookSourceService(); var totalBeforeAdd = service.Count(); // Act var model = new BookSource(); model.Description = "Test"; var result = service.AddNewBookSourcesValidation(model); var totalAfterAdded = service.Count(); bool validation; // Assert if (result == true) { if (totalBeforeAdd < totalAfterAdded) { validation = true; } else { validation = false; } } else { validation = false; } Assert.IsTrue(validation); }
/// <summary> /// 导出书源 /// </summary> private void Export_Click(object sender, RoutedEventArgs e) { try { BookSource bookSource = ListSource.SelectedItem as BookSource; if (bookSource != null && bookSource is BookSource) { Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = bookSource.Title; dlg.DefaultExt = ".json"; // Default file extension dlg.Filter = "BookSource (.json)|*.json"; // Filter files by extension // Show save file dialog box Nullable <bool> result = dlg.ShowDialog(); // Process save file dialog box results if (result == true) { // Save document string filename = dlg.FileName; using (StreamWriter sw = new StreamWriter(filename)) { sw.Write(JsonHelper.SerializeObject(bookSource)); } } } } catch (Exception ex) { new Tips(ex.Message).Show(); } }
public void Load(CharacterContent input) { Females = new List <CharacterContent>(); Males = new List <CharacterContent>(); Character = input; // find possible mothers and fathers BookSource s = DataContext as BookSource; foreach (CharacterContent c in s.Characters) { if (c == input) { continue; } if (c.Gender == CharacterGender.Male) { Males.Add(c); } else { Females.Add(c); } } Males.Add(s.DummyCharacter); Females.Add(s.DummyCharacter); x_episodesHolder.Children.Clear(); foreach (CharacterEpisodes ep in Character.Info) { x_episodesHolder.Children.Add(CreateExpander(ep)); } // notify all NotifyPropertyChanged("Males"); NotifyPropertyChanged("Females"); NotifyPropertyChanged("Character"); }
/// <summary> /// 获取书籍目录 /// </summary> /// <param name="book"></param> public static void GetList(Book book) { BookSource bs = GetBookSource(book.Source); Dictionary <string, string> NewList = new Dictionary <string, string>(); //范围 string temp_str = Tool.GetRegexStr(GetHtml.GetHttpWebRequest(book.Url), bs.DirectoryScopeRegular); //分割 string [] temp_strs = temp_str.Split(new string[] { bs.DirectoryCuttingRegular }, StringSplitOptions.RemoveEmptyEntries); foreach (string tempStr in temp_strs) { string Title = Tool.GetRegexStr(tempStr, bs.DirectoryTieleRegular); string Url = Tool.ObtainUrl(bs.Url, Tool.GetRegexStr(tempStr, bs.DirectoryUrlRegular), book.Url); //如果标题相同就会报错,所以这里回家进行简单的处理 if (!NewList.ContainsKey(Title) && Title.Trim().Length > 2) { NewList.Add(Title, Url); } /* 这里加上后会重复显示 * else * { * NewList.Add(Title + Guid.NewGuid(), Url); * }*/ } book.ListUrl = NewList; }
/// <summary> /// 更新全部书籍 /// </summary> public static void BooksUpdate(object ob) { //获取全部书籍 DataTable dt = SQLiteDBHelper.ExecuteDataTable("select *from Books", null); List <Book> Books = ModelConvertHelper <Book> .DataTableToList(dt); foreach (Book book in Books) { //获取初始搜索文本 string html = GetHtml.GetHttpWebRequest(book.Url); BookSource bs = GetBookSource(book.Source); //检测书源有效性 if (bs.Title is null) { Tips tips = new Tips(book.Name + "的书源不存在,请检查书源是否已经被删除掉?"); tips.Show(); return; } //获取最新章节 string LatestChapters = Tool.GetRegexStr(html, bs.NewestRegular).Trim(); //获取更新时间 string Update = Tool.GetRegexStr(html, bs.UpdateRegular).Trim(); SQLiteDBHelper.ExecuteNonQuery("Update Books set 'Newest' = '" + LatestChapters + "', 'Update' = '" + Tool.GetUpdataDate(Update) + "' where Id =" + book.Id, null); } ((MainWindow)ob).Dispatcher.Invoke(new Action(() => { ((MainWindow)ob).DataContext = DataFetch.GetBooks(); })); }
public void AddNewBookSourcesValidation(BookSource bookSources) { if (!String.IsNullOrEmpty(bookSources.Description)) { int exist = GetBookSourceId(bookSources.Description); if (exist != 0) { MessageBox.Show("The source already exist.", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { try { AddNewBookSources(bookSources); } catch (Exception ex) { MessageBox.Show("Error when trying to add new book source, details: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("Please type the new book source ", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public bool AddNewBookSourcesValidation(BookSource bookSources) { if (!String.IsNullOrEmpty(bookSources.Description)) { int exist = GetBookSourceId(bookSources.Description); if (exist != 0) { return(false); } else { try { AddNewBookSources(bookSources); return(true); } catch (Exception ex) { return(false); } } } else { return(false); } }
public void Done() { BookSource s = DataContext as BookSource; CurrentContent.Save(); s.Save(); }
/// <summary> /// 保存&更新书源 /// </summary> private void Keep_Click(object sender, RoutedEventArgs e) { BookSource bookSource = new BookSource(); bookSource.Title = sourceName.Text.Trim(); bookSource.Url = sourceUrl.Text.Trim(); bookSource.SearchUrl = SearchUrl.Text; bookSource.AddressRangeRegular = AddressRangeRegular.Text.Replace("'", "''"); bookSource.AddressCuttingRegular = AddressCuttingRegular.Text.Replace("'", "''"); bookSource.AddressRegular = AddressRegular.Text.Replace("'", "''"); bookSource.BookNameRegular = BookNameRegular.Text.Replace("'", "''"); bookSource.AuthorRegular = AuthorRegular.Text.Replace("'", "''"); bookSource.UpdateRegular = UpdateRegular.Text.Replace("'", "''"); bookSource.NewestRegular = NewestRegular.Text.Replace("'", "''"); bookSource.DetailsRegular = DetailsRegular.Text.Replace("'", "''"); bookSource.StateRegular = StateRegular.Text.Replace("'", "''"); bookSource.DirectoryScopeRegular = DirectoryScopeRegular.Text.Replace("'", "''"); bookSource.DirectoryCuttingRegular = DirectoryCuttingRegular.Text.Replace("'", "''"); bookSource.DirectoryTieleRegular = DirectoryTieleRegular.Text.Replace("'", "''"); bookSource.DirectoryUrlRegular = DirectoryUrlRegular.Text.Replace("'", "''"); bookSource.ContentTitleRegular = ContentTitleRegular.Text.Replace("'", "''"); bookSource.ContentRegular = ContentRegular.Text.Replace("'", "''"); bookSource.ImageRegular = ImageRegular.Text.Replace("'", "''"); bookSource.State = 1; //这个是更新原有源 if (((Button)sender).Content.ToString() != "保存当前书源") { int id = Convert.ToInt32(Keep.Tag); bookSource.Id = id; string Msg = DataFetch.SourceUpdate(bookSource) ? "更新成功~" : "更新失败!"; Tips tips = new Tips(Msg); tips.Show(); //加载书源 ListSource.ItemsSource = DataFetch.GetBookSources(); } else //这个是增加新源 { if (state_search && state_details && state_Catalog && state_Text) { if (sourceName.Text.Trim().Length > 0 && sourceName.Text != "请输入新书源名~" && sourceUrl.Text.Trim().Length > 0 && sourceUrl.Text != "请输入新书源URL~") { string Msg = DataFetch.SourceAdd(bookSource) ? "添加成功~" : "添加失败!"; new Tips(Msg).Show(); } else { new Tips("请输入书源名和书源链接!").Show(); } } else { new Tips("请将其他页面的内容全部填写完毕,并保证准确无误后在进行提交!").Show(); } } //加载书源 ListSource.ItemsSource = DataFetch.GetBookSources(); Empty(); }
/// <summary> /// 编辑书源 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Edit_Click(object sender, RoutedEventArgs e) { BookSource bookSource = ListSource.SelectedItem as BookSource; if (bookSource != null && bookSource is BookSource) { sourceName.Text = bookSource.Title; sourceUrl.Text = bookSource.Url; SearchUrl.Text = bookSource.SearchUrl; AddressRangeRegular.Text = bookSource.AddressRangeRegular; AddressCuttingRegular.Text = bookSource.AddressCuttingRegular; AddressRegular.Text = bookSource.AddressRegular; BookNameRegular.Text = bookSource.BookNameRegular; AuthorRegular.Text = bookSource.AuthorRegular; UpdateRegular.Text = bookSource.UpdateRegular; NewestRegular.Text = bookSource.NewestRegular; DetailsRegular.Text = bookSource.DetailsRegular; StateRegular.Text = bookSource.StateRegular; DirectoryScopeRegular.Text = bookSource.DirectoryScopeRegular; DirectoryCuttingRegular.Text = bookSource.DirectoryCuttingRegular; DirectoryTieleRegular.Text = bookSource.DirectoryTieleRegular; DirectoryUrlRegular.Text = bookSource.DirectoryUrlRegular; ContentTitleRegular.Text = bookSource.ContentTitleRegular; ContentRegular.Text = bookSource.ContentRegular; ImageRegular.Text = bookSource.ImageRegular; //识别更新还是增加 Keep.Content = "更新当前书源"; Keep.Tag = bookSource.Id; } }
public override void Save() { BookSource s = DataContext as BookSource; System.Diagnostics.Debug.Assert(s != null); SavePage(); s.Save(); }
/// <summary> /// 增加书源 /// </summary> /// <param name="bookSource">书源内容</param> /// <returns>返回结果</returns> public static bool SourceAdd(BookSource bookSource) { string sql = "INSERT INTO BookSource('Title','Url','SearchUrl','AddressRangeRegular','AddressCuttingRegular','AddressRegular','BookNameRegular','AuthorRegular','UpdateRegular','NewestRegular','DetailsRegular','StateRegular','DirectoryScopeRegular','DirectoryCuttingRegular','DirectoryTieleRegular','DirectoryUrlRegular','ContentTitleRegular','ContentRegular','ImageRegular','State') VALUES('" + bookSource.Title + "', '" + bookSource.Url + "', '" + bookSource.SearchUrl + "', '" + bookSource.AddressRangeRegular + "', '" + bookSource.AddressCuttingRegular + "', '" + bookSource.AddressRegular + "','" + bookSource.BookNameRegular + "', '" + bookSource.AuthorRegular + "', '" + bookSource.UpdateRegular + "', '" + bookSource.NewestRegular + "', '" + bookSource.DetailsRegular + "', '" + bookSource.StateRegular + "', '" + bookSource.DirectoryScopeRegular + "', '" + bookSource.DirectoryCuttingRegular + "', '" + bookSource.DirectoryTieleRegular + "', '" + bookSource.DirectoryUrlRegular + "', '" + bookSource.ContentTitleRegular + "', '" + bookSource.ContentRegular + "', '" + bookSource.ImageRegular + "'," + bookSource.State + ")"; TempData.UpdateBookSourceS(); return((SQLiteDBHelper.ExecuteNonQuery(sql, null) <= 0) ? false : true); }
public ActionResult EditBookSource(int bookSourceId) { BookSource editBookSource = new BookSource(); editBookSource = service.GetOneBookSource(bookSourceId); return(View("EditBookSource", editBookSource)); }
public BookRead(String name) { _source = new BookSource(); // TODO check the correct syntax of the file //_source.Load(name); InitializeComponent(); _turnPage = (Storyboard)this.Resources["TurnPage"]; }
public void SwitchToPage(object o, RoutedEventArgs args) { Button b = o as Button; BookSource c = DataContext as BookSource; c.SetScene(b.DataContext as SceneDescription); OnFinished(); }
public SimpleRacialTrait(string name, string description, Type categoryType, BookSource source, object traitCategory = null) { CategoryType = categoryType; Source = source; Name = name; Description = description; TraitCategory = traitCategory ?? BaseRacialTraits.None; }
private void AddNewBookSources(BookSource bookSources) { using (LaybraryTestContext db = new LaybraryTestContext()) { db.BookSources.Add(bookSources); db.SaveChanges(); } }
private void MoveBackClick(object sender, RoutedEventArgs e) { SavePage(); BookSource s = DataContext as BookSource; s.MoveBack(); LoadScene(); }
public FeatsAtFirstLevelRacialTrait(string name, string description, int numberOfFeats, Type categoryType, BookSource source, object traitCategory = null) { CategoryType = categoryType; Source = source; Name = name; Description = description; NumberOfFeats = numberOfFeats; TraitCategory = traitCategory ?? BaseRacialTraits.None; }
/// <summary> /// 构造函数入口 /// </summary> /// <param name="book">书籍信息</param> /// <param name="mainWindow">主窗口对象</param> /// <param name="config">配置项</param> public ReadingPage(Book book, MainWindow mainWindow = null, Config config = null) { InitializeComponent(); Thread thread = new Thread(new ThreadStart(delegate { try { this.book = book; this.mainWindow = mainWindow; this.config = config; //获取目录 DataFetch.GetList(book); bookSource = DataFetch.GetBookSource(book.Source); //主要为遍历目录 int i = 0; foreach (KeyValuePair <string, string> kvp in book.ListUrl) { if (kvp.Key.Trim().Length > 2) { i++; NewId.Add(i, kvp.Key); } } Dispatcher.Invoke((Action) delegate { if (book.Read == 0) { Jump(1); } else { Jump((int)book.Read); } }); } catch (Exception ex) { Tool.TextAdditional(ex.Message); } })); thread.IsBackground = true; //是否为后台线程 thread.Start(); this.Closed += BeforeClosing; //newText.IsEnabled = false; //窗口大小改变时 this.SizeChanged += new SizeChangedEventHandler(ReadingPage_Resize); //设置定时器(朗读) timer = new DispatcherTimer(); timer.Interval = new TimeSpan(10000000); //时间间隔为一秒 timer.Tick += new EventHandler(timer_Tick); }
public AddSkillPointsPerLevelRacialTrait(string name, string description, int pointsPerLevel, Type categoryType, BookSource source, object traitCategory = null) { CategoryType = categoryType; Source = source; Name = name; Description = description; SkillPointsPerLevel = pointsPerLevel; TraitCategory = traitCategory ?? BaseRacialTraits.None; }
public AddOptionalAbilityModifiersRacialTrait(string name, string description, Type categoryType, BookSource source, int number, object traitCategory = null) { CategoryType = categoryType; Name = name; Description = description; Number = number; Source = source; TraitCategory = traitCategory ?? BaseRacialTraits.None; }
private void CreateContentClick(object sender, RoutedEventArgs e) { BookSource s = DataContext as BookSource; IRiddleHandler h = x_types.SelectedItem as IRiddleHandler; h.Create(); s.CreatePage(); s.SetPage(h.CreateRiddle()); LoadScene(); }
private void ShowProgress(String desc) { BookSource c = DataContext as BookSource; String str = String.Format("{0} ( Page {1}/{2} )", desc, c.Position.ParagraphId + 1, c.Position.Scene.Pages.Count); x_progressText.Text = str; }
public ActionResult AddBookSource(string newBookSourceName, string newBookSourceLink) { BookSource newBookSource = new BookSource(); newBookSource.BookSourceName = newBookSourceName; newBookSource.BookSourceLink = newBookSourceLink; service.AddBookSource(newBookSource); return(RedirectToAction("GetBookSources", "Home")); }
/// <summary> /// 根据书源名获取书源对象 /// </summary> /// <param name="SourceName">书源名</param> /// <returns>返回书源对象</returns> public static BookSource GetBookSource(string SourceName) { //获取DataTable DataTable dt = SQLiteDBHelper.ExecuteDataTable("select *from BookSource where Title='" + SourceName + "'", null); //获取指定ID书籍的对象 BookSource source = DAL.ModelConvertHelper <BookSource> .DataTableToModel(dt); return(source); }
public BookPage() { this.InitializeComponent(); var sampleDataGroups = BookSource.GetGroupsAsync(); itemGridView.ItemsSource = sampleDataGroups; App.fullWidth = Window.Current.Bounds.Width; App.halfWidth = Window.Current.Bounds.Width / 2; App.readWidth = App.fullWidth; //this.DefaultViewModel["Books"] = sampleDataGroups; }