Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有没有办法在C#中设置窗口移动的动画?_C#_.net_Animation_Transition - Fatal编程技术网

有没有办法在C#中设置窗口移动的动画?

有没有办法在C#中设置窗口移动的动画?,c#,.net,animation,transition,C#,.net,Animation,Transition,我需要将一个窗口移动到不同的位置,但我不想简单地让它在当前位置消失并出现在所需的位置。我使用while cycle通过增加窗口的y坐标一次移动一个像素,但是在.NET中可能已经有了一些用于这些类型动画的实现方法。另外,我想能够设置动画的持续时间。在.NET中有任何方法可以制作这种动画吗?这就是我实现窗口移动的方式: while (window.Location.Y != newY) { window.Location = new Point(window.Location.X, wind

我需要将一个窗口移动到不同的位置,但我不想简单地让它在当前位置消失并出现在所需的位置。我使用while cycle通过增加窗口的y坐标一次移动一个像素,但是在.NET中可能已经有了一些用于这些类型动画的实现方法。另外,我想能够设置动画的持续时间。在.NET中有任何方法可以制作这种动画吗?这就是我实现窗口移动的方式:

while (window.Location.Y != newY)
{
    window.Location = new Point(window.Location.X, window.Location.Y + 1);
}
有几个问题: -您所指的窗口是什么? -这是什么类型的应用程序?WinForms?网络应用?还有别的吗


如果是web,则在客户端执行。使用jQuery。

您好,andrej您可以在WinForms中尝试此功能

        IntPtr ID; 
        int counter = 0;//index to move window

        public Form1()
        {
            InitializeComponent();
            ID = this.Handle; //get handle of form    
        }

        [DllImport("user32.dll", SetLastError = true)]
        internal static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);

        //place a timer and in his tick event...
        //and choose the interval of the tick.

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (counter <= Screen.PrimaryScreen.Bounds.Right)
                MoveWindow(ID, counter++, 0, this.Width, this.Height, true);
            else
                counter = 0;
        }
IntPtr-ID;
int计数器=0//移动窗口的索引
公共表格1()
{
初始化组件();
ID=this.Handle;//获取表单的句柄
}
[DllImport(“user32.dll”,SetLastError=true)]
内部静态外部布尔移动窗口(IntPtr hWnd、intx、inty、intnwidth、intnheight、bool bRepaint);
//放置一个计时器,在他的滴答声事件中。。。
//并选择滴答声的间隔。
私有无效计时器1_刻度(对象发送方,事件参数e)
{

如果(计数器您是否有一个矩形窗口或设置了透明键或其他类似的方法?每次移动窗口后,您需要给窗口时间重新绘制。实际上,它会一次移动一个像素,但移动速度很快,当您看到任何东西时,它会处于您使用System.Windows.Forms时使用的新位置。)(传统应用程序窗体)ou System.Windows.Controls(WPF)?我使用Windows.Forms,window只是经典窗体,FormBorderStyle设置为none,不透明度设置为75%。
int counter = 0;//index to move window

    public Form1()
    {
        InitializeComponent();   
    }

    //place a timer and in his tick event...
    //and choose the interval of the tick.

    private void timer1_Tick(object sender, EventArgs e)
    {
        if (counter <= Screen.PrimaryScreen.Bounds.Right)
            this.Location = new Point(counter++, 0);
        else
            counter = 0;
    }