Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Adds a mechanism in PredefinedValues to allow handle separator string values #645

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Xamarin.PropertyEditing.Mac/Controls/PredefinedValuesEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,22 @@ protected override void OnViewModelChanged (PropertyViewModel oldModel)

this.popupButtonList.RemoveAllItems ();
foreach (var item in ViewModel.PossibleValues) {
this.popupButtonList.AddItem (new NSMenuItem (item));
if (!string.IsNullOrEmpty (ViewModel.SeparatorString) && ViewModel.SeparatorString == item) {
this.popupButtonList.AddItem (NSMenuItem.SeparatorItem);
} else {
this.popupButtonList.AddItem (new NSMenuItem (item));
}
}
} else {
RequireComboBox ();

this.comboBox.RemoveAll ();
foreach (var item in ViewModel.PossibleValues) {
this.comboBox.Add (new NSString (item));
if (!string.IsNullOrEmpty (ViewModel.SeparatorString) && ViewModel.SeparatorString == item) {
this.comboBox.Add (NSMenuItem.SeparatorItem);
} else {
this.comboBox.Add (new NSString (item));
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions Xamarin.PropertyEditing/IHavePredefinedValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public interface IHavePredefinedValues<TValue>
/// </remarks>
bool IsValueCombinable { get; }

string SeparatorString { get; }

IReadOnlyDictionary<string, TValue> PredefinedValues { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public IReadOnlyDictionary<string, T> PredefinedValues
get;
}

public string SeparatorString { get; }

#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
public override async Task SetValueAsync<TValue> (object target, TValue value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public string ValueName
set { SetValueName (value); }
}

public string SeparatorString => this.predefinedValues.SeparatorString;

public bool IsConstrainedToPredefined => this.predefinedValues.IsConstrainedToPredefined;

protected override TValue CoerceValue (TValue validationValue)
Expand Down