从屏幕上撤消表格

时间:2018-06-09 21:17:13

标签: c# wpf forms position positioning

目前,当光标靠近它时程序会反弹,但它只是离开了屏幕 我无法将其保留在屏幕上(让它从显示器的边缘反弹)

public partial class Form1 : Form
{

    public Form1()
    {
        InitializeComponent();
    }

    private void timer1_Tick_1(object sender, EventArgs e)
    {
        this.TransparencyKey = this.BackColor;

        if(this.ClientRectangle.Contains(this.PointToClient(Cursor.Position)))
        {
            this.Location = new Point(Cursor.Position.X - (Cursor.Position.Y / 3) + (Cursor.Position.X / 2), Cursor.Position.Y - (Cursor.Position.X / 3) + (Cursor.Position.Y / 2));
        }
    }
}

更新

我想要一个远离光标的图像,但也不能离开屏幕(反弹回来)

0 个答案:

没有答案