我添加了四个图像,默认情况下我有背景图像。我用一个按钮随机改变背景。这是全景页面,我只想让我的应用程序保存最后一个状态(即记住最后一个背景图像),如果我的应用程序被激活,那么最后一个图像应该是默认背景图像。由于我已经在我的应用程序中添加了一些图像,所以我认为这不需要隔离存储。我需要的是当前背景图像(imguri)是否为bg1.jpg,如果我退出应用程序并重新启动它,则默认背景图像应为bg1.jpg。需要帮忙!
private void BackgroundBrowser_Click(object sender, RoutedEventArgs e)
{
string imguri = "";
click_count = click_count % 5;
switch (click_count)
{
case 0: imguri = "Image/bg.jpg"; break;
case 1: imguri = "Image/bg1.jpg"; break;
case 2: imguri = "Image/bg3.jpg"; break;
case 3: imguri = "Image/bg2.jpg"; break;
case 4: imguri = ""; break;
}
click_count++;
var app = Application.Current as App;
app.appBmp = new BitmapImage(new Uri(imguri, UriKind.Relative));
ImageBrush imageBrush = new ImageBrush();
imageBrush.Stretch = Stretch.UniformToFill;
imageBrush.Opacity = 0.7;
imageBrush.ImageSource = app.appBmp;
this.LayoutRoot.Background = imageBrush;
app.appbrush = imageBrush;
app.backchanged = true;
}