Skip to content

Commit 721fd85

Browse files
author
Antoine Aflalo
committed
Reimplement correctly the combobox
Use valueMember and displaying. Fixes #88
1 parent a8c22db commit 721fd85

File tree

6 files changed

+24
-13
lines changed

6 files changed

+24
-13
lines changed

SoundSwitch/Framework/TooltipInfoManager/TootipInfo/ITooltipInfo.cs

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
using AudioEndPointControllerWrapper;
2-
31
namespace SoundSwitch.Framework.TooltipInfoManager.TootipInfo
42
{
53
public interface ITooltipInfo
64
{
7-
85
/// <summary>
9-
/// Type of the Tooltip Info
6+
/// Type of the Tooltip Info
107
/// </summary>
118
TooltipInfoTypeEnum TypeEnum { get; }
9+
10+
/// <summary>
11+
/// Displaying label
12+
/// </summary>
13+
string Label { get; }
14+
1215
/// <summary>
13-
/// The text to display for this tooltip
16+
/// The text to display for this tooltip
1417
/// </summary>
1518
/// <returns></returns>
1619
string TextToDisplay();

SoundSwitch/Framework/TooltipInfoManager/TootipInfo/TooltipInfoBoth.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace SoundSwitch.Framework.TooltipInfoManager.TootipInfo
55
public class TooltipInfoBoth : ITooltipInfo
66
{
77
public TooltipInfoTypeEnum TypeEnum { get; } = TooltipInfoTypeEnum.Both;
8+
public string Label { get; } = TooltipInfo.both;
89

910
/// <summary>
1011
/// The text to display for this tooltip
@@ -24,7 +25,7 @@ public string TextToDisplay()
2425

2526
public override string ToString()
2627
{
27-
return TooltipInfo.both;
28+
return Label;
2829
}
2930
}
3031
}

SoundSwitch/Framework/TooltipInfoManager/TootipInfo/TooltipInfoNone.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace SoundSwitch.Framework.TooltipInfoManager.TootipInfo
55
public class TooltipInfoNone : ITooltipInfo
66
{
77
public TooltipInfoTypeEnum TypeEnum { get; } = TooltipInfoTypeEnum.None;
8+
public string Label { get; } = TooltipInfo.none;
89

910
public string TextToDisplay()
1011
{
@@ -14,7 +15,7 @@ public string TextToDisplay()
1415

1516
public override string ToString()
1617
{
17-
return TooltipInfo.none;
18+
return Label;
1819
}
1920
}
2021
}

SoundSwitch/Framework/TooltipInfoManager/TootipInfo/TooltipInfoPlayback.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace SoundSwitch.Framework.TooltipInfoManager.TootipInfo
88
public class TooltipInfoPlayback : ITooltipInfo
99
{
1010
public TooltipInfoTypeEnum TypeEnum { get; } = TooltipInfoTypeEnum.Playback;
11+
public string Label { get; } = TooltipInfo.playback;
1112

1213
/// <summary>
1314
/// The text to display for this tooltip
@@ -23,7 +24,7 @@ public string TextToDisplay()
2324

2425
public override string ToString()
2526
{
26-
return TooltipInfo.playback;
27+
return Label;
2728
}
2829
}
2930
}

SoundSwitch/Framework/TooltipInfoManager/TootipInfo/TooltipInfoRecording.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ namespace SoundSwitch.Framework.TooltipInfoManager.TootipInfo
77
{
88
public class TooltipInfoRecording : ITooltipInfo
99
{
10-
public TooltipInfoTypeEnum TypeEnum { get; } =TooltipInfoTypeEnum.Recording;
10+
public TooltipInfoTypeEnum TypeEnum { get; } = TooltipInfoTypeEnum.Recording;
11+
public string Label { get; } = TooltipInfo.recording;
1112

1213
/// <summary>
1314
/// The text to display for this tooltip
@@ -23,7 +24,7 @@ public string TextToDisplay()
2324

2425
public override string ToString()
2526
{
26-
return TooltipInfo.recording;
27+
return Label;
2728
}
2829
}
2930
}

SoundSwitch/UI/Forms/Settings.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ public Settings()
9696
var toolTipStealthUpdate = new ToolTip();
9797
toolTipStealthUpdate.SetToolTip(stealthUpdateCheckbox, SettingsString.stealthUpdateExplanation);
9898

99-
tooltipInfoComboBox.DataSource = new TooltipInfoFactory().AllImplementations.Values.ToArray();
99+
var tooltipInfoFactory = new TooltipInfoFactory();
100+
tooltipInfoComboBox.ValueMember = "TypeEnum";
101+
tooltipInfoComboBox.DisplayMember = "Label";
102+
tooltipInfoComboBox.DataSource = tooltipInfoFactory.AllImplementations.Values.ToArray();
103+
tooltipInfoComboBox.SelectedValue = TooltipInfoManager.CurrentTooltipInfo;
100104

101105
_loaded = true;
102106
}
@@ -223,8 +227,8 @@ private void tooltipInfoComboBox_SelectedValueChanged(object sender, EventArgs e
223227
if (value == null)
224228
return;
225229

226-
var tooltip = (ITooltipInfo) value;
227-
TooltipInfoManager.CurrentTooltipInfo = tooltip.TypeEnum;
230+
var tooltip = (TooltipInfoTypeEnum) value;
231+
TooltipInfoManager.CurrentTooltipInfo = tooltip;
228232
}
229233

230234
private void selectSoundButton_Click(object sender, EventArgs e)

0 commit comments

Comments
 (0)