編輯:地圖[] []充滿了按鈕如何使用帶按鈕的流媒體播放器。圖片
主要問題是.image似乎無法保存。 我想做一個負載,當我加載它在每個地圖[i] [j]恢復其以前的狀態。一切似乎exept的圖像配
FileStream file = new FileStream(@""+AppDomain.CurrentDomain.BaseDirectory+ "\\objects\\savegame"+spacing+".sav", FileMode.Create, FileAccess.ReadWrite);
StreamWriter sw = new StreamWriter(file);
for (Int32 i = 0; i <columns; i++)
{
for (Int32 j = 0; j < columns; j++)
{
sw.WriteLine(map[i][j].Enabled);
sw.WriteLine(map[i][j].Enabled);
sw.WriteLine(map[i][j].Image);
sw.WriteLine(map[i][j].Tag);
sw.WriteLine(map[i][j].Text);
sw.WriteLine(map[i][j].Name);
sw.WriteLine(map[i][j].Height);
sw.WriteLine(map[i][j].Width);
}
}
FileStream file = new FileStream(@"" + AppDomain.CurrentDomain.BaseDirectory + "\\objects\\savegame" + spacing + ".sav", FileMode.Create, FileAccess.ReadWrite);
StreamReader sr = new StreamReader(file);
for (Int32 i = 0; i < columns; i++)
{
for (Int32 j = 0; j < columns; j++)
{
map[i][j].Enabled = Convert.ToBoolean(sr.ReadLine());
map[i][j].Image = Convert.ToString(sr.ReadLine());// this is the problem
map[i][j].Tag = Convert.ToString(sr.ReadLine());
map[i][j].Text = Convert.ToString(sr.ReadLine());
map[i][j].Name = Convert.ToString(sr.ReadLine());
map[i][j].Height = Convert.ToInt32(sr.ReadLine());
map[i][j].Width = Convert.ToInt32(sr.ReadLine());
}
}
sr.Close();
}
//Sample location for the image --->map[i][j].Image = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "objects\\map\\mapgrass" + spacing + ".png");
什麼意思是「.image」? – 2013-03-22 15:16:01
我期望它將當前圖像的位置保存在一行中,但情況並非如此 – Kapein 2013-03-22 15:17:49
如果您需要位置,則需要保存諸如Left或Top之類的屬性。看到我的答案。 – 2013-03-22 15:24:38