76 lines
2.3 KiB
C#
76 lines
2.3 KiB
C#
|
using Newtonsoft.Json;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.Data;
|
|||
|
using System.Drawing;
|
|||
|
using System.IO;
|
|||
|
using System.Linq;
|
|||
|
using System.Net;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Windows.Forms;
|
|||
|
|
|||
|
namespace crypto
|
|||
|
{
|
|||
|
public partial class warn : Form
|
|||
|
{
|
|||
|
public warn()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
updateKonachanPic(this.pictureBox1);
|
|||
|
}
|
|||
|
public warn(string t)
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
this.label1.Text = t;
|
|||
|
this.label1.Left = ((this.Size.Width / 2) - (this.pictureBox1.Width / 2));
|
|||
|
updateKonachanPic(this.pictureBox1);
|
|||
|
}
|
|||
|
|
|||
|
private void pictureBox1_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
pictureBox1.Dispose();
|
|||
|
this.Dispose();
|
|||
|
}
|
|||
|
public static void updateKonachanPic(PictureBox pictureBox)
|
|||
|
{
|
|||
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://konachan.net/post.json?tags=+order%3Arandom+rating%3Asafe+blood&limit=1");
|
|||
|
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
|||
|
if (response.StatusCode == HttpStatusCode.OK)
|
|||
|
{
|
|||
|
Stream receiveStream = response.GetResponseStream();
|
|||
|
StreamReader readStream = null;
|
|||
|
|
|||
|
if (response.CharacterSet == null)
|
|||
|
{
|
|||
|
readStream = new StreamReader(receiveStream);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
|
|||
|
}
|
|||
|
|
|||
|
string data = readStream.ReadToEnd();
|
|||
|
JsonTextReader reader = new JsonTextReader(new StringReader(data));
|
|||
|
|
|||
|
List<KonachanPostJson> dataSet = JsonConvert.DeserializeObject<List<KonachanPostJson>>(data);
|
|||
|
KonachanPostJson[] bla = dataSet.ToArray();
|
|||
|
String t = bla[0].JpegUrl;
|
|||
|
Console.WriteLine(t);
|
|||
|
|
|||
|
pictureBox.ImageLocation = "http:" + t;
|
|||
|
response.Close();
|
|||
|
readStream.Close();
|
|||
|
|
|||
|
}
|
|||
|
pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
|
|||
|
}
|
|||
|
|
|||
|
private void label1_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|