Skip to content

Commit 60e5954

Browse files
committed
boost(banner): Added Center Position
1 parent 798bcdd commit 60e5954

8 files changed

+53
-4
lines changed

SoundSwitch/Framework/Banner/BannerPositionEnum.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public enum BannerPositionEnum
2121
TopRight = 2,
2222
BottomLeft = 3,
2323
BottomCenter = 4,
24-
BottomRight = 5
24+
BottomRight = 5,
25+
Center = 6
2526
}
2627
}

SoundSwitch/Framework/Banner/BannerPositionFactory.cs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class BannerPositionFactory : AbstractFactory<BannerPositionEnum, IPositi
2525
new PositionTopLeft(),
2626
new PositionTopCenter(),
2727
new PositionTopRight(),
28+
new PositionCenter(),
2829
new PositionBottomLeft(),
2930
new PositionBottomCenter(),
3031
new PositionBottomRight()

SoundSwitch/Framework/Banner/Position/APosition.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ internal class APosition
2222
public int PositionLeft(Screen screen) => screen.Bounds.X + 50;
2323
public int PositionBottom(Screen screen, int height, int offset) => screen.Bounds.Height - height - PositionTop(screen, 0) - offset;
2424
public int PositionRight(Screen screen, int width) => screen.Bounds.Width - width - PositionLeft(screen);
25-
public int PositionCenter(Screen screen, int width) => (screen.Bounds.Width - width) / 2;
25+
public int PositionCenterH(Screen screen, int width) => (screen.Bounds.Width - width) / 2;
26+
public int PositionCenterV(Screen screen, int height) => (screen.Bounds.Height - height) / 2;
2627
}
2728
}

SoundSwitch/Framework/Banner/Position/PositionBottomCenter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ internal class PositionBottomCenter : APosition, IPosition
2626
public Point GetScreenPosition(Screen screen, int height, int width, int offset)
2727
{
2828
return new Point(
29-
PositionCenter(screen, width),
29+
PositionCenterH(screen, width),
3030
PositionBottom(screen, height, offset)
3131
);
3232
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/********************************************************************
2+
* Copyright (C) 2015-2017 Antoine Aflalo
3+
*
4+
* This program is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU General Public License
6+
* as published by the Free Software Foundation; either version 2
7+
* of the License, or (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
********************************************************************/
14+
15+
using System.Drawing;
16+
using System.Windows.Forms;
17+
using SoundSwitch.Localization;
18+
19+
namespace SoundSwitch.Framework.Banner.Position
20+
{
21+
internal class PositionCenter : APosition, IPosition
22+
{
23+
public BannerPositionEnum TypeEnum => BannerPositionEnum.Center;
24+
public string Label => SettingsStrings.position_option_center;
25+
26+
public Point GetScreenPosition(Screen screen, int height, int width, int offset)
27+
{
28+
return new Point(
29+
PositionCenterH(screen, width),
30+
PositionCenterV(screen, height)
31+
);
32+
}
33+
}
34+
}

SoundSwitch/Framework/Banner/Position/PositionTopCenter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ internal class PositionTopCenter : APosition, IPosition
2626
public Point GetScreenPosition(Screen screen, int height, int width, int offset)
2727
{
2828
return new Point(
29-
PositionCenter(screen, width),
29+
PositionCenterH(screen, width),
3030
PositionTop(screen, offset)
3131
);
3232
}

SoundSwitch/Localization/SettingsStrings.Designer.cs

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SoundSwitch/Localization/SettingsStrings.resx

+3
Original file line numberDiff line numberDiff line change
@@ -558,4 +558,7 @@ Restore the state of the system when the application is closed.</value>
558558
<data name="troubleshooting.desc" xml:space="preserve">
559559
<value>If you need any help or further troubleshooting with SoundSwitch, you can visit the Help Discussion or Community Discord link, or help support us by visiting the Donate link below.</value>
560560
</data>
561+
<data name="position.option.center" xml:space="preserve">
562+
<value>Center</value>
563+
</data>
561564
</root>

0 commit comments

Comments
 (0)