ImageList

public void LoadImageList(string path, ref ImageList imageList)
{
// load files & add new data
imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth24Bit;
imageList.ImageSize = new System.Drawing.Size(30, 30);
imageList.TransparentColor = System.Drawing.Color.Transparent;

DirectoryInfo dir = new DirectoryInfo(path);
foreach (FileInfo file in dir.GetFiles())
{
try
{
imageList.Images.Add(Image.FromFile(file.FullName));
System.Diagnostics.Trace.WriteLine(“image loaded: ” + file.FullName);
}
catch
{
Console.WriteLine(“Failed to retrieve files”);
}
}
}

 

https://msdn.microsoft.com/ko-kr/library/aa983754(v=vs.71).aspx

ReadRssFeed

using System.Net; // HttpWebRequest

public static WeatherData ReadWeatherDataFeedBy(long woeid)
{
//create a new list of the rss feed items to return
string url = string.Format(“http://weather.yahooapis.com/forecastrss?w={0}”, woeid);

try
{
//create an http request which will be used to retrieve the rss feed
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Timeout = 200000;
request.Method = WebRequestMethods.Http.Get;

HttpWebResponse response = request.GetResponse() as HttpWebResponse;

if (response.StatusCode != HttpStatusCode.OK)
{
System.Diagnostics.Trace.WriteLine(“Response StatusCode: ” + response.StatusCode);
return null;
}

//loop through the rss items in the dataset and populate the list of rss feed items
using (DataSet rssData = new DataSet())
{
//read the xml from the stream of the web request
rssData.ReadXml(response.GetResponseStream());
//loop through the rss items in the dataset and populate the list of rss feed item
foreach (DataRow itemRow in rssData.Tables[“item”].Rows)
{
WeatherData weatherData = new WeatherData();
weatherData.WOEID = woeid;
weatherData.Title = (string)itemRow[“title”]; // Convert.ToString(itemRow[“title”]);
double lat, lon;
if (!double.TryParse((string)itemRow[“lat”], out lat))
return null;
weatherData.Lat = lat; //  latitude
if (!double.TryParse((string)itemRow[“long”], out lon))
return null;
weatherData.Lon = lon;  // longitude
weatherData.Link = url; // url link
string pubDate = (string)itemRow[“pubDate”]; // pubDate
string description = (string)itemRow[“description”]; // description

foreach (DataRow conditionRow in rssData.Tables[“condition”].Rows)
{
weatherData.Condition.Text = (string)conditionRow[“text”]; // weather condition text
weatherData.Condition.Code = int.Parse((string)conditionRow[“code”]); // weather condition code
weatherData.Condition.Temperature = int.Parse((string)conditionRow[“temp”]); // weather temperature
weatherData.Condition.Date = (string)conditionRow[“date”]; // weather published date
}

foreach (DataRow focastRow in rssData.Tables[“forecast”].Rows)
{
weatherData.FiveForecast.Add(new Forecast()
{
Day = (string)focastRow[“day”], // day
Date = (string)focastRow[“date”], // date
Low = int.Parse((string)focastRow[“low”]),  // low temperature
High = int.Parse((string)focastRow[“high”]), // high temperature
Text = (string)focastRow[“text”], // weather condition text
Code = int.Parse((string)focastRow[“code”]) // code
});
}

System.Diagnostics.Trace.WriteLine(weatherData);
return weatherData;
}
return null;
}
}
catch (Exception e)
{
System.Diagnostics.Trace.WriteLine(“Error while reading ” + e.Message);
return null;
}
}

SERIALIZATION

Person Serialization (Using BinaryFormatter or SoapFormatter)
http://dis.dankook.ac.kr/lectures/hci09/entry/Simple-Serialization

Person XML Serialization (Using XML Serializer or Soap XML Serializer)
http://dis.dankook.ac.kr/lectures/hci09/entry/XML-Serialization

Person Using ISerialable Interface
http://dis.dankook.ac.kr/lectures/hci09/entry/ISerialable

PersonList Serialization (Using BinaryFormatter or SoapFormatter)
http://dis.dankook.ac.kr/lectures/hci09/entry/PersonList-Serialization