2017-09-24 14:32:50 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows.Forms;
|
2017-09-24 15:56:11 -04:00
|
|
|
|
using System.Runtime.InteropServices;
|
2017-09-24 14:32:50 -04:00
|
|
|
|
|
|
|
|
|
namespace ShiftOS.Engine.WindowManager
|
|
|
|
|
{
|
|
|
|
|
public partial class ShiftWindow : Form
|
|
|
|
|
{
|
2017-09-27 18:32:16 -04:00
|
|
|
|
public uint Id { get; private set; }
|
|
|
|
|
|
|
|
|
|
public UserControl ChildControl { get; set; }
|
|
|
|
|
|
|
|
|
|
public ShiftWindow()
|
2017-09-24 14:32:50 -04:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
2017-09-27 18:32:16 -04:00
|
|
|
|
|
|
|
|
|
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;
|
2017-09-24 15:56:11 -04:00
|
|
|
|
|
|
|
|
|
[DllImportAttribute("user32.dll")]
|
2017-09-27 18:32:16 -04:00
|
|
|
|
private static extern int SendMessage(IntPtr hWnd,
|
2017-09-24 15:56:11 -04:00
|
|
|
|
int Msg, int wParam, int lParam);
|
2017-09-27 18:32:16 -04:00
|
|
|
|
|
2017-09-24 15:56:11 -04:00
|
|
|
|
[DllImportAttribute("user32.dll")]
|
2017-09-27 18:32:16 -04:00
|
|
|
|
private static extern bool ReleaseCapture();
|
2017-09-24 15:56:11 -04:00
|
|
|
|
|
|
|
|
|
private void Programtopbar_drag(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2017-09-27 18:32:16 -04:00
|
|
|
|
if (e.Button != MouseButtons.Left) return;
|
2017-09-24 15:56:11 -04:00
|
|
|
|
|
2017-09-27 18:32:16 -04:00
|
|
|
|
ReleaseCapture();
|
|
|
|
|
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
|
2017-09-24 15:56:11 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-27 18:32:16 -04:00
|
|
|
|
private void closebutton_Click(object sender, EventArgs e)
|
|
|
|
|
=> this.Close();
|
2017-09-24 22:06:41 -04:00
|
|
|
|
|
2017-09-27 18:32:16 -04:00
|
|
|
|
private void closebutton_MouseEnter(object sender, EventArgs e)
|
|
|
|
|
=> closebutton.BackColor = Color.Gray;
|
2017-09-24 22:06:41 -04:00
|
|
|
|
|
2017-09-27 18:32:16 -04:00
|
|
|
|
private void closebutton_MouseLeave(object sender, EventArgs e)
|
|
|
|
|
=> closebutton.BackColor = Color.Black;
|
2017-09-24 22:06:41 -04:00
|
|
|
|
|
2017-09-27 18:32:16 -04:00
|
|
|
|
private void maximizebutton_MouseEnter(object sender, EventArgs e)
|
|
|
|
|
=> maximizebutton.BackColor = Color.Gray;
|
2017-09-24 22:06:41 -04:00
|
|
|
|
|
2017-09-27 18:32:16 -04:00
|
|
|
|
private void maximizebutton_MouseLeave(object sender, EventArgs e)
|
|
|
|
|
=> maximizebutton.BackColor = Color.Black;
|
2017-09-24 22:06:41 -04:00
|
|
|
|
|
2017-09-27 18:32:16 -04:00
|
|
|
|
private void minimizebutton_MouseEnter(object sender, EventArgs e)
|
|
|
|
|
=> minimizebutton.BackColor = Color.Gray;
|
2017-09-25 18:49:40 -04:00
|
|
|
|
|
2017-09-27 18:32:16 -04:00
|
|
|
|
private void minimizebutton_MouseLeave(object sender, EventArgs e)
|
|
|
|
|
=> minimizebutton.BackColor = Color.Black;
|
2017-09-25 18:49:40 -04:00
|
|
|
|
|
2017-09-27 18:32:16 -04:00
|
|
|
|
private void closebutton_MouseDown(object sender, MouseEventArgs e)
|
|
|
|
|
=> closebutton.BackColor = Color.Black;
|
2017-09-25 18:49:40 -04:00
|
|
|
|
|
2017-09-27 18:32:16 -04:00
|
|
|
|
private void maximizebutton_MouseDown(object sender, MouseEventArgs e)
|
|
|
|
|
=> maximizebutton.BackColor = Color.Black;
|
2017-09-25 18:49:40 -04:00
|
|
|
|
|
2017-09-27 18:32:16 -04:00
|
|
|
|
private void minimizebutton_MouseDown(object sender, MouseEventArgs e)
|
|
|
|
|
=> minimizebutton.BackColor = Color.Black;
|
2017-09-25 18:49:40 -04:00
|
|
|
|
|
2017-09-27 18:32:16 -04:00
|
|
|
|
private void minimizebutton_MouseUp(object sender, MouseEventArgs e)
|
|
|
|
|
=> minimizebutton.BackColor = Color.Gray;
|
2017-09-25 18:49:40 -04:00
|
|
|
|
|
2017-09-27 18:32:16 -04:00
|
|
|
|
private void maximizebutton_MouseUp(object sender, MouseEventArgs e)
|
|
|
|
|
=> maximizebutton.BackColor = Color.Gray;
|
|
|
|
|
|
|
|
|
|
private void closebutton_MouseUp(object sender, MouseEventArgs e)
|
|
|
|
|
=> closebutton.BackColor = Color.Gray;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface IShiftWindowExtensions
|
|
|
|
|
{
|
|
|
|
|
void OnLoaded(ShiftWindow window);
|
|
|
|
|
}
|
2017-09-24 14:32:50 -04:00
|
|
|
|
}
|