VRDash/VRDash/Overlay/Actions/MinimizeWIndowAction.cs

41 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VRDash.Utilities;
namespace VRDash.Overlay.Actions
{
[OverlayActionInfo("Minize Window")]
public class MinimizeWindowAction : IWindowAction
{
public bool Enabled { get; set; } = true;
public void PreformAction(IOverlay intOverlay)
{
if (!Enabled) { return; }
if (!intOverlay.GetType().IsAssignableFrom(typeof(WindowOverlay)))
{
Console.WriteLine("This action cannot be performed on a non-WindowOverlay overlay.");
return;
}
WindowOverlay overlay = (WindowOverlay)intOverlay;
IntPtr handle = overlay.Config.Selector.GetWindowHandle();
PreformAction(handle);
}
public void PreformAction(IntPtr handle)
{
User32.ShowWindow(handle, User32.ShowWindowCommands.Minimize);
}
public override string ToString()
{
var attribute = (OverlayActionInfo)this.GetType().GetCustomAttributes(typeof(OverlayActionInfo), false).Single();
return attribute.Description;
}
}
}