/// <summary> /// Sélectionner un livre hors de la bibliothèque /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BT_AjoutBook_Click(object sender, EventArgs e) { TXT_Pages.Text = ""; PICB_Couverture.Image = null; PICB_Couverture.BackgroundImage = null; //OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.CheckFileExists = true; openFileDialog.Filter = "EPUB files (*.epub)"; openFileDialog.ShowDialog(); MessageBox.Show(openFileDialog.FileName); ClassEpubRead classEpubRead = new ClassEpubRead(openFileDialog.FileName); TXT_Auteurs.Text = classEpubRead.auteur; TXT_Titre.Text = classEpubRead.titre; PICB_Couverture.Image = classEpubRead.picture; CB_Genre.Text = classEpubRead.genre; TXT_IBSN.Text = classEpubRead.isbn; TXT_LanguesBook.Text = classEpubRead.langage; TXT_EditeurBook.Text = classEpubRead.editeur; TXT_DateBook.Text = classEpubRead.date; WB_text.DocumentText = "<html><body>" + classEpubRead.descri + "</body></html>"; RTB_Text.Text = classEpubRead.descri; TXT_PublieBook.Text = classEpubRead.droits; FileInfo(openFileDialog.FileName); }
private void LV_Livre_SelectedIndexChanged(object sender, EventArgs e) { if (LV_Livre.SelectedItems.Count > 0) { string selected = GetAllSelectedPath(true)[0]; PB_Couverture.BackgroundImage = null; ClassEpubRead classEpub = new ClassEpubRead(selected); PB_Couverture.Image = classEpub.picture; LBL_Auteur.Text = "Auteur : " + classEpub.auteur; LBL_Etiquette.Text = "Etiquette : " + classEpub.genre; LBL_Chemin.Text = "Chemin : " + selected; LBL_Format.Text = "Format : " + selected.Substring(selected.Length - 4, 4).ToUpper(); } }
public void SelectionLivre(string chemin) { PB_meta.BackgroundImage = null; ClassEpubRead classEpubRead = new ClassEpubRead(chemin); CB_Auteurs.Text = classEpubRead.auteur; TXT_titre.Text = classEpubRead.titre; PB_meta.Image = classEpubRead.picture; CB_editeur.Text = classEpubRead.editeur; WB_Description.DocumentText = classEpubRead.descri; WB_Description2.DocumentText = classEpubRead.descri; TXT_titredetails.Text = classEpubRead.titre; FileInfo(chemin); }
///////// FORM ///////// public FRM_Visualiser(Livres _livre) { livre = _livre; InitializeComponent(); EPubReader = new ClassEpubRead(livre.full_chemin_livre); EpubBook epubBook = EpubReader.ReadBook(livre.full_chemin_livre); foreach (EpubTextContentFile textContentFile in epubBook.ReadingOrder) { string htmlContent = textContentFile.Content; RTB_Test.Text = htmlContent; } if_fullscreen = 0; displayText = RTB_Test.Text; WB_Pages.DocumentText = "<html><div style='font-size:" + textSize + "px;width:" + (WB_Pages.Width - 55) + "px; margin-left:15px; margin-right:auto;'>" + displayText + "</div></html>"; }
/// <summary> /// lis les informations du livre qui a été sélectionné /// </summary> /// <param name="chemin"></param> public void SelectionLivre(string chemin) { PICB_Couverture.BackgroundImage = null; PICB_Couverture.Image = null; ClassEpubRead classEpubRead = new ClassEpubRead(chemin); TXT_Auteurs.Text = classEpubRead.auteur; //TXT_Titre.Text = classEpubRead.titre; PICB_Couverture.BackgroundImage = classEpubRead.picture; CB_Genre.Text = classEpubRead.genre; TXT_IBSN.Text = classEpubRead.isbn; TXT_LanguesBook.Text = classEpubRead.langage; TXT_EditeurBook.Text = classEpubRead.editeur; TXT_DateBook.Text = classEpubRead.date; //WB_text.DocumentText = "<html><body>" + classEpubRead.descri + "</body></html>"; TXT_PublieBook.Text = classEpubRead.droits; //RTB_Text.Text = WB_text.DocumentText; FileInfo(chemin); }
/// <summary> /// fonction qui lit le fichier binaire pour afficher les métadonnées modifier /// </summary> /// <param name="cheminMod"></param> /// <param name="chemin"></param> public void ReadModification(string cheminMod, string chemin) { int rbitsLength; PICB_Couverture.BackgroundImage = null; ClassEpubRead classEpubRead = new ClassEpubRead(chemin); FileStream fileStream = new FileStream(cheminMod, FileMode.Open); BinaryReader binaryReader = new BinaryReader(fileStream); try { for (int i = 0; i < Texts().Length; i++) { Texts()[i].Text = binaryReader.ReadString(); } CB_NoteBook.Text = binaryReader.ReadString(); WB_text.DocumentText = binaryReader.ReadString(); rbitsLength = binaryReader.ReadInt32(); // Taille du tableau du memoryStream.GetBuffer if (rbitsLength == 0) { PICB_Couverture.BackgroundImage = classEpubRead.picture; } else { byte[] rbits = binaryReader.ReadBytes(rbitsLength); // Récupère le nombre d'octets du flux de l'image MemoryStream memoryStream = new MemoryStream(rbits); PICB_Couverture.Image = Image.FromStream(memoryStream); // Créer une images à partir du flux d'octets memoryStream.Close(); } RTB_Text.Text = WB_text.DocumentText; } catch (Exception e) { //MessageBox.Show("Erreur" + e); ExceptionHandler.Message("Erreur récupération opf : " + e); } finally { fileStream.Close(); } }
public static void AjoutEpub(string PATH, string FileName, Bibliotheque biblio) { string chemin = "\\" + FileName, id_livre = "", id_auteur = "", id_collect = "", id_editeur = ""; Random rng = new Random(); SQLiteDataReader sqldr; try { ClassEpubRead epubRead = new ClassEpubRead(PATH); string hash = Hachage.FileToHashMD5(PATH); sqldr = biblio.Database.Extraction("SELECT id_livre FROM LIVRE WHERE hash LIKE '" + hash + "'"); sqldr.Read(); if (!sqldr.IsDBNull(0)) { //MessageBox.Show("Erreur le livre existe déjà dans la base " + sqldr[0].ToString(), "Erreur Ajout", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { id_livre = MakeID(rng, "L" + hash.Substring(0, 10)); //Détermination de l'id //Détermination des auteurs //MessageBox.Show(epubRead.auteur_prenom); sqldr = biblio.Database.Extraction("SELECT id_auteur FROM auteur WHERE nom_auteur LIKE '" + epubRead.auteur + "'"); sqldr.Read(); if (!sqldr.IsDBNull(0)) { id_auteur = (string)sqldr[0]; } else { id_auteur = MakeID(rng, "A" + hash.Substring(0, 10)); biblio.Database.Requete("INSERT INTO AUTEUR (id_auteur, nom_auteur, prenom_auteur) VALUES ('" + id_auteur + "', '" + epubRead.auteur + "', ' ')"); } //Determine si le livre existe déjà // determine la collection sqldr = biblio.Database.Extraction("SELECT id_collect, nom_collect FROM COLLECT WHERE nom_collect LIKE '" + epubRead.titre.Replace('\'', ' ') + "'"); sqldr.Read(); if (!sqldr.IsDBNull(0)) { id_collect = (string)sqldr[0]; } else { id_collect = MakeID(rng, "C" + hash.Substring(0, 10)); biblio.Database.Requete("INSERT INTO COLLECT (id_collect, nom_collect) VALUES ('" + id_collect + "', '" + epubRead.titre.Replace('\'', ' ') + "')"); } //Determination de l'editeur sqldr = biblio.Database.Extraction("SELECT id_editeur FROM EDITEUR WHERE nom_editeur LIKE '" + epubRead.editeur.Replace('\'', ' ') + "'"); sqldr.Read(); if (!sqldr.IsDBNull(0)) { id_editeur = (string)sqldr[0]; } else { id_editeur = MakeID(rng, "E" + hash.Substring(0, 10)); biblio.Database.Requete("INSERT INTO EDITEUR (id_editeur, nom_editeur) VALUES ('" + id_editeur + "', '" + epubRead.editeur.Replace('\'', ' ') + "')"); } if (epubRead.date == null) { if (epubRead.descri == null) { biblio.Database.Requete("INSERT INTO LIVRE (id_livre, titre, nbpages, evaluation, datepubli, chemin_livre, description, avancement, langue, hash, id_genre, id_tomes, id_serie) VALUES ('" + id_livre + "', '" + epubRead.titre.Replace('\'', ' ') + "', 100, 0, 11111, '" + chemin + "', 'Pas de descri', 0, 'fr', '" + hash + "', 0, null, null )"); } else { biblio.Database.Requete("INSERT INTO LIVRE (id_livre, titre, nbpages, evaluation, datepubli, chemin_livre, description, avancement, langue, hash, id_genre, id_tomes, id_serie) VALUES ('" + id_livre + "', '" + epubRead.titre.Replace('\'', ' ') + "', 100, 0, 11111, '" + chemin + "', '" + epubRead.descri.Replace('\'', ' ') + "', 0, 'fr', '" + hash + "', 0, null, null )"); } } else { if (epubRead.descri == null) { biblio.Database.Requete("INSERT INTO LIVRE (id_livre, titre, nbpages, evaluation, datepubli, chemin_livre, description, avancement, langue, hash, id_genre, id_tomes, id_serie) VALUES ('" + id_livre + "', '" + epubRead.titre.Replace('\'', ' ') + "', 100, 0,'" + epubRead.date.Replace('\'', ' ') + "', '" + chemin + "', 'Pas de descri', 0, 'fr', '" + hash + "', 0, null, null )"); } else { biblio.Database.Requete("INSERT INTO LIVRE (id_livre, titre, nbpages, evaluation, datepubli, chemin_livre, description, avancement, langue, hash, id_genre, id_tomes, id_serie) VALUES ('" + id_livre + "', '" + epubRead.titre.Replace('\'', ' ') + "', 100, 0,'" + epubRead.date.Replace('\'', ' ') + "', '" + chemin + "', '" + epubRead.descri.Replace("'", "''") + "', 0, 'fr', '" + hash + "', 0, null, null )"); } } //MessageBox.Show(epubRead.date); //MessageBox.Show("DESC " + epubRead.descri); //Détermination des genres //ExceptionHandler.Message("INSERT INTO LIVRE (id_livre, titre, nbpages, evaluation, datepubli, chemin_livre, description, avancement, langue, hash, id_genre, id_tomes, id_serie) VALUES ('" + id_livre + "', '" + epubRead.titre.Replace('\'', ' ') + "', 100, 0, '" + epubRead.date.Replace('\'', ' ') + "', '" + chemin + "', '" + epubRead.descri.Replace('\'', ' ') + "', 0, 'fr', '" + hash + "', 0, null, null )"); // revoir la requete //Ajout dans la base //biblio.Database.Requete("INSERT INTO LIVRE (id_livre, titre, nbpages, evaluation, datepubli, chemin_livre, description, avancement, langue, hash, id_genre, id_tomes, id_serie) VALUES ('" + id_livre + "', '" + epubRead.titre.Replace('\'', ' ') + "', 100, 0, '" + epubRead.date.Replace('\'', ' ') + "', '" + chemin + "', @'" + epubRead.descri.Replace('\'', ' ') + "', 0, 'fr', '" + hash + "', 0, null, null )"); biblio.Database.Requete("INSERT INTO EDITER_LIVRE (id_editeur, id_livre, id_collect, ISBN, pays) VALUES ('" + id_editeur + "', '" + id_livre + "', '" + id_collect + "', '" + epubRead.isbn + "', 'France')"); biblio.Database.Requete("INSERT INTO A_ECRIT (id_livre, id_auteur) VALUES ('" + id_livre + "', '" + id_auteur + "')"); File.Copy(PATH, biblio.CurrentPath + "\\" + FileName); } } catch (Exception exc) { ExceptionHandler.ExeptionCatch(exc); ExceptionHandler.Message(id_editeur + ", '" + id_livre + "', '" + id_collect + "', '" + id_auteur); } }