Skip to content

Commit

Permalink
#68 added multiple button selection to selectionView
Browse files Browse the repository at this point in the history
  • Loading branch information
enisn committed Feb 12, 2019
1 parent 872e0f9 commit df3b28b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion InputKit/Shared/Controls/SelectionView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,10 @@ private ISelection GetInstance(object obj)
switch (SelectionType)
{
case SelectionType.Button:
var btn =new SelectableButton(obj, this.Color);
case SelectionType.MultipleButton:
var btn = new SelectableButton(obj, this.Color);
btn.UnselectedColor = this.BackgroundColor;
btn.CanChangeSelectedState = SelectionType == SelectionType.MultipleButton;
return btn;
case SelectionType.RadioButton:
return new SelectableRadioButton(obj, this.Color);
Expand All @@ -303,6 +305,7 @@ private void SetTextBinding(View control)
switch (SelectionType)
{
case SelectionType.Button:
case SelectionType.MultipleButton:
(control as SelectableButton).SetBinding(SelectableButton.TextProperty, _binding);
break;
case SelectionType.RadioButton:
Expand All @@ -328,6 +331,7 @@ private void SetInstanceColor(View view, Color color)
switch (SelectionType)
{
case SelectionType.Button:
case SelectionType.MultipleButton:
{
if (view is Button)
{
Expand Down Expand Up @@ -370,6 +374,7 @@ public enum SelectionType
Button = 1,
RadioButton = 3,
CheckBox = 2,
MultipleButton = 4,
}

/// <summary>
Expand Down Expand Up @@ -406,6 +411,7 @@ public SelectableButton(object value) : this()
this.BorderColor = SelectionView.GlobalSetting.BorderColor;
this.UnselectedColor = SelectionView.GlobalSetting.BackgroundColor;
this.BorderWidth = 2;
this.Clicked += (s, args) => UpdateSelection();
}
///-----------------------------------------------------------------------------
/// <summary>
Expand Down Expand Up @@ -463,6 +469,15 @@ private void UpdateColors()
/// This button is disabled or not. Disabled buttons(if it's true) can not be choosen.
/// </summary>
public bool IsDisabled { get; set; } = false;
/// <summary>
/// Defines Can Selected State Change by itself
/// </summary>
public bool CanChangeSelectedState { get; set; }
private void UpdateSelection()
{
if (CanChangeSelectedState)
IsSelected = !IsSelected;
}
}

/// <summary>
Expand Down

0 comments on commit df3b28b

Please sign in to comment.