using System; using System.Globalization; using System.Windows; using System.Windows.Data; using Comal.Classes; using InABox.Core; namespace PRSDesktop { public class JobDocumentSetDetailsConverter : IValueConverter { public object Convert(object value, Type t, object parameter, CultureInfo culture) { try { if ((value == null) || String.Equals(value,"")) return ""; var details = Serialization.Deserialize(value.ToString()); if (String.Equals(parameter, "ID")) return details.ID; if (String.Equals(parameter, "Date")) return details.Date.IsEmpty() ? "" : String.Format("{0:dd MMM yy}",details.Date); if (String.Equals(parameter, "Size")) return (details.Size == PaperSize.NotSet) && String.IsNullOrWhiteSpace(details.Scale) ? "" : String.Format("{0} {1}",details.Size.ToString(), details.Scale).Trim(); if (String.Equals(parameter, "Employee")) return details.Employee; return parameter.ToString(); } catch (Exception e) { return e.Message; } } public object ConvertBack(object value, Type t, object parameter, CultureInfo culture) { return value.Equals(false) ? DependencyProperty.UnsetValue : parameter; } } }