private void backgroundWorker5_DoWork(object sender, DoWorkEventArgs e)
{
//****************************************CryptoPanic*******************************************
try
{
string url = "https://cryptopanic.com/api/posts/?auth_token=YOURAPIKEYcurrencies=" + Curr1.ToString()+","+Curr2.ToString();
string json = new WebClient().DownloadString(url);
var dataDeserialized = JsonConvert.DeserializeObject
dt_CryptoPanic.Clear();
try
{
for (int b = 0; b <= dataDeserialized.results.Count - 1; b++)
{
dt_CryptoPanic.Rows.Add(
dataDeserialized.results.domain,
dataDeserialized.results.votes.negative,
dataDeserialized.results.votes.positive,
dataDeserialized.results.votes.important,
dataDeserialized.results.votes.liked,
dataDeserialized.results.votes.disliked,
dataDeserialized.results.votes.lol,
dataDeserialized.results.votes.toxic,
dataDeserialized.results.votes.saved,
dataDeserialized.results.source.domain,
dataDeserialized.results.source.title,
dataDeserialized.results.source.region,
dataDeserialized.results.source.path,
dataDeserialized.results.title,
dataDeserialized.results.published_at,
dataDeserialized.results.slug,
dataDeserialized.results.currencies[0].code,
dataDeserialized.results.currencies[0].title,
dataDeserialized.results.currencies[0].slug,
dataDeserialized.results.currencies[0].url,
dataDeserialized.results.id,
dataDeserialized.results.created_at,
dataDeserialized.results.url
);
}
}
catch (InvalidOperationException ex)
{
MessageBox.Show(ex.Message, "BGW5 Second Try");
}
}
catch (InvalidOperationException ex)
{
MessageBox.Show(ex.Message, "BGW5 Premier Try");
}
}
private void backgroundWorker5_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
dataGridView2.Rows.Clear();
for (int c = 0; c <= dt_CryptoPanic.Rows.Count - 1; c++)
{
dataGridView2.Rows.Add(
//dt_CryptoPanic.Rows[c].ItemArray[0],//domain
dt_CryptoPanic.Rows[c].ItemArray[1],//negative
dt_CryptoPanic.Rows[c].ItemArray[2],//positive
dt_CryptoPanic.Rows[c].ItemArray[3],//important
dt_CryptoPanic.Rows[c].ItemArray[4],//liked
dt_CryptoPanic.Rows[c].ItemArray[5],//disliked
dt_CryptoPanic.Rows[c].ItemArray[6],//lol
dt_CryptoPanic.Rows[c].ItemArray[7],//toxic
//dt_CryptoPanic.Rows[c].ItemArray[8],//saved
dt_CryptoPanic.Rows[c].ItemArray[9],//source_domaine
//dt_CryptoPanic.Rows[c].ItemArray[10],//source_title
//dt_CryptoPanic.Rows[c].ItemArray[11],//source_region
//dt_CryptoPanic.Rows[c].ItemArray[12],//source_path
dt_CryptoPanic.Rows[c].ItemArray[13],//title
dt_CryptoPanic.Rows[c].ItemArray[14],//published_at
//dt_CryptoPanic.Rows[c].ItemArray[15],//slug
dt_CryptoPanic.Rows[c].ItemArray[16]//currencies_code
//dt_CryptoPanic.Rows[c].ItemArray[17],//currencies_title
//dt_CryptoPanic.Rows[c].ItemArray[18],//currencies_slug
//dt_CryptoPanic.Rows[c].ItemArray[19],//currencies_url
//dt_CryptoPanic.Rows[c].ItemArray[20],//id
//dt_CryptoPanic.Rows[c].ItemArray[21]//created_at
//dt_CryptoPanic.Rows[c].ItemArray[22]//url
);
}
dataGridView2.ClearSelection();
for (int c = 0; c <= dataGridView2.Rows.Count - 1; c++)
{
if (Convert.ToInt32(dataGridView2.Rows[c].Cells[0].Value) >0)
{
dataGridView2.Rows[c].Cells[0].Style.BackColor = Color.Red;
}
if (Convert.ToInt32(dataGridView2.Rows[c].Cells[1].Value) > 0)
{
dataGridView2.Rows[c].Cells[1].Style.BackColor = Color.Green;
}
if (Convert.ToInt32(dataGridView2.Rows[c].Cells[2].Value) > 0)
{
dataGridView2.Rows[c].Cells[2].Style.BackColor = Color.Yellow;
}
if (Convert.ToInt32(dataGridView2.Rows[c].Cells[3].Value) > 0)
{
dataGridView2.Rows[c].Cells[3].Style.BackColor = Color.Blue;
}
if (Convert.ToInt32(dataGridView2.Rows[c].Cells[4].Value) > 0)
{
dataGridView2.Rows[c].Cells[4].Style.BackColor = Color.Fuchsia;
}
if (Convert.ToInt32(dataGridView2.Rows[c].Cells[5].Value) > 0)
{
dataGridView2.Rows[c].Cells[5].Style.BackColor = Color.White;
dataGridView2.Rows[c].Cells[5].Style.ForeColor = Color.Black;
}
if (Convert.ToInt32(dataGridView2.Rows[c].Cells[6].Value) > 0)
{
dataGridView2.Rows[c].Cells[6].Style.BackColor = Color.Red;
}
}
TraceNews();
timer3.Start();
}
private void TraceNews()
{
int Neg_count = 0;
int Pos_count = 0;
int Imp_count = 0;
int Lik_count = 0;
int Dis_count = 0;
int Lol_count = 0;
int Tox_count = 0;
for (int r = 0; r <= dataGridView2.Rows.Count - 1; r++)
{
Neg_count = Neg_count + Convert.ToInt32(dataGridView2.Rows[r].Cells[0].Value);
Pos_count = Pos_count + Convert.ToInt32(dataGridView2.Rows[r].Cells[1].Value);
Imp_count = Imp_count + Convert.ToInt32(dataGridView2.Rows[r].Cells[2].Value);
Lik_count = Lik_count + Convert.ToInt32(dataGridView2.Rows[r].Cells[3].Value);
Dis_count = Dis_count + Convert.ToInt32(dataGridView2.Rows[r].Cells[4].Value);
Lol_count = Lol_count + Convert.ToInt32(dataGridView2.Rows[r].Cells[5].Value);
Tox_count = Tox_count + Convert.ToInt32(dataGridView2.Rows[r].Cells[6].Value);
}
chart3.Series[0].Points.Clear();
chart3.Series[1].Points.Clear();
chart3.Series[2].Points.Clear();
chart3.Series[3].Points.Clear();
chart3.Series[4].Points.Clear();
chart3.Series[5].Points.Clear();
chart3.Series[6].Points.Clear();
chart3.Series["Negative"].Points.AddY(Neg_count);
chart3.Series["Positive"].Points.AddY(Pos_count);
chart3.Series["Important"].Points.AddY(Imp_count);
chart3.Series["Liked"].Points.AddY(Lik_count);
chart3.Series["Disliked"].Points.AddY(Dis_count);
chart3.Series["Lol"].Points.AddY(Lol_count);
chart3.Series["Toxic"].Points.AddY(Tox_count);
chart3.Series["Negative"].IsValueShownAsLabel = true;
chart3.Series["Negative"].LabelFormat = "{#}";
chart3.Series["Negative"].LabelForeColor = Color.White;
chart3.Series["Positive"].IsValueShownAsLabel = true;
chart3.Series["Positive"].LabelFormat = "{#}";
chart3.Series["Positive"].LabelForeColor = Color.White;
chart3.Series["Important"].IsValueShownAsLabel = true;
chart3.Series["Important"].LabelFormat = "{#}";
chart3.Series["Important"].LabelForeColor = Color.White;
chart3.Series["Liked"].IsValueShownAsLabel = true;
chart3.Series["Liked"].LabelFormat = "{#}";
chart3.Series["Liked"].LabelForeColor = Color.White;
chart3.Series["Disliked"].IsValueShownAsLabel = true;
chart3.Series["Disliked"].LabelFormat = "{#}";
chart3.Series["Disliked"].LabelForeColor = Color.White;
chart3.Series["Lol"].IsValueShownAsLabel = true;
chart3.Series["Lol"].LabelFormat = "{#}";
chart3.Series["Lol"].LabelForeColor = Color.White;
chart3.Series["Toxic"].IsValueShownAsLabel = true;
chart3.Series["Toxic"].LabelFormat = "{#}";
chart3.Series["Toxic"].LabelForeColor = Color.White;
//chart3.ChartAreas[0].AxisX.Maximum = 2;
chart3.ChartAreas[0].RecalculateAxesScale();
//chart3.ChartAreas[0].AxisY.Maximum = 10;
}
}
}