Skip to content

Commit

Permalink
boost(banner): Added Center Position
Browse files Browse the repository at this point in the history
  • Loading branch information
XangelMusic committed Apr 28, 2024
1 parent 798bcdd commit 60e5954
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 4 deletions.
3 changes: 2 additions & 1 deletion SoundSwitch/Framework/Banner/BannerPositionEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public enum BannerPositionEnum
TopRight = 2,
BottomLeft = 3,
BottomCenter = 4,
BottomRight = 5
BottomRight = 5,
Center = 6
}
}
1 change: 1 addition & 0 deletions SoundSwitch/Framework/Banner/BannerPositionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class BannerPositionFactory : AbstractFactory<BannerPositionEnum, IPositi
new PositionTopLeft(),
new PositionTopCenter(),
new PositionTopRight(),
new PositionCenter(),
new PositionBottomLeft(),
new PositionBottomCenter(),
new PositionBottomRight()
Expand Down
3 changes: 2 additions & 1 deletion SoundSwitch/Framework/Banner/Position/APosition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ internal class APosition
public int PositionLeft(Screen screen) => screen.Bounds.X + 50;
public int PositionBottom(Screen screen, int height, int offset) => screen.Bounds.Height - height - PositionTop(screen, 0) - offset;
public int PositionRight(Screen screen, int width) => screen.Bounds.Width - width - PositionLeft(screen);
public int PositionCenter(Screen screen, int width) => (screen.Bounds.Width - width) / 2;
public int PositionCenterH(Screen screen, int width) => (screen.Bounds.Width - width) / 2;
public int PositionCenterV(Screen screen, int height) => (screen.Bounds.Height - height) / 2;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal class PositionBottomCenter : APosition, IPosition
public Point GetScreenPosition(Screen screen, int height, int width, int offset)
{
return new Point(
PositionCenter(screen, width),
PositionCenterH(screen, width),
PositionBottom(screen, height, offset)
);
}
Expand Down
34 changes: 34 additions & 0 deletions SoundSwitch/Framework/Banner/Position/PositionCenter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/********************************************************************
* 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 System.Drawing;
using System.Windows.Forms;
using SoundSwitch.Localization;

namespace SoundSwitch.Framework.Banner.Position
{
internal class PositionCenter : APosition, IPosition
{
public BannerPositionEnum TypeEnum => BannerPositionEnum.Center;
public string Label => SettingsStrings.position_option_center;

public Point GetScreenPosition(Screen screen, int height, int width, int offset)
{
return new Point(
PositionCenterH(screen, width),
PositionCenterV(screen, height)
);
}
}
}
2 changes: 1 addition & 1 deletion SoundSwitch/Framework/Banner/Position/PositionTopCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal class PositionTopCenter : APosition, IPosition
public Point GetScreenPosition(Screen screen, int height, int width, int offset)
{
return new Point(
PositionCenter(screen, width),
PositionCenterH(screen, width),
PositionTop(screen, offset)
);
}
Expand Down
9 changes: 9 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.

3 changes: 3 additions & 0 deletions SoundSwitch/Localization/SettingsStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -558,4 +558,7 @@ Restore the state of the system when the application is closed.</value>
<data name="troubleshooting.desc" xml:space="preserve">
<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>
</data>
<data name="position.option.center" xml:space="preserve">
<value>Center</value>
</data>
</root>

0 comments on commit 60e5954

Please sign in to comment.