public void AddCamerItem(int index, int columns) { string sqlExists = string.Format(" SELECT * FROM camerDevice WHERE deviceID='{0}'", videoDevices[index].MonikerString); DataTable ds = SQLiteHelper.ExecuteQuery(sqlExists).Tables[0]; int videwplayerWidth = 320; int controlWidth = this.Width; // VideoCaptureDevice videoSource = new VideoCaptureDevice(videoDevices[index].MonikerString); VideoCaptureDevice videoSource = new VideoCaptureDevice(videoDevices[index > 1 ? 0 : index].MonikerString); //videoSource.DesiredFrameSize = new System.Drawing.Size(320, 240); // videoSource.DesiredFrameRate = 1; videoSource.VideoResolution = videoSource.VideoCapabilities[Convert.ToInt32(ds.Rows[0]["frameSizeIndex"])]; VideoCapabilities d = videoSource.VideoCapabilities[0];// = new System.Drawing.Size(640, 480); AForge.Controls.VideoSourcePlayer videoplayer = new AForge.Controls.VideoSourcePlayer(); videoplayer.Top = 100; videoplayer.Left = 320 * (index) + 1; videoplayer.Height = 240; videoplayer.Name = "videoplayer" + index; videoplayer.Tag = ds.Rows[0]["name"]; videoplayer.Width = videwplayerWidth; videoplayer.NewFrame += new AForge.Controls.VideoSourcePlayer.NewFrameHandler(this.videoPlayer_NewFrame); videoPlayerlist.Add(videoplayer); int columnsIndex = index % columns == 0 ? index / columns : index % columns; int rowIndex = index % columns == 0 ? (index - columns + 1) / columns : index / columns; tablepanel.Controls.Add(videoplayer, columnsIndex, rowIndex); videoplayer.VideoSource = videoSource; videoplayer.Start(); //videoSourcePlayer.VideoSource = videoSource; //videoSourcePlayer.Start(); }
private void button1_Click(object sender, EventArgs e) { vkl = true; button5.Enabled = false; button4.Enabled = true; var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); height = Settings.height; width = Settings.width; player = new VideoSourcePlayer(); player.Top = 30; player.Left = 30; player.Width = width; player.Height = height; player.Show(); Controls.Add(player); button1.Top = height + 30; button1.Left = width + 50; button2.Top = height + 60; button2.Left = width + 50; button3.Top = height + 90; button3.Left = width + 50; button4.Top = height + 120; button4.Left = width + 50; button5.Top = height + 160; button5.Left = width + 50; cam = new AForge.Video.DirectShow.VideoCaptureDevice(videoDevices[0].MonikerString); cam.Start(); player.VideoSource = cam; player.Start(); }