Integrato menu contestuale per comandare il thread secondario di import Aggiornata UI per visualizzare eventi del thread separato Testato import ToDo: - [X] Inserire un lettore per visualizzare i racconti nel DB - [0/3] Inserire funzionalità avanzate di lettura: - [ ] navigazione avanzata fra i racconti (per id, per autore, per titolo, per tag ecc... - [ ] possibilità di filtrare i racconti - [ ] Notificon per poter nascondere il reader e centralizzare i comandi - [2/3] Integrare lo scraping dei racconti dal web e l'import da file - [X] Integrare lo scraping dei racconti da web, visualizzandolo sulla progress bar e label nella status bar. - [X] Integrare l'import dei racconti da file, visualizzandolo sulla progress bar e label nella status bar. - [ ] Upgradare lo skraping, importando i racconti via via che sono downloadati
738 lines
36 KiB
C#
738 lines
36 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.IO.Ports;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using A69WD.Data;
|
|
using A69WD.Net;
|
|
using A69WD.Service;
|
|
using A69WD.Site;
|
|
|
|
namespace A69WD.UI {
|
|
public partial class frmReader : Form {
|
|
|
|
MenuItem mSkrStart;
|
|
MenuItem mSkrStop;
|
|
MenuItem mImpStart;
|
|
MenuItem mImpStop;
|
|
|
|
private Service_Crawler serviceCrawler = null;
|
|
private Service_Importer ServiceImporter = null;
|
|
A69WD.Site.iSiteType siteA69 = null;
|
|
|
|
public frmReader() {
|
|
InitializeComponent();
|
|
|
|
// Imposto caption:
|
|
this.Text = String.Format("A69WD - Reader Vrs {0}", cTools.AssemblyVersion);
|
|
|
|
// Imposto field interni:
|
|
nav = new Navigator(25);
|
|
|
|
// Visualizzo la pagina iniziale di riepilogo dell'archivio
|
|
rtb.Text = nav.Home;
|
|
|
|
// Aggiorno la status bar
|
|
sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
|
|
// Menu comandi skraping:
|
|
MenuItem mSkr = new MenuItem("Skraping");
|
|
mSkrStart = new MenuItem("Start", MenuItem_Skraping_Start_Click, Shortcut.None);
|
|
mSkrStop = new MenuItem("Stop", MenuItem_Skraping_Stop_Click, Shortcut.None);
|
|
mSkr.MenuItems.Add(mSkrStart);
|
|
mSkr.MenuItems.Add(mSkrStop);
|
|
// Menu comandi importer:
|
|
MenuItem mImp = new MenuItem("Importer");
|
|
mImpStart = new MenuItem("Start", MenuItem_Importer_Start_Click, Shortcut.None);
|
|
mImpStop = new MenuItem("Stop", MenuItem_Importer_Stop_Click, Shortcut.None);
|
|
mImp.MenuItems.Add(mImpStart);
|
|
mImp.MenuItems.Add(mImpStop);
|
|
// Menu contestuale:
|
|
this.ContextMenu = new ContextMenu();
|
|
this.ContextMenu.MenuItems.Add(mSkr);
|
|
this.ContextMenu.MenuItems.Add(mImp);
|
|
// Enable only start
|
|
mSkrStart.Enabled = true;
|
|
mSkrStop.Enabled = false;
|
|
mImpStart.Enabled = true;
|
|
mImpStop.Enabled = false;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gestione della navigazione fra i racconti
|
|
/// </summary>
|
|
private Navigator nav = null;
|
|
|
|
|
|
private void KeyDownAnalisi(object sender, KeyEventArgs e) {
|
|
|
|
#region Keys.F1 --> Show Help
|
|
//if (e.KeyCode == Keys.F1) {
|
|
// sbMessage.Text = "Show Help";
|
|
// MessageBox.Show(this, Help(), "Help", MessageBoxButtons.OK);
|
|
// return;
|
|
//}
|
|
#endregion
|
|
|
|
#region Keys.ESC --> Hide Reader
|
|
if (e.KeyCode == Keys.Escape) {
|
|
//this.Hide();
|
|
this.Close();
|
|
return;
|
|
}
|
|
#endregion
|
|
|
|
#region Keys.F2 --> Show Rac by ID
|
|
//if (e.KeyCode == Keys.F2) {
|
|
// // Form per richiedere l'ID di un racconto specifico da visualizzare:
|
|
// frmRqId frmi = new frmRqId();
|
|
// frmi.Left = Left + (Width - frmi.Width) / 2;
|
|
// frmi.Top = Top + (Height - frmi.Height) / 2;
|
|
// // Visualizzo il racconto richiesto:
|
|
// if (frmi.ShowDialog() == DialogResult.OK) {
|
|
// rtb.Text = nav.SwitchTo(frmi.ID);
|
|
// sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
// }
|
|
// frmi.Close();
|
|
// return;
|
|
//}
|
|
#endregion
|
|
|
|
#region Keys.F3 --> Show Rac random
|
|
if (e.KeyCode == Keys.F3) {
|
|
// Show New Random Rac
|
|
rtb.Text = nav.RandomRac;
|
|
sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
return;
|
|
}
|
|
#endregion
|
|
|
|
#region Keys.F4 --> Genera un racconto nuovo
|
|
if (e.KeyCode == Keys.F4) {
|
|
// Genera un racconto nuovo
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.AppendLine("- ID Rac: 0");
|
|
sb.AppendLine("- Title: Titolo del nuovo racconto");
|
|
sb.AppendLine("- SubTit: ");
|
|
sb.AppendLine("- Autors: Mrk");
|
|
sb.AppendLine("- Voto: Non Letto");
|
|
sb.AppendLine("- Tags: Uncategorized");
|
|
sb.AppendLine("- Notes: SrcFile -|- Generated Internally");
|
|
sb.AppendLine(string.Format("- Creato: {0}", DateTime.Now.ToString("yyyy/MM/dd")));
|
|
sb.AppendLine(string.Format("- Update: {0}", DateTime.Now.ToString("yyyy/MM/dd")));
|
|
sb.AppendLine("- Origin: Mrk");
|
|
sb.AppendLine("- Trama: Trama del nuovo racconto");
|
|
rtb.Text = sb.ToString();
|
|
System.Windows.Forms.Clipboard.SetText(sb.ToString());
|
|
sbMessage.Text = string.Format("Generato un racconto nuovo, salvarlo con F8");
|
|
return;
|
|
}
|
|
#endregion
|
|
|
|
#region Keys.F5 --> Refresh Rac
|
|
if (e.KeyCode == Keys.F5) {
|
|
rtb.Text = nav.Refresh;
|
|
sbMessage.Text = string.Format("Racconto {0} Refresh", nav.ActualID.ToString("00000"));
|
|
return;
|
|
}
|
|
#endregion
|
|
|
|
#region Keys.F8 --> Edit Rac
|
|
if (e.KeyCode == Keys.F8) {
|
|
// Edit Rac
|
|
// Rileggo il testo che visualizzo (e che ho eventualmente editato) per recuperare i testi in esso e li salvo
|
|
// Se ID=0 o non specificato, aggiungo il testo come nuovo, altrimenti faccio l'update del racconto.
|
|
cRac[] racs = null;
|
|
int res = cRac.Read(rtb.Text, out racs);
|
|
if (res > 0) {
|
|
rtb.Text = string.Format("Trovati {0} racconti:\r\n", racs.Length);
|
|
res = 0;
|
|
foreach (cRac rac in racs) {
|
|
// Aggiorno il racconto in memoria
|
|
res += App.DB.UpdateRac(rac);
|
|
}
|
|
if (res == racs.Length) {
|
|
rtb.Text = nav.SwitchTo(racs[0].IDrac);
|
|
sbMessage.Text = string.Format("Importato/Aggiornato correttamente {0} racconti", res.ToString("00000"));
|
|
} else {
|
|
rtb.Text = App.DB.GetRacById(nav.ActualID).ToString();
|
|
sbMessage.Text = string.Format("Errore in lettura di {0}", nav.ActualID.ToString("00000"));
|
|
}
|
|
} else {
|
|
rtb.Text = "Lettura del racconto non riuscita";
|
|
}
|
|
return;
|
|
}
|
|
#endregion
|
|
|
|
#region Keys.F10 --> Bookmarks
|
|
if (e.KeyCode == Keys.F10) {
|
|
// ToDo: Keys.F10 --> Bookmarks
|
|
sbMessage.Text = "Keys.F10 --> Comando in sviluppo, non tutte le funzioni sono completate";
|
|
return;
|
|
}
|
|
#endregion
|
|
|
|
#region Keys.F12 --> Votazione
|
|
//if (e.KeyCode == Keys.F12 && (!e.Control) && (!e.Alt) && (!e.Shift)) {
|
|
// // Vote Rac
|
|
// long id = nav.ActualID;
|
|
// if (id < 0) return;
|
|
// frmVoto frmv = new frmVoto(App.DB.GetRacById(id));
|
|
// frmv.Left = Left + (Width - frmv.Width) / 2;
|
|
// frmv.Top = Top + (Height - frmv.Height) / 2;
|
|
// if (frmv.ShowDialog() == DialogResult.OK) {
|
|
// rtb.Text = nav.UpdateVoto(frmv.Voto);
|
|
// sbMessage.Text = string.Format("Racconto {0} Voted", nav.ActualID.ToString("00000"));
|
|
// } else {
|
|
// rtb.Text = nav.Refresh;
|
|
// sbMessage.Text = string.Format("Racconto {0} Refresh", nav.ActualID.ToString("00000"));
|
|
// }
|
|
// frmv.Close();
|
|
// return;
|
|
//}
|
|
#endregion
|
|
|
|
#region Keys.Alt+keys.H --> Home
|
|
if (e.Alt && (e.KeyCode == Keys.H)) {
|
|
rtb.Text = nav.Home;
|
|
sbMessage.Text = string.Format("Home {0}", nav.ActualID.ToString("00000"));
|
|
}
|
|
#endregion
|
|
|
|
#region Keys.Alt+Keys.Left --> Navigazione backward fra i racconti già visualizzati
|
|
if (e.Alt && (e.KeyCode == Keys.Left)) {
|
|
// Show Rac Backward
|
|
rtb.Text = nav.Backward;
|
|
sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
return;
|
|
}
|
|
#endregion
|
|
|
|
#region Keys.Alt+keys.Right --> Navigazione forward fra i racconti già visualizzati
|
|
if (e.Alt && (e.KeyCode == Keys.Right)) {
|
|
// Show Rac Forward
|
|
rtb.Text = nav.Forward;
|
|
sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
return;
|
|
}
|
|
#endregion
|
|
|
|
#region Keys.Alt+keys.Down --> Navigazione verso il racconto con ID precedente (ID Meno 1) a quello visualizzato
|
|
if (e.Alt && (e.KeyCode == Keys.Down)) {
|
|
// Show Rac Meno 1
|
|
rtb.Text = nav.Previous;
|
|
sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
return;
|
|
}
|
|
#endregion
|
|
|
|
#region Keys.Alt+keys.Up --> Navigazione verso il racconto con ID successivo (ID Più 1) a quello visualizzato
|
|
if (e.Alt && (e.KeyCode == Keys.Up)) {
|
|
// Show Rac Più 1
|
|
rtb.Text = nav.Next;
|
|
sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
return;
|
|
}
|
|
#endregion
|
|
|
|
#region Keys.Alt+keys.+ --> Incrementa la dimensione del font
|
|
if (e.Alt && (e.KeyCode == Keys.Add)) {
|
|
// Increse text size
|
|
Font f = new System.Drawing.Font(rtb.Font.FontFamily, rtb.Font.Size + 1.0F);
|
|
rtb.Font = f;
|
|
sbMessage.Text = string.Format("Racconto {0} Size Increase", nav.ActualID.ToString("00000"));
|
|
return;
|
|
}
|
|
#endregion
|
|
|
|
#region Keys.Alt+keys.- --> Decrementa la dimensione del font
|
|
if (e.Alt && (e.KeyCode == Keys.Subtract)) {
|
|
// Decrease text size
|
|
Font f = new System.Drawing.Font(rtb.Font.FontFamily, rtb.Font.Size - 1.0F);
|
|
rtb.Font = f;
|
|
sbMessage.Text = string.Format("Racconto {0} Size Decrease", nav.ActualID.ToString("00000"));
|
|
return;
|
|
}
|
|
#endregion
|
|
|
|
#region Keys.Alt+keys.* --> Imposta il font alla dimensione di default
|
|
if (e.Alt && (e.KeyCode == Keys.Multiply)) {
|
|
// Reset text size
|
|
Font f = new System.Drawing.Font(rtb.Font.FontFamily, (float)10.0);
|
|
rtb.Font = f;
|
|
sbMessage.Text = string.Format("Racconto {0} Size Default", nav.ActualID.ToString("00000"));
|
|
return;
|
|
}
|
|
#endregion
|
|
|
|
#region Keys.Alt+keys.F --> Editazione filtri:
|
|
//if (e.Alt && (e.KeyCode == Keys.F)) {
|
|
// // preparo l'interfaccia per la gestione filtri:
|
|
// frmFilters frmF = new frmFilters(DB);
|
|
// frmF.Left = Left + (Width - frmF.Width) / 2;
|
|
// frmF.Top = Top + (Height - frmF.Height) / 2;
|
|
// // Visualizzo l'interfaccia:
|
|
// if (frmF.ShowDialog() == DialogResult.OK) { sbMessage.Text = string.Format("FVoti: {0} - FTags: {1}", DB.FVoti, DB.FTags); }
|
|
// frmF.Close();
|
|
// return;
|
|
//}
|
|
#endregion
|
|
|
|
#region Keys.Alt+keys.A --> Navigazione fra i racconti dello stesso autore
|
|
//if (e.Alt && (e.KeyCode == Keys.A)) {
|
|
// // Show All Rac of this Autor
|
|
// frmList frml = new frmList();
|
|
// frml.Height = this.Height - 64;
|
|
// frml.Width = this.Width - 64;
|
|
// frml.Left = Left + (Width - frml.Width) / 2;
|
|
// frml.Top = Top + (Height - frml.Height) / 2;
|
|
// frml.Title = "Racconti dell'autore:";
|
|
// int res = DB.GetListByRacAutor(nav.ActualID, frml.LV);
|
|
// if ((res > 0) && (frml.ShowDialog() == DialogResult.OK)) {
|
|
// // Se racconto selezionato è uno solo, lo visualizzo, altrimenti mostro nuovo elenco
|
|
// if (frml.Num > 1) {
|
|
// // più racconti dallo stesso titolo:
|
|
// res = DB.GetListByTitle(frml.Descr, frml.LV);
|
|
// frml.Title = "Racconti con il titolo: " + frml.Descr;
|
|
// if ((res > 0) && (frml.ShowDialog() == DialogResult.OK)) {
|
|
// rtb.Text = nav.SwitchTo(frml.ID);
|
|
// sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
// }
|
|
// } else {
|
|
// // 1 solo racconto
|
|
// rtb.Text = nav.SwitchTo(frml.ID);
|
|
// sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
// }
|
|
// }
|
|
// frml.Close();
|
|
// return;
|
|
//}
|
|
#endregion
|
|
|
|
#region Keys.Alt+keys.T --> Navigazione fra i racconti via tag:
|
|
//if (e.Alt && (e.KeyCode == Keys.T)) {
|
|
// // Show All Tag
|
|
// frmList frml = new frmList();
|
|
// frml.Height = this.Height - 64;
|
|
// frml.Width = this.Width - 64;
|
|
// frml.Left = Left + (Width - frml.Width) / 2;
|
|
// frml.Top = Top + (Height - frml.Height) / 2;
|
|
// frml.Title = "Elenco Tags:";
|
|
// int res = DB.GetListTags(nav.ActualID, frml.LV);
|
|
// if ((res > 0) && (frml.ShowDialog() == DialogResult.OK)) {
|
|
// // Show all rac del tag selezionato
|
|
// res = DB.GetListByTags(frml.ID, frml.LV);
|
|
// frml.Title = "Racconti del tag: " + frml.Descr;
|
|
// if ((res > 0) && (frml.ShowDialog() == DialogResult.OK)) {
|
|
// // Se racconto selezionato è uno solo, lo visualizzo, altrimenti mostro nuovo elenco
|
|
// if (frml.Num > 1) {
|
|
// // più racconti dallo stesso titolo:
|
|
// res = DB.GetListByTitle(frml.Descr, frml.LV);
|
|
// frml.Title = "Racconti con il titolo: " + frml.Descr;
|
|
// if ((res > 0) && (frml.ShowDialog() == DialogResult.OK)) {
|
|
// rtb.Text = nav.SwitchTo(frml.ID);
|
|
// sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
// }
|
|
// } else {
|
|
// // 1 solo racconto
|
|
// rtb.Text = nav.SwitchTo(frml.ID);
|
|
// sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
// }
|
|
// }
|
|
// }
|
|
// frml.Close();
|
|
// return;
|
|
//}
|
|
#endregion
|
|
|
|
#region Keys.Alt+keys.V --> Navigazione fra i racconti via Voto:
|
|
//if (e.Alt && (e.KeyCode == Keys.V)) {
|
|
// // Show All Voto
|
|
// frmList frml = new frmList();
|
|
// frml.Height = this.Height - 64;
|
|
// frml.Width = this.Width - 64;
|
|
// frml.Left = Left + (Width - frml.Width) / 2;
|
|
// frml.Top = Top + (Height - frml.Height) / 2;
|
|
// frml.Title = "Elenco Voti Assegnati:";
|
|
// int res = DB.GetListVoti(nav.ActualID, frml.LV);
|
|
// if ((res > 0) && (frml.ShowDialog() == DialogResult.OK)) {
|
|
// // Show all rac del tag selezionato
|
|
// frml.Title = "Racconti del voto: " + frml.Descr;
|
|
// res = DB.GetListByVoto(frml.ID, frml.LV);
|
|
// if ((res > 0) && (frml.ShowDialog() == DialogResult.OK)) {
|
|
// rtb.Text = nav.SwitchTo(frml.ID);
|
|
// sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
// }
|
|
// }
|
|
// frml.Close();
|
|
// return;
|
|
//}
|
|
#endregion
|
|
|
|
#region Keys.Alt+keys.D --> Navigazione fra i racconti via Data:
|
|
//if (e.Alt && (!e.Shift) && (e.KeyCode == Keys.D)) {
|
|
// // Show All Year
|
|
// frmList frml = new frmList();
|
|
// frml.Height = this.Height - 64;
|
|
// frml.Width = this.Width - 64;
|
|
// frml.Left = Left + (Width - frml.Width) / 2;
|
|
// frml.Top = Top + (Height - frml.Height) / 2;
|
|
// frml.Title = "Elenco per anno di creazione:";
|
|
// int res = DB.GetListByCreationDate(frml.LV);
|
|
// if ((res > 0) && (frml.ShowDialog() == DialogResult.OK)) {
|
|
// if (frml.Num == 1) {
|
|
// // Per l'anno vi è 1 solo racconto, e quindi lo mostro direttamente:
|
|
// rtb.Text = nav.SwitchTo(frml.ID);
|
|
// sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
// } else {
|
|
// // Show all Month dell'anno selezionato
|
|
// string strYear = frml.Descr;
|
|
// res = DB.GetListByYear(strYear, frml.LV);
|
|
// frml.Title = "Elenco mesi dell'anno " + strYear;
|
|
// if ((res > 0) && (frml.ShowDialog() == DialogResult.OK)) {
|
|
// if (frml.Num == 1) {
|
|
// // Per l'anno e mese selezionato, vi è 1 solo racconto, e quindi lo mostro direttamente:
|
|
// rtb.Text = nav.SwitchTo(frml.ID);
|
|
// sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
// } else {
|
|
// // Show all Days del mese, dell'anno, selezionato
|
|
// string strMonth = frml.Descr;
|
|
// res = DB.GetListByMonth(strYear, strMonth, frml.LV);
|
|
// frml.Title = "Elenco giorni del mese " + strMonth + "/" + strYear;
|
|
// if ((res > 0) && (frml.ShowDialog() == DialogResult.OK)) {
|
|
// if (frml.Num == 1) {
|
|
// // solo un racconto nel mese indicato, lo visualizzo subito
|
|
// rtb.Text = nav.SwitchTo(frml.ID);
|
|
// sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
// } else {
|
|
// string strDay = frml.Descr;
|
|
// res = DB.GetListByDay(strYear, strMonth, strDay, frml.LV);
|
|
// frml.Title = "Elenco racconti del giorno " + strDay + "/" + strMonth + "/" + strYear;
|
|
// if ((res > 0) && (frml.ShowDialog() == DialogResult.OK)) {
|
|
// // Se racconto selezionato è uno solo, lo visualizzo, altrimenti mostro nuovo elenco
|
|
// if (frml.Num > 1) {
|
|
// // più racconti dallo stesso titolo:
|
|
// res = DB.GetListByTitle(frml.Descr, frml.LV);
|
|
// frml.Title = "Racconti con il titolo: " + frml.Descr;
|
|
// if ((res > 0) && (frml.ShowDialog() == DialogResult.OK)) {
|
|
// rtb.Text = nav.SwitchTo(frml.ID);
|
|
// sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
// }
|
|
// } else {
|
|
// // 1 solo racconto
|
|
// rtb.Text = nav.SwitchTo(frml.ID);
|
|
// sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// frml.Close();
|
|
// return;
|
|
//}
|
|
#endregion
|
|
|
|
#region Keys.Alt+keys.L --> Navigazione degli ultimi 25 racconti updated e non letti:
|
|
//if (e.Alt && (e.KeyCode == Keys.L)) {
|
|
// #region
|
|
// // Show last 25 racconti updated:
|
|
// frmList frml = new frmList();
|
|
// frml.Height = this.Height - 64;
|
|
// frml.Width = this.Width - 64;
|
|
// frml.Left = Left + (Width - frml.Width) / 2;
|
|
// frml.Top = Top + (Height - frml.Height) / 2;
|
|
// frml.Title = "Ultimi 25 racconti modificati:";
|
|
// int res = DB.GetListByUpdate(50, frml.LV);
|
|
// if ((res > 0) && (frml.ShowDialog() == DialogResult.OK)) {
|
|
// // Vi è un solo racocnto e lo visualizzo:
|
|
// rtb.Text = nav.SwitchTo(frml.ID);
|
|
// sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
// }
|
|
// frml.Close();
|
|
// //this.Select();
|
|
// return;
|
|
// #endregion
|
|
//}
|
|
#endregion
|
|
|
|
#region Keys.Alt+keys.I --> Navigazione fra i racconti via iniziale titolo:
|
|
//if (e.Alt && (!e.Shift) && (e.KeyCode == Keys.I)) {
|
|
// // Show All Iniziali
|
|
// frmList frml = new frmList();
|
|
// frml.Height = this.Height - 64;
|
|
// frml.Width = this.Width - 64;
|
|
// frml.Left = Left + (Width - frml.Width) / 2;
|
|
// frml.Top = Top + (Height - frml.Height) / 2;
|
|
// frml.Title = "Elenco iniziali dei titoli:";
|
|
// int res = DB.GetListByIniziali(frml.LV);
|
|
// if ((res > 0) && (frml.ShowDialog() == DialogResult.OK)) {
|
|
// if (frml.Num == 1) {
|
|
// // Per l'iniziale vi è 1 solo racconto, e quindi lo mostro direttamente:
|
|
// rtb.Text = nav.SwitchTo(frml.ID);
|
|
// sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
// } else {
|
|
// // Show all titoli con l'iniziale selezionata
|
|
// string iniziale = frml.Descr;
|
|
// res = DB.GetListByIniziale(iniziale, frml.LV);
|
|
// frml.Title = "Elenco titoli con l'iniziale " + iniziale;
|
|
// if ((res > 0) && (frml.ShowDialog() == DialogResult.OK)) {
|
|
// // Se racconto selezionato è uno solo, lo visualizzo, altrimenti mostro nuovo elenco
|
|
// if (frml.Num > 1) {
|
|
// // più racconti dallo stesso titolo:
|
|
// res = DB.GetListByTitle(frml.Descr, frml.LV);
|
|
// frml.Title = "Racconti con il titolo: " + frml.Descr;
|
|
// if ((res > 0) && (frml.ShowDialog() == DialogResult.OK)) {
|
|
// rtb.Text = nav.SwitchTo(frml.ID);
|
|
// sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
// }
|
|
// } else {
|
|
// // 1 solo racconto
|
|
// rtb.Text = nav.SwitchTo(frml.ID);
|
|
// sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// frml.Close();
|
|
// return;
|
|
//}
|
|
#endregion
|
|
|
|
#region Shift+keys.Alt+keys.D --> Visualizza tutti i racconti non letti con la data attuale:
|
|
//if (e.Alt && e.Shift && (e.KeyCode == Keys.D)) {
|
|
// // ricavo la data del racconto visualizzato:
|
|
// cRac rac = App.DB.GetRacById(nav.ActualID);
|
|
// string strYear = rac.Creato.Year.ToString("0000");
|
|
// string strMonth = rac.Creato.Month.ToString("00");
|
|
// string strDay = rac.Creato.Day.ToString("00");
|
|
// // Show tutti i racconti non letti della data indicata:
|
|
// frmList frml = new frmList();
|
|
// frml.Height = this.Height - 64;
|
|
// frml.Width = this.Width - 64;
|
|
// frml.Left = Left + (Width - frml.Width) / 2;
|
|
// frml.Top = Top + (Height - frml.Height) / 2;
|
|
// int res = DB.GetListByDay(strYear, strMonth, strDay, frml.LV);
|
|
// frml.Title = "Elenco racconti del giorno " + strDay + "/" + strMonth + "/" + strYear;
|
|
// if ((res > 0) && (frml.ShowDialog() == DialogResult.OK)) {
|
|
// // Se racconto selezionato è uno solo, lo visualizzo, altrimenti mostro nuovo elenco
|
|
// if (frml.Num > 1) {
|
|
// // più racconti dallo stesso titolo:
|
|
// res = DB.GetListByTitle(frml.Descr, frml.LV);
|
|
// frml.Title = "Racconti con il titolo: " + frml.Descr;
|
|
// if ((res > 0) && (frml.ShowDialog() == DialogResult.OK)) {
|
|
// rtb.Text = nav.SwitchTo(frml.ID);
|
|
// sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
// }
|
|
// } else {
|
|
// // 1 solo racconto
|
|
// rtb.Text = nav.SwitchTo(frml.ID);
|
|
// sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
// }
|
|
// }
|
|
// frml.Close();
|
|
// return;
|
|
//}
|
|
#endregion
|
|
|
|
#region Shift+Keys.Alt+keys.I --> Navigazione fra i racconti con la stessa iniziale del titolo:
|
|
//if (e.Alt && e.Shift && (e.KeyCode == Keys.I)) {
|
|
// // ricavo L'iniziale del titolo del racocnto visualizzato:
|
|
// cRac rac = App.DB.GetRacById(nav.ActualID);
|
|
// string iniziale = rac.Title.Substring(0, 1);
|
|
// // Show All Iniziali
|
|
// frmList frml = new frmList();
|
|
// frml.Height = this.Height - 64;
|
|
// frml.Width = this.Width - 64;
|
|
// frml.Left = Left + (Width - frml.Width) / 2;
|
|
// frml.Top = Top + (Height - frml.Height) / 2;
|
|
// int res = DB.GetListByIniziale(iniziale, frml.LV);
|
|
// frml.Title = "Elenco titoli con l'iniziale " + iniziale;
|
|
// if ((res > 0) && (frml.ShowDialog() == DialogResult.OK)) {
|
|
// // Se racconto selezionato è uno solo, lo visualizzo, altrimenti mostro nuovo elenco
|
|
// if (frml.Num > 1) {
|
|
// // più racconti dallo stesso titolo:
|
|
// res = DB.GetListByTitle(frml.Descr, frml.LV);
|
|
// frml.Title = "Racconti con il titolo: " + frml.Descr;
|
|
// if ((res > 0) && (frml.ShowDialog() == DialogResult.OK)) {
|
|
// rtb.Text = nav.SwitchTo(frml.ID);
|
|
// sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
// }
|
|
// } else {
|
|
// // 1 solo racconto
|
|
// rtb.Text = nav.SwitchTo(frml.ID);
|
|
// sbMessage.Text = string.Format("Racconto {0}", nav.ActualID.ToString("00000"));
|
|
// }
|
|
// }
|
|
// frml.Close();
|
|
// return;
|
|
//}
|
|
#endregion
|
|
|
|
#region Shift+keys.Alt+F12 --> Ricrea l'intero DB eliminando i racconti segnati da eliminare
|
|
if (e.KeyCode == Keys.F12 && (!e.Control) && e.Alt && e.Shift) {
|
|
// ToDo: Shift+Alt+F12 --> Ricrea l'intero DB eliminando i racconti segnati da eliminare
|
|
sbMessage.Text = "Shift+Alt+F12 --> Comando in sviluppo, non tutte le funzioni sono completate";
|
|
return;
|
|
}
|
|
#endregion
|
|
|
|
#region Keys.Alt+Keys.Q --> Esegue una query personalizzata:
|
|
if (e.Alt && (e.KeyCode == Keys.Z)) {
|
|
// ToDo: Keys.Alt+Keys.Q --> Esegue una query personalizzata
|
|
sbMessage.Text = "Keys.Alt+Keys.Q --> Comando in sviluppo, non tutte le funzioni sono completate";
|
|
return;
|
|
}
|
|
#endregion
|
|
|
|
#region Keys.Alt+keys.Z --> Analisi Racconti Duplicati:
|
|
if (e.Alt && (e.KeyCode == Keys.Z)) {
|
|
// ToDo: Keys.Alt+keys.Z --> Analisi Racconti Duplicati:
|
|
sbMessage.Text = "Shift+Alt+F12 --> Comando in sviluppo, non tutte le funzioni sono completate";
|
|
return;
|
|
}
|
|
#endregion
|
|
|
|
#region Keys.Alt+keys.S --> Crea uno snapshot di n racconti formattati e li converte in ebook
|
|
//if (e.Alt && (e.KeyCode == Keys.S)) {
|
|
// // // ToDo: Keys.Alt+keys.S --> Crea uno snapshot di n racconti formattati e li converte in ebook
|
|
// // sbMessage.Text = "Keys.Alt+keys.S --> Comando in sviluppo, non tutte le funzioni sono completate";
|
|
// // return;
|
|
// cmdCreaEbook();
|
|
//}
|
|
#endregion
|
|
|
|
#region Keys.Alt+keys.U --> Unione di due racconti
|
|
//if (e.Alt && (e.KeyCode == Keys.U)) {
|
|
// // ToDo: Keys.Alt+keys.U --> Unione di due racconti
|
|
// // - chiede l'ID dei due racconti da unire
|
|
// frmIDs frmid = new frmIDs();
|
|
// frmid.Left = Left + (Width - frmid.Width) / 2;
|
|
// frmid.Top = Top + (Height - frmid.Height) / 2;
|
|
// if (frmid.ShowDialog() != DialogResult.OK) {
|
|
// sbMessage.Text = "Anullato inserimento degli ID dei racconti da unire";
|
|
// return;
|
|
// }
|
|
// if ((frmid.IDleft <= 0) || (frmid.IDright <= 0)) {
|
|
// sbMessage.Text = "ID dei racconti da unire non validi";
|
|
// return;
|
|
// }
|
|
// // - ricavo i due racconti da unire:
|
|
// cRac left = DB.GetRacById(frmid.IDleft);
|
|
// cRac right = DB.GetRacById(frmid.IDright);
|
|
// frmid.Close();
|
|
// // - visualizza il form di unione
|
|
// frmUnion frm = new frmUnion(left, right, DB);
|
|
// if (frm.ShowDialog() == DialogResult.OK) {
|
|
// // - Left: il racconto unione:
|
|
// left = frm.Unione;
|
|
// // - Right: lo indico come duplicato:
|
|
// right.Title = "Doppione";
|
|
// right.SubTitle = left.strIDrac;
|
|
// right.Voto = "Da Cancellare";
|
|
// right.Tags.Clear();
|
|
// right.Tags.Add("Doppione");
|
|
// right.Notes.Clear();
|
|
// right.Notes.Add(new cNota("SrcFile", "Doppione"));
|
|
// right.Trama = "Racconto duplicato del " + left.strIDrac;
|
|
// // - Aggiorno il DB
|
|
// if ((right.IsValid) && (left.IsValid)) {
|
|
// App.DB.UpdateRac(right);
|
|
// App.DB.UpdateRac(left);
|
|
// }
|
|
// }
|
|
// frm.Close();
|
|
// return;
|
|
//}
|
|
#endregion
|
|
|
|
#region
|
|
|
|
#endregion
|
|
}
|
|
|
|
|
|
private void frmReader_FormClosing(object sender, FormClosingEventArgs e) {
|
|
// Prima di chiudere, devo fermare l'importazione o lo scraping
|
|
if (serviceCrawler != null) { serviceCrawler.StopWorker(); }
|
|
if (ServiceImporter != null) { ServiceImporter.StopWorker(); }
|
|
}
|
|
|
|
|
|
async void MenuItem_Skraping_Start_Click(object sender, EventArgs e) {
|
|
// Update menu
|
|
mSkrStart.Enabled = false;
|
|
mSkrStop.Enabled = true;
|
|
mImpStart.Enabled = false;
|
|
mImpStop.Enabled = false;
|
|
|
|
// - Creo istanza del client per il sito con autenticazione:
|
|
sbStatusLabel.Text = "Login on A69";
|
|
siteA69 = new cSite_A69();
|
|
|
|
// - Eseguo l'autenticazione
|
|
bool res = await siteA69.Authenticate();
|
|
if (res) {
|
|
sbStatusLabel.Text = "sito loggato: " + res.ToString();
|
|
Logger.Information("A69 logged");
|
|
} else {
|
|
Logger.Information("Errore di autenticazione al sito A69.");
|
|
return;
|
|
}
|
|
|
|
// - Verifico path per il download
|
|
if (!System.IO.Directory.Exists(Cfg.Settings.PathDownloadWorking)) System.IO.Directory.CreateDirectory(Cfg.Settings.PathDownloadWorking);
|
|
|
|
// Preparo il servizio
|
|
serviceCrawler = new Service_Crawler(sb);
|
|
// Inserisco i link iniziali nella coda
|
|
if (!cLink_A69.InsertStartLink(serviceCrawler)) {
|
|
sbStatusLabel.Text = "A69 fault.";
|
|
return;
|
|
}
|
|
// avvio il servizio
|
|
serviceCrawler.StartWorker(siteA69);
|
|
}
|
|
|
|
void MenuItem_Skraping_Stop_Click(object sender, EventArgs e) {
|
|
// Update menu
|
|
mSkrStart.Enabled = false;
|
|
mSkrStop.Enabled = false;
|
|
mImpStart.Enabled = true;
|
|
mImpStop.Enabled = false;
|
|
|
|
if (serviceCrawler != null) { serviceCrawler.StopWorker(); }
|
|
}
|
|
|
|
void MenuItem_Importer_Start_Click(object sender, EventArgs e) {
|
|
// Update menu
|
|
mSkrStart.Enabled = false;
|
|
mSkrStop.Enabled = false;
|
|
mImpStart.Enabled = false;
|
|
mImpStop.Enabled = true;
|
|
|
|
// Preparo il servizio
|
|
ServiceImporter = new Service_Importer(sb);
|
|
|
|
// Per ora uso la directory di default, poi metteremo selezione
|
|
string path = Cfg.Settings.PathDownloadWorking;
|
|
|
|
// avvio il servizio
|
|
ServiceImporter.StartWorker(path);
|
|
|
|
}
|
|
void MenuItem_Importer_Stop_Click(object sender, EventArgs e) {; }
|
|
|
|
|
|
}
|
|
}
|