How to create emailto hyperlink in Windows Phone - xaml

I'm trying to create a hyper link in my windows phone XAML and code behind. Below is my code, but when I try this in my phone emulator, I get the below error:
"Can't send - Make sure you've set up an account and try again."
Will the below work on my actual phone?
XAML:
<HyperlinkButton
Content="Click to Email"
Click="Hyperlink_Click"
/>
CodeBehind:
EmailComposeTask email = new EmailComposeTask();
email.Subject = "Subject";
email.To = "myemail#email.com";
email.Show();

As mentioned in the msdn article, it seems that the Emulator doesn't work properly with the Email Compose Task. So better if you could test it in your device!

Related

Show an image and a message in a toast notification on windows phone

I am trying to show an Image and text on windows phone. The text works but the image does not show up at all the docs on msdn says that it should though
here is my code ...
ToastTemplateType toastTemplate = ToastTemplateType.ToastImageAndText02;
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);
XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");
toastTextElements[0].AppendChild(toastXml.CreateTextNode("Hello World!"));
XmlNodeList toastImageAttributes = toastXml.GetElementsByTagName("image");
((XmlElement)toastImageAttributes[0]).SetAttribute("src", "ms-appx:///assets/Square71x71Logo.scale-240.png");
((XmlElement)toastImageAttributes[0]).SetAttribute("alt", "red graphic");
ToastNotification toast = new ToastNotification(toastXml);
ToastNotificationManager.CreateToastNotifier().Show(toast);
Results
Expected Results
Image Square71x71Logo.scale-240.png
You cannot include an image in a toast on Windows Phone 8.1. The template will always be the app's logo then two text fields.
This is documented near the top of the Toast Template Catalog documentation on MSDN.

Creating WP8 in-app video is not generating a .jpg thumbnail

