コード例 #1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determine if the drop down should go above the ScrPassageControl or
		/// below it.
		/// </summary>
		/// <param name="screenPoint">point on the screen of the</param>
		/// <param name="dropDown">drop down control</param>
		/// <returns>true to go above, false to go below</returns>
		/// ------------------------------------------------------------------------------------
		private bool DropDownShouldGoUp(Point screenPoint, ScrPassageDropDown dropDown)
		{
			// determine the usable space on the screen that contains the top left
			// corner of the ScrPassageControl.
			Rectangle rcAllowable = ScreenUtils.AdjustedWorkingArea(Screen.FromPoint(screenPoint));

			// If there is not enough space to go down, then go up
			return (rcAllowable.Height - screenPoint.Y - Height - dropDown.Height < 0);
		}
コード例 #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Position the drop down control.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void PositionDropDown(ScrPassageDropDown dropDown)
		{
			Point screenPoint = PointToScreen(new Point(0, 0));

			// If there is no room below the ScrPassageControl for the drop down then
			// position above, otherwise position below.
			if (DropDownShouldGoUp(screenPoint, dropDown))
				screenPoint.Y -= dropDown.Height;
			else
				screenPoint.Y += Height;
			dropDown.DesktopLocation = screenPoint;

			// Make sure that the drop down fits on the screen.
			Rectangle rect = new Rectangle(dropDown.DesktopLocation,
				new Size(dropDown.Width, dropDown.Height));
			ScreenUtils.EnsureVisibleRect(ref rect);
			dropDown.DesktopLocation = new Point(rect.Left, rect.Top);
		}