コード例 #1
0
        async Task vTaskLoop_MonitorTaskbar()
        {
            try
            {
                while (TaskCheckLoop(vTask_MonitorTaskbar))
                {
                    try
                    {
                        //Check taskbar visibility
                        AVTaskbarInformation taskbarInfo = new AVTaskbarInformation();

                        //Check if auto hide is enabled
                        if (taskbarInfo.IsAutoHide && taskbarInfo.IsVisible)
                        {
                            //Get the current active screen
                            int            monitorNumber          = Convert.ToInt32(Setting_Load(vConfigurationCtrlUI, "DisplayMonitor"));
                            DisplayMonitor displayMonitorSettings = GetSingleMonitorEnumDisplay(monitorNumber);

                            //Get the current taskbar size
                            int taskbarSize = 0;
                            if (taskbarInfo.Position == AppBarPosition.ABE_BOTTOM)
                            {
                                AVActions.ActionDispatcherInvoke(delegate
                                {
                                    try
                                    {
                                        //Update taskbar margin
                                        taskbarSize             = (int)(taskbarInfo.Bounds.Height / displayMonitorSettings.DpiScaleVertical);
                                        grid_Application.Margin = new Thickness(0, 0, 0, taskbarSize);
                                    }
                                    catch { }
                                });
                                continue;
                            }
                        }

                        //Reset taskbar margin
                        AVActions.ActionDispatcherInvoke(delegate
                        {
                            try
                            {
                                grid_Application.Margin = new Thickness(0);
                            }
                            catch { }
                        });
                    }
                    catch { }
                    finally
                    {
                        //Delay the loop task
                        await TaskDelayLoop(1000, vTask_MonitorTaskbar);
                    }
                }
            }
            catch { }
        }
コード例 #2
0
ファイル: MonitorTaskbar.cs プロジェクト: dumbie/CtrlUI
        async Task LoopMonitorTaskbar()
        {
            try
            {
                while (TaskCheckLoop(vTask_MonitorTaskbar))
                {
                    try
                    {
                        //Check taskbar visibility
                        AVTaskbarInformation taskbarInfo = new AVTaskbarInformation();
                        vTaskBarPosition = taskbarInfo.Position;

                        //Check if auto hide is enabled
                        if (taskbarInfo.IsAutoHide && taskbarInfo.IsVisible)
                        {
                            //Get the current active screen
                            int            monitorNumber          = Convert.ToInt32(Setting_Load(vConfigurationCtrlUI, "DisplayMonitor"));
                            DisplayMonitor displayMonitorSettings = GetSingleMonitorEnumDisplay(monitorNumber);

                            //Get the current taskbar size
                            int taskbarSize = 0;
                            if (vTaskBarPosition == AppBarPosition.ABE_TOP || vTaskBarPosition == AppBarPosition.ABE_BOTTOM)
                            {
                                taskbarSize = (int)(taskbarInfo.Bounds.Height / displayMonitorSettings.DpiScaleVertical);
                            }
                            else
                            {
                                taskbarSize = (int)(taskbarInfo.Bounds.Width / displayMonitorSettings.DpiScaleHorizontal);
                            }

                            //Check the taskbar margin
                            if (vTaskBarAdjustMargin != taskbarSize)
                            {
                                vTaskBarAdjustMargin = taskbarSize;

                                //Update the fps overlay position
                                await UpdateFpsOverlayPosition(vTargetProcess.Name);
                            }
                        }
                        else
                        {
                            //Check the taskbar margin
                            if (vTaskBarAdjustMargin != 0)
                            {
                                vTaskBarAdjustMargin = 0;

                                //Update the fps overlay position
                                await UpdateFpsOverlayPosition(vTargetProcess.Name);
                            }
                        }
                    }
                    catch { }
                    finally
                    {
                        //Delay the loop task
                        await TaskDelayLoop(1000, vTask_MonitorTaskbar);
                    }
                }
            }
            catch { }
        }