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


C# Form.PointToClient方法代码示例

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


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

示例1: Draw

        public static Point[] Draw(Pen pen, Form parent)
        {
            sPen = pen;
            // Record the start point
            mPos = parent.PointToClient(Control.MousePosition);
            // Create a transparent form on top of  the parent form
            mMask = new Form();
            mMask.FormBorderStyle = FormBorderStyle.None;
            mMask.BackColor = Color.Magenta;
            mMask.TransparencyKey = mMask.BackColor;

            mMask.ShowInTaskbar = false;
            mMask.StartPosition = FormStartPosition.Manual;
            mMask.Size = parent.ClientSize;
            mMask.Location = parent.PointToScreen(Point.Empty);
            mMask.MouseMove += MouseMove;
            mMask.MouseUp += MouseUp;
            mMask.Paint += PaintRectangle;
            mMask.Load += DoCapture;
            // Display the overlay
            mMask.ShowDialog(parent);
            // Clean-up and calculate return value
            mMask.Dispose();
            mMask = null;
            var pos = parent.PointToClient(Control.MousePosition);

            return new[] {mPos, pos};
        }
开发者ID:Khanchai,项目名称:Paint,代码行数:28,代码来源:LineTools.cs

示例2: FindControlAtCursor

 public static Control FindControlAtCursor(Form form)
 {
     Point pos = Cursor.Position;
     if (form.Bounds.Contains(pos))
         return FindControlAtPoint(form, form.PointToClient(Cursor.Position));
     return null;
 }
开发者ID:rodrigos01,项目名称:toggldesktop,代码行数:7,代码来源:MainWindowController.cs

示例3: Input

        public Input(Form form)
        {
            this.form = form;

            KeysDown = new List<Keys>();
            KeysPressed = new List<Keys>();
            KeysReleased = new List<Keys>();
            MousePoint = form.PointToClient(Cursor.Position);
            MouseWheelDelta = 0;
        }
开发者ID:WebFreak001,项目名称:BulletSharp,代码行数:10,代码来源:Input.cs

示例4: Input

        public Input(Form form)
        {
            this.form = form;
            form.KeyDown += new KeyEventHandler(form_KeyDown);
            form.KeyUp += new KeyEventHandler(form_KeyUp);
            form.MouseDown += new MouseEventHandler(form_MouseDown);
            form.MouseMove += new MouseEventHandler(form_MouseMove);
            form.MouseUp += new MouseEventHandler(form_MouseUp);
            form.MouseWheel += new MouseEventHandler(form_MouseWheel);

            KeysDown = new List<Keys>();
            KeysPressed = new List<Keys>();
            KeysReleased = new List<Keys>();
            MousePoint = form.PointToClient(Cursor.Position);
            MouseWheelDelta = 0;
        }
开发者ID:WebFreak001,项目名称:BulletSharp,代码行数:16,代码来源:Input.cs

示例5: SetJsonInformation

        public static string SetJsonInformation(Form form, Stopwatch stopWatch, DateTime startTime)
        {
            // Get current time
            m_CurrenTime = DateTime.Now;

            // Evaluate running time
            m_TimeElasped = m_CurrenTime.Subtract(startTime);

            // Current cursor position.
            Point relativePoint = form.PointToClient(Cursor.Position);

            // Set time stamp
            //TODO: Use GetTimeStamp method.
            string timeStamp = m_TimeElasped.ToString();

            string strToReturn = SetJsonFormat(relativePoint.X, relativePoint.Y, timeStamp);
            return strToReturn;
        }
开发者ID:yafim,项目名称:eyeLog,代码行数:18,代码来源:Utils.cs

