mirror of
https://github.com/ckaczor/wpf-notifyicon.git
synced 2026-01-17 01:35:40 -05:00
Removed some warnings, and added dotnet core 3.1 support
This commit is contained in:
@@ -6,9 +6,12 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
||||
{
|
||||
/// <summary>
|
||||
/// This contains the logic to access the location of the app bar and communicate with it.
|
||||
/// </summary>
|
||||
public class AppBarInfo
|
||||
{
|
||||
[DllImport("user32.dll")]
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||
|
||||
[DllImport("shell32.dll")]
|
||||
@@ -18,24 +21,22 @@ namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
||||
private static extern int SystemParametersInfo(uint uiAction, uint uiParam,
|
||||
IntPtr pvParam, uint fWinIni);
|
||||
|
||||
|
||||
private const int ABE_BOTTOM = 3;
|
||||
private const int ABE_LEFT = 0;
|
||||
private const int ABE_RIGHT = 2;
|
||||
private const int ABE_TOP = 1;
|
||||
|
||||
private const int ABM_GETTASKBARPOS = 0x00000005;
|
||||
|
||||
// SystemParametersInfo constants
|
||||
private const uint SPI_GETWORKAREA = 0x0030;
|
||||
|
||||
private APPBARDATA m_data;
|
||||
|
||||
/// <summary>
|
||||
/// Get on which edge the app bar is located
|
||||
/// </summary>
|
||||
public ScreenEdge Edge
|
||||
{
|
||||
get { return (ScreenEdge) m_data.uEdge; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the working area
|
||||
/// </summary>
|
||||
public Rectangle WorkArea
|
||||
{
|
||||
get { return GetRectangle(m_data.rc); }
|
||||
@@ -44,9 +45,14 @@ namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
||||
private Rectangle GetRectangle(RECT rc)
|
||||
{
|
||||
return new Rectangle(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
|
||||
}
|
||||
}
|
||||
|
||||
public void GetPosition(string strClassName, string strWindowName)
|
||||
/// <summary>
|
||||
/// Update the location of the appbar with the specified classname and window name.
|
||||
/// </summary>
|
||||
/// <param name="strClassName">string</param>
|
||||
/// <param name="strWindowName">string</param>
|
||||
private void GetPosition(string strClassName, string strWindowName)
|
||||
{
|
||||
m_data = new APPBARDATA();
|
||||
m_data.cbSize = (uint) Marshal.SizeOf(m_data.GetType());
|
||||
@@ -68,23 +74,41 @@ namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Updates the system taskbar position
|
||||
/// </summary>
|
||||
public void GetSystemTaskBarPosition()
|
||||
{
|
||||
GetPosition("Shell_TrayWnd", null);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A value that specifies an edge of the screen.
|
||||
/// </summary>
|
||||
public enum ScreenEdge
|
||||
{
|
||||
/// <summary>
|
||||
/// Undefined
|
||||
/// </summary>
|
||||
Undefined = -1,
|
||||
Left = ABE_LEFT,
|
||||
Top = ABE_TOP,
|
||||
Right = ABE_RIGHT,
|
||||
Bottom = ABE_BOTTOM
|
||||
/// <summary>
|
||||
/// Left edge.
|
||||
/// </summary>
|
||||
Left = 0,
|
||||
/// <summary>
|
||||
/// Top edge.
|
||||
/// </summary>
|
||||
Top = 1,
|
||||
/// <summary>
|
||||
/// Right edge.
|
||||
/// </summary>
|
||||
Right = 2,
|
||||
/// <summary>
|
||||
/// Bottom edge.
|
||||
/// </summary>
|
||||
Bottom = 3
|
||||
}
|
||||
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct APPBARDATA
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user