1
votes

ok so i want to screen capture the layout for an app im working on i would like to set screen capture to a button or applicationbar item and after capture go directly into email with that screen shot to send off

i seen here : How to take a screenshot and send by email programaticly on dotnet

and here: C# Take ScreenShot of .net control within application and attach to Outlook Email

but im not sure it applies to windows phone 8. I know you can take a screenshot via home button and power button but i would like this done in one swoop if possible

i intially was going to have textboxes filled out and them have an email generated looking somehting like this

 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;

but i didnt like the output of it, wasnt properly aligned etc...thanks in advance!

2

2 Answers

1
votes

Simply use this code on click of button..

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;
    }

then after use this code to save image on camera roll..

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);
        }
    }

now you can check in your camera roll the screen captured will be saved.
Make sure once check on your WMAppManifest.xml and in capability you check-mark on all capability then run your code I am sure it will work

0
votes

For taking screen-shots you can follow this link..

http://www.developer.nokia.com/Community/Wiki/index.php?title=How_to_take_screenshot_on_Windows_Phone&ampdiff=176659&ampoldid=175825

and there is no way still in Windows phone 8 SDK to send email via EmailTask with an attachment.