Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 映射一个按钮以进行屏幕截图,然后打开composetask以通过电子邮件wp8发送_C#_Windows Phone 8 - Fatal编程技术网

C# 映射一个按钮以进行屏幕截图,然后打开composetask以通过电子邮件wp8发送

C# 映射一个按钮以进行屏幕截图,然后打开composetask以通过电子邮件wp8发送,c#,windows-phone-8,C#,Windows Phone 8,好的,我想截屏im正在使用的应用程序的布局我想将截屏设置为按钮或应用程序栏项目,截屏后直接进入电子邮件并发送截屏 我在这里看到: 在这里: 但我不确定它是否适用于WindowsPhone8。我知道你可以通过主页按钮和电源按钮截图,但如果可能的话,我希望一次完成 我本来打算填写文本框,然后生成一封类似这样的电子邮件 private void email_Click(object sender, EventArgs e) { EmailComposeTask emailC

好的,我想截屏im正在使用的应用程序的布局我想将截屏设置为按钮或应用程序栏项目,截屏后直接进入电子邮件并发送截屏

我在这里看到:

在这里:

但我不确定它是否适用于WindowsPhone8。我知道你可以通过主页按钮和电源按钮截图,但如果可能的话,我希望一次完成

我本来打算填写文本框,然后生成一封类似这样的电子邮件

 private void email_Click(object sender, EventArgs e)
    {

        EmailComposeTask emailComposeTask = new EmailComposeTask();

        string first = infoBox1.Text;
        string second = infoBox2.Text;
        string third = infoBox3.Text;
        string fourth = infoBox4.Text;

        string one = amountBox1.Text;
        string two = amountBox2.Text;
        string three = amountBox3.Text;
        string four = amountBox4.Text;

        emailComposeTask.To = "";


        emailComposeTask.Body =    

            first + " " + " " + " " + " " + " " + " " + " " +  one + Environment.NewLine +
            second + " " + " " + " " + " " + " " + " " + " " + two + Environment.NewLine +
            third + " " + " " + " " + " " + " " + " " + " " +  three + Environment.NewLine +
            fourth + " " + " " + " " + " " + " " + " " + " " + four + Environment.NewLine;

但我不喜欢它的输出,没有正确对齐等…提前感谢

要拍摄屏幕截图,您可以点击此链接


而且,在Windows phone 8 SDK中,仍然无法通过EmailTask发送带有附件的电子邮件。

要拍摄屏幕截图,请点击此链接


在Windows phone 8 SDK中,仍然无法通过EmailTask发送带有附件的电子邮件。

只需单击按钮即可使用此代码

private void ApplicationBarIconButton_Click(object sender, EventArgs e)
    {
        var fileName = String.Format("WmDev_{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", "WmDev Capture Screen", MessageBoxButton.OK);

        string 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);
        }
    }
现在,您可以签入您的相机卷,捕获的屏幕将被保存。

确保一旦检查了WMAppManifest.xml,并在“功能”中选中所有功能,然后运行代码。我确信它会工作的。

只需单击按钮即可使用此代码

private void ApplicationBarIconButton_Click(object sender, EventArgs e)
    {
        var fileName = String.Format("WmDev_{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", "WmDev Capture Screen", MessageBoxButton.OK);

        string 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);
        }
    }
现在,您可以签入您的相机卷,捕获的屏幕将被保存。

确保一旦检查了WMAppManifest.xml,并在capability中选中所有功能,然后运行代码,我相信它会工作的

谢谢您的参考,事实上,我一直在寻找更精致的方式,我是说像诺基亚920这样的手机本机就有这个选项,所以难道没有更简单的方法来调用屏幕截图并将其映射到按钮或其他东西吗?我想你想在点击按钮时调用屏幕截图吗?是的,我确实喜欢在页面或应用程序栏上放置一个摄像头按钮,以获取screen shotok好让您可以使用此代码:-我在这里发布了我的代码,您可以在需要的地方使用。或者下载(代码示例源文件:Media:WmDev CaptureScreen.zip)表单确定插入您的代码并查看您发送的链接..当按applicationbarbutton UnauthorizedAccessException时,将抛出并停止..抱歉仍了解更多信息谢谢您的参考,事实上,我一直在寻找更精致的方式,我是说像诺基亚920这样的手机本机就有这个选项,所以难道没有更简单的方法来调用屏幕截图并将其映射到按钮或其他东西吗?我想你想在点击按钮时调用屏幕截图吗?是的,我确实喜欢在页面或应用程序栏上放置一个摄像头按钮,以获取screen shotok好让您可以使用此代码:-我在这里发布了我的代码,您可以在需要的地方使用。或者下载(代码示例源文件:Media:WmDev CaptureScreen.zip)表单确定插入您的代码并查看您发送的链接..当按下applicationbarbutton UnauthorizedAccessException时抛出并停止..抱歉仍了解更多信息感谢您与我一起坚持WMAppManifest.xml是关键再次感谢!伙计,谢谢你跟我说出来,WMAppManifest.xml是关键,再次感谢!