Skip to content

Commit

Permalink
Merge pull request LeDragoX#43 from LeDragoX/develop
Browse files Browse the repository at this point in the history
Add support to `multi-monitor` setups on GUI
  • Loading branch information
LeDragoX authored Jul 4, 2022
2 parents efb6372 + 13e5e8a commit 0fea935
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 19 deletions.
11 changes: 4 additions & 7 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ body:
label: Operating System
description: Versions before Windows 10 are not supported
options:
- Windows 11 (64-bits)
- Windows 11 (ARM64)
- Windows 10 (64-bits)
- Windows 10 (32-bits)
- Windows 10 (ARM64)
- Windows 11
- Windows 10
validations:
required: true
- type: input
Expand Down Expand Up @@ -86,8 +83,8 @@ body:
label: Logs
description: |
**Only needed if it's error related**
Put your log file from: C:\Users\{ Your User }\AppData\Local\Temp\Win10ScriptXXX_YYYY-MM-DD_hh-mm-ss.txt
TIP: press `Win + R` and type: `%Temp%`, then find the log file
Put your log file from: C:\Users\{ Your User }\AppData\Local\Temp\Win-DT-Logs\Win10ScriptXXX_YYYY-MM-DD_hh-mm-ss.txt
TIP: press `Win + R` and type `%Temp%` then hit `ENTER`, now find the log file
validations:
required: false
- type: textarea
Expand Down
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
open-pull-requests-limit: 10
schedule:
interval: "daily"
time: "00:00"
timezone: "Etc/UCT"
2 changes: 1 addition & 1 deletion .github/workflows/powershell-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ jobs:

# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v1
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Just open an **issue** or send me a **pull request** to the `develop` branch.

These aren't extremely strict rules, just the necessary to keep being productive and not staring at rules the entire time.

You can use this guide to help with coding on PowerShell (better than i do), link: <https://github.com/PoshCode/PowerShellPracticeAndStyle>
You can use [this guide](https://github.com/PoshCode/PowerShellPracticeAndStyle) to help with coding on PowerShell (better than i do).

### VS Code settings (Json)

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ These scripts will Customize, Debloat and Improve Privacy/Performance and System

[![PSScriptAnalyzer](https://github.com/LeDragoX/Win-Debloat-Tools/actions/workflows/powershell-linter.yml/badge.svg?style=flat)](https://github.com/LeDragoX/Win-Debloat-Tools/actions/workflows/powershell-linter.yml)
![GitHub issues](https://img.shields.io/github/issues/LeDragoX/Win-Debloat-Tools?label=Issues)
![GitHub](https://img.shields.io/github/license/LeDragoX/Win-Debloat-Tools?color=blue&label=License)
![GitHub license](https://img.shields.io/github/license/LeDragoX/Win-Debloat-Tools?color=blue&label=License)
[![Commit rate](https://img.shields.io/github/commit-activity/m/LeDragoX/Win-Debloat-Tools?label=Commits)](https://github.com/LeDragoX/Win-Debloat-Tools/commits/master)
![GitHub last commit (branch)](https://img.shields.io/github/last-commit/LeDragoX/Win-Debloat-Tools/main?label=Last%20commit)
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/LeDragoX/Win-Debloat-Tools?label=Code%20size)
Expand Down Expand Up @@ -243,6 +243,10 @@ Get-Service "NVDisplay.ContainerLocalSystem" | Set-Service -StartupType Automati
- [Daniel Persson](https://www.youtube.com/channel/UCnG-TN23lswO6QbvWhMtxpA) - by [_this video_](https://youtu.be/EfrT_Bvgles) (and script explanation);
- [matthewjberger](https://gist.github.com/matthewjberger) - by [_this script_](https://gist.github.com/matthewjberger/2f4295887d6cb5738fa34e597f457b7f).

## ➕ Contributing

If you want to contribute, please check out the [CONTRIBUTING.md](CONTRIBUTING.md) file.

## 📝 License

Licensed under the [MIT](LICENSE.txt) license.
Expand Down
10 changes: 7 additions & 3 deletions Win10ScriptGUI.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function Show-GUI() {

Set-UIFont # Load the Layout Font
$ScreenWidth, $ScreenHeight = Get-CurrentResolution # Get the Screen Size
$ScreenProportion = $ScreenWidth / $ScreenHeight # 16:9 ~1.777...

$Script:NeedRestart = $false
$DoneTitle = "Information"
Expand All @@ -27,11 +28,14 @@ function Show-GUI() {
$VerticalScrollWidth = 17

# To Forms
If ($ScreenWidth -gt 1024) {
If ($ScreenProportion -lt 1.5) {
$FormWidth = ($ScreenWidth * 0.99) + $VerticalScrollWidth # Small Resolution Width + Scroll Width
$FormHeight = $ScreenHeight * 0.85
} ElseIf ($ScreenProportion -lt 2.0) {
$FormWidth = ($ScreenWidth * 0.85) + $VerticalScrollWidth # Scaled Resolution Width + Scroll Width
$FormHeight = $ScreenHeight * 0.85
} Else {
$FormWidth = ($ScreenWidth * 0.99) + $VerticalScrollWidth # ~ 870.4 + Scroll Width
} ElseIf ($ScreenProportion -ge 2.0) {
$FormWidth = ($ScreenWidth * 0.65) + $VerticalScrollWidth # Scaled Resolution Width + Scroll Width
$FormHeight = $ScreenHeight * 0.85
}

Expand Down
28 changes: 22 additions & 6 deletions src/lib/ui-helper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,31 @@ function Get-CurrentResolution {
$ScreenHeight = $null

# Accepts Scaling/DPI
$DisplayInfo = [System.Windows.Forms.SystemInformation]::VirtualScreen
$ScreenWidth = $DisplayInfo.Width
$ScreenHeight = $DisplayInfo.Height
[System.Windows.Forms.SystemInformation]::VirtualScreen | ForEach-Object {
If (!$ScreenWidth -or !$ScreenHeight) {
$ScreenWidth = $_.Width
$ScreenHeight = $_.Height
}

If (($_.Width) -and ($_.Width -le $ScreenWidth)) {
$ScreenWidth = $_.Width
$ScreenHeight = $_.Height
}
}

# Doesn't accepts Scaling/DPI (rollback method)
If (!$ScreenWidth -or !$ScreenHeight) {
$DisplayInfo = Get-CimInstance -class "Win32_VideoController" | Select-Object *
$ScreenWidth = $DisplayInfo.CurrentHorizontalResolution
$ScreenHeight = $DisplayInfo.CurrentVerticalResolution
Get-CimInstance -Class "Win32_VideoController" | ForEach-Object {
If (!$ScreenWidth -or !$ScreenHeight) {
$ScreenWidth = $_.CurrentHorizontalResolution
$ScreenHeight = $_.CurrentVerticalResolution
}

If (($_.CurrentHorizontalResolution) -and ($_.CurrentHorizontalResolution -le $ScreenWidth)) {
$ScreenWidth = $_.CurrentHorizontalResolution
$ScreenHeight = $_.CurrentVerticalResolution
}
}
}

Write-Verbose "Width: $ScreenWidth, Height: $ScreenHeight"
Expand Down

0 comments on commit 0fea935

Please sign in to comment.