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 #1470

Closed
wants to merge 2 commits into from
Closed
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
}
}
3 changes: 2 additions & 1 deletion 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 All @@ -34,4 +35,4 @@ 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.positionOptionCenter;

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
10 changes: 10 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.

5 changes: 4 additions & 1 deletion SoundSwitch/Localization/SettingsStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
Expand Down Expand Up @@ -525,4 +525,7 @@ Restore the state of the system when the application is closed.</value>
<data name="notification.single.tooltip" xml:space="preserve">
<value>Only show one banner at a time and replace its content.</value>
</data>
<data name="positionOptionCenter" xml:space="preserve">
<value>Center</value>
</data>
</root>