Click here to Skip to main content
15,881,852 members
Articles / Mobile Apps / Windows Phone 7

Podium

Rate me:
Please Sign up or sign in to vote.
4.91/5 (18 votes)
4 Oct 2010CPOL4 min read 55.3K   26   12
Podium is a PowerPoint add-in and Windows Phone 7 app for controlling Powerpoint from Windows phone 7 devices

Introduction

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:

CreateANewAddin.png - Click to enlarge image

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 SlideShowNextSlide & 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.

C#
window.View.Slide.Copy();

Once the slide is in the clipboard, it's very easy to dump to file:

C#
var data = Clipboard.GetDataObject();
if (data == null) return;
if (!data.GetDataPresent(DataFormats.Bitmap, true)) return;

Image image = (Image)data.GetData(DataFormats.Bitmap, true);
image.Save(CachePathFromGuid(guid), ImageFormat.Jpeg);

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:

C#
[ServiceContract]
public interface IRegistrationService
{
    [OperationContract, WebGet]
    void Register(string uri);
 
    [OperationContract, WebGet]
    void Unregister(string uri);
 
    [OperationContract, WebGet]
    byte[] GetSlide(Guid guid);
 
    [OperationContract, WebGet]
    void PreviousSlide();
        
    [OperationContract, WebGet]
    void NextSlide();
}

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 GetSlide, PreviousSlide & 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.[2] It is scheduled to launch in Europe on October 21, 2010, and in the US on November 8.[3] 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.[4] Microsoft officially unveiled Windows Phone 7 during Mobile World Congress 2010 (February 15)[5] in Barcelona and revealed additional details at MIX 2010 (March 15). Windows Phone 7 was released to manufacturing on September 1, 2010,[6] and the final SDK was made available on September 16.[7]

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

CreateANewPhoneApp.png - Click to enlarge image

The UI for this application is very simple… There will only be one screen which waits for new slides.

WaitForPresenter.PNG - Click to enlarge image

If a new slide is available, download and show it:

SlideAvailable.PNG - Click to enlarge image

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 SupportedOrientations and Orientation on the page, both to “Landscape”.

For easy navigation, I also added some buttons to the ApplicationBar:

“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.”

XML
<phone:PhoneApplicationPage.ApplicationBar>
    <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
        <shell:ApplicationBarIconButton IconUri="/Assets/Icons/LeftArrow.png" 
			Text="Previous" 
                          	x:Name="PreviousButton" Click="PreviousButton_Click" />
        <shell:ApplicationBarIconButton IconUri="/Assets/Icons/RightArrow.png" 
			Text="Next" 
                       	x:Name="NextButton" Click="NextButton_Click" />
    </shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

And this is how it looks:

podium/AppBarButtons.png

Push Notification

podium/PushNotification.PNG

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 PushNotifier.

C#
notifier = new PushNotifier("PodiumChannel", "PodiumService");
notifier.Subscribed += new EventHandler(notifier_SubscribeToService);
notifier.HttpNotificationReceived += 
	new EventHandler<Microsoft.Phone.Notification.HttpNotificationEventArgs>
		(notifier_HttpNotificationReceived);
notifier.Open();

Once the PushNotifier is created, handle the Subscribe & HttpNotificationReceived events! Once everything is setup, call Open().

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:

C#
var subscribers = RegistrationService.GetSubscribers();
notifier.SendToastNotification(subscribers, "Podium", 
			"This is a toast", OnMessageSent);

Gestures

Gesture recognition has historically been hard to do! Not anymore… I use the GestureService (Provided by the Silverlight for Windows Phone Toolkit):

XML
<toolkit:GestureService.GestureListener>
    <toolkit:GestureListener 
        Flick="GestureListener_Flick" 
        DoubleTap="GestureListener_DoubleTap" 
        Tap="GestureListener_Tap" />
</toolkit:GestureService.GestureListener>

Conclusion

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!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
South Africa South Africa
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralSomebody Stop Me... Pin
Dewey17-Oct-10 21:05
Dewey17-Oct-10 21:05 
GeneralRe: Somebody Stop Me... Pin
rudigrobler26-Oct-10 1:01
rudigrobler26-Oct-10 1:01 
GeneralMy vote of 5 Pin
Adrian Cole9-Oct-10 9:52
Adrian Cole9-Oct-10 9:52 
GeneralRe: My vote of 5 Pin
rudigrobler10-Oct-10 19:02
rudigrobler10-Oct-10 19:02 
Generalexcellent Rudi Pin
Sacha Barber6-Oct-10 22:29
Sacha Barber6-Oct-10 22:29 
GeneralRe: excellent Rudi Pin
rudigrobler6-Oct-10 23:43
rudigrobler6-Oct-10 23:43 
GeneralExcellent use of technology Pin
Stephan Johnson5-Oct-10 0:21
Stephan Johnson5-Oct-10 0:21 
GeneralRe: Excellent use of technology Pin
rudigrobler6-Oct-10 23:44
rudigrobler6-Oct-10 23:44 
GeneralWOW! Pin
quicoli1-Oct-10 1:10
quicoli1-Oct-10 1:10 
GeneralRe: WOW! Pin
rudigrobler1-Oct-10 1:52
rudigrobler1-Oct-10 1:52 
GeneralTOO COOL! Pin
PHenry30-Sep-10 16:50
PHenry30-Sep-10 16:50 
GeneralRe: TOO COOL! Pin
rudigrobler30-Sep-10 19:06
rudigrobler30-Sep-10 19:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.