Click here to Skip to main content
6,629,885 members and growing! (23,811 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » Windows Presentation Foundation » Applications     Beginner License: The Code Project Open License (CPOL)

PhotoBooth

By rudigrobler

An article on how to create a kiosk application that displays photos received via BlueTooth.
XML, C# 1.0, C# 2.0, C# 3.0, Windows, .NET, XAML, WPF, Dev
Version:10 (See All)
Posted:17 Jun 2009
Updated:25 Jun 2009
Views:10,139
Bookmarked:49 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
12 votes for this article.
Popularity: 5.29 Rating: 4.90 out of 5

1

2
1 vote, 8.3%
3
1 vote, 8.3%
4
10 votes, 83.3%
5

Banner.png

Introduction

This article describe some very basic techniques on how to create a photo kiosk (similar to the Kodak Picture Kiosk).

Architecture

Architecture.png

PhotoBooth uses the default MainView/MainViewModel created by the MVVM Toolkit. Various "sub-views" then gets shown or hidden based on the properties on the MainViewModel!

The MainViewModel has a ObservableCollection of photos. This gets populated by the OBEX listener. We also keep track of the current selected photo (by using CollectionView)

view = (ListCollectionView)CollectionViewSource.GetDefaultView(Photos); 
view.CurrentChanged += delegate 
{ 
    SelectedPhoto = (string)view.CurrentItem; 
};

Marlon has a excellent article on this technique available here. Just remember the IsSynchronizedWithCurrentItem="True".

PhotoBooth has four sub-views:

WelcomeView

WelcomeView.png

This is the "Oooo, look at me... I am so pretty" screen to get customers to use the kiosk!

PhotoBrowserView

PhotoBrowserView.png

PhotoBrowserView shows all the photos received by the kiosk. The view can also interact with the ViewModel using two commands:

  • Clear - Removes all the photos
  • Checkout - Starts the checkout procedure

This view is only visible if HasPhotos is true.

PhotoEditView

PhotoEditView.png

The PhotoEditView allows editing and sharing of photos (not implemented yet). Basic navigation commands are available on the ViewModel:

  • NextPhoto
  • PreviousPhoto
  • UnselectPhoto

This view is only visible if IsPhotoSelected is true.

CheckoutView

CheckoutView.png

Finally, the CheckoutView shows a basket-like view of all the photos you have uploaded; here, you can also select the size of the photo to be printed!

This view is only visible if BusyCheckingOut is true.

Bluetooth

  • Bluetooth is an open wireless protocol for exchanging data over short distances from fixed and mobile devices.
  • OBEX (OBject EXchange) is a communications protocol that facilitates the exchange of binary objects between devices.

Our PhotoBooth receives photos via Bluetooth (using the OBEX protocol). We will be using the 32 Feet library from In The Hand.

Tip: If you are developing using a 64-bit OS, also do the following (thank you big red):

Change Project > PhotoBooth Properties > Build > Platform Target: x86 (it defaults to Any CPU).

Here is the code to start the OBEX listener:

private ObexListener listener; 

private void StartObexListener() 
{ 
    radio = InTheHand.Net.Bluetooth.BluetoothRadio.PrimaryRadio; 
    
    if (radio != null) 
    { 
        radio.Mode = InTheHand.Net.Bluetooth.RadioMode.Discoverable; 
        
        listener = new ObexListener(ObexTransport.Bluetooth); 
        listener.Start(); 
        
        dispatcher = Dispatcher.CurrentDispatcher; 
        System.Threading.Thread t = new System.Threading.Thread(
           new System.Threading.ThreadStart(ObexRequestHandler)); 
        t.Start(); 
    } 
} 

private void ObexRequestHandler() 
{ 
    if (radio == null) 
        return; 

    while (listener.IsListening) 
    { 
        try 
        { 
            ObexListenerContext olc = listener.GetContext(); 
            ObexListenerRequest olr = olc.Request; 
            string filename = 
              System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + 
               "\\" + DateTime.Now.ToString("yyMMddHHmmss") + 
               " " + Uri.UnescapeDataString(olr.RawUrl.TrimStart(new char[] { '/' })); 
            olr.WriteFile(filename); 
            dispatcher.Invoke(new Action(delegate() 
            { 
                Photos.Add(filename); 
                OnPropertyChanged("HasPhotos"); 
            })); 
        } catch (Exception ex) 
        { 
            break; 
        } 
    } 
}

Two things to notice about this code: we force our Bluetooth radio to Discoverable mode, and we store a reference to the current Dispatcher. This allows us to Invoke back to the correct thread when we receive a photo on our background thread!

Read more here.

PhotoBooth also displays the current status of the Bluetooth radios using tooltips.

BluetoothStatusOn.png

Here is the markup:

<Image Source="..\Resources\Images\bluetooth_blue.png">
    <Image.ToolTip> 
        <ToolTip> 
            <StackPanel> 
                <TextBlock Text="{Binding Radio.Name}" FontWeight="Bold"/> 
                <TextBlock Text="{Binding Radio.Manufacturer, StringFormat='Manufacturer: {0}'}" /> 
                <TextBlock Text="{Binding Radio.SoftwareManufacturer, StringFormat='Software: {0}'}" /> 
                <TextBlock Text="{Binding Radio.LocalAddress, StringFormat='Address: {0}'}" /> 
                <TextBlock Text="{Binding Radio.Mode, StringFormat='Mode: {0}'}" /> 
            </StackPanel> 
        </ToolTip> 
    </Image.ToolTip> 
</Image>

And if no radio is found?

BluetoothStatusOff.png

Animations

Most kiosks have some very fancy animations to attract the attention of the customers. I unfortunately have no design skills! The only animation that I will be using is the AnimatedWrapPanel. This gives me very basic animation on each new photo received!

<ListBox> 
    <ListBox.ItemsPanel> 
        <ItemsPanelTemplate> 
            <layout:AnimatedWrapPanel /> 
        </ItemsPanelTemplate> 
    </ListBox.ItemsPanel> 
</ListBox>

Read more here.

Kiosk Tips

Most kiosks are a single application system; remember to make your application run full screen and remove the border chrome.

WindowState="Maximized" 
WindowStyle="None"

Kiosks usually uses touch screens. It is very common to then hide the cursor.

Cursor="None"

And, that's it...

License

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

About the Author

rudigrobler


Member

Location: South Africa South Africa

Other popular Windows Presentation Foundation articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 14 of 14 (Total in Forum: 14) (Refresh)FirstPrevNext
GeneralAnimatingPanelBase PinmemberJianping Yan6:27 24 Aug '09  
GeneralNice, well writen, well documented and gorgeous PinmemberRaul Mainardi Neto17:55 18 Jul '09  
GeneralRe: Nice, well writen, well documented and gorgeous Pinmemberrudigrobler0:39 20 Jul '09  
Generalwhy listener.IsListening PinmemberUnruled Boy3:59 26 Jun '09  
General64-bit Dev Environment Pinmemberbig red19:52 25 Jun '09  
GeneralRe: 64-bit Dev Environment Pinmemberrudigrobler21:27 25 Jun '09  
GeneralThe force is strong PinmvpPete O'Hanlon13:20 25 Jun '09  
GeneralRe: The force is strong Pinmemberrudigrobler21:28 25 Jun '09  
Generalafter run, it is frozen and nothing can be run PinmemberSeraph_summer10:40 17 Jun '09  
GeneralRe: after run, it is frozen and nothing can be run Pinmemberrudigrobler10:48 17 Jun '09  
GeneralRe: after run, it is frozen and nothing can be run PinmemberSeraph_summer11:02 17 Jun '09  
GeneralRe: after run, it is frozen and nothing can be run Pinmemberrudigrobler0:26 18 Jun '09  
GeneralNot bad my son PinmvpSacha Barber5:33 17 Jun '09  
GeneralRe: Not bad my son Pinmemberrudigrobler6:46 17 Jun '09  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 25 Jun 2009
Editor: Smitha Vijayan
Copyright 2009 by rudigrobler
Everything else Copyright © CodeProject, 1999-2009
Web21 | Advertise on the Code Project