Click here to Skip to main content
15,891,943 members
Articles / Desktop Programming / WPF

The WPF Podcatcher Series - Part 2 (Structural Skinning)

Rate me:
Please Sign up or sign in to vote.
4.97/5 (58 votes)
5 Mar 2008CPOL16 min read 253.3K   7.2K   166  
The second article in a series devoted to a WPF application that plays streaming audio podcasts off the Internet. This article discusses the idea and implementation of look-less applications.
using System.Windows.Data;
using System.Windows.Input;
using Podder.Model;
using Podder.Properties;

namespace Podder.UI
{
    /// <summary>
    /// Allows the user to add and remove podcasts.
    /// </summary>
    public partial class PodcastsDialog : ConfigurableWindow
    {
        #region Data

        ConfigurableWindowSettings _configurableWindowSettings;

        #endregion // Data

        #region Constructor

        public PodcastsDialog(PodcastCollection podcasts, Podcast selectedPodcast)
        {
            InitializeComponent();            
            
            // Create a PodcastsControl and give it a new collection view
            // so that changes made in this dialog do not reflect in the main UI.
            ListCollectionView podcastsView = new ListCollectionView(podcasts);

            podcastsView.Filter = podcast => podcast is FavoriteEpisodes == false;

            if (podcastsView.PassesFilter(selectedPodcast))
                podcastsView.MoveCurrentTo(selectedPodcast);

            // Set the DataContext to our special collection view 
            // so that it takes effect in the dialog.
            base.DataContext = podcastsView;

            PodcastsControl podcastsControl = new PodcastsControl(podcastsView);
            base.Content = podcastsControl;

            Commands.AutoDetectFeedUrlOnClipboard.Execute(null, podcastsControl);
        }

        #endregion // Constructor

        #region Base Class Overrides

        #region CreateSettings

        protected override IConfigurableWindowSettings CreateSettings()
        {
            if (_configurableWindowSettings == null)
            {
                _configurableWindowSettings = new ConfigurableWindowSettings(
                    Settings.Default,
                    "PodcastsDialogIsFirstRun",
                    "PodcastsDialogLocation",
                    "PodcastsDialogSize",
                    "PodcastsDialogState");
            }

            return _configurableWindowSettings;
        }

        #endregion // CreateSettings

        #region OnClosed

        protected override void OnClosed(System.EventArgs e)
        {
            base.OnClosed(e);

            if (_configurableWindowSettings.IsFirstRun)
                _configurableWindowSettings.IsFirstRun = false;
        }

        #endregion // OnClosed

        #endregion // Base Class Overrides

        #region Command Sinks

        #region Close

        void Close_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            this.Close();
        }

        #endregion // Close

        #endregion // Command Sinks
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Software Developer (Senior)
United States United States
Josh creates software, for iOS and Windows.

He works at Black Pixel as a Senior Developer.

Read his iOS Programming for .NET Developers[^] book to learn how to write iPhone and iPad apps by leveraging your existing .NET skills.

Use his Master WPF[^] app on your iPhone to sharpen your WPF skills on the go.

Check out his Advanced MVVM[^] book.

Visit his WPF blog[^] or stop by his iOS blog[^].

See his website Josh Smith Digital[^].

Comments and Discussions