In this article, Rudi Grobler creates a Windows Phone 7 companion tool for PowerPoint which allows users to control their PowerPoint presentation.
What is Podium
Podium actually consists of 2 parts… First is a PowerPoint 2010 add-in which monitors PowerPoint for slideshows. Once a slideshow starts, it will send a push notification (toast message) to a Windows Phone 7 device to “announce” that a slideshow is ready! Once the slideshow is actually started (By pressing F5), the add-in will capture each slide as an image (JPG) and send another push notification (RAW http) to the device with the id of the given slide! If the phone application is running, once it receives this notification, it will call back into PowerPoint (using a self hosted WCF service) and fetch the slide image. By tapping or flicking on the screen, the user can send a message back to PowerPoint to go to the next or previous slide!
PowerPoint 2010 VSTO
I just created a default PowerPoint 2010 Add-in:
Note: VSTO 2010 is part of Visual Studio 2010.
I need to “detect” if a new presentation is opened. This is easily achievable by just listening for the
PresentationOpen event. Once I receive this, I send a new toast notification (I will cover this a little later). Next on the list is when a slideshow starts or goes to a next slide… The events I listen for are
SlideShowBegin. For each of these events, I need to capture the new slide as a JPG. These events pass a copy of the
SlideShowWindow in their
EventArgs… and the
SlideShowWindow can be used to capture its slide to the clipboard.
Once the slide is in the clipboard, it's very easy to dump to file:
var data = Clipboard.GetDataObject();
if (data == null) return;
if (!data.GetDataPresent(DataFormats.Bitmap, true)) return;
Image image = (Image)data.GetData(DataFormats.Bitmap, true);
The only other thing I still need to do is create a unique id for each image (using Guids) and send this to the device.
Self-hosted WCF Service
The PowerPoint add-in hosts a very basic WCF service:
public interface IRegistrationService
void Register(string uri);
void Unregister(string uri);
byte GetSlide(Guid guid);
Note: For the self-hosting WCF service to work, the application needs to be run as administrator.
The Register/Unregister is used for the push notification and the
NextSlide is to control or interact with PowerPoint.
Windows Phone 7
Note: For this article, I am assuming a basic understanding of Silverlight.
Windows Phone 7 is a mobile operating system developed by Microsoft, and is the successor to their Windows Mobile platform. It is scheduled to launch in Europe on October 21, 2010, and in the US on November 8. Microsoft's goal is to create a compelling user experience by redesigning the user interface, integrating the operating system with other services, and strictly controlling the hardware it runs on. Microsoft officially unveiled Windows Phone 7 during Mobile World Congress 2010 (February 15) in Barcelona and revealed additional details at MIX 2010 (March 15). Windows Phone 7 was released to manufacturing on September 1, 2010, and the final SDK was made available on September 16.
Windows Phone 7 uses Silverlight as its programming model which opens up loads of new opportunities for WPF/Silverlight developers. Before we can start first download the Windows Phone Developer Tools. Once this is installed, we can create a new Windows Phone application
The UI for this application is very simple… There will only be one screen which waits for new slides.
If a new slide is available, download and show it:
This application ONLY supports landscape orientation (This makes more sense for my specific scenario). To restrict an application to only a specific orientation, set the
Orientation on the page, both to “
For easy navigation, I also added some buttons to the
“The Application Bar is displayed as a row of between one and four icon buttons along the bottom of the phone’s screen. The icon buttons are used to provide users with quick access to an application’s most common tasks.”
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
x:Name="PreviousButton" Click="PreviousButton_Click" />
x:Name="NextButton" Click="NextButton_Click" />
And this is how it looks:
Push Notification works as follows:
The phone opens a channel to the notification service in the cloud (1). Once the channel is opened (2) successfully the phone sends the channel uri to the self-hosted WCF service (3). Once this is done, we are ready! Now PowerPoint can send messages to the phone using this uri supplied (4 + 2).
All of this is encapsulated in a
PushNotifier class (on the phone). All you need to do to get going is create a new instance of
notifier = new PushNotifier("PodiumChannel", "PodiumService");
notifier.Subscribed += new EventHandler(notifier_SubscribeToService);
PushNotifier is created, handle the
HttpNotificationReceived events! Once everything is setup, call
On the client side (PowerPoint add-in), there is a
NotificationSenderUtility class that takes care of sending the toast and RAW http notifications! Here is an example of a toast message:
var subscribers = RegistrationService.GetSubscribers();
"This is a toast", OnMessageSent);
Gesture recognition has historically been hard to do! Not anymore… I use the
GestureService (Provided by the Silverlight for Windows Phone Toolkit):
The fact that skills translate from desktop/WPF to web/Silverlight and now phone/Silverlight is a HUGE strength of the Microsoft eco-system! Overnight thousands of WPF and Silverlight developers instantly became mobile developers! Show me any other platform capable of this?
If you want to learn more about Windows Phone 7, check out my blog… I regularly blog about WP7, Silverlight and WPF!