Skip to content

Commit

Permalink
boost(notification): Added Top Center/Bottom Center to Banner Positio…
Browse files Browse the repository at this point in the history
…ns (#1347)

* feat(notification): Banner positions

* Update SoundSwitch/Framework/Banner/BannerForm.cs

Co-authored-by: Antoine Aflalo <Belphemur@users.noreply.github.com>

* fix(notification): added Top Center and Bottom Center to Banner Positions.

---------

Co-authored-by: Antoine Aflalo <Belphemur@users.noreply.github.com>
  • Loading branch information
XangelMusic and Belphemur authored Dec 30, 2023
1 parent 40892fe commit 1566fc9
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 5 deletions.
3 changes: 3 additions & 0 deletions SoundSwitch/Framework/Banner/BannerForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,17 @@ internal void SetData(BannerData data)
var screen = GetScreen();
var positionLeft = screen.Bounds.X + 50;
var positionRight = screen.Bounds.Width - Width - positionLeft;
var positionCenterH = (screen.Bounds.Width - Width) / 2;
var positionTop = screen.Bounds.Y + 60;
var positionBottom = screen.Bounds.Height - Height - positionTop;

Location = AppModel.Instance.BannerPosition switch
{
BannerPositionEnum.TopLeft => new Point(positionLeft, positionTop),
BannerPositionEnum.TopCenter => new Point(positionCenterH, positionTop),
BannerPositionEnum.TopRight => new Point(positionRight, positionTop),
BannerPositionEnum.BottomLeft => new Point(positionLeft, positionBottom),
BannerPositionEnum.BottomCenter => new Point(positionCenterH, positionBottom),
BannerPositionEnum.BottomRight => new Point(positionRight, positionBottom),
_ => new Point(0, 0)
};
Expand Down
8 changes: 5 additions & 3 deletions SoundSwitch/Framework/Banner/BannerPositionEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ namespace SoundSwitch.Framework.Banner
public enum BannerPositionEnum
{
TopLeft = 0,
TopRight = 1,
BottomLeft = 2,
BottomRight = 3
TopCenter = 1,
TopRight = 2,
BottomLeft = 3,
BottomCenter = 4,
BottomRight = 5
}
}
4 changes: 2 additions & 2 deletions SoundSwitch/Framework/Banner/BannerPositionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
* GNU General Public License for more details.
********************************************************************/

using System.Collections.Generic;
using System.Linq;
using SoundSwitch.Framework.Banner;
using SoundSwitch.Framework.Banner.Position;
using SoundSwitch.Framework.Factory;
Expand All @@ -26,8 +24,10 @@ public class BannerPositionFactory : AbstractFactory<BannerPositionEnum, IPositi
<BannerPositionEnum, IPosition>
{
new PositionTopLeft(),
new PositionTopCenter(),
new PositionTopRight(),
new PositionBottomLeft(),
new PositionBottomCenter(),
new PositionBottomRight()
};

Expand Down
24 changes: 24 additions & 0 deletions SoundSwitch/Framework/Banner/Position/PositionBottomCenter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/********************************************************************
* Copyright (C) 2015-2017 Antoine Aflalo
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
********************************************************************/

using SoundSwitch.Localization;

namespace SoundSwitch.Framework.Banner.Position
{
internal class PositionBottomCenter : IPosition
{
public BannerPositionEnum TypeEnum => BannerPositionEnum.BottomCenter;
public string Label => SettingsStrings.positionOptionBottomCenter;
}
}
24 changes: 24 additions & 0 deletions SoundSwitch/Framework/Banner/Position/PositionTopCenter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/********************************************************************
* Copyright (C) 2015-2017 Antoine Aflalo
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
********************************************************************/

using SoundSwitch.Localization;

namespace SoundSwitch.Framework.Banner.Position
{
internal class PositionTopCenter : IPosition
{
public BannerPositionEnum TypeEnum => BannerPositionEnum.TopCenter;
public string Label => SettingsStrings.positionOptionTopCenter;
}
}
18 changes: 18 additions & 0 deletions 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.resx
Original file line number Diff line number Diff line change
Expand Up @@ -516,4 +516,10 @@ Restore the state of the system when the application is closed.</value>
<data name="positionOptionTopRight" xml:space="preserve">
<value>Top Right</value>
</data>
<data name="positionOptionBottomCenter" xml:space="preserve">
<value>Bottom Center</value>
</data>
<data name="positionOptionTopCenter" xml:space="preserve">
<value>Top Center</value>
</data>
</root>

0 comments on commit 1566fc9

Please sign in to comment.