/// <summary> /// On mouse move over title bar /// </summary> /// <param name="sender">sender of the event</param> /// <param name="e">event arg</param> private void OnMouseMoveInTitleBar(object sender, MouseEventArgs e) { if (_sizeMode == zSizeMode.Move) { Point location = TitleBar.PointToScreen(e.Location); ContinueMovementByMouse(location); return; } int buttonIndex = _titleRenderer.TitleBarButtonIndexUnderMouse; _titleRenderer.UpdateTitleBarButtonIndexUnderMouse(e.Location); if (buttonIndex != _titleRenderer.TitleBarButtonIndexUnderMouse) { TitleBar.Invalidate(); } Cursor cursor = Cursors.Default; if (buttonIndex >= 0) { cursor = Cursors.Hand; } else if (_positioner != null) { if (_positioner.CanMove && CanMoveByMouse) { cursor = Cursors.SizeAll; } } TitleBar.Cursor = cursor; }
/// <summary> /// On un-hightlight timer /// </summary> /// <param name="sender">sender of the event</param> /// <param name="e">even argument</param> private void OnUnhighlightTimer(object sender, EventArgs e) { int buttonIndex = _titleRenderer.TitleBarButtonIndexUnderMouse; if (buttonIndex >= 0) { Point mousePos = TitleBar.PointToClient(Control.MousePosition); _titleRenderer.UpdateTitleBarButtonIndexUnderMouse(mousePos); if (_titleRenderer.TitleBarButtonIndexUnderMouse != buttonIndex) { TitleBar.Invalidate(); } } }
/// <summary> /// Apply top form margins /// </summary> private void ApplyTopFormMargins() { int topOffset = 0; Margins margins = GetMargins(out topOffset); if (topOffset == 0) { TopMargin.Top = FormsPanel.Top; TopMargin.Left = FormsPanel.Left; TopMargin.Width = FormsPanel.Width; TopMargin.Height = margins.Bottom; TitleBar.Top = TopMargin.Bottom; TitleBar.Left = TopMargin.Left; TitleBar.Width = TopMargin.Width; TitleBar.Height = margins.Top - margins.Bottom; BottomMargin.Top = FormsPanel.Bottom - margins.Bottom; BottomMargin.Left = TopMargin.Left; BottomMargin.Width = TopMargin.Width; BottomMargin.Height = margins.Bottom; LeftMargin.Top = TitleBar.Bottom; LeftMargin.Left = FormsPanel.Left; LeftMargin.Width = margins.Left; LeftMargin.Height = BottomMargin.Top - TitleBar.Bottom; RightMargin.Top = TitleBar.Bottom; RightMargin.Left = FormsPanel.Right - margins.Right; RightMargin.Width = margins.Right; RightMargin.Height = BottomMargin.Top - TitleBar.Bottom; _titleRenderer.ContentTopOffset = 0; } else { TopMargin.Top = FormsPanel.Top - margins.Top; TopMargin.Left = 0; TopMargin.Width = Width; TopMargin.Height = DefaultTopMargin; TitleBar.Top = TopMargin.Bottom; TitleBar.Left = TopMargin.Left; TitleBar.Width = TopMargin.Width; TitleBar.Height = DefaultTitleHeight; BottomMargin.Top = FormsPanel.Bottom; BottomMargin.Left = TopMargin.Left; BottomMargin.Width = TopMargin.Width; BottomMargin.Height = margins.Bottom; LeftMargin.Top = TitleBar.Bottom; LeftMargin.Left = FormsPanel.Left - margins.Left; LeftMargin.Width = margins.Left; LeftMargin.Height = BottomMargin.Top - TitleBar.Bottom; RightMargin.Top = TitleBar.Bottom; RightMargin.Left = FormsPanel.Right; RightMargin.Width = margins.Right; RightMargin.Height = BottomMargin.Top - TitleBar.Bottom; _titleRenderer.ContentTopOffset = DefaultTopTitleOffset; } FormsContainerControlCollection forms = (FormsContainerControlCollection)FormsPanel.Controls; Form selectedForm = forms.TopControl as Form; if (selectedForm != null) { _titleRenderer.Icon = selectedForm.Icon; _titleRenderer.Text = selectedForm.Text; selectedForm.Bounds = FormsPanel.ClientRectangle; } _titleRenderer.TitleBarBounds = TitleBar.ClientRectangle; TitleBar.Invalidate(); }