Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boost(banner): Added Center Position #1471

Merged
merged 2 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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">
<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>
Loading