2using System.Collections.Generic;
3using System.ComponentModel;
4using System.ComponentModel.Design;
5using System.Drawing.Design;
6using System.Globalization;
10using MockPlugin.Properties;
25 public string VisibleName => LocalizeMockPlugin.DateColumn_VisibleName_Date;
36 yield
return new ColumnHeaderMenu(() => LocalizeMockPlugin.DateColumn_ColumnHeaderMenu_Fill_down, cells =>
IncreaseBy(cells, dt => dt));
37 yield
return new ColumnHeaderMenu(() => LocalizeMockPlugin.DateColumn_ColumnHeaderMenu_Daily, cells =>
IncreaseBy(cells, dt => dt.Add(TimeSpan.FromDays(1))));
38 yield
return new ColumnHeaderMenu(() => LocalizeMockPlugin.DateColumn_ColumnHeaderMenu_Weekly, cells =>
IncreaseBy(cells,dt => dt.Add(TimeSpan.FromDays(7))));
39 yield
return new ColumnHeaderMenu(() => LocalizeMockPlugin.DateColumn_ColumnHeaderMenu_Monthly, cells =>
IncreaseBy(cells, dt => dt.AddMonths(1)));
43 private void IncreaseBy(IReadOnlyList<ICellAccessor> cells, Func<DateTime,DateTime> adder)
47 var currVal = (
MyDate) cells[0].Value;
48 foreach (var someCell
in cells.Skip(1))
50 currVal =
new MyDate(adder(currVal.DateTime));
51 someCell.Value = currVal;
60 [Editor(typeof(MyDateEditor),typeof(UITypeEditor))]
61 [TypeConverter(typeof(MyDateConverter))]
72 return DateTime.ToString(CultureInfo.InvariantCulture);
81 private readonly TypeConverter
mConv = TypeDescriptor.GetConverter(typeof(DateTime));
82 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture,
object value, Type destinationType)
86 return mConv.ConvertTo(context, CultureInfo.InvariantCulture, mdt.DateTime, destinationType);
88 return mConv.ConvertTo(context, CultureInfo.InvariantCulture, value, destinationType);
91 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture,
object value)
94 if (value is DateTime dt)
99 return new MyDate((DateTime)
mConv.ConvertFrom(context, CultureInfo.InvariantCulture, value));
102 public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
104 return mConv.CanConvertFrom(context, sourceType);
107 public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
109 return mConv.CanConvertTo(context, destinationType);
118 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider,
object value)
123 return new MyDate((DateTime)base.EditValue(context, provider, mdt.DateTime));
125 return base.EditValue(context, provider, value);
Classes and interfaces that are meant for plugins. The classes and interfaces below this namespace ar...
Interfaces for custom sample list column type definitions. These interfaces allow you to define new c...
The classes in this namespace demonstrate how to define your own sample list column types.
Implement this interface on a class that defines a custom column that can be used just like a builtin...
Just a general purpose column header menu.
Example column type that allows to pick a date and time from a graphical editor.
string InternalName
Nametag that will be used internally for storing a column of this type in the method....
void IncreaseBy(IReadOnlyList< ICellAccessor > cells, Func< DateTime, DateTime > adder)
string VisibleName
Column type name that will be presented to the user in the method editor in the "Cell Type" column....
IEnumerable< object > ComboboxItems
List of possible values that can be presented to the user in a drop-down list.
IEnumerable< IColumnMenu > ColumnHeaderMenu
Provide some column header menus for increasing the date in typically used steps.
Type ValueType
Used for getting information which UITypeEditor, TypeConverter etc to use for your column.
Simple wrapper around DateTime that makes sure to always use the invariant culture.
override string ToString()
Just like the default converter, but always use the invariant culture and wraps/unwraps the "MyDate".
readonly TypeConverter mConv
override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
Just unwrap and edit the inner DateTime.
override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)