减去表格的一半是什么意思?

时间:2013-04-17 05:50:01

标签: c#

我在新表格中有这个构造函数:

public MagnifierForm(Point MousePosition)
        {
            _doMove = true;
            FormBorderStyle = FormBorderStyle.None;
            ShowInTaskbar = false;
            TopMost = true;
            Width = 150;
            Height = 150;
            GraphicsPath gp = new GraphicsPath();
            gp.AddEllipse(ClientRectangle);
            Region = new Region(gp);
            mTimer = new Timer();
            mTimer.Enabled = true;
            mTimer.Interval = 20;
            mTimer.Tick += new EventHandler(HandleTimer);
            mScreenImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
                                     Screen.PrimaryScreen.Bounds.Height);

            //maybe subtract half of the forms width/height from the points (offset them)
            mStartPoint = MousePosition;
            mTargetPoint = MousePosition;
            speed = 0.35F;
        }

在构造函数的底部,我添加了以下代码:

mStartPoint = MousePosition;
mTargetPoint = MousePosition;

在Form1中我有这段代码:

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == (Keys.Control | Keys.M))
            {
                if (mf == null)
                {
                    mf = new Magnifier20070401.MagnifierForm(System.Windows.Forms.Cursor.Position);
                    mf.StartPosition = FormStartPosition.Manual;
                    mf.Location = Control.MousePosition;
                    mf.Show();

                    this.Select();
                }
                else if (mf.IsDisposed)
                {
                    mf = new Magnifier20070401.MagnifierForm(System.Windows.Forms.Cursor.Position);
                    mf.StartPosition = FormStartPosition.Manual;
                    mf.Location = Control.MousePosition;
                    mf.Show();
                }
                else
                {
                    mf.Close();
                    mf = null;
                }
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }

一切都很好。 而这个mStartPoint设置了表格的位置/位置也很好。

但这句话是什么意思? //可以从点中减去表格宽度/高度的一半(偏移它们)

sentecense与:mStartPoint和mTargetPoint

有关

如果我想使用这句话,有人可以告诉我一个例子吗?

1 个答案:

答案 0 :(得分:0)

我认为这个帖子最初是here

按照上一行:

mScreenImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
                                     Screen.PrimaryScreen.Bounds.Height);

我认为作者说你应该计算捕捉表格的一部分,在开头时通过将表格的宽度和高度除以其他来知道要显示的部分。如果您的代码是正确的,我会假设您正在计算需要显示的表单部分以及不同放大率的不同大小。

相关问题