using System; using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { internal class TimeSpanEditorControl : EntryPropertyEditor { public TimeSpanEditorControl (IHostResourceProvider hostResources) : base (hostResources) { } protected override EntryPropertyEditorDelegate CreateDelegate (PropertyViewModel viewModel) { return new TimeSpanDelegate (viewModel); } protected override void UpdateAccessibilityValues () { base.UpdateAccessibilityValues (); Entry.AccessibilityTitle = string.Format (Properties.Resources.AccessibilityTimeSpan, ViewModel.Property.Name); } private class TimeSpanDelegate : EntryPropertyEditorDelegate { public TimeSpanDelegate (PropertyViewModel viewModel) : base (viewModel) { } protected override TimeSpan GetValue (string value) { return TimeSpan.Parse (value); } protected override bool CanGetValue (string value) { return TimeSpan.TryParse (value, out _); } } } }