diff --git a/SoundSwitch/Framework/Banner/BannerData.cs b/SoundSwitch/Framework/Banner/BannerData.cs
index f82c13cb8b..71a6a3951e 100644
--- a/SoundSwitch/Framework/Banner/BannerData.cs
+++ b/SoundSwitch/Framework/Banner/BannerData.cs
@@ -1,20 +1,21 @@
/********************************************************************
-* 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.
-********************************************************************/
+ * 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.Diagnostics.CodeAnalysis;
using System.Drawing;
using SoundSwitch.Framework.Audio;
+using SoundSwitch.Framework.Banner.Position;
namespace SoundSwitch.Framework.Banner
{
@@ -43,17 +44,22 @@ public class BannerData
///
[AllowNull]
public CachedSound SoundFile { get; internal set; }
-
+
///
/// On what device to play the
///
[AllowNull]
public string CurrentDeviceId { get; internal set; }
+ ///
+ /// Position of the banner
+ ///
+ public IPosition Position { get; internal set; }
+
///
/// Set the priority of the notification
/// If a notification is being shown a higher priority comes, it will replace it, if a lower, nothing will happens.
///
public int Priority { get; set; } = -1;
}
-}
+}
\ No newline at end of file
diff --git a/SoundSwitch/Framework/Banner/BannerForm.cs b/SoundSwitch/Framework/Banner/BannerForm.cs
index c5fb3ed907..bd27741812 100644
--- a/SoundSwitch/Framework/Banner/BannerForm.cs
+++ b/SoundSwitch/Framework/Banner/BannerForm.cs
@@ -1,16 +1,16 @@
/********************************************************************
-* 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.
-********************************************************************/
+ * 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;
using System.Drawing;
@@ -111,22 +111,8 @@ internal void SetData(BannerData data)
Region = Region.FromHrgn(RoundedCorner.CreateRoundRectRgn(0, 0, Width, Height , 20, 20));
var screen = GetScreen();
- var positionLeft = screen.Bounds.X + 50;
- var positionRight = screen.Bounds.Width - Width - positionLeft;
- var positionCenterH = (screen.Bounds.Width - Width) / 2;
- var positionTop = screen.Bounds.Y + 60;
- var positionBottom = screen.Bounds.Height - Height - positionTop;
-
- Location = AppModel.Instance.BannerPosition switch
- {
- BannerPositionEnum.TopLeft => new Point(positionLeft, positionTop),
- BannerPositionEnum.TopCenter => new Point(positionCenterH, positionTop),
- BannerPositionEnum.TopRight => new Point(positionRight, positionTop),
- BannerPositionEnum.BottomLeft => new Point(positionLeft, positionBottom),
- BannerPositionEnum.BottomCenter => new Point(positionCenterH, positionBottom),
- BannerPositionEnum.BottomRight => new Point(positionRight, positionBottom),
- _ => new Point(0, 0)
- };
+
+ Location = data.Position.GetScreenPosition(screen, Height, Width);
_timerHide.Enabled = true;
diff --git a/SoundSwitch/Framework/Banner/Position/IPosition.cs b/SoundSwitch/Framework/Banner/Position/IPosition.cs
index 5d962e7dca..58a9545fd0 100644
--- a/SoundSwitch/Framework/Banner/Position/IPosition.cs
+++ b/SoundSwitch/Framework/Banner/Position/IPosition.cs
@@ -1,22 +1,32 @@
/********************************************************************
-* 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.
-********************************************************************/
+ * 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.Framework.Factory;
namespace SoundSwitch.Framework.Banner.Position
{
public interface IPosition : IEnumImpl
{
+ ///
+ /// Get position in the screen for the banner
+ ///
+ ///
+ ///
+ ///
+ ///
+ public Point GetScreenPosition(Screen screen, int height, int width);
}
}
\ No newline at end of file
diff --git a/SoundSwitch/Framework/Banner/Position/PositionBottomCenter.cs b/SoundSwitch/Framework/Banner/Position/PositionBottomCenter.cs
index 4b46a81551..04f841f33f 100644
--- a/SoundSwitch/Framework/Banner/Position/PositionBottomCenter.cs
+++ b/SoundSwitch/Framework/Banner/Position/PositionBottomCenter.cs
@@ -1,17 +1,19 @@
/********************************************************************
-* 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.
-********************************************************************/
+ * 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
@@ -20,5 +22,13 @@ internal class PositionBottomCenter : IPosition
{
public BannerPositionEnum TypeEnum => BannerPositionEnum.BottomCenter;
public string Label => SettingsStrings.positionOptionBottomCenter;
+
+ public Point GetScreenPosition(Screen screen, int height, int width)
+ {
+ var positionCenterH = (screen.Bounds.Width - width) / 2;
+ var positionTop = screen.Bounds.Y + 60;
+ var positionBottom = screen.Bounds.Height - height - positionTop;
+ return new Point(positionCenterH, positionBottom);
+ }
}
-}
+}
\ No newline at end of file
diff --git a/SoundSwitch/Framework/Banner/Position/PositionBottomLeft.cs b/SoundSwitch/Framework/Banner/Position/PositionBottomLeft.cs
index aa477df2eb..44eafdce09 100644
--- a/SoundSwitch/Framework/Banner/Position/PositionBottomLeft.cs
+++ b/SoundSwitch/Framework/Banner/Position/PositionBottomLeft.cs
@@ -1,17 +1,19 @@
/********************************************************************
-* 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.
-********************************************************************/
+ * 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
@@ -20,5 +22,13 @@ internal class PositionBottomLeft : IPosition
{
public BannerPositionEnum TypeEnum => BannerPositionEnum.BottomLeft;
public string Label => SettingsStrings.positionOptionBottomLeft;
+
+ public Point GetScreenPosition(Screen screen, int height, int width)
+ {
+ var positionTop = screen.Bounds.Y + 60;
+ var positionLeft = screen.Bounds.X + 50;
+ var positionBottom = screen.Bounds.Height - height - positionTop;
+ return new Point(positionLeft, positionBottom);
+ }
}
-}
+}
\ No newline at end of file
diff --git a/SoundSwitch/Framework/Banner/Position/PositionBottomRight.cs b/SoundSwitch/Framework/Banner/Position/PositionBottomRight.cs
index 8431e06bd4..51a062e982 100644
--- a/SoundSwitch/Framework/Banner/Position/PositionBottomRight.cs
+++ b/SoundSwitch/Framework/Banner/Position/PositionBottomRight.cs
@@ -1,17 +1,19 @@
/********************************************************************
-* 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.
-********************************************************************/
+ * 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
@@ -20,5 +22,14 @@ internal class PositionBottomRight : IPosition
{
public BannerPositionEnum TypeEnum => BannerPositionEnum.BottomRight;
public string Label => SettingsStrings.positionOptionBottomRight;
+
+ public Point GetScreenPosition(Screen screen, int height, int width)
+ {
+ var positionLeft = screen.Bounds.X + 50;
+ var positionRight = screen.Bounds.Width - width - positionLeft;
+ var positionTop = screen.Bounds.Y + 60;
+ var positionBottom = screen.Bounds.Height - height - positionTop;
+ return new Point(positionRight, positionBottom);
+ }
}
-}
+}
\ No newline at end of file
diff --git a/SoundSwitch/Framework/Banner/Position/PositionTopCenter.cs b/SoundSwitch/Framework/Banner/Position/PositionTopCenter.cs
index 9c012c1bb2..81829cd17a 100644
--- a/SoundSwitch/Framework/Banner/Position/PositionTopCenter.cs
+++ b/SoundSwitch/Framework/Banner/Position/PositionTopCenter.cs
@@ -1,17 +1,19 @@
/********************************************************************
-* 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.
-********************************************************************/
+ * 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
@@ -20,5 +22,12 @@ internal class PositionTopCenter : IPosition
{
public BannerPositionEnum TypeEnum => BannerPositionEnum.TopCenter;
public string Label => SettingsStrings.positionOptionTopCenter;
+
+ public Point GetScreenPosition(Screen screen, int height, int width)
+ {
+ var positionCenterH = (screen.Bounds.Width - width) / 2;
+ var positionTop = screen.Bounds.Y + 60;
+ return new Point(positionCenterH, positionTop);
+ }
}
-}
+}
\ No newline at end of file
diff --git a/SoundSwitch/Framework/Banner/Position/PositionTopLeft.cs b/SoundSwitch/Framework/Banner/Position/PositionTopLeft.cs
index 07b1c3eca5..7bb271ef04 100644
--- a/SoundSwitch/Framework/Banner/Position/PositionTopLeft.cs
+++ b/SoundSwitch/Framework/Banner/Position/PositionTopLeft.cs
@@ -1,17 +1,19 @@
/********************************************************************
-* 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.
-********************************************************************/
+ * 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
@@ -20,5 +22,11 @@ internal class PositionTopLeft : IPosition
{
public BannerPositionEnum TypeEnum => BannerPositionEnum.TopLeft;
public string Label => SettingsStrings.positionOptionTopLeft;
+ public Point GetScreenPosition(Screen screen, int height, int width)
+ {
+ var positionLeft = screen.Bounds.X + 50;
+ var positionTop = screen.Bounds.Y + 60;
+ return new Point(positionLeft, positionTop);
+ }
}
}
diff --git a/SoundSwitch/Framework/Banner/Position/PositionTopRight.cs b/SoundSwitch/Framework/Banner/Position/PositionTopRight.cs
index 0c7ac41509..513882905b 100644
--- a/SoundSwitch/Framework/Banner/Position/PositionTopRight.cs
+++ b/SoundSwitch/Framework/Banner/Position/PositionTopRight.cs
@@ -1,17 +1,19 @@
/********************************************************************
-* 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.
-********************************************************************/
+ * 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
@@ -20,5 +22,14 @@ internal class PositionTopRight : IPosition
{
public BannerPositionEnum TypeEnum => BannerPositionEnum.TopRight;
public string Label => SettingsStrings.positionOptionTopRight;
+
+ public Point GetScreenPosition(Screen screen, int height, int width)
+ {
+ var positionLeft = screen.Bounds.X + 50;
+ var positionRight = screen.Bounds.Width - width - positionLeft;
+ var positionTop = screen.Bounds.Y + 60;
+
+ return new Point(positionRight, positionTop);
+ }
}
-}
+}
\ No newline at end of file
diff --git a/SoundSwitch/Framework/NotificationManager/Notification/NotificationBanner.cs b/SoundSwitch/Framework/NotificationManager/Notification/NotificationBanner.cs
index afc3a0564b..31f2986b84 100644
--- a/SoundSwitch/Framework/NotificationManager/Notification/NotificationBanner.cs
+++ b/SoundSwitch/Framework/NotificationManager/Notification/NotificationBanner.cs
@@ -1,16 +1,16 @@
/********************************************************************
-* 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.
-********************************************************************/
+ * 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;
using System.Drawing;
@@ -34,6 +34,7 @@ public class NotificationBanner : INotification
public INotificationConfiguration Configuration { get; set; }
private readonly BannerManager _bannerManager = new();
+ private readonly BannerPositionFactory _bannerPositionFactory = new();
public bool SupportIcon => true;
@@ -44,7 +45,8 @@ public void NotifyProfileChanged(Profile.Profile profile, Bitmap icon, uint? pro
Priority = 1,
Image = icon,
Title = string.Format(SettingsStrings.profile_notification_text, profile.Name),
- Text = string.Join("\n", profile.Devices.Select(wrapper => wrapper.DeviceInfo.NameClean).Distinct())
+ Text = string.Join("\n", profile.Devices.Select(wrapper => wrapper.DeviceInfo.NameClean).Distinct()),
+ Position = _bannerPositionFactory.Get(Configuration.BannerPosition)
};
_bannerManager.ShowNotification(bannerData);
}
@@ -59,7 +61,8 @@ public void NotifyMuteChanged(string microphoneName, bool newMuteState)
{
Priority = 2,
Image = icon,
- Title = title
+ Title = title,
+ Position = _bannerPositionFactory.Get(Configuration.BannerPosition)
};
_bannerManager.ShowNotification(bannerData);
}
@@ -69,7 +72,8 @@ public void NotifyDefaultChanged(DeviceFullInfo audioDevice)
var toastData = new BannerData
{
Image = audioDevice.LargeIcon.ToBitmap(),
- Text = audioDevice.NameClean
+ Text = audioDevice.NameClean,
+ Position = _bannerPositionFactory.Get(Configuration.BannerPosition)
};
if (audioDevice.Type == DataFlow.Render && Configuration.CustomSound != null && File.Exists(Configuration.CustomSound.FilePath))
{
diff --git a/SoundSwitch/Framework/NotificationManager/Notification/configuration/INotificationConfiguration.cs b/SoundSwitch/Framework/NotificationManager/Notification/configuration/INotificationConfiguration.cs
index 0a3b58870f..1e2a916e66 100644
--- a/SoundSwitch/Framework/NotificationManager/Notification/configuration/INotificationConfiguration.cs
+++ b/SoundSwitch/Framework/NotificationManager/Notification/configuration/INotificationConfiguration.cs
@@ -1,20 +1,21 @@
/********************************************************************
-* 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.
-********************************************************************/
+ * 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.IO;
using System.Windows.Forms;
using SoundSwitch.Framework.Audio;
+using SoundSwitch.Framework.Banner;
namespace SoundSwitch.Framework.NotificationManager.Notification.Configuration
{
@@ -23,5 +24,6 @@ public interface INotificationConfiguration
NotifyIcon Icon { get; set; }
Stream DefaultSound { get; set; }
CachedSound CustomSound { get; set; }
+ BannerPositionEnum BannerPosition { get; set; }
}
}
\ No newline at end of file
diff --git a/SoundSwitch/Framework/NotificationManager/Notification/configuration/NotificationConfiguration.cs b/SoundSwitch/Framework/NotificationManager/Notification/configuration/NotificationConfiguration.cs
index bb8b50a400..f823949e39 100644
--- a/SoundSwitch/Framework/NotificationManager/Notification/configuration/NotificationConfiguration.cs
+++ b/SoundSwitch/Framework/NotificationManager/Notification/configuration/NotificationConfiguration.cs
@@ -1,20 +1,21 @@
/********************************************************************
-* 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.
-********************************************************************/
+ * 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.IO;
using System.Windows.Forms;
using SoundSwitch.Framework.Audio;
+using SoundSwitch.Framework.Banner;
namespace SoundSwitch.Framework.NotificationManager.Notification.Configuration
{
@@ -23,5 +24,6 @@ public class NotificationConfiguration : INotificationConfiguration
public NotifyIcon Icon { get; set; }
public Stream DefaultSound { get; set; }
public CachedSound CustomSound { get; set; }
+ public BannerPositionEnum BannerPosition { get; set; }
}
}
\ No newline at end of file
diff --git a/SoundSwitch/Framework/NotificationManager/NotificationManager.cs b/SoundSwitch/Framework/NotificationManager/NotificationManager.cs
index e308d2e485..4b6fee1630 100644
--- a/SoundSwitch/Framework/NotificationManager/NotificationManager.cs
+++ b/SoundSwitch/Framework/NotificationManager/NotificationManager.cs
@@ -1,16 +1,16 @@
/********************************************************************
-* 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.
-********************************************************************/
+ * 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;
using System.Diagnostics;
@@ -49,9 +49,15 @@ public void Init()
_model.NotificationSettingsChanged += ModelOnNotificationSettingsChanged;
SetNotification(_model.NotificationSettings);
_model.CustomSoundChanged += ModelOnCustomSoundChanged;
+ _model.BannerPositionChanged += ModelOnBannerPositionChanged;
Log.Information("Notification manager initiated");
}
+ private void ModelOnBannerPositionChanged(object sender, BannerPositionUpdatedEvent e)
+ {
+ _notification.Configuration.BannerPosition = e.NewBannerPosition;
+ }
+
private void ModelOnCustomSoundChanged(object sender, CustomSoundChangedEvent customSoundChangedEvent)
{
_notification.OnSoundChanged(customSoundChangedEvent.NewSound);
@@ -69,7 +75,8 @@ private void SetNotification(NotificationTypeEnum notificationTypeEnum)
_notification.Configuration = new NotificationConfiguration()
{
Icon = _model.TrayIcon.NotifyIcon,
- DefaultSound = Resources.NotificationSound
+ DefaultSound = Resources.NotificationSound,
+ BannerPosition = AppModel.Instance.BannerPosition,
};
try
{
@@ -102,7 +109,7 @@ private void ModelOnDefaultDeviceChanged(object sender, DeviceDefaultChangedEven
return deviceInfo.Type switch
{
DataFlow.Capture => _model.AvailableRecordingDevices.FirstOrDefault(info => info.Equals(deviceInfo)),
- _ => _model.AvailablePlaybackDevices.FirstOrDefault(info => info.Equals(deviceInfo))
+ _ => _model.AvailablePlaybackDevices.FirstOrDefault(info => info.Equals(deviceInfo))
};
}
@@ -127,7 +134,7 @@ private Bitmap GetIcon(Profile.Profile profile, uint? processId)
{
return null;
}
-
+
Bitmap icon = null;
if (processId.HasValue)
{