有没有办法简化这段代码?或以任何方式创建另一个类页面以保持主页尽可能干净。我计划拥有数百个文本文件,因为我是新手,所以我不是解决这个问题的最佳方法。我正在尝试制作一个带有 Xbox 360 成就指南的应用程序,但每场游戏平均大约有 40 个成就。(这是分配的文本文件)。
if (selectedIndex == "0")
{
var Tutorial = Application.GetResourceStream(new Uri("Resources/Games/MaxPayne3/StoryRelated.txt", UriKind.Relative));
using (Stream Text = Tutorial.Stream)
{
StreamReader sr = new StreamReader(Text);
Guide.Text = "Story Complete [MEDIUM]\n" + Environment.NewLine + sr.ReadToEnd();
Title.Text = "Feel The Payne";
AppBarMenuDisable.IsEnabled = false;
}
}
else if (selectedIndex == "1")
{
var Tutorial = Application.GetResourceStream(new Uri("Resources/Games/MaxPayne3/StoryRelated.txt", UriKind.Relative));
using (Stream Text = Tutorial.Stream)
{
StreamReader sr = new StreamReader(Text);
Guide.Text = "Story Complete [HARD]\n" + Environment.NewLine + sr.ReadToEnd();
Title.Text = "Serious Payne";
AppBarMenuDisable.IsEnabled = false;
}
}
else if (selectedIndex == "2")
{
var Tutorial = Application.GetResourceStream(new Uri("Resources/Games/MaxPayne3/StoryRelated.txt", UriKind.Relative));
using (Stream Text = Tutorial.Stream)
{
StreamReader sr = new StreamReader(Text);
Guide.Text = "Story Complete [OLD SCHOOL]\n" + Environment.NewLine + sr.ReadToEnd();
Title.Text = "Maximum Payne";
AppBarMenuDisable.IsEnabled = false;
}
}
else if (selectedIndex == "3")
{
var Tutorial = Application.GetResourceStream(new Uri("Resources/Games/MaxPayne3/TextFile1.txt", UriKind.Relative));
using (Stream Text = Tutorial.Stream)
{
StreamReader sr = new StreamReader(Text);
Guide.Text = sr.ReadToEnd();
Title.Text = "Payne In The Ass";
AppBarMenuDisable.IsEnabled = false;
}
}
else if (selectedIndex == "4")
{
var Tutorial = Application.GetResourceStream(new Uri("Resources/Games/MaxPayne3/StoryRelated.txt", UriKind.Relative));
using (Stream Text = Tutorial.Stream)
{
StreamReader sr = new StreamReader(Text);
Guide.Text = sr.ReadToEnd();
Title.Text = "Part I Complete";
AppBarMenuDisable.IsEnabled = false;
}
}
else if (selectedIndex == "5")
{
var Tutorial = Application.GetResourceStream(new Uri("Resources/Games/MaxPayne3/StoryRelated.txt", UriKind.Relative));
using (Stream Text = Tutorial.Stream)
{
StreamReader sr = new StreamReader(Text);
Guide.Text = sr.ReadToEnd();
Title.Text = "Part II Complete";
AppBarMenuDisable.IsEnabled = false;
}
}
else if (selectedIndex == "6")
{
var Tutorial = Application.GetResourceStream(new Uri("Resources/Games/MaxPayne3/StoryRelated.txt", UriKind.Relative));
using (Stream Text = Tutorial.Stream)
{
StreamReader sr = new StreamReader(Text);
Guide.Text = sr.ReadToEnd();
Title.Text = "Part III Complete";
AppBarMenuDisable.IsEnabled = false;
}
}
else if (selectedIndex == "7")
{
var Tutorial = Application.GetResourceStream(new Uri("Resources/Games/MaxPayne3/TextFile2.txt", UriKind.Relative));
using (Stream Text = Tutorial.Stream)
{
StreamReader sr = new StreamReader(Text);
Guide.Text = sr.ReadToEnd();
Title.Text = "A New York Minute";
AppBarMenuDisable.IsEnabled = false;
}
}
else if (selectedIndex == "8")
{
var Tutorial = Application.GetResourceStream(new Uri("Resources/Games/MaxPayne3/TextFile3.txt", UriKind.Relative));
using (Stream Text = Tutorial.Stream)
{
StreamReader sr = new StreamReader(Text);
Guide.Text = sr.ReadToEnd();
Title.Text = "The Shadows Rushed Me";
AppBarMenuDisable.IsEnabled = false;
}
}
else if (selectedIndex == "9")
{
var Tutorial = Application.GetResourceStream(new Uri("Resources/Games/MaxPayne3/TextFile4.txt", UriKind.Relative));
using (Stream Text = Tutorial.Stream)
{
StreamReader sr = new StreamReader(Text);
Guide.Text = sr.ReadToEnd();
Title.Text = "Out The Window";
YouTubeLink.URL = "http://www.youtube.com/watch?v=lRg6ygA-M_Y";
}
}
我希望将这些文本文件放在 Internet 的某个位置,因为用户可以根据需要检索它们。