1

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!

Community
  • 1
  • 1

2 Answers2

1

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

Sopuli
  • 421
  • 1
  • 8
  • 15
Mohit
  • 516
  • 7
  • 24
0

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.

Mohit
  • 516
  • 7
  • 24
  • thanks for the reference, i was actually looking for something more refined way i mean phones like the nokia 920 have this option as native so isnt there a more simple to call a screenshot and map it to a button or something?. – Dangelo Leonard Apr 30 '13 at 20:40
  • I think you want to call screen-shots on click of button? – Mohit May 01 '13 at 03:50
  • yessiirr i do like putting a camera button on page or on application bar that takes the screen shot – Dangelo Leonard May 01 '13 at 05:20
  • ok well so you can use this code:----http://pastie.org/7747288 I posted my code here you can use where you need.or download (Code Example Source file: Media:WmDev CaptureScreen.zip) form http://www.developer.nokia.com/Community/Wiki/How_to_capture_screen_programmatically_in_Windows_Phone_7 – Mohit May 01 '13 at 10:15
  • ok inserted your code and over look link you sent..when pressing the applicationbarbutton UnauthorizedAccessException is throw and stops there..sorry still learning more and more – Dangelo Leonard May 01 '13 at 10:38
  • But my proposal is you can download sample code and check it..I think you missed some piece of code.please for more reference download the Zip file given in above link. – Mohit May 01 '13 at 11:21
  • ok yea i only use the piece that you post in pastie ill check the sample code – Dangelo Leonard May 01 '13 at 15:48
  • the exception happens on this line of code......................... new MediaLibrary().SavePicture(name, stream); – Dangelo Leonard May 01 '13 at 15:55
  • 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. – Mohit May 02 '13 at 04:16