Пример #1
0
        /// <summary>
        /// Attempts to get the information on primary taskbar.
        /// </summary>
        /// <param name="taskbarRect">Primary taskbar rectange</param>
        /// <param name="taskbarAlignment">Primary taskbar alignment</param>
        /// <param name="isShown">Whether primary taskbar is shown or hidden</param>
        /// <returns>True if successfully gets</returns>
        internal static bool TryGetTaskbar(out Rect taskbarRect, out TaskbarAlignment taskbarAlignment, out bool isShown)
        {
            var data = new APPBARDATA {
                cbSize = (uint)Marshal.SizeOf <APPBARDATA>()
            };

            var result = SHAppBarMessage(
                ABM_GETTASKBARPOS,
                ref data);

            if (Convert.ToBoolean(result))
            {
                taskbarRect      = data.rc;
                taskbarAlignment = ConvertToTaskbarAlignment(data.uEdge);

                if (TryGetWindow(PrimaryTaskbarWindowClassName, out _, out Rect rect))
                {
                    // SHAppBarMessage function returns primary taskbar rectangle as if the taskbar
                    // is fully shown even when it is actually hidden. In contrast, GetWindowRect
                    // function returns actual, current primary taskbar rectangle. Thus, if those
                    // rectangles do not match, the taskbar is hidden in full or part.
                    isShown = (taskbarRect == rect);
                    return(true);
                }
            }
            taskbarRect      = Rect.Empty;
            taskbarAlignment = default;
            isShown          = default;
            return(false);
Пример #2
0
 void checkSides(float distance1, TaskbarAlignment alignment1, float distance2, TaskbarAlignment alignment2, float distance3, TaskbarAlignment alignment3)
 {
     if (distance1 < distance2)
     {
         if (distance3 < distance1)
         {
             Alignment = alignment3;
         }
         else
         {
             Alignment = alignment1;
         }
     }
     else
     {
         if (distance3 < distance2)
         {
             Alignment = alignment3;
         }
         else
         {
             Alignment = alignment2;
         }
     }
 }
Пример #3
0
        public static bool TryGetTaskbar(out Rect taskbarRect, out TaskbarAlignment taskbarAlignment)
        {
            var data = new APPBARDATA {
                cbSize = (uint)Marshal.SizeOf <APPBARDATA>()
            };

            if (SHAppBarMessage(
                    ABM_GETTASKBARPOS,
                    ref data))
            {
                taskbarRect      = data.rc;
                taskbarAlignment = ConvertToTaskbarAlignment(data.uEdge);
                return(true);
            }
            taskbarRect      = Rect.Empty;
            taskbarAlignment = default;
            return(false);
Пример #4
0
        public static bool TryGetTaskbar(out Rect taskbarRect, out TaskbarAlignment taskbarAlignment)
        {
            var data = new APPBARDATA {
                cbSize = (uint)Marshal.SizeOf <APPBARDATA>()
            };

            if (SHAppBarMessage(
                    ABM.ABM_GETTASKBARPOS,
                    ref data) == IntPtr.Zero)
            {
                taskbarRect      = Rect.Empty;
                taskbarAlignment = TaskbarAlignment.None;
                return(false);
            }

            taskbarRect      = new Rect(data.rc.left, data.rc.top, data.rc.right - data.rc.left, data.rc.bottom - data.rc.top);
            taskbarAlignment = ConvertToTaskbarAlignment(data.uEdge);
            return(true);
        }
        public NotifyWindow(Window ownerWindow, Point pivotLocation)
        {
            InitializeComponent();

            this.Topmost = true;
            this.ShowInTaskbar = false;

            // Assigning ownerWindow to this.Owner will bring the owner window at the top (not the topmost)
            // when this window is activated. Such behavior is not desirable.
            this._ownerWindow = ownerWindow;

            if (this._ownerWindow != null)
                this._ownerWindow.Closing += OnOwnerWindowClosing;

            this._pivotLocation = pivotLocation;
            this._taskbarAlignment = WindowPosition.GetTaskbarAlignment();

            this.DataContext = new NotifyWindowViewModel(ownerWindow);
        }
Пример #6
0
        public NotifyWindow(Window ownerWindow, Point pivotLocation)
        {
            InitializeComponent();

            this.Topmost       = true;
            this.ShowInTaskbar = false;

            // Assigning ownerWindow to this.Owner will bring the owner window at the top (not the topmost)
            // when this window is activated. Such behavior is not desirable.
            this._ownerWindow = ownerWindow;

            if (this._ownerWindow != null)
            {
                this._ownerWindow.Closing += OnOwnerWindowClosing;
            }

            this._pivotLocation    = pivotLocation;
            this._taskbarAlignment = WindowPosition.GetTaskbarAlignment();

            this.DataContext = new NotifyWindowViewModel(ownerWindow);
        }