/[gr2lib]/trunk/gr2lib/core/ui/typeeditors/UIComboValueSelector.cs
ViewVC logotype

Annotation of /trunk/gr2lib/core/ui/typeeditors/UIComboValueSelector.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 160 - (hide annotations) (download)
Thu Jul 22 10:20:55 2010 UTC (9 years, 6 months ago) by william
File size: 1440 byte(s)
Add UIEditor to edit EnumType Values via a dropdown combobox

1 william 160 using System;
2     using System.Collections.Generic;
3     using System.Linq;
4     using System.Text;
5     using System.Drawing.Design;
6     using System.ComponentModel;
7     using System.Windows.Forms.Design;
8    
9     namespace gr2lib.core.ui.typeeditors
10     {
11     internal class UIComboValueSelector<ENUM_TYPE, ENUM_BASE_TYPE> : UITypeEditor
12     where ENUM_BASE_TYPE : IConvertible
13     //where T : IValueType<string>
14     {
15     public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
16     {
17     return UITypeEditorEditStyle.Modal;
18     }
19     public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
20     {
21     IWindowsFormsEditorService editorService = null;
22     if (provider != null)
23     {
24     editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
25     }
26     ComboValueSelector<ENUM_TYPE, ENUM_BASE_TYPE> selectionControl = null;
27     if (editorService != null)
28     {
29    
30     //IPairedValueType<VALUE_TYPE> _tmp = (PairedValueType<VALUE_TYPE>)value;
31    
32     selectionControl = new ComboValueSelector<ENUM_TYPE, ENUM_BASE_TYPE>(value);
33    
34     editorService.DropDownControl(selectionControl);
35     }
36    
37     return selectionControl.Value;
38     }
39     }
40     }

  ViewVC Help
Powered by ViewVC 1.1.22