【发布时间】:2014-06-07 17:42:48
【问题描述】:
几个月前我创建了一个 Windows Phone 应用程序,现在我也希望将它用于 Windows 应用商店。 除了保存高分之外,我已经完成了所有工作。我尝试过通读 API,但由于某种原因似乎无法理解。
那么,谁能告诉我以下 Windows Phone 代码对于 Windows 应用商店应用程序应该是什么样的?考虑到其他一切,我预计它会几乎相同。谢谢。
private IsolatedStorageSettings appsettings = IsolatedStorageSettings.ApplicationSettings;
private void SetHighScore()
{
if (appsettings.Contains("highscore"))
{
int high = Convert.ToInt32(appsettings["highscore"]);
if (score > high) //if the current score is greater than the high score, make it the new high score
{
appsettings.Remove("highscore");
appsettings.Add("highscore", score);
GoogleAnalytics.EasyTracker.GetTracker().SendEvent("mainpage", "highscore " + score.ToString(), null, score);
}
else //if the current score if less than or equal to the high score, do nothing
{
//do nothing
}
}
else
{
appsettings.Add("highscore", score); //if there is no high score already set, set it to the current score
}
}
private void GetHighScore()
{
if (appsettings.Contains("highscore")) //if there is a highscore display it
{
int high = Convert.ToInt32(appsettings["highscore"]);
txbHighScore.Text = high.ToString();
}
else //if there is no highscore display zero
{
txbHighScore.Text = "0";
}
}
【问题讨论】:
标签: c# windows-store-apps storage windows-store