Skip to content

Commit

Permalink
Merge pull request #1471 from Belphemur/banner-center
Browse files Browse the repository at this point in the history
boost(banner): Added Center Position
  • Loading branch information
XangelMusic authored Apr 28, 2024
2 parents 798bcdd + dc30bb1 commit 71ec9a1
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 6 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
}
}
5 changes: 3 additions & 2 deletions SoundSwitch/Framework/Banner/BannerPositionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ public class BannerPositionFactory : AbstractFactory<BannerPositionEnum, IPositi
new PositionTopRight(),
new PositionBottomLeft(),
new PositionBottomCenter(),
new PositionBottomRight()
new PositionBottomRight(),
new PositionCenter()
};

public BannerPositionFactory() : base(Positions)
{
}
}
}
}
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">

Check warning on line 558 in SoundSwitch/Localization/SettingsStrings.resx

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Resource is not overridden in specific culture

Resource is not overridden in Arabic, Bulgarian, Chinese (Simplified), Chinese (Traditional), Croatian, Czech, Danish, Dutch, Finnish (Finland), German, Greek (Greece), Hebrew, Hungarian, Japanese (Japan), Korean, Norwegian Bokmål, Polish (Poland), Portuguese, Portuguese (Brazil), Russian (Russia), Serbian, Slovenian, Spanish, Swedish (Sweden), Thai, Turkish, Ukrainian
<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">

Check warning on line 561 in SoundSwitch/Localization/SettingsStrings.resx

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Resource is not overridden in specific culture

Resource is not overridden in Arabic, Bulgarian, Chinese (Simplified), Chinese (Traditional), Croatian, Czech, Danish, Dutch, Finnish (Finland), French, German, Greek (Greece), Hebrew, Hungarian, Italian (Italy), Japanese (Japan), Korean, Norwegian Bokmål, Polish (Poland), Portuguese, Portuguese (Brazil), Russian (Russia), Serbian, Slovenian, Spanish, Swedish (Sweden), Thai, Turkish, Ukrainian
<value>Center</value>
</data>
</root>

0 comments on commit 71ec9a1

Please sign in to comment.