diff --git a/ShiftOS/ShiftOS/Desktop.cs b/ShiftOS/ShiftOS/Desktop.cs index f2e9442..20524ef 100644 --- a/ShiftOS/ShiftOS/Desktop.cs +++ b/ShiftOS/ShiftOS/Desktop.cs @@ -16,7 +16,7 @@ namespace ShiftOS private SystemContext CurrentSystem = null; private bool _inUnity = false; private int _lastWorkspaceChildCount = -1; - + public SystemContext GetCurrentSystem() { return CurrentSystem; @@ -25,7 +25,6 @@ namespace ShiftOS public Desktop(SystemContext InSystem) { this.CurrentSystem = InSystem; - this.DoubleBuffered = true; InitializeComponent(); ResetAppLauncher(); } @@ -70,7 +69,8 @@ namespace ShiftOS // Otherwise, we get a wallpaper. if(skin.HasImage("desktopbackground")) { - this.BackgroundImage = skin.GetImage("desktopbackground"); + if(this.BackgroundImage != skin.GetImage("desktopbackground")) + this.BackgroundImage = skin.GetImage("desktopbackground"); this.BackgroundImageLayout = skin.GetSkinData().desktopbackgroundlayout; } else @@ -86,7 +86,8 @@ namespace ShiftOS // Set the desktop panel background if(skin.HasImage("desktoppanel")) { - DesktopPanel.BackgroundImage = skin.GetImage("desktoppanel"); + if(DesktopPanel.BackgroundImage != skin.GetImage("desktoppanel")) + DesktopPanel.BackgroundImage = skin.GetImage("desktoppanel"); DesktopPanel.BackgroundImageLayout = skin.GetSkinData().desktoppanellayout; DesktopPanel.BackColor = Color.Transparent; } @@ -125,7 +126,8 @@ namespace ShiftOS if(skin.HasImage("panelclock")) { TimePanel.BackColor = Color.Transparent; - TimePanel.BackgroundImage = skin.GetImage("panelclock"); + if(TimePanel.BackgroundImage != skin.GetImage("panelclock")) + TimePanel.BackgroundImage = skin.GetImage("panelclock"); TimePanel.BackgroundImageLayout = skin.GetSkinData().panelclocklayout; } else @@ -198,7 +200,8 @@ namespace ShiftOS { AppLauncherMenu.Text = ""; AppLauncherMenu.BackColor = Color.Transparent; - AppLauncherMenu.BackgroundImage = skin.GetImage("applauncher"); + if(AppLauncherMenu.BackgroundImage != skin.GetImage("applauncher")) + AppLauncherMenu.BackgroundImage = skin.GetImage("applauncher"); AppLauncherMenu.BackgroundImageLayout = skin.GetSkinData().applauncherlayout; } else diff --git a/ShiftOS/ShiftOS/SkinContext.cs b/ShiftOS/ShiftOS/SkinContext.cs index 56b8258..d4f7a19 100644 --- a/ShiftOS/ShiftOS/SkinContext.cs +++ b/ShiftOS/ShiftOS/SkinContext.cs @@ -171,6 +171,7 @@ namespace ShiftOS Console.WriteLine(" --> Read enable window corners..."); _skin.enablecorners = bool.Parse(stream.ReadLine()); + _skin.enablebordercorners = _skin.enablecorners; Console.WriteLine(" --> Read titlebar corner width..."); _skin.titlebarcornerwidth = Convert.ToInt32(stream.ReadLine()); @@ -340,7 +341,7 @@ namespace ShiftOS // but never made it into this format because of the 0.0.8 format being implemented // by William. - for(int i = 0; i < (100 - 73); i++) + for(int i = 0; i < (100 - 73) - 1; i++) { stream.ReadLine(); } @@ -362,14 +363,29 @@ namespace ShiftOS } _skinimages.Add("closebtn", GetImage(fs, ImageFileNames[0])); + _skinimages.Add("closebtnhover", GetImage(fs, ImageFileNames[1])); + _skinimages.Add("closebtnclick", GetImage(fs, ImageFileNames[2])); _skinimages.Add("titlebar", GetImage(fs, ImageFileNames[3])); _skinimages.Add("desktopbackground", GetImage(fs, ImageFileNames[6])); _skinimages.Add("rollbtn", GetImage(fs, ImageFileNames[9])); - _skinimages.Add("titlebarright", GetImage(fs, ImageFileNames[12])); - _skinimages.Add("titlebarleft", GetImage(fs, ImageFileNames[15])); + _skinimages.Add("rollbtnhover", GetImage(fs, ImageFileNames[10])); + _skinimages.Add("rollbtnclick", GetImage(fs, ImageFileNames[11])); + _skinimages.Add("rightcorner", GetImage(fs, ImageFileNames[12])); + _skinimages.Add("leftcorner", GetImage(fs, ImageFileNames[15])); _skinimages.Add("desktoppanel", GetImage(fs, ImageFileNames[18])); _skinimages.Add("panelclock", GetImage(fs, ImageFileNames[21])); _skinimages.Add("applauncher", GetImage(fs, ImageFileNames[24])); + _skinimages.Add("applaunchermouseover", GetImage(fs, ImageFileNames[25])); + _skinimages.Add("applauncherclick", GetImage(fs, ImageFileNames[26])); + _skinimages.Add("borderleft", GetImage(fs, ImageFileNames[27])); + _skinimages.Add("borderright", GetImage(fs, ImageFileNames[30])); + _skinimages.Add("borderbottom", GetImage(fs, ImageFileNames[33])); + _skinimages.Add("bottomrightcorner", GetImage(fs, ImageFileNames[36])); + _skinimages.Add("bottomleftcorner", GetImage(fs, ImageFileNames[39])); + _skinimages.Add("minbtn", GetImage(fs, ImageFileNames[42])); + _skinimages.Add("minbtnhover", GetImage(fs, ImageFileNames[43])); + _skinimages.Add("minbtnclick", GetImage(fs, ImageFileNames[44])); + _skinimages.Add("panelbutton", GetImage(fs, ImageFileNames[45])); } diff --git a/ShiftOS/ShiftOS/SystemContext.cs b/ShiftOS/ShiftOS/SystemContext.cs index 45c4e63..210d03a 100644 --- a/ShiftOS/ShiftOS/SystemContext.cs +++ b/ShiftOS/ShiftOS/SystemContext.cs @@ -32,7 +32,7 @@ namespace ShiftOS public bool LaunchProgram(string InExecutableName) { // Does the program exist in our typemap? - if(!_programTypeMap.ContainsKey(InExecutableName)) + if (!_programTypeMap.ContainsKey(InExecutableName)) { // Program doesn't exist. return false; @@ -169,7 +169,7 @@ namespace ShiftOS // Set up WinForms to run normally. Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - + ToolStripManager.Renderer = new ToolStripSkinRenderer(this); // Load all programs in the game. diff --git a/ShiftOS/ShiftOS/Windowing/Window.Designer.cs b/ShiftOS/ShiftOS/Windowing/Window.Designer.cs index f52b4f6..115f097 100644 --- a/ShiftOS/ShiftOS/Windowing/Window.Designer.cs +++ b/ShiftOS/ShiftOS/Windowing/Window.Designer.cs @@ -29,22 +29,21 @@ private void InitializeComponent() { this.TitleBarHolder = new System.Windows.Forms.Panel(); - this.TitleBarLeft = new System.Windows.Forms.Panel(); + this.IconBox = new System.Windows.Forms.PictureBox(); + this.TitleText = new System.Windows.Forms.Label(); + this.MinimizeButton = new System.Windows.Forms.Panel(); + this.RollButton = new System.Windows.Forms.Panel(); + this.CloseButton = new System.Windows.Forms.Panel(); this.TitleBarRight = new System.Windows.Forms.Panel(); + this.TitleBarLeft = new System.Windows.Forms.Panel(); this.BottomBarHolder = new System.Windows.Forms.Panel(); - this.BottomBar = new System.Windows.Forms.Panel(); this.BottomRight = new System.Windows.Forms.Panel(); this.BottomLeft = new System.Windows.Forms.Panel(); this.RightBar = new System.Windows.Forms.Panel(); this.LeftBar = new System.Windows.Forms.Panel(); - this.CloseButton = new System.Windows.Forms.Panel(); - this.RollButton = new System.Windows.Forms.Panel(); - this.MinimizeButton = new System.Windows.Forms.Panel(); - this.TitleText = new System.Windows.Forms.Label(); - this.IconBox = new System.Windows.Forms.PictureBox(); this.TitleBarHolder.SuspendLayout(); - this.BottomBarHolder.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.IconBox)).BeginInit(); + this.BottomBarHolder.SuspendLayout(); this.SuspendLayout(); // // TitleBarHolder @@ -62,15 +61,58 @@ this.TitleBarHolder.Name = "TitleBarHolder"; this.TitleBarHolder.Size = new System.Drawing.Size(601, 30); this.TitleBarHolder.TabIndex = 0; + this.TitleBarHolder.MouseDown += new System.Windows.Forms.MouseEventHandler(this.TitleBarMouseDown); // - // TitleBarLeft + // IconBox // - this.TitleBarLeft.BackColor = System.Drawing.Color.Gray; - this.TitleBarLeft.Dock = System.Windows.Forms.DockStyle.Left; - this.TitleBarLeft.Location = new System.Drawing.Point(0, 0); - this.TitleBarLeft.Name = "TitleBarLeft"; - this.TitleBarLeft.Size = new System.Drawing.Size(2, 30); - this.TitleBarLeft.TabIndex = 1; + this.IconBox.BackColor = System.Drawing.Color.Black; + this.IconBox.Location = new System.Drawing.Point(7, 7); + this.IconBox.Name = "IconBox"; + this.IconBox.Size = new System.Drawing.Size(16, 16); + this.IconBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.IconBox.TabIndex = 8; + this.IconBox.TabStop = false; + // + // TitleText + // + this.TitleText.AutoSize = true; + this.TitleText.BackColor = System.Drawing.Color.Transparent; + this.TitleText.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold); + this.TitleText.ForeColor = System.Drawing.Color.White; + this.TitleText.Location = new System.Drawing.Point(26, 6); + this.TitleText.Name = "TitleText"; + this.TitleText.Size = new System.Drawing.Size(100, 17); + this.TitleText.TabIndex = 5; + this.TitleText.Text = "Window Title"; + // + // MinimizeButton + // + this.MinimizeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.MinimizeButton.BackColor = System.Drawing.Color.Black; + this.MinimizeButton.Location = new System.Drawing.Point(520, 3); + this.MinimizeButton.Name = "MinimizeButton"; + this.MinimizeButton.Size = new System.Drawing.Size(24, 24); + this.MinimizeButton.TabIndex = 7; + // + // RollButton + // + this.RollButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.RollButton.BackColor = System.Drawing.Color.Black; + this.RollButton.Location = new System.Drawing.Point(547, 3); + this.RollButton.Name = "RollButton"; + this.RollButton.Size = new System.Drawing.Size(24, 24); + this.RollButton.TabIndex = 6; + this.RollButton.MouseClick += new System.Windows.Forms.MouseEventHandler(this.RollButton_MouseClick); + // + // CloseButton + // + this.CloseButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.CloseButton.BackColor = System.Drawing.Color.Black; + this.CloseButton.Location = new System.Drawing.Point(574, 3); + this.CloseButton.Name = "CloseButton"; + this.CloseButton.Size = new System.Drawing.Size(24, 24); + this.CloseButton.TabIndex = 5; + this.CloseButton.MouseClick += new System.Windows.Forms.MouseEventHandler(this.CloseButton_MouseClick); // // TitleBarRight // @@ -81,10 +123,18 @@ this.TitleBarRight.Size = new System.Drawing.Size(2, 30); this.TitleBarRight.TabIndex = 2; // + // TitleBarLeft + // + this.TitleBarLeft.BackColor = System.Drawing.Color.Gray; + this.TitleBarLeft.Dock = System.Windows.Forms.DockStyle.Left; + this.TitleBarLeft.Location = new System.Drawing.Point(0, 0); + this.TitleBarLeft.Name = "TitleBarLeft"; + this.TitleBarLeft.Size = new System.Drawing.Size(2, 30); + this.TitleBarLeft.TabIndex = 1; + // // BottomBarHolder // this.BottomBarHolder.BackColor = System.Drawing.Color.Transparent; - this.BottomBarHolder.Controls.Add(this.BottomBar); this.BottomBarHolder.Controls.Add(this.BottomRight); this.BottomBarHolder.Controls.Add(this.BottomLeft); this.BottomBarHolder.Dock = System.Windows.Forms.DockStyle.Bottom; @@ -93,16 +143,6 @@ this.BottomBarHolder.Size = new System.Drawing.Size(601, 2); this.BottomBarHolder.TabIndex = 1; // - // BottomBar - // - this.BottomBar.BackColor = System.Drawing.Color.Gray; - this.BottomBar.Dock = System.Windows.Forms.DockStyle.Fill; - this.BottomBar.ForeColor = System.Drawing.Color.White; - this.BottomBar.Location = new System.Drawing.Point(2, 0); - this.BottomBar.Name = "BottomBar"; - this.BottomBar.Size = new System.Drawing.Size(597, 2); - this.BottomBar.TabIndex = 0; - // // BottomRight // this.BottomRight.BackColor = System.Drawing.Color.Gray; @@ -139,55 +179,6 @@ this.LeftBar.Size = new System.Drawing.Size(2, 314); this.LeftBar.TabIndex = 4; // - // CloseButton - // - this.CloseButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.CloseButton.BackColor = System.Drawing.Color.Black; - this.CloseButton.Location = new System.Drawing.Point(574, 3); - this.CloseButton.Name = "CloseButton"; - this.CloseButton.Size = new System.Drawing.Size(24, 24); - this.CloseButton.TabIndex = 5; - // - // RollButton - // - this.RollButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.RollButton.BackColor = System.Drawing.Color.Black; - this.RollButton.Location = new System.Drawing.Point(547, 3); - this.RollButton.Name = "RollButton"; - this.RollButton.Size = new System.Drawing.Size(24, 24); - this.RollButton.TabIndex = 6; - // - // MinimizeButton - // - this.MinimizeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.MinimizeButton.BackColor = System.Drawing.Color.Black; - this.MinimizeButton.Location = new System.Drawing.Point(520, 3); - this.MinimizeButton.Name = "MinimizeButton"; - this.MinimizeButton.Size = new System.Drawing.Size(24, 24); - this.MinimizeButton.TabIndex = 7; - // - // TitleText - // - this.TitleText.AutoSize = true; - this.TitleText.BackColor = System.Drawing.Color.Transparent; - this.TitleText.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold); - this.TitleText.ForeColor = System.Drawing.Color.White; - this.TitleText.Location = new System.Drawing.Point(26, 6); - this.TitleText.Name = "TitleText"; - this.TitleText.Size = new System.Drawing.Size(100, 17); - this.TitleText.TabIndex = 5; - this.TitleText.Text = "Window Title"; - // - // IconBox - // - this.IconBox.BackColor = System.Drawing.Color.Black; - this.IconBox.Location = new System.Drawing.Point(7, 7); - this.IconBox.Name = "IconBox"; - this.IconBox.Size = new System.Drawing.Size(16, 16); - this.IconBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; - this.IconBox.TabIndex = 8; - this.IconBox.TabStop = false; - // // Window // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -203,8 +194,8 @@ this.Size = new System.Drawing.Size(601, 346); this.TitleBarHolder.ResumeLayout(false); this.TitleBarHolder.PerformLayout(); - this.BottomBarHolder.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.IconBox)).EndInit(); + this.BottomBarHolder.ResumeLayout(false); this.ResumeLayout(false); } @@ -215,7 +206,6 @@ private System.Windows.Forms.Panel TitleBarRight; private System.Windows.Forms.Panel TitleBarLeft; private System.Windows.Forms.Panel BottomBarHolder; - private System.Windows.Forms.Panel BottomBar; private System.Windows.Forms.Panel BottomRight; private System.Windows.Forms.Panel BottomLeft; private System.Windows.Forms.Panel RightBar; diff --git a/ShiftOS/ShiftOS/Windowing/Window.cs b/ShiftOS/ShiftOS/Windowing/Window.cs index e8ec4c0..dad4dac 100644 --- a/ShiftOS/ShiftOS/Windowing/Window.cs +++ b/ShiftOS/ShiftOS/Windowing/Window.cs @@ -15,6 +15,9 @@ namespace ShiftOS.Windowing public partial class Window : UserControl { private SystemContext _currentSystem = null; + private int PreRollHeight = 0; + private bool IsRolled = false; + public Window() { @@ -35,6 +38,8 @@ namespace ShiftOS.Windowing private void OnDesktopUpdated(object sender, EventArgs e) { + this.BackColor = Color.Transparent; + // Get the skin data. var skin = this.CurrentSystem.GetSkinContext(); var skindata = skin.GetSkinData(); @@ -112,6 +117,183 @@ namespace ShiftOS.Windowing RollButton.BackColor = skindata.rollbtncolour; } + // Set up the minimize button background. + if (skin.HasImage("minbtn")) + { + MinimizeButton.BackColor = Color.Transparent; + if (MinimizeButton.BackgroundImage != skin.GetImage("minbtn")) + MinimizeButton.BackgroundImage = skin.GetImage("minbtn"); + MinimizeButton.BackgroundImageLayout = skindata.minbtnlayout; + } + else + { + MinimizeButton.BackgroundImage = null; + MinimizeButton.BackColor = skindata.minbtncolour; + } + + // Set up the widths of our borders. + this.LeftBar.Width = skindata.borderwidth; + this.RightBar.Width = skindata.borderwidth; + this.BottomBarHolder.Height = skindata.borderwidth; + + // Bottom corners get their heights from the bottom bar holder, but their widths must be set. + this.BottomLeft.Width = this.LeftBar.Width; + this.BottomRight.Width = this.RightBar.Width; + + // Should we show the titlebar corners? + if(skindata.enablecorners) + { + // Show titlebar corners. + this.TitleBarLeft.Show(); + this.TitleBarRight.Show(); + + // Set their widths. + this.TitleBarLeft.Width = skindata.titlebarcornerwidth; + this.TitleBarRight.Width = this.TitleBarLeft.Width; + + // Set their backgrounds. + if(skin.HasImage("leftcorner")) + { + if (TitleBarLeft.BackgroundImage != skin.GetImage("leftcorner")) + TitleBarLeft.BackgroundImage = skin.GetImage("leftcorner"); + TitleBarLeft.BackgroundImageLayout = skindata.leftcornerlayout; + TitleBarLeft.BackColor = Color.Transparent; + } + else + { + TitleBarLeft.BackColor = skindata.leftcornercolour; + TitleBarLeft.BackgroundImage = null; + } + + if (skin.HasImage("rightcorner")) + { + if (TitleBarRight.BackgroundImage != skin.GetImage("rightcorner")) + TitleBarRight.BackgroundImage = skin.GetImage("rightcorner"); + TitleBarRight.BackgroundImageLayout = skindata.rightcornerlayout; + TitleBarRight.BackColor = Color.Transparent; + } + else + { + TitleBarRight.BackColor = skindata.rightcornercolour; + TitleBarRight.BackgroundImage = null; + } + + } + else + { + // Hide them. + this.TitleBarLeft.Hide(); + this.TitleBarRight.Hide(); + } + + // Should we show the border corners? + if (skindata.enablebordercorners) + { + // Show titlebar corners. + this.BottomLeft.Show(); + this.BottomRight.Show(); + + // Set their backgrounds. + if (skin.HasImage("bottomleftcorner")) + { + if (BottomLeft.BackgroundImage != skin.GetImage("bottomleftcorner")) + BottomLeft.BackgroundImage = skin.GetImage("bottomleftcorner"); + BottomLeft.BackgroundImageLayout = skindata.bottomleftcornerlayout; + BottomLeft.BackColor = Color.Transparent; + } + else + { + BottomLeft.BackColor = skindata.bottomleftcornercolour; + BottomLeft.BackgroundImage = null; + } + + if (skin.HasImage("bottomrightcorner")) + { + if (BottomRight.BackgroundImage != skin.GetImage("bottomrightcorner")) + BottomRight.BackgroundImage = skin.GetImage("bottomrightcorner"); + BottomRight.BackgroundImageLayout = skindata.bottomrightcornerlayout; + BottomRight.BackColor = Color.Transparent; + } + else + { + BottomRight.BackColor = skindata.bottomrightcornercolour; + BottomRight.BackgroundImage = null; + } + + } + else + { + // Hide them. + this.BottomLeft.Hide(); + this.BottomRight.Hide(); + } + + + // Set the titlebar background. + if (skin.HasImage("titlebar")) + { + if(this.TitleBarHolder.BackgroundImage != skin.GetImage("titlebar")) + { + this.TitleBarHolder.BackgroundImage = skin.GetImage("titlebar"); + } + this.TitleBarHolder.BackColor = Color.Transparent; + this.TitleBarHolder.BackgroundImageLayout = skindata.titlebarlayout; + } + else + { + this.TitleBarHolder.BackColor = skindata.titlebarcolour; + this.TitleBarHolder.BackgroundImage = null; + } + + if(skin.HasImage("borderleft")) + { + if(this.LeftBar.BackgroundImage != skin.GetImage("borderleft")) + { + this.LeftBar.BackgroundImage = skin.GetImage("borderleft"); + } + this.LeftBar.BackColor = Color.Transparent; + this.LeftBar.BackgroundImageLayout = skindata.borderleftlayout; + } + else + { + this.LeftBar.BackColor = skindata.borderleftcolour; + this.LeftBar.BackgroundImage = null; + } + + if (skin.HasImage("borderright")) + { + if (this.RightBar.BackgroundImage != skin.GetImage("borderright")) + { + this.RightBar.BackgroundImage = skin.GetImage("borderright"); + } + this.RightBar.BackColor = Color.Transparent; + this.RightBar.BackgroundImageLayout = skindata.borderrightlayout; + } + else + { + this.RightBar.BackColor = skindata.borderrightcolour; + this.RightBar.BackgroundImage = null; + } + + if (skin.HasImage("borderbottom")) + { + if (this.BottomBarHolder.BackgroundImage != skin.GetImage("borderbottom")) + { + this.BottomBarHolder.BackgroundImage = skin.GetImage("borderbottom"); + } + this.BottomBarHolder.BackColor = Color.Transparent; + this.BottomBarHolder.BackgroundImageLayout = skindata.borderbottomlayout; + } + else + { + this.BottomBarHolder.BackColor = skindata.borderbottomcolour; + this.BottomBarHolder.BackgroundImage = null; + } + + if(IsRolled) + { + Height = TitleBarHolder.Height; + } } @@ -134,5 +316,54 @@ namespace ShiftOS.Windowing get => this.IconBox.Image; set => this.IconBox.Image = value; } + + private void TitleBarMouseDown(object sender, MouseEventArgs e) + { + if (this.CurrentSystem.HasShiftoriumUpgrade("draggablewindows")) + { + if (e.Button == MouseButtons.Left) + { + this.TitleBarHolder.Capture = false; + this.TitleText.Capture = false; + this.IconBox.Capture = false; + this.TitleBarLeft.Capture = false; + this.TitleBarRight.Capture = false; + const ushort WM_NCLBUTTONDOWN = 0xA1; + const long HTCAPTION = 2; + Message msg = Message.Create(this.Handle, WM_NCLBUTTONDOWN, new IntPtr(HTCAPTION), IntPtr.Zero); + this.DefWndProc(ref msg); + } + } + } + + public event EventHandler WindowClosed; + + protected virtual void OnClose() { } + + public void Close() + { + WindowClosed?.Invoke(this, EventArgs.Empty); + OnClose(); + this.Parent?.Controls.Remove(this); + } + + private void CloseButton_MouseClick(object sender, MouseEventArgs e) + { + this.Close(); + } + + private void RollButton_MouseClick(object sender, MouseEventArgs e) + { + if(IsRolled) + { + this.Height = PreRollHeight; + } + else + { + PreRollHeight = this.Height; + this.Height = TitleBarHolder.Height; + } + IsRolled = !IsRolled; + } } }