aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Engine/WindowManager/ShiftWindow.cs
blob: a8b9c79c30662bbd6e2e29e8cd7b974ec16a7e6b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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 = ShiftSkinData.btnCloseHoverColor;

        private void closebutton_MouseLeave(object sender, EventArgs e)
            => btnClose.BackColor = ShiftSkinData.btnCloseColor;

		private void maximizebutton_MouseEnter(object sender, EventArgs e) 
			=> btnMax.BackColor = ShiftSkinData.btnMaxHoverColor;

        private void maximizebutton_MouseLeave(object sender, EventArgs e)
            => btnMax.BackColor = ShiftSkinData.btnMaxColor;

        private void minimizebutton_MouseEnter(object sender, EventArgs e)
            => btnMin.BackColor = ShiftSkinData.btnMinHoverColor;
        

        private void minimizebutton_MouseLeave(object sender, EventArgs e)
            => btnMin.BackColor = ShiftSkinData.btnMinColor;

        /*
		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;
            */

	}

	public interface IShiftWindowExtensions
	{
		void OnLoaded(ShiftWindow window);
	}
}