Torna al Thread
public partial class Form1 : Form
{
int totMeta;
int CurrMeta;
HtmlElementCollection metaColl;
public Form1()
{
InitializeComponent();
totMeta = 0;
CurrMeta = -1;
labCurrMeta.Text = "-";
labTotMeta.Text = totMeta.ToString();
this.Invalidate();
}
private void buttonNaviga_Click(object sender, EventArgs e)
{
wb.Navigate("www.sito.it");
}
private void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
checkBoxDC.Checked = true;
ContaMetaTotali();
UpdateTotMetaLabel();
}
private void UpdateTotMetaLabel()
{
labTotMeta.Text = totMeta.ToString();
labTotMeta.Invalidate();
}
/// <summary>
/// Qui riempio le variabili di classe che permettono l'automazione dei button e le visualizzazioni
/// </summary>
private void ContaMetaTotali()
{
HtmlDocument doc = wb.Document;
metaColl = doc.GetElementsByTagName("meta");
totMeta = metaColl.Count;
}
private void wb_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
checkBoxDC.Checked = false;
}
private void buttonPrev_Click(object sender, EventArgs e)
{
if (CurrMeta < 0)
return;
else
{
CurrMeta--;
UpdateLabels(CurrMeta);
}
}
private void UpdateLabels(int CurrMeta)
{
if (CurrMeta >= 0 && CurrMeta < metaColl.Count)
{
string description = metaColl[CurrMeta].GetAttribute("name").ToString();
string content = metaColl[CurrMeta].GetAttribute("content").ToString();
txtContent.Text = content;
labCurrMeta.Text = CurrMeta.ToString();
txtDesc.Text = description;
txtDesc.Invalidate();
labCurrMeta.Invalidate();
txtContent.Invalidate();
}
}
private void buttonSucc_Click(object sender, EventArgs e)
{
if (CurrMeta < metaColl.Count-1)
{
CurrMeta++;
UpdateLabels(CurrMeta);
}
else
return;
}
}