//, ContextHandler contextHandler) public FloatingForm(DockingManager dockingManager, Zone zone) { // The caller is responsible for setting our initial screen location this.StartPosition = FormStartPosition.Manual; // Not in task bar to prevent clutter this.ShowInTaskbar = false; // Make sure the main Form owns us this.Owner = dockingManager.Container.FindForm(); // Need to know when the Zone is removed this.ControlRemoved += new ControlEventHandler(OnZoneRemoved); // Add the Zone as the only content of the Form Controls.Add(zone); // Default state _redocker = null; _intercept = false; _zone = zone; _dockingManager = dockingManager; // Assign any event handler for context menu // if (contextHandler != null) // this.Context += contextHandler; // Default color this.BackColor = _dockingManager.BackColor; this.ForeColor = _dockingManager.InactiveTextColor; // Monitor changes in the Zone content _zone.Windows.Inserted += new CollectionChange(OnWindowInserted); _zone.Windows.Removing += new CollectionChange(OnWindowRemoving); _zone.Windows.Removed += new CollectionChange(OnWindowRemoved); if (_zone.Windows.Count == 1) { // The first Window to be added. Tell it to hide details _zone.Windows[0].HideDetails(); // Monitor change in window title _zone.Windows[0].FullTitleChanged += new EventHandler(OnFullTitleChanged); // Grab any existing title this.Text = _zone.Windows[0].FullTitle; } // Need to hook into message pump so that the ESCAPE key can be // intercepted when in redocking mode Application.AddMessageFilter(this); }
public WindowDetailCaption(DockingManager manager, Size fixedSize, EventHandler closeHandler, EventHandler restoreHandler, EventHandler invertAutoHideHandler) //, ContextHandler contextHandler) : base(manager) { // Setup correct color remapping depending on initial colors DefineButtonRemapping(); // Default state _maxButton = null; _hideButton = null; _maxInterface = null; _redocker = null; _showCloseButton = true; _showHideButton = true; _ignoreHideButton = false; _pinnedImage = false; // Prevent flicker with double buffering and all painting inside WM_PAINT SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); // Our size is always fixed at the required length in both directions // as one of the sizes will be provided for us because of our docking this.Size = fixedSize; if (closeHandler != null) this.Close += closeHandler; if (restoreHandler != null) this.Restore += restoreHandler; if (invertAutoHideHandler != null) this.InvertAutoHide += invertAutoHideHandler; // if (contextHandler != null) // this.Context += contextHandler; // Let derived classes override the button creation CreateButtons(); // Need to hook into message pump so that the ESCAPE key can be // intercepted when in redocking mode Application.AddMessageFilter(this); }
public HotZoneFloating(Rectangle hotArea, Rectangle newSize, Point offset, RedockerContent redocker) : base(hotArea, newSize) { // Store initial state _offset = offset; _redocker = redocker; Size floatSize = CalculateFloatingSize(); float widthPercentage = (float)floatSize.Width / (float)_newSize.Width; float heightPercentage = (float)floatSize.Height / (float)_newSize.Height; _newSize.Width = floatSize.Width; _newSize.Height = floatSize.Height + SystemInformation.ToolWindowCaptionHeight; _offset.X = (int)((float) _offset.X * widthPercentage); _offset.Y = (int)((float) _offset.Y * heightPercentage); // We do not want the indicator to be too far away from the cursor, so limit check the offset if (_offset.X > newSize.Width) _offset.X = newSize.Width; if (_offset.Y > newSize.Height) _offset.Y = newSize.Height; }
protected override void WndProc(ref Message m) { // Want to notice when the window is maximized if (m.Msg == (int)Win32.Msgs.WM_NCLBUTTONDBLCLK) { // Redock and kill ourself Restore(); // We do not want to let the base process the message as the // restore might fail due to lack of permission to restore to // old state. In that case we do not want to maximize the window return; } else if (m.Msg == (int)Win32.Msgs.WM_NCLBUTTONDOWN) { if (!_intercept) { // Perform a hit test against our own window to determine // which area the mouse press is over at the moment. uint result = User32.SendMessage(this.Handle, (int)Win32.Msgs.WM_NCHITTEST, 0, (uint)m.LParam); // Only want to override the behviour of moving the window via the caption box if (result == HITTEST_CAPTION) { // Remember new state _intercept = true; // Capture the mouse until the mouse us is received this.Capture = true; // Ensure that we gain focus and look active this.Activate(); // Get mouse position to inscreen coordinates Win32.POINT mousePos; mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU); mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16); // Find adjustment to bring screen to client coordinates Point topLeft = PointToScreen(new Point(0, 0)); topLeft.Y -= SystemInformation.CaptionHeight; topLeft.X -= SystemInformation.BorderSize.Width; // Begin a redocking activity _redocker = new RedockerContent(this, new Point(mousePos.x - topLeft.X, mousePos.y - topLeft.Y)); return; } } } else if (m.Msg == (int)Win32.Msgs.WM_MOUSEMOVE) { if (_intercept) { Win32.POINT mousePos; mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU); mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16); _redocker.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 0, mousePos.x, mousePos.y, 0)); return; } } else if (m.Msg == (int)Win32.Msgs.WM_LBUTTONUP) { if (_intercept) { Win32.POINT mousePos; mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU); mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16); _redocker.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, mousePos.x, mousePos.y, 0)); // Release capture this.Capture = false; // Reset state _intercept = false; return; } } else if ((m.Msg == (int)Win32.Msgs.WM_NCRBUTTONUP) || (m.Msg == (int)Win32.Msgs.WM_NCMBUTTONDOWN) || (m.Msg == (int)Win32.Msgs.WM_NCMBUTTONUP) || (m.Msg == (int)Win32.Msgs.WM_RBUTTONDOWN) || (m.Msg == (int)Win32.Msgs.WM_RBUTTONUP) || (m.Msg == (int)Win32.Msgs.WM_MBUTTONDOWN) || (m.Msg == (int)Win32.Msgs.WM_MBUTTONUP)) { // Prevent middle and right mouse buttons from interrupting // the correct operation of left mouse dragging return; } else if (m.Msg == (int)Win32.Msgs.WM_NCRBUTTONDOWN) { if (!_intercept) { // Get screen coordinates of the mouse Win32.POINT mousePos; mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU); mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16); // Box to transfer as parameter OnContext(new Point(mousePos.x, mousePos.y)); return; } } base.WndProc(ref m); }
public bool PreFilterMessage(ref Message m) { // Has a key been pressed? if (m.Msg == (int)Win32.Msgs.WM_KEYDOWN) { // Is it the ESCAPE key? if ((int)m.WParam == (int)Win32.VirtualKeys.VK_ESCAPE) { // Are we in redocking mode? if (_redocker != null) { // Cancel the redocking activity _redocker.QuitTrackingMode(null); // Put back the page that was removed when dragging started RestoreDraggingPage(); // No longer need the object _redocker = null; return true; } } } return false; }
protected void OnPageDragQuit(object sender, MouseEventArgs e) { // Are we currently in a redocking state? if (_redocker != null) { // Put back the page that was removed when dragging started RestoreDraggingPage(); // No longer need the object _redocker = null; } }
protected void OnPageDragEnd(object sender, MouseEventArgs e) { // Are we currently in a redocking state? if (_redocker != null) { // Let the redocker finish off bool moved = _redocker.OnMouseUp(e); // If the tab was not positioned somewhere else if (!moved) { // Put back the page that was removed when dragging started RestoreDraggingPage(); } // No longer need the object _redocker = null; } }
public WindowContentTabbed(DockingManager manager, VisualStyle vs) : base(manager, vs) { _redocker = null; _activeContent = null; // Create the TabControl used for viewing the Content windows _tabControl = new SharpClient.UI.Controls.TabControl(); // It should always occupy the remaining space after all details _tabControl.Dock = DockStyle.Fill; // Show tabs only if two or more tab pages exist _tabControl.HideTabsMode = SharpClient.UI.Controls.TabControl.HideTabsModes.HideUsingLogic; // Hook into the TabControl notifications _tabControl.GotFocus += new EventHandler(OnTabControlGotFocus); _tabControl.LostFocus += new EventHandler(OnTabControlLostFocus); _tabControl.PageGotFocus += new EventHandler(OnTabControlGotFocus); _tabControl.PageLostFocus += new EventHandler(OnTabControlLostFocus); _tabControl.SelectionChanged += new EventHandler(OnSelectionChanged); _tabControl.PageDragStart += new MouseEventHandler(OnPageDragStart); _tabControl.PageDragMove += new MouseEventHandler(OnPageDragMove); _tabControl.PageDragEnd += new MouseEventHandler(OnPageDragEnd); _tabControl.PageDragQuit += new MouseEventHandler(OnPageDragQuit); _tabControl.DoubleClickTab += new SharpClient.UI.Controls.TabControl.DoubleClickTabHandler(OnDoubleClickTab); //_tabControl.Font = manager.TabControlFont; _tabControl.BackColor = manager.BackColor; _tabControl.ForeColor = manager.InactiveTextColor; // Define the visual style required _tabControl.Style = vs; // Allow developers a chance to override default settings //manager.OnTabControlCreated(_tabControl); switch(vs) { case VisualStyle.IDE: Controls.Add(_tabControl); break; case VisualStyle.Plain: // Only the border at the pages edge and not around the whole control _tabControl.InsetBorderPagesOnly = !_manager.PlainTabBorder; // We want a border around the TabControl so it is indented and looks consistent // with the Plain look and feel, so use the helper Control 'BorderForControl' BorderForControl bfc = new BorderForControl(_tabControl, _plainBorder); // It should always occupy the remaining space after all details bfc.Dock = DockStyle.Fill; // Define the default border border bfc.BackColor = _manager.BackColor; // When in 'VisualStyle.Plain' we need to Controls.Add(bfc); break; } // Need to hook into message pump so that the ESCAPE key can be // intercepted when in redocking mode Application.AddMessageFilter(this); }
protected void OnPageDragStart(object sender, MouseEventArgs e) { if (this.RedockAllowed) { // There must be a selected page for this event to occur SharpClient.UI.Controls.TabPage page = _tabControl.SelectedTab; // Event page must specify its Content object Content c = page.Tag as Content; // Remember the position of the tab before it is removed _dragPageIndex = _tabControl.TabPages.IndexOf(page); // Remove page from TabControl _tabControl.TabPages.Remove(page); // Force the entire window to redraw to ensure the Redocker does not start drawing // the XOR indicator before the window repaints itself. Otherwise the repainted // control will interfere with the XOR indicator. this.Refresh(); // Start redocking activity for the single Content of this WindowContent _redocker = new RedockerContent(_tabControl, c, this, new Point(e.X, e.Y)); } }
protected override void OnMouseUp(MouseEventArgs e) { // The double click event will cause the control to be destroyed as // the Contents are restored to their alternative positions, so need to // double check the control is not already dead if (!IsDisposed) { // Are we currently in a redocking state? if (_redocker != null) { // Let the redocker finish off _redocker.OnMouseUp(e); // No longer need the object _redocker = null; } // Right mouse button can generate a Context event if (e.Button == MouseButtons.Right) { // Get screen coordinates of the mouse Point pt = this.PointToScreen(new Point(e.X, e.Y)); // Box to transfer as parameter OnContext(pt); } } base.OnMouseUp(e); }
protected override void OnMouseDown(MouseEventArgs e) { // The double click event will cause the control to be destroyed as // the Contents are restored to their alternative positions, so need to // double check the control is not already dead if (!IsDisposed) { // Left mouse down begins a redocking action if (e.Button == MouseButtons.Left) { if (this.ParentWindow.RedockAllowed) { WindowContent wc = this.ParentWindow as WindowContent; // Is our parent a WindowContent instance? if (wc != null) { // Start redocking activity for the whole WindowContent _redocker = new RedockerContent(this, wc, new Point(e.X, e.Y)); } } } this.Focus(); } base.OnMouseDown(e); }
protected override void OnDoubleClick(EventArgs e) { // The double click event will cause the control to be destroyed as // the Contents are restored to their alternative positions, so need to // double check the control is not already dead if (!IsDisposed) { // Are we currently in a redocking state? if (_redocker != null) { // No longer need the object _redocker = null; } } // Fire attached event handlers OnRestore(); }