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

📄 splitviewwidget.cs

📁 Fireball.CodeEditor is an source code editor control derived from the best compona SyntaxBox Control
💻 CS
📖 第 1 页 / 共 2 页
字号:
		{
		}

		private void Horizontal_MouseDown(object sender, MouseEventArgs e)
		{
			Action = SizeAction.SizeH;
			StartPos = new Point(e.X, e.Y);
			Horizontal.BringToFront();
			Horizontal.BackColor = SystemColors.ControlDark;
			FirstTime = true;
		}

		private void Vertical_MouseDown(object sender, MouseEventArgs e)
		{
			Action = SizeAction.SizeV;
			StartPos = new Point(e.X, e.Y);
			Vertical.BringToFront();
			Vertical.BackColor = SystemColors.ControlDark;
			FirstTime = true;
		}

		private void Center_MouseDown(object sender, MouseEventArgs e)
		{
			Action = SizeAction.SizeA;
			StartPos = new Point(e.X, e.Y);
			Vertical.BringToFront();
			Horizontal.BringToFront();
			Vertical.BackColor = SystemColors.ControlDark;
			Horizontal.BackColor = SystemColors.ControlDark;
			FirstTime = true;
		}

		private void Horizontal_MouseUp(object sender, MouseEventArgs e)
		{
			int xDiff = 0;
			int yDiff = StartPos.Y - e.Y;
			//	StartPos=new Point (e.X,e.Y);
			ReSize(xDiff, yDiff);

			Action = SizeAction.None;
			DoResize();
		}

		private void Vertical_MouseUp(object sender, MouseEventArgs e)
		{
			int xDiff = StartPos.X - e.X;
			int yDiff = 0;
			//	StartPos=new Point (e.X,e.Y);
			ReSize(xDiff, yDiff);

			Action = SizeAction.None;
			DoResize();
			this.Refresh();
		}

		private void Center_MouseUp(object sender, MouseEventArgs e)
		{
			int xDiff = StartPos.X - e.X;
			int yDiff = StartPos.Y - e.Y;
			//	StartPos=new Point (e.X,e.Y);
			ReSize(xDiff, yDiff);

			Action = SizeAction.None;
			DoResize();
		}

		private void Horizontal_MouseMove(object sender, MouseEventArgs e)
		{
			if (Action == SizeAction.SizeH && e.Button == MouseButtons.Left)
			{
				Point start;
				int x = e.X;
				int y = e.Y;


				if (y + Horizontal.Top > this.Height - 4)
					y = this.Height - 4 - Horizontal.Top;
				if (y + Horizontal.Top < 0)
					y = 0 - Horizontal.Top;

				if (!FirstTime)
				{
					start = this.PointToScreen(this.Location);
					start.Y += PrevPos.Y + Horizontal.Location.Y;
					ControlPaint.FillReversibleRectangle(new Rectangle(start.X, start.Y, this.Width, 3), Color.Black);
				}
				else
					FirstTime = false;

				start = this.PointToScreen(this.Location);
				start.Y += y + Horizontal.Location.Y;
				ControlPaint.FillReversibleRectangle(new Rectangle(start.X, start.Y, this.Width, 3), Color.Black);

				PrevPos = new Point(x, y);
			}
		}

		private void Vertical_MouseMove(object sender, MouseEventArgs e)
		{
			if (Action == SizeAction.SizeV && e.Button == MouseButtons.Left)
			{
				Point start;
				int x = e.X;
				int y = e.Y;

				if (x + Vertical.Left > this.Width - 4)
					x = this.Width - 4 - Vertical.Left;
				if (x + Vertical.Left < 0)
					x = 0 - Vertical.Left;


				if (!FirstTime)
				{
					start = this.PointToScreen(this.Location);
					start.X += PrevPos.X + Vertical.Location.X;
					ControlPaint.FillReversibleRectangle(new Rectangle(start.X, start.Y, 3, this.Height), Color.Black);
				}
				else
					FirstTime = false;

				start = this.PointToScreen(this.Location);
				start.X += x + Vertical.Location.X;
				ControlPaint.FillReversibleRectangle(new Rectangle(start.X, start.Y, 3, this.Height), Color.Black);

				PrevPos = new Point(x, y);
			}
		}

		private void Center_MouseMove(object sender, MouseEventArgs e)
		{
			if (Action == SizeAction.SizeA && e.Button == MouseButtons.Left)
			{
				Point start;
				int x = e.X - Center.Width/2;
				int y = e.Y - Center.Height/2;

				if (!FirstTime)
				{
					start = this.PointToScreen(this.Location);
					start.X += PrevPos.X + Vertical.Location.X;
					ControlPaint.FillReversibleRectangle(new Rectangle(start.X, start.Y, 3, this.Height), Color.Black);

					start = this.PointToScreen(this.Location);
					start.Y += PrevPos.Y + Horizontal.Location.Y;
					ControlPaint.FillReversibleRectangle(new Rectangle(start.X, start.Y, this.Width, 3), SystemColors.ControlDark);

				}
				else
					FirstTime = false;

				start = this.PointToScreen(this.Location);
				start.X += x + Vertical.Location.X;
				ControlPaint.FillReversibleRectangle(new Rectangle(start.X, start.Y, 3, this.Height), Color.Black);

				start = this.PointToScreen(this.Location);
				start.Y += y + Horizontal.Location.Y;
				ControlPaint.FillReversibleRectangle(new Rectangle(start.X, start.Y, this.Width, 3), SystemColors.ControlDark);


				PrevPos = new Point(x, y);
			}
		}


		private void ReSize(int x, int y)
		{
			//if (x==0 && y==0)
			//	return;


			this.SuspendLayout();

			int xx = Vertical.Left - x;
			int yy = Horizontal.Top - y;

			if (xx < 0)
				xx = 0;

			if (yy < 0)
				yy = 0;

			if (yy > this.Height - Horizontal.Height - SystemInformation.VerticalScrollBarWidth*3)
				yy = this.Height - Horizontal.Height - SystemInformation.VerticalScrollBarWidth*3;


			if (xx > this.Width - Vertical.Width - SystemInformation.VerticalScrollBarWidth*3)
				xx = this.Width - Vertical.Width - SystemInformation.VerticalScrollBarWidth*3;

			if (xx != Vertical.Left)
				Vertical.Left = xx;

			if (yy != Horizontal.Top)
				Horizontal.Top = yy;


			int CenterY = (Horizontal.Top + Horizontal.Height/2) - Center.Height/2;
			int CenterX = (Vertical.Left + Vertical.Width/2) - Center.Width/2;

			Center.Location = new Point(CenterX, CenterY);
			this.ResumeLayout();
			this.Invalidate();

			try
			{
				if (UpperLeft != null)
					UpperLeft.Refresh();
				if (UpperLeft != null)
					UpperLeft.Refresh();
				if (UpperLeft != null)
					UpperLeft.Refresh();
				if (UpperLeft != null)
					UpperLeft.Refresh();
			}
			catch
			{
			}
			OnResizing();
			//DoResize();	
			//this.Refresh ();
		}

		private void ReSize2()
		{
			int xx = Vertical.Left;
			int yy = Horizontal.Top;

			if (xx < 0)
				xx = 0;

			if (yy < 0)
				yy = 0;

			if (yy > this.Height - Horizontal.Height - SystemInformation.VerticalScrollBarWidth*3)
			{
				yy = this.Height - Horizontal.Height - SystemInformation.VerticalScrollBarWidth*3;
				if (yy != Horizontal.Top)
					Horizontal.Top = yy;
			}


			if (xx > this.Width - Vertical.Width - SystemInformation.VerticalScrollBarWidth*3)
			{
				xx = this.Width - Vertical.Width - SystemInformation.VerticalScrollBarWidth*3;
				if (xx != Vertical.Left)
					Vertical.Left = xx;
			}

			int CenterY = (Horizontal.Top + Horizontal.Height/2) - Center.Height/2;
			int CenterX = (Vertical.Left + Vertical.Width/2) - Center.Width/2;

			Center.Location = new Point(CenterX, CenterY);
		}

		private void Center_DoubleClick(object sender, EventArgs e)
		{
			Horizontal.Top = -100;
			Vertical.Left = -100;
			DoResize();
		}

		private void Vertical_DoubleClick(object sender, EventArgs e)
		{
			Vertical.Left = -100;
			DoResize();
		}

		private void Horizontal_DoubleClick(object sender, EventArgs e)
		{
			Horizontal.Top = -100;
			DoResize();
		}

		/// <summary>
		/// Splits the view horiziontally.
		/// </summary>
		public void Split5050h()
		{
			Horizontal.Top = this.Height/2;
			DoResize();
		}

		/// <summary>
		/// Splits teh view vertically.
		/// </summary>
		public void Split5050v()
		{
			Vertical.Left = this.Width/2;
			DoResize();
		}

		public int SplitviewV
		{
			get { return Vertical.Left; }
			set
			{
				Vertical.Left = value;
				DoResize();
			}
		}

		public int SplitviewH
		{
			get { return Horizontal.Top; }
			set
			{
				Horizontal.Top = value;
				DoResize();
			}
		}


		public void ResetSplitview()
		{
			Vertical.Left = 0;
			Horizontal.Top = 0;
			DoResize();
		}

		/// <summary>
		/// Start dragging the horizontal splitter.
		/// </summary>
		public void InvokeMouseDownh()
		{
			IntPtr hwnd = Horizontal.Handle;
			NativeUser32Api.SendMessage(hwnd, (int) WindowMessage.WM_LBUTTONDOWN, 0, 0);
		}

		/// <summary>
		/// Start dragging the vertical splitter.
		/// </summary>
		public void InvokeMouseDownv()
		{
			IntPtr hwnd = Vertical.Handle;
            NativeUser32Api.SendMessage(hwnd, (int)WindowMessage.WM_LBUTTONDOWN, 0, 0);
		}

		private void SplitViewControl_Leave(object sender, EventArgs e)
		{
		}

		private void SplitViewControl_Enter(object sender, EventArgs e)
		{
		}


		private void SplitViewControl_VisibleChanged(object sender, EventArgs e)
		{
		}
	}
}

⌨️ 快捷键说明

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