2017-09-24 18:32:50 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
2017-09-24 19:56:11 +00:00
|
|
|
|
using System.Runtime.InteropServices;
|
2017-11-05 23:47:46 +00:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using ShiftOS.Engine.Misc;
|
2017-09-24 18:32:50 +00:00
|
|
|
|
|
|
|
|
|
namespace ShiftOS.Engine.WindowManager
|
|
|
|
|
{
|
2017-11-05 23:47:46 +00:00
|
|
|
|
public partial class ShiftWindow : Form
|
|
|
|
|
{
|
|
|
|
|
const int WmNclbuttondown = 0xA1;
|
|
|
|
|
const int HtCaption = 0x2;
|
2017-09-27 22:32:16 +00:00
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
public ShiftWindow()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
2017-09-27 22:32:16 +00:00
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
public uint Id { get; private set; }
|
|
|
|
|
|
|
|
|
|
public UserControl ChildControl { get; set; }
|
2017-09-27 22:32:16 +00:00
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
public uint SetId()
|
|
|
|
|
{
|
2017-09-27 22:32:16 +00:00
|
|
|
|
do
|
|
|
|
|
{
|
2017-11-05 23:47:46 +00:00
|
|
|
|
Id = (uint) Tools.Rnd.Next(100000, 999999);
|
2017-11-11 13:53:55 +00:00
|
|
|
|
} while (ShiftWM.Windows.FirstOrDefault(w => w.Id == Id) != null);
|
2017-09-27 22:32:16 +00:00
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
return Id;
|
|
|
|
|
}
|
2017-09-27 22:32:16 +00:00
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
[DllImport("user32.dll")]
|
|
|
|
|
static extern int SendMessage(
|
|
|
|
|
IntPtr hWnd,
|
|
|
|
|
int msg,
|
|
|
|
|
int wParam,
|
|
|
|
|
int lParam);
|
2017-09-24 19:56:11 +00:00
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
[DllImport("user32.dll")]
|
|
|
|
|
static extern bool ReleaseCapture();
|
2017-09-27 22:32:16 +00:00
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
void Programtopbar_drag(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button != MouseButtons.Left) return;
|
2017-09-24 19:56:11 +00:00
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
ReleaseCapture();
|
|
|
|
|
SendMessage(Handle, WmNclbuttondown, HtCaption, 0);
|
|
|
|
|
}
|
2017-09-24 19:56:11 +00:00
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
void closebutton_Click(object sender, EventArgs e)
|
|
|
|
|
=> Close();
|
2017-09-24 19:56:11 +00:00
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
void closebutton_MouseEnter(object sender, EventArgs e)
|
2017-11-25 15:59:48 +00:00
|
|
|
|
=> btnClose.BackColor = ShiftSkinData.Colors.BtnCloseHoverColor;
|
2017-09-25 02:06:41 +00:00
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
void closebutton_MouseLeave(object sender, EventArgs e)
|
2017-11-25 15:59:48 +00:00
|
|
|
|
=> btnClose.BackColor = ShiftSkinData.Colors.BtnCloseColor;
|
2017-09-25 02:06:41 +00:00
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
void maximizebutton_MouseEnter(object sender, EventArgs e)
|
2017-11-25 15:59:48 +00:00
|
|
|
|
=> btnMax.BackColor = ShiftSkinData.Colors.BtnMaxHoverColor;
|
2017-09-25 02:06:41 +00:00
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
void maximizebutton_MouseLeave(object sender, EventArgs e)
|
2017-11-25 15:59:48 +00:00
|
|
|
|
=> btnMax.BackColor = ShiftSkinData.Colors.BtnMaxColor;
|
2017-09-25 02:06:41 +00:00
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
void minimizebutton_MouseEnter(object sender, EventArgs e)
|
2017-11-25 15:59:48 +00:00
|
|
|
|
=> btnMin.BackColor = ShiftSkinData.Colors.BtnMinHoverColor;
|
2017-09-25 02:06:41 +00:00
|
|
|
|
|
2017-09-25 22:49:40 +00:00
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
void minimizebutton_MouseLeave(object sender, EventArgs e)
|
2017-11-25 15:59:48 +00:00
|
|
|
|
=> btnMin.BackColor = ShiftSkinData.Colors.BtnMinColor;
|
2017-09-25 22:49:40 +00:00
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
/*
|
2017-09-27 22:32:16 +00:00
|
|
|
|
private void closebutton_MouseDown(object sender, MouseEventArgs e)
|
2017-10-14 15:27:27 +00:00
|
|
|
|
=> btnClose.BackColor = Color.Black;
|
2017-09-25 22:49:40 +00:00
|
|
|
|
|
2017-09-27 22:32:16 +00:00
|
|
|
|
private void maximizebutton_MouseDown(object sender, MouseEventArgs e)
|
2017-10-14 15:27:27 +00:00
|
|
|
|
=> btnMax.BackColor = Color.Black;
|
2017-09-25 22:49:40 +00:00
|
|
|
|
|
2017-09-27 22:32:16 +00:00
|
|
|
|
private void minimizebutton_MouseDown(object sender, MouseEventArgs e)
|
2017-10-14 15:27:27 +00:00
|
|
|
|
=> btnMin.BackColor = Color.Black;
|
2017-11-05 23:47:46 +00:00
|
|
|
|
*/
|
2017-09-27 22:32:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface IShiftWindowExtensions
|
|
|
|
|
{
|
|
|
|
|
void OnLoaded(ShiftWindow window);
|
|
|
|
|
}
|
2017-11-05 23:47:46 +00:00
|
|
|
|
}
|