7
namespace Stetic.Editor
9
public class DateTimeEditorCell: PropertyEditorCell
11
protected override string GetValueText ()
13
return ((DateTime)Value).ToLongDateString ();
16
protected override IPropertyEditor CreateEditor (Gdk.Rectangle cell_area, Gtk.StateType state)
18
return new DateTimeEditor ();
22
public class DateTimeEditor: Gtk.HBox, IPropertyEditor
27
public DateTimeEditor()
29
entry = new Gtk.Entry ();
30
entry.Changed += OnChanged;
31
PackStart (entry, true, true, 0);
35
public void Initialize (PropertyDescriptor descriptor)
39
public void AttachObject (object ob)
46
time = (DateTime) value;
47
entry.Changed -= OnChanged;
48
entry.Text = time.ToString ("G");
49
entry.Changed += OnChanged;
53
void OnChanged (object o, EventArgs a)
55
string s = entry.Text;
57
foreach (string form in formats) {
59
time = DateTime.ParseExact (s, form, null);
60
if (ValueChanged != null)
61
ValueChanged (this, a);
68
public event EventHandler ValueChanged;
70
static string[] formats = {"u", "G", "g", "d", "T", "t"};