当前位置: 首页>>代码示例>>C#>>正文


C# Control.PointToScreen方法代码示例

本文整理汇总了C#中System.Windows.Forms.Control.PointToScreen方法的典型用法代码示例。如果您正苦于以下问题:C# Control.PointToScreen方法的具体用法?C# Control.PointToScreen怎么用?C# Control.PointToScreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.Control的用法示例。


在下文中一共展示了Control.PointToScreen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DragObject

		public DragObject(ReportRootDesigner designer, Control dragControl, object hitTestObject, int initialX, int initialY)
		{
			m_designer = designer;
			m_dragControl = dragControl;
			m_hitObject = hitTestObject;
			m_initialX = initialX;
			m_initialY = initialY;
			m_mouseOffset = new Point(0, 0);
			m_screenOffset = new Point(0, 0);
			m_screenOffset = dragControl.PointToScreen(m_screenOffset);

			// The drag actually consists of all objects that are currently selected.
			//
			ISelectionService ss = designer.SelectionService;
			IDesignerHost host = designer.Host;

			m_dragShapes = new ArrayList();

			if (ss != null && host != null)
			{
				ICollection selectedObjects = ss.GetSelectedComponents();
				foreach(object o in selectedObjects)
				{
					IComponent comp = o as IComponent;
					if (comp != null)
					{
						ItemDesigner des = host.GetDesigner(comp) as ItemDesigner;
						if (des != null)
						{
							m_dragShapes.Add(des);
						}
					}
				}
			}
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:35,代码来源:DragObject.cs

示例2: PopupWindow

        public PopupWindow(Control parent, string caption, Point location, bool mayBeToLeft)
        {
            m_message = caption;

            InitializeComponent();

            SizeF sizef = messageLabel.CreateGraphics().MeasureString(m_message, messageLabel.Font);
            int labelWidth = (int)(sizef.Width * 1.05f);	// need just a little bit to make sure it stays single line
            int labelHeight = (int)(sizef.Height);

            Rectangle bounds = new Rectangle(location.X + SHIFT_HORIZ, location.Y - SHIFT_VERT, labelWidth, labelHeight);
            if(mayBeToLeft && parent != null)
            {
                try
                {
                    Rectangle parentBounds = new Rectangle(parent.PointToScreen(new Point(0, 0)), parent.Size);
                    //m_message = "" + parentBounds;
                    if(!parentBounds.Contains(bounds))
                    {
                        bounds = new Rectangle(location.X - labelWidth - SHIFT_HORIZ, location.Y - SHIFT_VERT, labelWidth, labelHeight);
                    }
                }
                catch {}
            }
            this.Bounds = bounds;

            messageLabel.Text = m_message;
            this.Focus();	// this normally won't work as Project.ShowPopup tries to return focus to parent. Hover mouse to regain focus
        }
开发者ID:slgrobotics,项目名称:QuakeMap,代码行数:29,代码来源:PopupWindow.cs

示例3: GetTipSize

		public static Size GetTipSize(Control control, Graphics graphics, TipSection tipData)
		{
			Size tipSize = Size.Empty;
			SizeF tipSizeF = SizeF.Empty;
			
			RectangleF workingArea = GetWorkingArea(control);
			
			PointF screenLocation = control.PointToScreen(Point.Empty);
			
			SizeF maxLayoutSize = new SizeF(workingArea.Right - screenLocation.X - HorizontalBorder * 2,
			                                workingArea.Bottom - screenLocation.Y - VerticalBorder * 2);
			
			if (maxLayoutSize.Width > 0 && maxLayoutSize.Height > 0) {
				graphics.TextRenderingHint =
					TextRenderingHint.AntiAliasGridFit;
				
				tipData.SetMaximumSize(maxLayoutSize);
				tipSizeF = tipData.GetRequiredSize();
				tipData.SetAllocatedSize(tipSizeF);
				
				tipSizeF += new SizeF(HorizontalBorder * 2,
				                      VerticalBorder   * 2);
				tipSize = Size.Ceiling(tipSizeF);
			}
			
			if (control.ClientSize != tipSize) {
				control.ClientSize = tipSize;
			}
			
			return tipSize;
		}
开发者ID:Clancey,项目名称:MonoMac.Windows.Form,代码行数:31,代码来源:TipPainter.cs

示例4: Show

 /// <summary>
 /// Shows the form on the specifies parent in the specifies location.
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="startLocation"></param>
 /// <param name="width"></param>
 public void Show(Control parent, Point startLocation, int width)
 {
     _parentControl = parent;
     Point location = parent.PointToScreen(startLocation);
     this.Location = location;            
     this.Width = width;
     this.Show();
 }
开发者ID:TimVelo,项目名称:StackBuilder,代码行数:14,代码来源:ContextMenuForm.cs

示例5: GetTipSize

		public static Size GetTipSize(Control control, Graphics graphics, TipSection tipData)
		{
			Size tipSize = Size.Empty;
			SizeF tipSizeF = SizeF.Empty;
			
			if (workingArea == RectangleF.Empty) {
				Form ownerForm = control.FindForm();
				if (ownerForm.Owner != null) {
					ownerForm = ownerForm.Owner;
				}
				
				workingArea = Screen.GetWorkingArea(ownerForm);
			}
			
			PointF screenLocation = control.PointToScreen(Point.Empty);
			SizeF maxLayoutSize = new SizeF(workingArea.Right /*- screenLocation.X*/ - HorizontalBorder * 2,
			                                workingArea.Bottom /*- screenLocation.Y*/ - VerticalBorder * 2);
			
			float global_max_x = workingArea.Right - HorizontalBorder * 2;
			
			if (maxLayoutSize.Width > 0 && maxLayoutSize.Height > 0) {
				/*graphics.TextRenderingHint =
				TextRenderingHint.AntiAliasGridFit;*/
				tipData.GlobalMaxX = global_max_x;
				tipData.SetMaximumSize(maxLayoutSize);
				//if (tipData.LeftOffset > 0) 
				//	control.Left = control.Left - tipData.LeftOffset;
				tipSizeF = tipData.GetRequiredSize();
				tipData.SetAllocatedSize(tipSizeF);
				
				tipSizeF += new SizeF(HorizontalBorder * 2,
				                      VerticalBorder   * 2);
				tipSize = Size.Ceiling(tipSizeF);
			}
			if (control is ICSharpCode.TextEditor.Gui.InsightWindow.PABCNETInsightWindow)
			{
				Rectangle rect = Rectangle.Ceiling(workingArea);
				Point pt = (control as ICSharpCode.TextEditor.Gui.InsightWindow.PABCNETInsightWindow).GetCusorCoord();
				if (pt.X + tipSize.Width > rect.Width)
				{
					control.Location = new Point(rect.Width-tipSize.Width,pt.Y);
				}
			}
			else
			{
				Rectangle rect = Rectangle.Ceiling(workingArea);
				Point pt = control.Location;
				if (pt.X + tipSize.Width > rect.Width)
				{
					control.Location = new Point(rect.Width-tipSize.Width,pt.Y);
				}
			}
			if (control.ClientSize != tipSize) {
				control.ClientSize = tipSize;
			}
			
			return tipSize;
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:58,代码来源:TipPainter.cs

示例6: VirtualPaint

        public static void VirtualPaint(IVirtualTransparencyHost host, Control child, PaintEventArgs args)
        {
            Control hostControl = (Control)host;
            bool rtl = host is Form && ((Form)host).RightToLeft == RightToLeft.Yes && ((Form)host).RightToLeftLayout;

            Point childLocation = child.PointToScreen(new Point(0, 0));
            Point hostLocation = hostControl.PointToScreen(new Point(rtl ? hostControl.ClientSize.Width : 0, 0));
            Point relativeChildLocation = new Point(childLocation.X - hostLocation.X, childLocation.Y - hostLocation.Y);

            if (relativeChildLocation == Point.Empty)
            {
                // no translation transform required
                host.Paint(args);
                return;
            }

            Rectangle relativeClipRectangle = args.ClipRectangle;
            relativeClipRectangle.Offset(relativeChildLocation);
            args.Graphics.SetClip(relativeClipRectangle, CombineMode.Replace);

            // Global transformations applied in GDI+ land don't apply to
            // GDI calls. So we need to drop down to GDI, apply a transformation
            // there, then wrap with GDI+.

            IntPtr hdc = args.Graphics.GetHdc();
            try
            {
                Gdi32.GraphicsMode oldGraphicsMode = Gdi32.SetGraphicsMode(hdc, Gdi32.GraphicsMode.Advanced);

                Gdi32.XFORM xformOrig;
                Gdi32.GetWorldTransform(hdc, out xformOrig);
                try
                {
                    Gdi32.XFORM xform = xformOrig;
                    xform.eDx -= relativeChildLocation.X;
                    xform.eDy -= relativeChildLocation.Y;
                    Gdi32.SetWorldTransform(hdc, ref xform);

                    using (Graphics g = Graphics.FromHdc(hdc))
                    {
                        host.Paint(new PaintEventArgs(g, relativeClipRectangle));
                    }
                }
                finally
                {
                    Gdi32.SetWorldTransform(hdc, ref xformOrig);
                    Gdi32.SetGraphicsMode(hdc, oldGraphicsMode);
                }
            }
            finally
            {
                args.Graphics.ReleaseHdc(hdc);
            }
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:54,代码来源:VirtualTransparency.cs

示例7: DrawTip

		public static Size DrawTip(Control control, Graphics graphics, TipSection tipData)
		{
			Size tipSize = Size.Empty;
			SizeF tipSizeF = SizeF.Empty;
			
			PointF screenLocation = control.PointToScreen(Point.Empty);
			
			if (workingArea == RectangleF.Empty) {
				Form ownerForm = control.FindForm();
				if (ownerForm.Owner != null) {
					ownerForm = ownerForm.Owner;
				}
				
				workingArea = Screen.GetWorkingArea(ownerForm);
			}
	
			SizeF maxLayoutSize = new SizeF(workingArea.Right - screenLocation.X - HorizontalBorder * 2,
			                                workingArea.Bottom - screenLocation.Y - VerticalBorder * 2);
			
			if (maxLayoutSize.Width > 0 && maxLayoutSize.Height > 0) {
				//graphics.TextRenderingHint =
				//TextRenderingHint.AntiAliasGridFit;
				
				tipData.SetMaximumSize(maxLayoutSize);
				tipSizeF = tipData.GetRequiredSize();
				tipData.SetAllocatedSize(tipSizeF);
				
				tipSizeF += new SizeF(HorizontalBorder * 2,
				                      VerticalBorder   * 2);
				tipSize = Size.Ceiling(tipSizeF);
			}
			
			if (control.ClientSize != tipSize) {
				control.ClientSize = tipSize;
			}
			
			if (tipSize != Size.Empty) {
				Rectangle borderRectangle = new Rectangle
				(Point.Empty, tipSize - new Size(1, 1));
				
				RectangleF displayRectangle = new RectangleF
				(HorizontalBorder, VerticalBorder,
				 tipSizeF.Width - HorizontalBorder * 2,
				 tipSizeF.Height - VerticalBorder * 2);
				
				// DrawRectangle draws from Left to Left + Width. A bug? :-/
				graphics.DrawRectangle(SystemPens.WindowFrame,
				                       borderRectangle);
				tipData.Draw(new PointF(HorizontalBorder, VerticalBorder));
			}
			return tipSize;
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:52,代码来源:TipPainter.cs

示例8: AdjustLoacation

 private static void AdjustLoacation(Control ctl)
 {
     if (formLoading != null)
     {
         formLoading.Size = ctl.Size;
         formLoading.Location = ctl.PointToScreen(new Point(0, 0));
         formLoading.pbLoading.Location = new Point((formLoading.Width - formLoading.pbLoading.Width) / 2
             , (formLoading.Height - formLoading.pbLoading.Height) / 2 - 10);
         formLoading.labelMsg.Location = new Point(
             (formLoading.Width - formLoading.labelMsg.Width) / 2,
             (formLoading.pbLoading.Location.X + formLoading.pbLoading.Height + 10));
     }
 }
开发者ID:caocf,项目名称:workspace-kepler,代码行数:13,代码来源:FormLoading.cs

示例9: ThumbnailViewForm

        internal ThumbnailViewForm(Control baseControl, DiagramClientView diagramClientView)
        {
            if (baseControl == null)
            {
                throw new ArgumentNullException("baseControl");
            }
            if (diagramClientView == null)
            {
                throw new ArgumentNullException("diagramClientView");
            }

            // Initialize the form.
            TopMost = true;
            ShowInTaskbar = false;
            FormBorderStyle = FormBorderStyle.None;
            StartPosition = FormStartPosition.Manual;

            // Position form so that its center lines up with the center of thumbnail control
            // at designer's bottom-right corner.
            var location = baseControl.PointToScreen(new Point(baseControl.Width / 2, baseControl.Height / 2));
            location.Offset(-ViewSize / 2, -ViewSize / 2);
            Bounds = new Rectangle(location.X, location.Y, ViewSize, ViewSize);

            // Make sure thumbnail form fits the screen and doesn't go below or off the right
            // edge of the screen.
            var screenBounds = Screen.FromControl(diagramClientView).WorkingArea;
            if (Right > screenBounds.Right)
            {
                Left = screenBounds.Right - Width;
            }
            if (Bottom > screenBounds.Bottom)
            {
                Top = screenBounds.Bottom - Height;
            }

            // Initialize a panel to host pan/zoom control.
            var panel1 = new Panel();
            panel1.Dock = DockStyle.Fill;
            panel1.BorderStyle = BorderStyle.FixedSingle;
            Controls.Add(panel1);

            // Initialize and dock pan/zoom control on the panel.
            _panZoomPanel = new PanZoomPanel();
            _panZoomPanel.Dock = DockStyle.Fill;
            panel1.Controls.Add(_panZoomPanel);
            _panZoomPanel.InvalidateImage(diagramClientView);

            Cursor.Hide();
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:49,代码来源:ThumbnailViewForm.cs

示例10: ShowForScope

 public void ShowForScope(Control control, Point pos)
 {
     List<Rectangle> rects = textBox.GetSurroundingRects(scope);
     Point screenPoint = control.PointToScreen(pos);
     Point clientPoint = control.PointToClient(screenPoint);
     Rectangle hitTest = new Rectangle(clientPoint, new Size(4,4));
     if(rects.Count>0)
     {
     //                ShowUnderScopeRect(rects[0], control.PointToScreen(pos), control);
         foreach (Rectangle rect in rects)
         {
             if(rect.IntersectsWith(hitTest))
             {
                 ShowUnderScopeRect(rect, control.PointToScreen(pos), control);
                 return;
             }
         }
         base.Show(control, pos);
     }
     else
     {
         base.Show(control, pos);
     }
 }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:24,代码来源:SmartContextMenu.cs

示例11: Show

 private void Show(Control control, Point pos, int flags)
 {
     if (control == null)
     {
         throw new ArgumentNullException("control");
     }
     if (!control.IsHandleCreated || !control.Visible)
     {
         throw new ArgumentException(System.Windows.Forms.SR.GetString("ContextMenuInvalidParent"), "control");
     }
     this.sourceControl = control;
     this.OnPopup(EventArgs.Empty);
     pos = control.PointToScreen(pos);
     System.Windows.Forms.SafeNativeMethods.TrackPopupMenuEx(new HandleRef(this, base.Handle), flags, pos.X, pos.Y, new HandleRef(control, control.Handle), null);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:ContextMenu.cs

示例12: MouseLeaveExtend

 private static void MouseLeaveExtend(this Control ctl, Action function, Control baseControl)
 {
     ctl.MouseLeave += (object sender, EventArgs arg) =>
     {
         Point p = Control.MousePosition;
         Rectangle r = new Rectangle(baseControl.PointToScreen(Point.Empty), baseControl.Size);
         if (!r.Contains(p))
         {
             function();
         }
     };
     foreach (Control c in ctl.Controls)
     {
         c.MouseLeaveExtend(function, baseControl);
     }
 }
开发者ID:shakasi,项目名称:shakasi.github.com,代码行数:16,代码来源:ControlExtend.cs

示例13: DrawFixedWidthTip

        public static Size DrawFixedWidthTip(Control control, Graphics graphics, TipSection tipData)
        {
            Size tipSize = Size.Empty;
            SizeF tipSizeF = SizeF.Empty;

            PointF screenLocation = control.PointToScreen(new Point(control.Width, 0));

            RectangleF workingArea = GetWorkingArea(control);

            SizeF maxLayoutSize = new SizeF(screenLocation.X - HorizontalBorder * 2,
                                            workingArea.Bottom - screenLocation.Y - VerticalBorder * 2);

            if (maxLayoutSize.Width > 0 && maxLayoutSize.Height > 0) {
                graphics.TextRenderingHint =
                    TextRenderingHint.AntiAliasGridFit;

                tipData.SetMaximumSize(maxLayoutSize);
                tipSizeF = tipData.GetRequiredSize();
                tipData.SetAllocatedSize(tipSizeF);

                tipSizeF += new SizeF(HorizontalBorder * 2,
                                      VerticalBorder   * 2);
                tipSize = Size.Ceiling(tipSizeF);
            }

            if (control.Height != tipSize.Height) {
                control.Height = tipSize.Height;
            }

            if (tipSize != Size.Empty) {
                Rectangle borderRectangle = new Rectangle
                    (Point.Empty, control.Size - new Size(1, 1));

                RectangleF displayRectangle = new RectangleF
                    (HorizontalBorder, VerticalBorder,
                     tipSizeF.Width - HorizontalBorder * 2,
                     tipSizeF.Height - VerticalBorder * 2);

                // DrawRectangle draws from Left to Left + Width. A bug? :-/
                graphics.DrawRectangle(SystemPens.WindowFrame,
                                       borderRectangle);
                tipData.Draw(new PointF(HorizontalBorder, VerticalBorder));
            }
            return tipSize;
        }
开发者ID:pusp,项目名称:o2platform,代码行数:45,代码来源:TipPainter.cs

示例14: Show

        public void Show(Control control, Point position)
        {
            if (control == null)
                Location = position;
            else
                Location = control.PointToScreen(Point.Empty) + position;
            int height = 0;
            int width = 160;
            for (int i = 0; i < Items.Count; i++)
            {
                if (Items[i].JustVisual) continue;
                if (Items[i] is ToolStripMenuItem && !String.IsNullOrEmpty((Items[i] as ToolStripMenuItem).ShortcutKeys))
                    width = 220;
                height += 24;
            }
            Size = new Drawing.Size(width, height);

            if (Location.X + width > Screen.PrimaryScreen.WorkingArea.Width)
                Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - width, Location.Y);

            Visible = true;

            for (int i = 0; i < Items.Count; i++)
            {
                if (Items[i] is ToolStripDropDownItem)
                {
                    var ddi = Items[i] as ToolStripDropDownItem;
                    ddi.ArrowImage = ApplicationBehaviour.Resources.Images.DropDownRightArrow;
                    ddi.ArrowColor = Color.Black;
                }
                Items[i].ForeColor = Color.FromArgb(64, 64, 64);
                Items[i].HoverColor = Color.FromArgb(160, 210, 222, 245);
                Items[i].TextAlign.LineAlignment = StringAlignment.Center;
                switch (Orientation)
                {
                    case Forms.Orientation.Horizontal:

                        break;
                    case Forms.Orientation.Vertical:
                        Items[i].Size = new Size(Size.Width, 24);
                        break;
                }
            }
        }
开发者ID:Meragon,项目名称:Unity-WinForms,代码行数:44,代码来源:ToolStripDropDown.cs

示例15: CentreInControl

		/// <summary>
		/// Position this form in the centre of the specified control.
		/// </summary>
		internal void CentreInControl(Control control)
		{
			// max size of this form is the size of the specified control
			var maxSize = control.Size;

			// computer centre of host control in screen coordinates
			var centre = control.PointToScreen(new Point(0, 0));
			centre.Offset(control.Width / 2, control.Height / 2);

			// compute size of form
			var w = Math.Min(_idealSize.Width, maxSize.Width);
			var h = Math.Min(_idealSize.Height, maxSize.Height);

			// compute upper left corner location
			var x = centre.X - (w/2);
			var y = centre.Y - (h/2);
			
			// update position
			this.Bounds = new Rectangle(x, y, w, h);
		}
开发者ID:nhannd,项目名称:Xian,代码行数:23,代码来源:WorkspaceDialogBoxForm.cs


注:本文中的System.Windows.Forms.Control.PointToScreen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。