コード例 #1
0
 private void sp_Resize(object sender, EventArgs e)
 {
     if (!chkXh.Checked)
     {
         int wei = this.Width;
         int hei = this.Height - 60;
         int sm  = getsm(ar.Count);
         int i   = 0;
         int y0  = 30;
         foreach (Control c in ar)
         {
             wz w1 = GetWZ(sm, i, wei, hei, 0, y0);
             c.Location = new System.Drawing.Point(w1.x, w1.y);
             c.Size     = new System.Drawing.Size(w1.w, w1.h);
             i          = i + 1;
         }
     }
 }
コード例 #2
0
        public void spxshi()
        {
            try
            {
                TC.yx = false;

                //清除现有镜头
                this.Cursor = Cursors.WaitCursor;
                foreach (mjpeg.cameraW c in arc)
                {
                    c.mjpegSource.Yx = false;
                    c.Stop();
                    c.Dispose();
                }
                foreach (Vlc.DotNet.Forms.VlcControl c in arr)
                {
                    c.Stop();
                    c.Dispose();
                }
                ar.Clear();
                arc.Clear();
                arr.Clear();
                GC.Collect();
                int sm = getsm(jtss.Count);
                TC.yx = true;
                //显示
                int wei = this.Width;
                int hei = this.Height - 60;
                int y0  = 30;
                int i   = 0;
                foreach (JT jt1 in jtss)
                {
                    if (i < sm)
                    {
                        bool rtsp = jt1.url.Trim().ToUpper().Substring(0, 4) == "RTSP";
                        if (rtsp)
                        {
                            Vlc.DotNet.Forms.VlcControl vlc = new Vlc.DotNet.Forms.VlcControl();
                            ((System.ComponentModel.ISupportInitialize)(vlc)).BeginInit();
                            this.SuspendLayout();

                            wz w1 = GetWZ(sm, i, wei, hei, 0, y0);
                            vlc.Location = new System.Drawing.Point(w1.x, w1.y);
                            vlc.Size     = new System.Drawing.Size(w1.w, w1.h);
                            this.Controls.Add(vlc);
                            try
                            {
                                vlc.VlcLibDirectoryNeeded += vlc_VlcLibDirectoryNeeded;
                                ((System.ComponentModel.ISupportInitialize)(vlc)).EndInit();
                                this.ResumeLayout(false);

                                vlc.Video.AspectRatio = vlc.Width.ToString() + ":" + vlc.Height.ToString();

                                vlc.Play(new Uri(jt1.url));
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("联系计算机人员安装VLC控件:" + ex.ToString());
                            }
                            //vlc.Play(new Uri("rtsp://169.85.100.36/axis-media/media.amp?camera=1"));
                            ar.Add(vlc);
                            arr.Add(vlc);
                            vlc.Resize += vlc_Resize;
                        }
                        else
                        {
                            c = new cameraW();
                            wz w1 = GetWZ(sm, i, wei, hei, 0, y0);
                            c.Location = new System.Drawing.Point(w1.x, w1.y);
                            c.Size     = new System.Drawing.Size(w1.w, w1.h);
                            c.Source   = jt1.url;
                            this.Controls.Add(c);
                            ar.Add(c);
                            arc.Add(c);
                            c.Start();
                        }
                        i = i + 1;
                    }
                }
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message); }
            finally
            { this.Cursor = Cursors.Default; }
        }
コード例 #3
0
        wz GetWZ(int sm, int i, int wei, int hei, int x0, int y0)
        {
            wz w1 = new wz();

            switch (sm)
            {
            case 1:
                w1.x = 0;
                w1.y = y0;
                w1.h = hei - y0;
                w1.w = wei;
                //c.Location = new System.Drawing.Point(0, 0 + y0);
                //c.Dock = System.Windows.Forms.DockStyle.Fill;
                break;

            case 2:
                //c.Location = new System.Drawing.Point(i * wei / 2, 0 + y0);
                //c.Size = new System.Drawing.Size(wei / 2, hei);
                w1.x = i * wei / 2;
                w1.y = y0;
                w1.h = hei;
                w1.w = wei / 2;
                break;

            case 4:
                int[,] wz = new int[, ] {
                    { 0, 0 }, { 1, 0 }, { 0, 1 }, { 1, 1 }
                };
                //c.Location = new System.Drawing.Point(wz[i, 0] * wei / 2, wz[i, 1] * hei / 2 + y0);
                //c.Size = new System.Drawing.Size(wei / 2, hei / 2);
                w1.x = wz[i, 0] * wei / 2;
                w1.y = wz[i, 1] * hei / 2 + y0;
                w1.h = hei / 2;
                w1.w = wei / 2;
                break;

            case 6:
                int[,] wz6 = new int[, ] {
                    { 0, 0 }, { 1, 0 }, { 2, 0 }, { 0, 1 }, { 1, 1 }, { 2, 1 }
                };
                //c.Location = new System.Drawing.Point(wz6[i, 0] * wei / 3, wz6[i, 1] * hei / 2 + y0);
                //c.Size = new System.Drawing.Size(wei / 3, hei / 2);
                w1.x = wz6[i, 0] * wei / 3;
                w1.y = wz6[i, 1] * hei / 2 + y0;
                w1.h = hei / 2;
                w1.w = wei / 3;
                break;

            case 8:
                int[,] wz8 = new int[, ] {
                    { 0, 0 }, { 1, 0 }, { 2, 0 }, { 3, 0 }, { 0, 1 }, { 1, 1 }, { 2, 1 }, { 3, 1 }
                };
                //c.Location = new System.Drawing.Point(wz8[i, 0] * wei / 4, wz8[i, 1] * hei / 2 + y0);
                //c.Size = new System.Drawing.Size(wei / 4, hei / 2);
                w1.x = wz8[i, 0] * wei / 4;
                w1.y = wz8[i, 1] * hei / 2 + y0;
                w1.h = hei / 2;
                w1.w = wei / 4;
                break;

            case 9:
                int[,] wz9 = new int[, ] {
                    { 0, 0 }, { 1, 0 }, { 2, 0 }, { 0, 1 }, { 1, 1 }, { 2, 1 }, { 0, 2 }, { 1, 2 }, { 2, 2 }
                };
                //c.Location = new System.Drawing.Point(wz9[i, 0] * wei / 3, wz9[i, 1] * hei / 3 + y0);
                //c.Size = new System.Drawing.Size(wei / 3, hei / 3);
                w1.x = wz9[i, 0] * wei / 3;
                w1.y = wz9[i, 1] * hei / 3 + y0;
                w1.h = hei / 3;
                w1.w = wei / 3;
                break;

            case 12:
                int[,] wz12 = new int[, ] {
                    { 0, 0 }, { 1, 0 }, { 2, 0 }, { 3, 0 }, { 0, 1 }, { 1, 1 }, { 2, 1 }, { 3, 1 }, { 0, 2 }, { 1, 2 }, { 2, 2 }, { 3, 2 }
                };
                //c.Location = new System.Drawing.Point(wz12[i, 0] * wei / 4, wz12[i, 1] * hei / 3 + y0);
                //c.Size = new System.Drawing.Size(wei / 4, hei / 3);
                w1.x = wz12[i, 0] * wei / 4;
                w1.y = wz12[i, 1] * hei / 3 + y0;
                w1.h = hei / 3;
                w1.w = wei / 4;
                break;

            default:
                break;
            }
            return(w1);
        }