Skip to main content

Microsoft® Surface® Live Stream Code Sample

ive Stream enables businesses to engage their customers face-to-face using the most recent and relevant Twitter™, Flickr®, and RSS newsfeeds.

C# (5.9 MB)
 
 
 
 
 
4.3 Star
(4)
6,672 times
Add to favorites
4/19/2011
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

C#
using System.Windows;
using FeedProcessor.Enums;
using LiveStream.Helpers;
using Microsoft.Surface.Presentation;
using Microsoft.Surface.Presentation.Controls;

namespace LiveStream.Controls
{
    /// <summary>
    /// Contains controls for an administrator of the application. Initiated by TagVisualizer.
    /// </summary>
    public partial class AdminPanel : SurfaceUserControl
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="AdminPanel"/> class.
        /// </summary>
        public AdminPanel()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Initialize control states.
        /// </summary>
        internal void Setup()
        {
            if (AppState.Instance.RetrievalOrder == RetrievalOrder.Chronological)
            {
                _chronologicalBtn.IsChecked = true;
            }
            else
            {
                _randomBtn.IsChecked = true;
            }
        }

        /// <summary>
        /// Handles the Checked event of the mode RadioButtons.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void ModeBtn_Checked(object sender, RoutedEventArgs e)
        {
            if (sender == _chronologicalBtn && AppState.Instance.RetrievalOrder != RetrievalOrder.Chronological)
            {
                AppState.Instance.RetrievalOrder = RetrievalOrder.Chronological;
                _randomBtn.IsChecked = false;
            }
            else if (sender == _randomBtn && AppState.Instance.RetrievalOrder != RetrievalOrder.Random)
            {
                AppState.Instance.RetrievalOrder = RetrievalOrder.Random;
                _chronologicalBtn.IsChecked = false;
            }
        }

        /// <summary>
        /// Handles the ContactTapGesture event of the RemoveBansBtn control. Removes all bans.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Microsoft.Surface.Presentation.ContactEventArgs"/> instance containing the event data.</param>
        private void RemoveBansBtn_ContactTapGesture(object sender, ContactEventArgs e)
        {
            AppState.Instance.RemoveBans();
        }

        /// <summary>
        /// Hide the admin panel when the close button is tapped.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Microsoft.Surface.Presentation.ContactEventArgs"/> instance containing the event data.</param>
        private void Close_ContactTapGesture(object sender, ContactEventArgs e)
        {
            AppState.Instance.IsAdminTagPresent = false;
        }

        /// <summary>
        /// When the volume is adjusted, play an audio sample to test it.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        private void VolumeSlider_IsAnyContactCapturedWithinChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (!(sender as SurfaceSlider).IsAnyContactCapturedWithin)
            {
                Audio.Instance.PlayCue("streamItem_tapDown");
            }
        }
    }
}