c# xs螢幕截圖 如何以編程方式在Windows Phone上截圖?



ix關機 (1)

這裡是代碼:

private void ApplicationBarScreenshotButton_Click(object sender, EventArgs e)
{
    var fileName = String.Format("MyImage_{0:}.jpg", DateTime.Now.Ticks);
    WriteableBitmap bmpCurrentScreenImage = new WriteableBitmap((int)this.ActualWidth, (int)this.ActualHeight);
    bmpCurrentScreenImage.Render(LayoutRoot, new MatrixTransform());
    bmpCurrentScreenImage.Invalidate();
    SaveToMediaLibrary(bmpCurrentScreenImage, fileName, 100);
    MessageBox.Show("Captured image " + fileName + " Saved Sucessfully", "WP Capture Screen", MessageBoxButton.OK);

    currentFileName = fileName;
}

public void SaveToMediaLibrary(WriteableBitmap bitmap, string name, int quality)
{
    using (var stream = new MemoryStream())
    {
        // Save the picture to the Windows Phone media library.
        bitmap.SaveJpeg(stream, bitmap.PixelWidth, bitmap.PixelHeight, 0, quality);
        stream.Seek(0, SeekOrigin.Begin);
        new MediaLibrary().SavePicture(name, stream);
    }
}

當你點擊AppBar按鈕時​​,它將截取屏幕截圖並將圖片保存到Windows Phone媒體庫

我需要使用Windows Phone截圖。 我不想用手動模擬器和電源+啟動按鈕截圖。 有什麼可以通過編程來完成嗎?





screenshot