| | 1 | | namespace PropertyGridHelpers.Controls |
| | 2 | | { |
| | 3 | | #if NET5_0_OR_GREATER |
| | 4 | | /// <summary> |
| | 5 | | /// Represents a strongly-typed wrapper for a ComboBox item, |
| | 6 | | /// associating custom display text with an underlying value. |
| | 7 | | /// </summary> |
| | 8 | | /// <typeparam name="T"> |
| | 9 | | /// The type of the value associated with this ComboBox item. |
| | 10 | | /// </typeparam> |
| | 11 | | /// <param name="displayText">The text shown to the user.</param> |
| | 12 | | /// <param name="value">The backing value represented by this item.</param> |
| 304 | 13 | | public class ItemWrapper<T>(string displayText, T value) |
| | 14 | | #else |
| | 15 | | /// <summary> |
| | 16 | | /// Represents a strongly-typed wrapper for a ComboBox item, |
| | 17 | | /// associating custom display text with an underlying value. |
| | 18 | | /// </summary> |
| | 19 | | /// <typeparam name="T"> |
| | 20 | | /// The type of the value associated with this ComboBox item. |
| | 21 | | /// </typeparam> |
| | 22 | | public class ItemWrapper<T> |
| | 23 | | #endif |
| | 24 | | { |
| | 25 | | /// <summary> |
| | 26 | | /// Gets the text displayed in the ComboBox for this item. |
| | 27 | | /// </summary> |
| | 28 | | /// <value> |
| | 29 | | /// The human-readable text shown to the user. |
| | 30 | | /// </value> |
| | 31 | | public string DisplayText |
| | 32 | | { |
| 60 | 33 | | get; |
| | 34 | | #if NET5_0_OR_GREATER |
| 304 | 35 | | } = displayText; |
| | 36 | | #else |
| | 37 | | } |
| | 38 | | #endif |
| | 39 | |
|
| | 40 | | /// <summary> |
| | 41 | | /// Gets the value associated with this item. |
| | 42 | | /// </summary> |
| | 43 | | /// <value> |
| | 44 | | /// The strongly-typed backing value. |
| | 45 | | /// </value> |
| | 46 | | public T Value |
| | 47 | | { |
| 928 | 48 | | get; |
| | 49 | | #if NET5_0_OR_GREATER |
| 304 | 50 | | } = value; |
| | 51 | | #else |
| | 52 | | } |
| | 53 | | #endif |
| | 54 | |
|
| | 55 | | #if NET5_0_OR_GREATER |
| | 56 | | #else |
| | 57 | | /// <summary> |
| | 58 | | /// Initializes a new instance of the <see cref="ItemWrapper{T}"/> class. |
| | 59 | | /// </summary> |
| | 60 | | /// <param name="displayText">The text shown to the user.</param> |
| | 61 | | /// <param name="value">The backing value represented by this item.</param> |
| | 62 | | public ItemWrapper(string displayText, T value) |
| | 63 | | { |
| | 64 | | DisplayText = displayText; |
| | 65 | | Value = value; |
| | 66 | | } |
| | 67 | | #endif |
| | 68 | |
|
| | 69 | | /// <summary> |
| | 70 | | /// Returns the display text for this item. |
| | 71 | | /// </summary> |
| | 72 | | /// <returns> |
| | 73 | | /// A string containing the <see cref="DisplayText"/>. |
| | 74 | | /// </returns> |
| 28 | 75 | | public override string ToString() => DisplayText; |
| | 76 | | } |
| | 77 | | } |