X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem.Design%2FSystem.ComponentModel.Design%2FDateTimeEditor.cs;h=bb0677cb0189ef2a0f81c25d901b29f7f6ba4085;hb=83a2cc75f87a21c00c6ea3e1c6cc20c0a4eeb153;hp=ff93ce7d229aa39b75c8686caec359f3b6ffec3b;hpb=2007998771b1c4d9e762943676d7959daaf74385;p=mono.git diff --git a/mcs/class/System.Design/System.ComponentModel.Design/DateTimeEditor.cs b/mcs/class/System.Design/System.ComponentModel.Design/DateTimeEditor.cs index ff93ce7d229..bb0677cb018 100644 --- a/mcs/class/System.Design/System.ComponentModel.Design/DateTimeEditor.cs +++ b/mcs/class/System.Design/System.ComponentModel.Design/DateTimeEditor.cs @@ -2,9 +2,11 @@ // System.ComponentModel.Design.DateTimeEditor // // Authors: -// Gert Driesen (drieseng@users.sourceforge.net) +// Andreas Nahr (ClassDevelopment@A-SoftTech.com) +// Gert Driesen (drieseng@users.sourceforge.net) // // (C) 2004 Novell +// (C) 2007 Andreas Nahr // // @@ -28,21 +30,62 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -using System.Windows.Forms; + +using System; +using System.ComponentModel; using System.Drawing.Design; +using System.Windows.Forms; +using System.Windows.Forms.Design; namespace System.ComponentModel.Design { public class DateTimeEditor : UITypeEditor { + private class EditorControl : MonthCalendar + { + public EditorControl () + { + MaxSelectionCount = 1; + } + } + + private IWindowsFormsEditorService editorService; + private EditorControl control = new EditorControl (); + private DateTime editContent; + public DateTimeEditor () { + control.DateSelected += new DateRangeEventHandler (control_DateSelected); } - [MonoTODO] public override object EditValue (ITypeDescriptorContext context, IServiceProvider provider, object value) { - throw new NotImplementedException (); + if (context != null && provider != null) + { + editorService = (IWindowsFormsEditorService)provider.GetService (typeof (IWindowsFormsEditorService)); + if (editorService != null) + { + if (!(value is DateTime)) + return value; + + editContent = (DateTime)value; + if (editContent > control.MaxDate || editContent < control.MinDate) + control.SelectionStart = DateTime.Today; + else + control.SelectionStart = editContent; + + editorService.DropDownControl (control); + + return editContent; + } + } + return base.EditValue (context, provider, value); + } + + void control_DateSelected (object sender, DateRangeEventArgs e) + { + editContent = e.Start; + editorService.CloseDropDown (); } public override UITypeEditorEditStyle GetEditStyle (ITypeDescriptorContext context)