Files

32 lines
2.1 KiB
PowerShell

# Temporary Windows reference workload with the same geometry/marker as GTK.
$ErrorActionPreference='Stop'
Add-Type -ReferencedAssemblies System.Windows.Forms,System.Drawing -TypeDefinition @'
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
public class VDIDragReference : Form {
[DllImport("user32.dll")] public static extern bool SetProcessDPIAware();
int seq=0; bool held=false; Point target=new Point(800,700);
readonly Timer expiry=new Timer();
public VDIDragReference() {
Text="VDI temporary drag reference"; FormBorderStyle=FormBorderStyle.None;
Bounds=Screen.PrimaryScreen.Bounds; TopMost=true; DoubleBuffered=true;
expiry.Interval=600000; expiry.Tick+=delegate { Close(); }; expiry.Start();
}
protected override void OnMouseDown(MouseEventArgs e) { if(e.Button==MouseButtons.Left) { held=true; seq=0; Invalidate(); } base.OnMouseDown(e); }
protected override void OnMouseUp(MouseEventArgs e) { if(e.Button==MouseButtons.Left) { held=false; Invalidate(); } base.OnMouseUp(e); }
protected override void OnMouseMove(MouseEventArgs e) { if(held) { seq=Math.Max(0,Math.Min(300,(int)Math.Round((e.X-800)/4.0))); target=e.Location; Invalidate(); } base.OnMouseMove(e); }
protected override void OnPaint(PaintEventArgs e) {
var g=e.Graphics; g.Clear(Color.FromArgb(240,245,250));
using(var f=new Font("Arial",20)) g.DrawString("Windows 2560 x 1440: held-button selection / video response probe",f,Brushes.Black,60,50);
if(held) { using(var b=new SolidBrush(Color.FromArgb(50,40,100,230))) g.FillRectangle(b,500,350,Math.Max(1,target.X-500),Math.Max(1,target.Y-350)); g.DrawRectangle(Pens.Blue,500,350,Math.Max(1,target.X-500),Math.Max(1,target.Y-350)); }
for(int i=0;i<16;i++) g.FillRectangle((seq&(1<<i))!=0?Brushes.White:Brushes.Black,40+i*40,1350,40,70);
g.FillRectangle(held?Brushes.White:Brushes.Black,720,1350,40,70);
for(int i=0;i<8;i++) g.FillRectangle((0xa5&(1<<i))!=0?Brushes.White:Brushes.Black,800+i*40,1350,40,70);
}
}
'@
[VDIDragReference]::SetProcessDPIAware() | Out-Null
[Windows.Forms.Application]::Run((New-Object VDIDragReference))