public Form1()
{
InitializeComponent();
this.DoubleBuffered = true;//设置本窗体
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲
}
//切换视频
int channelNum = 0;//摄像头频道个数
private void btnChange_Click(object sender, EventArgs e)
{
#region 摄像头
int userID = aNVCurr.Login();
aNVCurr.SetUserID(userID);
aNVPre.SetUserID(userID);
aNVCurr.StartRealPlay(0, 0, 0);
aNVPre.StartRealPlay(1, 0, 0);
#endregion
if (showVideo == 1)
{
aNVPre.Left = aNVCurr.Left - aNVPre.Width;//第二个视频的左坐标
}
else
{
aNVCurr.Left = aNVPre.Left - aNVCurr.Width;
}
timer1.Enabled = true;
}
int showVideo = 1;
#region 移动视频
private void timer1_Tick(object sender, EventArgs e)
{
if (showVideo == 1)//第一个视频
{
if (aNVPre.Left < 0)
{
aNVPre.BringToFront();
aNVPre.Left += VideoPl.Width / 100;//移动第二个视频
}
else
{
showVideo = 2;
aNVPre.Left = 0;
timer1.Enabled = false;
}
}
else//第二个视频
{
if (aNVCurr.Left < 0)
{
aNVCurr.BringToFront();
aNVCurr.Left += VideoPl.Width / 100;//移动第一个视频
}
else
{
showVideo = 1;
aNVCurr.Left = 0;
timer1.Enabled = false;
}
}
}
#endregion