⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 floatinglform.cs

📁 Magic Library 1.7,有说明文档
💻 CS
📖 第 1 页 / 共 2 页
字号:
				{
					c.RecordFloatingRestore();
					c.Docked = true;
				}
			}
		}

        protected void Restore()
        {
			if (_zone != null)
			{
				ContentCollection cc = ZoneHelper.Contents(_zone);

				// Record restore object for each Content
				foreach(Content c in cc)
				{
					c.RecordFloatingRestore();
					c.Docked = true;
				}

				// Ensure each content is removed from any Parent
				foreach(Content c in cc)
					_dockingManager.HideContent(c, false, true);
				
				// Now restore each of the Content
				foreach(Content c in cc)
					_dockingManager.ShowContent(c);

				_dockingManager.UpdateInsideFill();
			}

			this.Close();
        }

		protected override void OnMove(EventArgs e)
		{
			Point newPos = this.Location;
			
			// Grab the aggregate collection of all Content objects in the Zone
			ContentCollection cc = ZoneHelper.Contents(_zone);
			
			// Update each one with the new FloatingForm location
			foreach(Content c in cc)
				c.DisplayLocation = newPos;			

			base.OnMove(e);
		}

		protected override void OnClosing(CancelEventArgs e)
		{
			if (_zone != null)
			{
				ContentCollection cc = ZoneHelper.Contents(_zone);

				// Record restore object for each Content
				foreach(Content c in cc)
					c.RecordRestore();

				// Ensure each content is removed from any Parent
				foreach(Content c in cc)
                {
					// Is content allowed to be hidden?
                    if (!_dockingManager.OnContentHiding(c))
						_dockingManager.HideContent(c, false, true);
					else
					{
						// At least one Content refuses to die, so do not
						// let the whole floating form be closed down
						e.Cancel = true;
					}
                }
			}

			// Must set focus back to the main application Window
			if (this.Owner != null)
				this.Owner.Activate();

			base.OnClosing(e);
		}

        protected override void OnResize(System.EventArgs e)
        {
            // Grab the aggregate collection of all Content objects in the Zone
            ContentCollection cc = ZoneHelper.Contents(_zone);
			
			// Do not include the caption height of the tool window in the saved height
			Size newSize = new Size(this.Width, this.Height - SystemInformation.ToolWindowCaptionHeight);
			
            // Update each one with the new FloatingForm location
            foreach(Content c in cc)
                c.FloatingSize = newSize;

            base.OnResize(e);
        }

        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 a redocking activity?
                    if (_intercept)
                    {
                        // Quite redocking
                        _redocker.QuitTrackingMode(null);

                        // Release capture
                        this.Capture = false;
                    
                        // Reset state
                        _intercept = false;

                        return true;
                    }
                }
            }
            
            return false;
        }

        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);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -