ShiftOS-Rewind/ShiftOS.Engine/WindowManager/ShiftWindow.cs
AShifter e9a8a6df70 More Skinning
You can now set a skin and it will persist throughout all windows -
though there is a bug where hovering over a context button will change
it's color and leaving it will change it back to black. Will fix
soon™️.
2017-10-14 09:27:27 -06:00

93 lines
2.6 KiB
C#

using System;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace ShiftOS.Engine.WindowManager
{
public partial class ShiftWindow : Form
{
public uint Id { get; private set; }
public UserControl ChildControl { get; set; }
public ShiftWindow()
{
InitializeComponent();
}
public uint SetId()
{
do
{
Id = (uint)Tools.Rnd.Next(100000, 999999);
}
while (ShiftWM.Windows.FirstOrDefault(w => w.Id == Id) != null);
return Id;
}
private const int WM_NCLBUTTONDOWN = 0xA1;
private const int HT_CAPTION = 0x2;
[DllImportAttribute("user32.dll")]
private static extern int SendMessage(IntPtr hWnd,
int Msg, int wParam, int lParam);
[DllImportAttribute("user32.dll")]
private static extern bool ReleaseCapture();
private void Programtopbar_drag(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left) return;
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
private void closebutton_Click(object sender, EventArgs e)
=> this.Close();
private void closebutton_MouseEnter(object sender, EventArgs e)
=> btnClose.BackColor = Color.Gray;
private void closebutton_MouseLeave(object sender, EventArgs e)
=> btnClose.BackColor = Color.Black;
private void maximizebutton_MouseEnter(object sender, EventArgs e)
=> btnMax.BackColor = Color.Gray;
private void maximizebutton_MouseLeave(object sender, EventArgs e)
=> btnMax.BackColor = Color.Black;
private void minimizebutton_MouseEnter(object sender, EventArgs e)
=> btnMin.BackColor = Color.Gray;
private void minimizebutton_MouseLeave(object sender, EventArgs e)
=> btnMin.BackColor = Color.Black;
private void closebutton_MouseDown(object sender, MouseEventArgs e)
=> btnClose.BackColor = Color.Black;
private void maximizebutton_MouseDown(object sender, MouseEventArgs e)
=> btnMax.BackColor = Color.Black;
private void minimizebutton_MouseDown(object sender, MouseEventArgs e)
=> btnMin.BackColor = Color.Black;
private void minimizebutton_MouseUp(object sender, MouseEventArgs e)
=> btnMin.BackColor = Color.Gray;
private void maximizebutton_MouseUp(object sender, MouseEventArgs e)
=> btnMax.BackColor = Color.Gray;
private void closebutton_MouseUp(object sender, MouseEventArgs e)
=> btnClose.BackColor = Color.Gray;
}
public interface IShiftWindowExtensions
{
void OnLoaded(ShiftWindow window);
}
}