[Snippets]Parse json string and fullscreen form on C#

1. Parse a json string from http response.

Json string:
{
	"name": "Hero",
	"age": 5,
	"color": "silver"
};
C# code:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("your url");

request.MaximumAutomaticRedirections = 4;

request.MaximumResponseHeadersLength = 4;

// Set credentials to use for this request.

request.Credentials = CredentialCache.DefaultCredentials;

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

using (var reader = new System.IO.StreamReader(response.GetResponseStream(), Encoding.UTF8))

{

string responseText = reader.ReadToEnd();

var jss = new JavaScriptSerializer();

// you can use this data type: List<Dictionary<string, string>> if you have many keyvalue pairs

var halls = jss.Deserialize<Dictionary<string, string>>(responseText);     // use dictionary type to convert keyvalue pair from json string

}

2. Make your form fullscreen and show it on extend screen first.

BTW, you can use this to do slideshow with picturebox

Screen[] screens = Screen.AllScreens;

Rectangle rect = screens[0].WorkingArea;

if (screens.Count() == 2 && screens[0].Primary)

{

rect = screens[1].WorkingArea;    // set our rect as the second screen if the first one is primary

}

// form setting

PictureBox showPic = new PictureBox();

Form showForm = new Form();

showForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;   // no border, only show content

showForm.Width = rect.Width;

showForm.Height = rect.Height;

showForm.Location = rect.Location;

showForm.TopMost = true;   // always on top

showPic.Image = Image.FromFile("imagefile");

showPic.Size = showForm.Size;

showPic.SizeMode = PictureBoxSizeMode.Zoom;

showPic.Location = new Point(0, 0);

showForm.Controls.Add(showPic);

showForm.Show();