diff --git a/SoundSwitch/Framework/Banner/BannerPositionEnum.cs b/SoundSwitch/Framework/Banner/BannerPositionEnum.cs index c07fcff1fa..a7c09403ba 100644 --- a/SoundSwitch/Framework/Banner/BannerPositionEnum.cs +++ b/SoundSwitch/Framework/Banner/BannerPositionEnum.cs @@ -21,6 +21,7 @@ public enum BannerPositionEnum TopRight = 2, BottomLeft = 3, BottomCenter = 4, - BottomRight = 5 + BottomRight = 5, + Center = 6 } } \ No newline at end of file diff --git a/SoundSwitch/Framework/Banner/BannerPositionFactory.cs b/SoundSwitch/Framework/Banner/BannerPositionFactory.cs index 15267e3283..04128d48c6 100644 --- a/SoundSwitch/Framework/Banner/BannerPositionFactory.cs +++ b/SoundSwitch/Framework/Banner/BannerPositionFactory.cs @@ -25,6 +25,7 @@ public class BannerPositionFactory : AbstractFactory 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; } } \ No newline at end of file diff --git a/SoundSwitch/Framework/Banner/Position/PositionBottomCenter.cs b/SoundSwitch/Framework/Banner/Position/PositionBottomCenter.cs index b3c82bd253..0df2905d4b 100644 --- a/SoundSwitch/Framework/Banner/Position/PositionBottomCenter.cs +++ b/SoundSwitch/Framework/Banner/Position/PositionBottomCenter.cs @@ -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) ); } diff --git a/SoundSwitch/Framework/Banner/Position/PositionCenter.cs b/SoundSwitch/Framework/Banner/Position/PositionCenter.cs new file mode 100644 index 0000000000..bb7a292b6d --- /dev/null +++ b/SoundSwitch/Framework/Banner/Position/PositionCenter.cs @@ -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) + ); + } + } +} \ No newline at end of file diff --git a/SoundSwitch/Framework/Banner/Position/PositionTopCenter.cs b/SoundSwitch/Framework/Banner/Position/PositionTopCenter.cs index 400c2ccc43..b4db34fc44 100644 --- a/SoundSwitch/Framework/Banner/Position/PositionTopCenter.cs +++ b/SoundSwitch/Framework/Banner/Position/PositionTopCenter.cs @@ -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) ); } diff --git a/SoundSwitch/Localization/SettingsStrings.Designer.cs b/SoundSwitch/Localization/SettingsStrings.Designer.cs index 738b9670f3..39a14b4f88 100644 --- a/SoundSwitch/Localization/SettingsStrings.Designer.cs +++ b/SoundSwitch/Localization/SettingsStrings.Designer.cs @@ -1,6 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -546,6 +547,15 @@ internal static string positionOptionBottomRight { } } + /// + /// Looks up a localized string similar to Center. + /// + internal static string positionOptionCenter { + get { + return ResourceManager.GetString("positionOptionCenter", resourceCulture); + } + } + /// /// Looks up a localized string similar to Top Center. /// diff --git a/SoundSwitch/Localization/SettingsStrings.resx b/SoundSwitch/Localization/SettingsStrings.resx index 603a7de447..ec131c82be 100644 --- a/SoundSwitch/Localization/SettingsStrings.resx +++ b/SoundSwitch/Localization/SettingsStrings.resx @@ -59,7 +59,7 @@ : using a System.ComponentModel.TypeConverter : and then encoded with base64 encoding. --> - + @@ -525,4 +525,7 @@ Restore the state of the system when the application is closed. Only show one banner at a time and replace its content. + + Center + \ No newline at end of file