Skip to content

Commit

Permalink
feat(banner:on-screen-time): Settings to change how long the banner s…
Browse files Browse the repository at this point in the history
…tays on the screen

Fixes #1467
  • Loading branch information
Belphemur committed May 7, 2024
1 parent 6aea86a commit 41644f5
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,7 @@ public interface ISoundSwitchConfiguration : IConfiguration
/// How many banner notification can be displayed at the same time on the screen
/// </summary>
int MaxNumberNotification { get; set; }

TimeSpan BannerOnScreenTime { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public SoundSwitchConfiguration()
NotificationSettings = NotificationTypeEnum.BannerNotification;
BannerPosition = BannerPositionEnum.TopLeft;
MaxNumberNotification = 5;
BannerOnScreenTime = TimeSpan.FromSeconds(3);

AutoAddNewConnectedDevices = false;

Expand All @@ -73,6 +74,8 @@ public SoundSwitchConfiguration()
MigratedFields = new HashSet<string>();
}

public TimeSpan BannerOnScreenTime { get; set; }

public int MaxNumberNotification { get; set; }
public HashSet<string> SelectedPlaybackDeviceListId { get; }
public HashSet<string> SelectedRecordingDeviceListId { get; }
Expand Down
19 changes: 18 additions & 1 deletion SoundSwitch/Localization/SettingsStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions SoundSwitch/Localization/SettingsStrings.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -582,4 +582,10 @@ Restaurer l'état du système quand l'application est fermée.</value>
<data name="troubleshooting" xml:space="preserve">
<value>Dépannage</value>
</data>
<data name="notification.banner.onscreen.time" xml:space="preserve">
<value>Seconde visible</value>
</data>
<data name="notification.banner.onscreen.time.tooltip" xml:space="preserve">
<value>Durée de visibilité de la bannière à l'écran en secondes.</value>
</data>
</root>
6 changes: 6 additions & 0 deletions SoundSwitch/Localization/SettingsStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -561,4 +561,10 @@ Restore the state of the system when the application is closed.</value>
<data name="position.option.center" xml:space="preserve">
<value>Center</value>
</data>
<data name="notification.banner.onscreen.time" xml:space="preserve">
<value>On screen time</value>
</data>
<data name="notification.banner.onscreen.time.tooltip" xml:space="preserve">
<value>How long the banner stays on the screen in seconds.</value>
</data>
</root>
16 changes: 16 additions & 0 deletions SoundSwitch/Model/AppModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ private AppModel()

public ProfileManager ProfileManager { get; private set; }

public int BannerOnScreenTimeSecs
{
get => (int)BannerOnScreenTime.TotalSeconds;
set => BannerOnScreenTime = TimeSpan.FromSeconds(value);
}
public TimeSpan BannerOnScreenTime
{
get => AppConfigs.Configuration.BannerOnScreenTime;
set
{
if (value <= TimeSpan.FromSeconds(1)) return;
if(value >= TimeSpan.FromMinutes(1)) return;
AppConfigs.Configuration.BannerOnScreenTime = value;
AppConfigs.Configuration.Save();
}
}
/// <summary>
/// How many notification to show at the same time
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions SoundSwitch/Model/IAppModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ public interface IAppModel : IDisposable
/// </summary>
bool IsSingleNotification { get; set; }

TimeSpan BannerOnScreenTime { get; set; }
int BannerOnScreenTimeSecs { get; set; }

#endregion

#region Events
Expand Down
124 changes: 75 additions & 49 deletions SoundSwitch/UI/Forms/Settings.Designer.cs

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions SoundSwitch/UI/Forms/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,13 @@ public SettingsForm(IAudioDeviceLister audioDeviceLister)
positionComboBox.SelectedValue = AppModel.Instance.BannerPosition;
var positionToolTip = new ToolTip();
positionToolTip.SetToolTip(positionComboBox, SettingsStrings.position_tooltip);



var onScreenTimeTooltip = new ToolTip();
onScreenTimeTooltip.SetToolTip(onScreenUpDown, SettingsStrings.notification_banner_onscreen_time_tooltip);
onScreenTimeTooltip.SetToolTip(onScreenTimeLabel, SettingsStrings.notification_banner_onscreen_time_tooltip);
onScreenUpDown.DataBindings.Add(nameof(NumericUpDown.Value), AppModel.Instance, nameof(AppModel.BannerOnScreenTimeSecs), false, DataSourceUpdateMode.OnPropertyChanged);

var singleNotification = new ToolTip();
singleNotification.SetToolTip(singleNotificationCheckbox, SettingsStrings.notification_single_tooltip);
singleNotificationCheckbox.DataBindings.Add(nameof(CheckBox.Checked), AppModel.Instance, nameof(AppModel.IsSingleNotification), false, DataSourceUpdateMode.OnPropertyChanged);
Expand Down Expand Up @@ -369,7 +375,8 @@ private void LocalizeForm()
usePrimaryScreenCheckbox.Text = SettingsStrings.usePrimaryScreen;
positionLabel.Text = SettingsStrings.position;
singleNotificationCheckbox.Text = SettingsStrings.notification_single;

onScreenTimeLabel.Text = SettingsStrings.notification_banner_onscreen_time;

// Settings - Troubleshooting
resetAudioDevicesGroupBox.Text = SettingsStrings.resetAudioDevices;
resetAudioDevicesLabel.Text = SettingsStrings.resetAudioDevices_desc;
Expand Down

0 comments on commit 41644f5

Please sign in to comment.