123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows.Data;
- using System.Windows.Media;
- using Xceed.Wpf.DataGrid;
- using System.Data;
- using System.Windows;
- namespace Aitex.UI.RecipeEditor
- {
- public class TimeSpanConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- try
- {
- string v = (string)value;
- DateTime dt;
- if (!DateTime.TryParse(v, out dt))
- return new DateTime(0);
- dt = new DateTime(1, 1, 1, dt.Hour, dt.Minute, dt.Second);
- return dt;
- }
- catch (Exception ex)
- {
- System.Diagnostics.Debug.WriteLine(ex.Message);
- }
- return new DateTime(0);
- }
- public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- try
- {
- DateTime dt = (DateTime)value;
- return string.Format("{0}:{1}:{2}", dt.Hour.ToString("00"), dt.Minute.ToString("00"), dt.Second.ToString("00"));
- }
- catch (Exception ex)
- {
- System.Diagnostics.Debug.WriteLine(ex.Message);
- }
- return "00:00:00";
- }
- }
- }
|