1

我可以在将图像保存到媒体库时显示进度指示器,但我不知道如何IsVisible = false在图片保存后更改。以下是我用于它的代码 -

async void Save_Click(object sender, EventArgs e)
    {
        ProgressIndicator progress = new ProgressIndicator();
        progress.IsVisible = true;
        progress.IsIndeterminate = true;
        progress.Text = "saving image...";

        //Save a copy of the image
        using (MediaLibrary library = new MediaLibrary())
        {
            var imgStream = (await App.CurrPhoto.RawSession.RenderToJpegAsync()).AsStream();
            library.SavePicture(DateTime.UtcNow.Ticks.ToString(), imgStream);
        }

        SystemTray.SetProgressIndicator(this, progress);
    }
4

1 回答 1

3

在执行操作之前设置ProgressIndicator,然后在保存代码之后将其禁用。

ProgressIndicator progress = new ProgressIndicator();
progress.IsVisible = true;
progress.IsIndeterminate = true;
progress.Text = "saving image...";

//set the indicator before the save code
SystemTray.SetProgressIndicator(this, progress);

//Save a copy of the image
using (MediaLibrary library = new MediaLibrary())
{
   var imgStream = (await App.CurrPhoto.RawSession.RenderToJpegAsync()).AsStream();
   library.SavePicture(DateTime.UtcNow.Ticks.ToString(), imgStream);
}

//disable it
SystemTray.SetProgressIndicator(this, null);
于 2013-09-09T14:47:22.423 回答