Compilata da CSiCoAlm il 2021/11/07 - Corretto bug rilevato (ISSUE 01) - Inserita solita icona per i tools. - Sistemato la classe cTools inserendo tutti i tools trovati finora
90 lines
3.3 KiB
C#
90 lines
3.3 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.Diagnostics;
|
|
|
|
namespace A69WD {
|
|
|
|
public partial class frmDownloader : Form {
|
|
|
|
|
|
public frmDownloader() {
|
|
InitializeComponent();
|
|
this.Text = String.Format("A69WD - Dowloader Testi Vrs {0}", cTools.AssemblyVersion);
|
|
engine = new cA69Engine(this.wb1);
|
|
engine.Updating += Engine_Updating;
|
|
}
|
|
|
|
cA69Engine engine = null;
|
|
|
|
|
|
/// <summary>
|
|
/// Metodo per scansionare i link da un file di testo ed inserirli come da downloadare se non ci sono già
|
|
/// </summary>
|
|
private void btnImportLinks_Click(object sender, EventArgs e) {
|
|
// Chiedo il file di testo da caricare
|
|
lblST.Text = " ";
|
|
this.openFileDialog1.InitialDirectory = Cfg.Settings.PathApplicationRoot;
|
|
if (this.openFileDialog1.ShowDialog() == DialogResult.OK) {
|
|
lblST.Text = string.Format("Importati {0} link", engine.ImportLinkFromFile(openFileDialog1.FileNames[0]));
|
|
}
|
|
}
|
|
|
|
private void btnDownloadAll_Click(object sender, EventArgs e) {
|
|
engine.Start(true);
|
|
}
|
|
|
|
private void btnShowLog_Click(object sender, EventArgs e) {
|
|
cTools.ShowOnNotepad(Cfg.Settings.PathFileLogs);
|
|
}
|
|
|
|
private void btnHide_Click(object sender, EventArgs e) {
|
|
if (MessageBox.Show("Metodo ancora da terminare, la finestra non sarà più visibile, killare il processo", "ATTENZIONE", MessageBoxButtons.OKCancel) == DialogResult.OK){
|
|
this.Hide();
|
|
}
|
|
}
|
|
|
|
private void btnClose_Click(object sender, EventArgs e) { if (engine.Stop()) this.Close(); }
|
|
|
|
#region Gestione eventi dal engine
|
|
|
|
private void Engine_Updating(object sender, EngineEventArgs e) { EngineUpdatingStatus(e.Message, e.NTot, e.NtoDown, e.NDown); }
|
|
|
|
delegate void EngineUpdatingStatusCallback(string Message, int NTot, int NtoDown, int NDown);
|
|
private void EngineUpdatingStatus(string Message, int NTot, int NtoDown, int NDown) {
|
|
try {
|
|
// InvokeRequired required compares the thread ID of the
|
|
// calling thread to the thread ID of the creating thread.
|
|
// If these threads are different, it returns true.
|
|
if (lblST.InvokeRequired) {
|
|
EngineUpdatingStatusCallback callBack = new EngineUpdatingStatusCallback(EngineUpdatingStatus);
|
|
this.Invoke(callBack, new object[] { Message, NTot, NtoDown, NDown });
|
|
} else {
|
|
lblST.Text = string.Format("{4} - {3} | {2} | {1} - {0}", Message, NTot, NtoDown, NDown, DateTime.Now.ToString("HH:mm:ss"));
|
|
Logger.Information(lblST.Text);
|
|
}
|
|
} catch (Exception ex) {
|
|
Logger.Log(new object[] { "Error Code: ER05553", "Errore in EngineUpdatingStatus():", ex });
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}//class frmDownloader
|
|
}//namespace A69WD
|