Chronos Plugins 5.9.0
This documentation covers the plugin interfaces definitions and an example implementation.
Loading...
Searching...
No Matches
CreamTypeColumn.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Globalization;
5using System.Linq;
8using MockPlugin.Properties;
10
12{
16 // ReSharper disable once UnusedType.Global
18 {
19 public string InternalName => "MockPlugin_Cream";
20 public string VisibleName => "Cream Type";
21
22 public IEnumerable<object> ComboboxItems =>
23 Enum.GetValues(typeof(BrewFrappuccino.CreamType)).OfType<object>();
24 public Type ValueType => typeof(BrewFrappuccino.CreamType);
25
26 public IEnumerable<IColumnMenu> ColumnHeaderMenu
27 {
28 get
29 {
30 yield return new ColumnHeaderMenu(() => LocalizeMockPlugin.CreamTypeColumn_ColumnHeaderMenu_Fill_down, FillDown);
31 yield return new ColumnHeaderMenu(() => LocalizeMockPlugin.CreamTypeColumn_ColumnHeaderMenu_Cycle_through, CycleThrough);
32 }
33 }
34
35 private void CycleThrough(IReadOnlyList<ICellAccessor> cells)
36 {
37 if (cells.Count >= 2)
38 {
39 var allValues = Enum.GetValues(typeof(BrewFrappuccino.CreamType)).Cast<BrewFrappuccino.CreamType>().ToArray();
40 var currVal = (BrewFrappuccino.CreamType) cells[0].Value;
41 foreach (var someCell in cells.Skip(1))
42 {
43 var validItems = someCell.Column.StandardItems;
44 var roundtrips = 0;
45 do
46 {
47 if (currVal == allValues.Last())
48 {
49 currVal = allValues.First();
50 roundtrips += 1;
51 }
52 else
53 {
54 currVal += 1;
55 }
56 } while (roundtrips < 2 && (validItems?.Count ?? 0) > 0 && !validItems.Contains(currVal.ToString()));
57 someCell.Value = currVal;
58 }
59 }
60 }
61
66 private void FillDown(IReadOnlyList<ICellAccessor> cells)
67 {
68 if (cells.Count >= 2)
69 {
70 var topVal = cells[0].Value;
71 foreach (var someCell in cells.Skip(1))
72 {
73 someCell.Value = topVal;
74 }
75 }
76 }
77 }
78
82 public class CreamTypeConverter : EnumConverter
83 {
87 public CreamTypeConverter() : base(typeof(BrewFrappuccino.CreamType))
88 {
89 }
90
99 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
100 {
101 return base.ConvertFrom(context, culture, value);
102 }
103 }
104
105}
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...
Definition ColumnMenu.cs:4
Example task implementations. Since there are lots of things that can be done from a task,...
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...
Definition ColumnType.cs:18
Just a general purpose column header menu.
Simple case: Enum based column. Possible values are given in the StandardItems, custom editor is not ...
string VisibleName
Column type name that will be presented to the user in the method editor in the "Cell Type" column....
void CycleThrough(IReadOnlyList< ICellAccessor > cells)
void FillDown(IReadOnlyList< ICellAccessor > cells)
Fill all given cells with the value of the top row.
Type ValueType
Used for getting information which UITypeEditor, TypeConverter etc to use for your column.
IEnumerable< object > ComboboxItems
List of possible values that can be presented to the user in a drop-down list.
string InternalName
Nametag that will be used internally for storing a column of this type in the method....
IEnumerable< IColumnMenu > ColumnHeaderMenu
If this is not null, it declares column header menu entries that can be used for "Autofill" like feat...
Just provide a TypeConverter, and Chronos is happy.
override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
The actual conversion work string->object is done here.
CreamTypeConverter()
Luckily we can inherit everything necessary.
A task working on a complex parameter set.
CreamType
Enum properties result in nice drop-down lists.