Click here to Skip to main content
12,248,978 members (36,454 online)
Click here to Skip to main content

Stats

41.6K views
765 downloads
17 bookmarked
Posted

(Hybrid Smart Client) RSS Media Player

, 9 Mar 2009 CPOL
A WPF application for viewing RSS video feeds. Built using the MVVM pattern.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace RSSVideoPlayer.DataConverters
{

    public class DoubleToPercent : IValueConverter
    {

        // Define the Convert method to change a DateTime object to a month string. 
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            // value is the data from the source object. 
            double thisdbl = (double)value;
            int percent = (int)(thisdbl * 100);

            // Return the value to pass to the target. 
            return percent;
        }

        // ConvertBack is not implemented for a OneWay binding. 
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public class TimeLineConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            // value is the data from the source object. 
            TimeSpan thisTS = (TimeSpan)value;
            double totalMS = (double)thisTS.TotalMilliseconds;
            // Return the value to pass to the target. 
            return totalMS;
        }

        // ConvertBack is not implemented for a OneWay binding. 
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            TimeSpan thisTS = new TimeSpan(0, 0, 0, 0, (int)Math.Round((double)value,0));
            return thisTS;
        }
    }

    public class TimeSpanToString : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            TimeSpan ts = (TimeSpan)value;
            StringBuilder sb = new StringBuilder();
            sb.Append(ts.Hours + ":");
            sb.Append(ts.Minutes + ":");
            sb.Append(ts.Seconds);
            return sb.ToString();
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }




}

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)

Share

About the Author

Paul_Wade
Software Developer (Senior) Anytime Fitness
United States United States
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.160426.1 | Last Updated 9 Mar 2009
Article Copyright 2009 by Paul_Wade
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid