42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using VDash.Utilities;
|
|
|
|
namespace VDash.Overlay.Actions
|
|
{
|
|
[OverlayActionInfo("Maximize Window")]
|
|
public class MaximizeWindowAction : IWindowAction
|
|
{
|
|
public bool Enabled { get; set; }
|
|
|
|
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.Maximize);
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
var attribute = (OverlayActionInfo)this.GetType().GetCustomAttributes(typeof(OverlayActionInfo), false).Single();
|
|
return attribute.Description;
|
|
}
|
|
}
|
|
}
|