public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { String toolTip = String.Empty; if (values.Length == 2) { if (values[0] is TimeSpan) { TimeSpan duration = (TimeSpan)values[0]; if (duration > new TimeSpan(0)) { if (values[1] is TimeSpan) { TimeSpan ellapsed = (TimeSpan)values[1]; TimeSpan remaining = duration - ellapsed; DateTime finishTime = DateTime.Now + remaining; toolTip += "Duration: " + IntelligentString.FormatDuration(duration, false); toolTip += Environment.NewLine + "Ellapsed: " + IntelligentString.FormatDuration(ellapsed, false); toolTip += Environment.NewLine + "Remaining: " + IntelligentString.FormatDuration(remaining, false); toolTip += Environment.NewLine + "Finish time: " + finishTime.ToString("h:mm tt"); } } } } return(toolTip); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { IntelligentString summary = IntelligentString.Empty; String strShowSize = "True"; Boolean showSize = true; if (parameter != null) { strShowSize = parameter.ToString(); Boolean.TryParse(strShowSize, out showSize); } if (value is IEnumerable <MediaItem> ) { MediaItem[] mediaItems = (value as IEnumerable <MediaItem>).ToArray(); int numberOfItems = mediaItems.Length; Int64 size = 0; TimeSpan duration = new TimeSpan(); String type = "Media Item"; if (numberOfItems > 0) { type = mediaItems[0].Type.ToString(); } foreach (MediaItem mediaItem in mediaItems) { size += mediaItem.Parts.Size; duration += mediaItem.Parts.Duration; if (type != mediaItem.Type.ToString()) { type = "Media Item"; } } if (numberOfItems == 1) { summary += "1 " + type + " - "; } else { summary += numberOfItems.ToString() + " " + type + "s - "; } if (showSize) { summary += IntelligentString.FormatSize(size) + " - "; } summary += IntelligentString.FormatDuration(duration, false); } return(summary); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value is TimeSpan) { Boolean includeMilliseconds = System.Convert.ToBoolean(parameter.ToString()); TimeSpan ts = (TimeSpan)value; return(IntelligentString.FormatDuration(ts, includeMilliseconds)); } return(String.Empty); }