I've been told that when I allow the user to create a video from within my app, a .jpg thumbnail image is supposed to be generated automatically. However, using windows phone power tools, I can see that only the video is generated, no image. Here is the code below:
EDIT: the QUESTION here, is HOW does one GET a thumbnail image from a given video that is saved in isolated storage?
' Set recording state: start recording.
Private Async Sub StartVideoRecording()
Try
App.ViewModel.IsDataLoaded = False
'isoStore = Await ApplicationData.Current.LocalFolder.GetFolderAsync("IsolatedStore")
strVideoName = GenerateVideoName()
isoFile = Await isoVideoFolder.CreateFileAsync(strVideoName, CreationCollisionOption.ReplaceExisting)
thisAccessStream = Await isoFile.OpenAsync(FileAccessMode.ReadWrite)
Await avDevice.StartRecordingToStreamAsync(thisAccessStream)
'save the name of the video file into the list of video files in isolated storage settings
Dim videoList As New List(Of InfoViewModel)
isoSettings = IsolatedStorageSettings.ApplicationSettings
If isoSettings.Contains("ListOfVideos") Then
videoList = isoSettings("ListOfVideos")
Else
isoSettings.Add("ListOfVideos", videoList)
End If
videoList.Add(New InfoViewModel With {.Name = strVideoName, .DateRecorded = Date.Now})
isoSettings("ListOfVideos") = videoList
isoSettings.Save()
isoSettings = Nothing
' Set the button states and the message.
UpdateUI(ButtonState.Recording, "Recording...")
Catch e As Exception
' If recording fails, display an error.
Me.Dispatcher.BeginInvoke(Sub() txtDebug.Text = "ERROR: " & e.Message.ToString())
End Try
End Sub
In Windows Phone 7.0 it wasn't possible using the "official" SDK to access the camera other than using CameraCaptureTask. But using Microsoft.Phone.InteropServices library it was possible to create a custom camera view in the application. If you used this VideoCamera class, it had an event called ThumbnailSavedToDisk, which might be what you have heard about. But apps using Microsoft.Phone.InteropServices was never allowed in the Windows Phone Marketplace. You can read more about it here.
To generate a thumbnail from a video file one solution would be to read up on how the MP4 file format works and extract one of the frames and use that as a thumbnail. Unfortunatly I haven't found any libraries that can do this.
Another, but far from optimal solution, would be to play the video in a MediaElement and then render that Control to a bitmap. This can be done with the following code (written in XAML/C#, I don't know VB.net, but should be easy to port):
<MediaElement
x:Name="VideoPlayer"
Width="640"
Height="480"
AutoPlay="True"
RenderTransformOrigin="0.5, 0.5"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Stretch="Fill"
Canvas.Left="80"/>
And then to create the thumbnail:
// Set an event handler for when video has loaded
VideoPlayer.MediaOpened += VideoPlayer_MediaOpened;
// Read video from storage
IsolatedStorageFileStream videoFile = new IsolatedStorageFileStream("MyVideo.mp4", FileMode.Open, FileAccess.Read, IsolatedStorageFile.GetUserStoreForApplication());
VideoPlayer.SetSource(videoFile);
// Start playback
VideoPlayer.Play();
And then create the event handler which "captures" the thumbnail:
void VideoPlayer_MediaOpened(object sender, RoutedEventArgs e)
{
Thread.Sleep(100); // Wait for a short time to avoid black frame
WriteableBitmap wb = new WriteableBitmap(VideoPlayer, new TranslateTransform());
thumbnailImageHolder.Source = wb; // Setting it to a Image in the XAML code to see it
VideoPlayer.Stop();
}
Here is how it looks when using a modified version of the Video Recorder Sample. (The small image with the blue border in the upper right corner is the thumbnail of the recorded video. Behind is the camera Viewer.)

Change the tile image of a shortcut tile pinned on the metro desktop

we have created a tile shortcut, which is similar to pinning the IE shortcuts on the screen. We have done this through code. We want an image should come on this tile. How do we add image to such a shortcut tile. we are running an exe first on windows 7 desktop mode and then making the pin to screen event click using the shell scripting. the tile is similar to any internet address pinned on the desktop
See this sample app...
The basic code you will need to achieve this is as follows...
Uri logo = new Uri("ms-appx:///Assets/squareTile-sdk.png");
Uri smallLogo = new Uri("ms-appx:///Assets/smallTile-sdk.png");
string tileActivationArguments = MainPage.logoSecondaryTileId + " WasPinnedAt=" + DateTime.Now.ToLocalTime().ToString();
SecondaryTile secondaryTile = new SecondaryTile(MainPage.logoSecondaryTileId,
"Title text shown on the tile",
"Name of the tile the user sees when searching for the tile",
tileActivationArguments,
TileOptions.ShowNameOnLogo,
logo);
secondaryTile.ForegroundText = ForegroundText.Dark;
secondaryTile.SmallLogo = smallLogo;
bool isPinned = await await secondaryTile.RequestCreateAsync();

Customize the Prompt Box of Javascript

As the Title says, I am invoking a Prompt-box of very-flexible Javascript by the below command in my Silverlight application.
string input = System.Windows.Browser.HtmlPage.Window.Invoke("prompt", new string[] { "YOUR QUESTION GOES HERE", "THE ANSWER INPUT GOES HERE.." }) as string;
But what i want is to customize the prompt box in terms of resizing, alignment, and Prompt-box header content. How can i pass such parameters in the above code, without breaking its core Functionality ??
Jquery Plugins are available....you can use
http://theinfiniteloopblog.com/programming/jscript/custom-javascript-alert-and-confirm-dialog-boxes/

Outlook "save as html" on a mail message toolbar

The medical company I work for has a EMR system setup to keep digital copies of patient files so they are searchable as well as quick to access. A new request has come through to be able to save e-mail to the EMR system, however it does not display .msg files very nicely. It does display files nicely as .htm, so was hoping i could figure out a way to save email messages to a specific folder in a .htm format with the user just hitting a single button.
Should i be looking at making an add-in using vs 2010 to do this simple task? Or would there be a better way to do this?
I've explored making an Add-In breifly over the past few days using command bars but have hit numerous problems with adding the menu item to mail items, as well as losing event handlers or having them fire quite a few times, so i'm wondering if i'm barking up the wrong tree.
Edit: Looking at ribbon bar customization as well, may have to upgrade some users that are still using 2003, but seems like it might be the better option than command bars going forward.
Ribbon bar was the best path i found, however i had trouble finding a great how-to for the start-to-finish project, so i'll make a small write up here.
To add a button to the ribbon for only existing mail messages including a image for the button.
Using VS 2010
New project, Office, select "Outlook 2007 add in", enter a name for your project.
To your newly created project, Add a new item "Ribbon (XML)" name it however you want, i'll call it CustomRibbon
open your newly created CustomRibbon.xml file and change the tab node to have the following
<tab idMso="TabReadMessage">
<group insertBeforeMso="GroupActions" id="CustomGroup" label="GroupNameThatShowsInOutlook">
<button id="btnCustomButton"
label = "Text For The Custom Button"
supertip="tip for the button hover"
onAction ="ButtonClicked"
size="large"
getImage="GetCustomButtonImage" />
</group>
</tab>
This then has 2 callback functions to the CustomRibbon.cs file, one called GetCustomButtonImage, the other ButtonClicked.
open CustomRibbon.cs to fill this in, in the Ribbon Callbacks region add the following
public void ButtonClicked(Office.IRibbonControl Control)
{
//Do work here
}
also add the following in the same section
public stdole.IPictureDisp GetCustomButtonImage(Office.IRibbonControl control)
{
System.Drawing.Image myImage;
myImage = OutlookAddIn.Properties.Resources.ImageName;
return AxHostConverter.ImageToPictureDisp(myImage);
}
this will then show there is a class missing, we'll get to that shortly, but first we are going to add in the last part we need in CustomRibbon.cs. In the IRibbonExtensibility Members region, in GetCustomUI change the existing code
public string GetCustomUI(string ribbonID)
{
if (ribbonID == "Microsoft.Outlook.Mail.Read")
{
return GetResourceText("OutlookAddIn.CustomRibbon.xml");
}
else
{
return "";
}
}
Add a new class to your project call it AxHostConverter, add add this to the top
using System.Windows.Forms;
using System.Drawing;
Then change the class to have the following code
class AxHostConverter : AxHost
{
private AxHostConverter() : base("") { }
static public stdole.IPictureDisp ImageToPictureDisp(Image image)
{
return (stdole.IPictureDisp)GetIPictureDispFromPicture(image);
}
static public Image PictureDispToImage(stdole.IPictureDisp pictureDisp)
{
return GetPictureFromIPicture(pictureDisp);
}
}
Add your image for your button to the project, and change the GetCustomButtonImage function to use that resource. I used a PNG and had good luck with transparencies displaying well.
And finally, all that should be left is to add the following to ThisAddIn.cs
protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
{
return new CustomRibbon();
}
Add whatever code you are wanting to ButtonClicked and you are set.
Deploy using Clickonce and installation is fairly straightforward.