示例6: Clip

        public static void Clip(Processor processor)
        {
            Control.CheckForIllegalCrossThreadCalls = false;

            var clipForm = new Form
            {
                FormBorderStyle = FormBorderStyle.None,
                BackColor = Color.Black,
                Opacity = 0.25,
                ShowInTaskbar = false,
                TopMost = true
            };

            Label sizeLabel;
            clipForm.Controls.Add(sizeLabel = new Label
            {
                AutoSize = false,
                Size = new Size(90, 13),
                Left = clipForm.Width - 75,
                Top = clipForm.Height - 55,
                Anchor = (AnchorStyles.Bottom | AnchorStyles.Right),
                ForeColor = Color.White
            });

            List<Form> forms = new List<Form>();
            foreach (Screen screen in Screen.AllScreens)
            {
                var screenForm = new Form
                {
                    Bounds = screen.Bounds,
                    StartPosition = FormStartPosition.Manual,
                    WindowState = FormWindowState.Maximized,
                    FormBorderStyle = FormBorderStyle.None,
                    Opacity = 0.01,
                    Cursor = Cursors.Cross,
                    ShowInTaskbar = false,
                    TopMost = true
                };
                PictureBox screenImage;
                screenForm.Controls.Add(screenImage = new PictureBox
                {
                    Dock = DockStyle.Fill,
                    Image = GetScreenshot(screen),
                });
                screenForm.Show();
                screenForm.Focus();
                forms.Add(screenForm);

                new Thread(() =>
                {
                    Thread.Sleep(50);
                    screenForm.Opacity = 1.0;
                }).Start();

                screenImage.MouseDown += (s, e) =>
                {
                    var cursorColor = GetColor(screenImage, e.Location);
                    clipForm.BackColor = cursorColor.ToArgb() > Color.Black.ToArgb() / 2 ? Color.Black : Color.White;
                    sizeLabel.ForeColor = cursorColor.ToArgb() > Color.Black.ToArgb() / 2 ? Color.White : Color.Black;
                };

                screenImage.MouseDown += (s, e) =>
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        _selectingArea = true;
                        _startPoint = screenImage.PointToScreen(e.Location);
                        clipForm.Location = _startPoint;
                        clipForm.Size = new Size(1, 1);
                        clipForm.Show();
                    }
                };

                screenImage.MouseMove += (s, e) =>
                {
                    if (_selectingArea)
                    {
                        var newPoint = screenImage.PointToScreen(e.Location);
                        var point = new Point(Math.Min(newPoint.X, _startPoint.X), Math.Min(newPoint.Y, _startPoint.Y));
                        var size = new Size(Math.Max(newPoint.X, _startPoint.X) - point.X, Math.Max(newPoint.Y, _startPoint.Y) - point.Y);
                        if (clipForm.Location != point) clipForm.Location = point;
                        clipForm.Size = size;
                        sizeLabel.Text = size.Width + " x " + size.Height;
                    }
                };

                screenImage.MouseUp += (s, e) =>
                {
                    _selectingArea = false;
                    clipForm.Close();

                    forms.ForEach(f => f.Visible = false); // uncomment for debug

                    Bitmap bitmap;
                    if (screen.Bounds.Contains(clipForm.Bounds))
                        bitmap = GetClip(screenImage.Image, new Rectangle(screenForm.PointToClient(clipForm.Location), clipForm.Size));
                    else bitmap = Collage(forms, clipForm.Location, clipForm.Size);

                    forms.ForEach(f => f.Close());

//.........这里部分代码省略.........
开发者ID:topharley,项目名称:scrns.ru,代码行数:101,代码来源:Clipper.cs

示例7: GetCurrPosition

 public Vector2 GetCurrPosition( Form hWindow )
 {
     var posRel = hWindow.PointToClient(new Point((int)m_CurrPos.X, (int)m_CurrPos.Y));
     return new Vector2(posRel.X, posRel.Y);
 }
开发者ID:aik6980,项目名称:GameFramework,代码行数:5,代码来源:InputManager.cs

示例8: TestPublicMethods

		public void TestPublicMethods ()
		{
			// Public Methods that force Handle creation:
			// - CreateGraphics ()
			// - GetChildAtPoint ()
			// - Invoke, BeginInvoke throws InvalidOperationException if Handle has not been created
			// - PointToClient ()
			// - PointToScreen ()
			// - RectangleToClient ()
			// - RectangleToScreen ()
			// - Select ()
			// - Show (IWin32Window)
			// Notes:
			// - CreateControl does NOT force Handle creation!
			
			Form c = new Form ();

			c.BringToFront ();
			Assert.IsFalse (c.IsHandleCreated, "A1");
			
			c.Contains (new Form ());
			Assert.IsFalse (c.IsHandleCreated, "A2");
			
			c.CreateControl ();
			Assert.IsFalse (c.IsHandleCreated, "A3");
			
			c = new Form ();
			Graphics g = c.CreateGraphics ();
			g.Dispose ();
			Assert.IsTrue (c.IsHandleCreated, "A4");
			c.Dispose ();
			c = new Form ();
			
			c.Dispose ();
			Assert.IsFalse (c.IsHandleCreated, "A5");
			c = new Form ();

			// This is weird, it causes a form to appear that won't go away until you move the mouse over it, 
			// but it doesn't create a handle??
			//DragDropEffects d = c.DoDragDrop ("yo", DragDropEffects.None);
			//Assert.IsFalse (c.IsHandleCreated, "A6");
			//Assert.AreEqual (DragDropEffects.None, d, "A6b");
			
			//Bitmap b = new Bitmap (100, 100);
			//c.DrawToBitmap (b, new Rectangle (0, 0, 100, 100));
			//Assert.IsFalse (c.IsHandleCreated, "A7");
			//b.Dispose ();
			c.FindForm ();
			Assert.IsFalse (c.IsHandleCreated, "A8");
			
			c.Focus ();
			Assert.IsFalse (c.IsHandleCreated, "A9");

			c.GetChildAtPoint (new Point (10, 10));
			Assert.IsTrue (c.IsHandleCreated, "A10");
			c.Dispose ();
			c = new Form ();
			
			c.GetContainerControl ();
			Assert.IsFalse (c.IsHandleCreated, "A11");
			c.Dispose ();
			
			c = new Form ();
			c.GetNextControl (new Control (), true);
			Assert.IsFalse (c.IsHandleCreated, "A12");
			c.GetPreferredSize (Size.Empty);
			Assert.IsFalse (c.IsHandleCreated, "A13");
			c.Hide ();
			Assert.IsFalse (c.IsHandleCreated, "A14");
			
			c.Invalidate ();
			Assert.IsFalse (c.IsHandleCreated, "A15");
			
			//c.Invoke (new InvokeDelegate (InvokeMethod));
			//Assert.IsFalse (c.IsHandleCreated, "A16");
			c.PerformLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A17");
			
			c.PointToClient (new Point (100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A18");
			c.Dispose ();
			c = new Form ();
			
			c.PointToScreen (new Point (100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A19");
			c.Dispose ();
			
			c = new Form ();
			
			//c.PreProcessControlMessage   ???
			//c.PreProcessMessage          ???
			c.RectangleToClient (new Rectangle (0, 0, 100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A20");
			c.Dispose ();
			c = new Form ();
			c.RectangleToScreen (new Rectangle (0, 0, 100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A21");
			c.Dispose ();
			c = new Form ();
			c.Refresh ();
//.........这里部分代码省略.........
开发者ID:BrzVlad,项目名称:mono,代码行数:101,代码来源:FormHandleTest.cs

示例9: Draw

            public void Draw(Form popup)
            {
                //determine popup position
                int max = targetWnd.Top + target.Top;

                Position pos = Position.Top;
                int resX = Screen.PrimaryScreen.Bounds.Width, resY = Screen.PrimaryScreen.Bounds.Height;

                if (resY - (targetWnd.Top + target.Top) > max)
                {
                    max = resY - (targetWnd.Top + target.Top);
                    pos = Position.Bottom;
                }

                if (targetWnd.Left + target.Left > max)
                {
                    max = targetWnd.Left + target.Left;
                    pos = Position.Left;
                }

                if (resX - (targetWnd.Left + target.Left) > max)
                {
                    max = resX - (targetWnd.Left + target.Left);
                    pos = Position.Right;
                }

                //position popup
                Label lbl = (Label)popup.Controls["lbl"];
                Button buttAdv = (Button)popup.Controls["buttAdv"];
                Panel butts = (Panel)popup.Controls["butts"];

                Rectangle back = new Rectangle();
                Point a = new Point(), coords = new Point();
                Size pointSize = getPointerSize(pos, lbl, buttAdv, butts);

                switch (pos)
                {
                    case Position.Top:
                        lbl.Left = 7;
                        lbl.Top = 5;
                        positionButtons(lbl, buttAdv, butts);

                        back = new Rectangle(new Point(2, 2), getBackSize(lbl, buttAdv, butts));
                        a = new Point(back.Left + back.Width / 2, back.Top + back.Height);

                        popup.Width = Math.Max(5 + lbl.Width + 5, 12 + target.Width + 12);
                        popup.Height = 7 + lbl.Height + 5 + (buttAdv.Visible ? buttAdv.Height + 5 : 0) + butts.Height + 7 + 150 + 7 + target.Height + 7;

                        coords = target.PointToScreen(new Point(target.Width / 2, 0));
                        popup.Location = checkBounds(popup, coords.X + target.Width / 2 + 12 - popup.Width, coords.Y + target.Height + 7 - popup.Height);
                        break;
                    case Position.Bottom:
                        lbl.Left = 7;
                        lbl.Top = pointSize.Height + 5;
                        positionButtons(lbl, buttAdv, butts);

                        back = new Rectangle(new Point(2, pointSize.Height - 2), getBackSize(lbl, buttAdv, butts));
                        a = new Point(back.Left + back.Width / 2, back.Top);

                        popup.Width = back.Width;
                        popup.Height = pointSize.Height + back.Height;

                        coords = target.PointToScreen(new Point(target.Width / 2, target.Height));
                        popup.Location = checkBounds(popup, coords.X - popup.Width / 2, coords.Y - target.Height - 5);
                        break;
                    case Position.Left:
                        lbl.Left = 7;
                        lbl.Top = 5;
                        positionButtons(lbl, buttAdv, butts);

                        back = new Rectangle(new Point(0, 2), getBackSize(lbl, buttAdv, butts));
                        a = new Point(back.Left + back.Width, back.Top + back.Height / 2);

                        popup.Width = back.Width + pointSize.Width;
                        popup.Height = pointSize.Height;

                        coords = target.PointToScreen(new Point(0, target.Height / 2));
                        popup.Location = checkBounds(popup, coords.X + target.Width + 12 - popup.Width, coords.Y - target.Height / 2 - 5);
                        break;
                    case Position.Right:
                        lbl.Left = pointSize.Width + 5;
                        lbl.Top = 5;
                        positionButtons(lbl, buttAdv, butts);

                        back = new Rectangle(new Point(pointSize.Width - 2, 2), getBackSize(lbl, buttAdv, butts));
                        a = new Point(back.Left, back.Top + back.Height / 2);

                        popup.Width = pointSize.Width + back.Width;
                        popup.Height = pointSize.Height;

                        coords = target.PointToScreen(new Point(target.Width, target.Height / 2));
                        popup.Location = checkBounds(popup, coords.X - target.Width - 12, coords.Y - target.Height / 2 - 5);
                        break;
                }

                Point b = popup.PointToClient(coords);

                //draw
                Graphics gfx = popup.CreateGraphics();
                gfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
//.........这里部分代码省略.........
开发者ID:Winterstark,项目名称:GenericForms,代码行数:101,代码来源:classTutorial.cs

示例10: InForm

 private bool InForm(Form f, Point screenPoint)
 {
     Point p = f.PointToClient(screenPoint);
     return p.X > 0 && p.X < f.Size.Width && p.Y > 0 && p.Y < f.Size.Height;
 }
开发者ID:blahblahblahblah831,项目名称:brawltools2,代码行数:5,代码来源:ModelForm.cs


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