Example #1
0
 public void EnableSplitScreen(SplitScreenType type = SplitScreenType.Horizontal)
 {
     if (!_canUseSplitScreen)
     {
         return;
     }
     if (_splitScreenActive)
     {
         return;
     }
     _splitScreenActive = true;
     splitScreenType    = type;
     _controllers[0].SetCameraViewport(0, splitScreenType);
     _controllers[1].SetCameraViewport(1, splitScreenType);
 }
Example #2
0
        /// <summary>
        /// 设置6、8分屏布局
        /// </summary>
        private void SetMasterSlaveScreen(SplitScreenType aType)
        {
            HideAllViewer();

            // 6分屏布局为一个大屏,5个小屏,横竖为3个,相当于9分屏中的左上四屏合一
            int  tmpCount  = (int)aType / 2;
            int  perWidth  = this.pnlBase.Width / tmpCount;
            int  perHeight = this.pnlBase.Height / tmpCount;
            Size perSize   = new Size(perWidth, perHeight);
            Size mainSize  = new Size(this.pnlBase.Width - perWidth, this.pnlBase.Height - perHeight);

            RTSPViewer tmpViewer = mViewers[0];

            tmpViewer.Location = new Point(0, 0);
            tmpViewer.Size     = mainSize;
            tmpViewer.Visible  = true;

            // 右手边两个分屏
            for (int i = 1; i < tmpCount; i++)
            {
                tmpViewer          = mViewers[i];
                tmpViewer.Location = new Point(mainSize.Width, (i - 1) * perHeight);
                tmpViewer.Size     = perSize;
                tmpViewer.Visible  = true;
            }

            for (int i = tmpCount; i < (int)aType; i++)
            {
                tmpViewer          = mViewers[i];
                tmpViewer.Location = new Point((i - tmpCount) * perWidth, mainSize.Height);
                tmpViewer.Size     = perSize;
                tmpViewer.Visible  = true;
            }

            if (mSelectedViewer == null)
            {
                return;
            }
            if (mViewers.FindIndex((x) => x == mSelectedViewer) >= (int)aType)
            {
                // 超出分屏个数则不清除选中状态
                mSelectedViewer = null;
            }
        }
Example #3
0
        public void SetCameraViewport(int index, SplitScreenType type)
        {
            Enable();
            switch (index)
            {
            case 0:
                camera.rect = type == SplitScreenType.Horizontal ? new Rect(0f, 0f, 0.5f, 1f) : new Rect(0.5f, 0f, 0.5f, 1f);
                Debug.Log("[SplitScreenController]: assigning camera 1 viewport");
                break;

            case 1:
                camera.rect = type == SplitScreenType.Horizontal ? new Rect(0.5f, 0f, 0.5f, 1f) : new Rect(0f, 0f, 0.5f, 1f);
                Debug.Log("[SplitScreenController]: assigning camera 2 viewport");
                break;

            default:
                Debug.LogError("[SplitScreenController]: index is out of bounds");
                break;
            }
        }
Example #4
0
        /// <summary>
        /// 符合4、9、16矩阵的分屏布局
        /// </summary>
        private void SetMatrixScreen(SplitScreenType aType)
        {
            HideAllViewer();

            // 每行每列的视频输出窗口个数
            int  tmpCount  = (int)Math.Sqrt((int)aType);
            int  perWidth  = this.pnlBase.Width / tmpCount;
            int  perHeight = this.pnlBase.Height / tmpCount;
            Size perSize   = new Size(perWidth, perHeight);

            for (int i = 0; i < tmpCount; i++)
            {
                for (int j = 0; j < tmpCount; j++)
                {
                    RTSPViewer tmpViewer = mViewers[i * tmpCount + j];
                    tmpViewer.Location = new Point(j * perWidth, i * perHeight);
                    tmpViewer.Size     = perSize;
                    tmpViewer.Visible  = true;
                    if (j == tmpCount - 1)
                    {
                        // 最后一列对齐控件右边
                        tmpViewer.Width += this.pnlBase.Right - tmpViewer.Right;
                    }
                    if (i == tmpCount - 1)
                    {
                        tmpViewer.Height += this.pnlBase.Bottom - tmpViewer.Bottom;
                    }
                }
            }

            if (mSelectedViewer == null)
            {
                return;
            }
            if (mViewers.FindIndex((x) => x == mSelectedViewer) >= (int)aType)
            {
                // 超出分屏个数则不清除选中状态
                mSelectedViewer = null;
            }
        }
Example #5
0
        /// <summary>
        /// 根据数量设置分屏布局
        /// </summary>
        /// <param name="aType"></param>
        private void SetLayout(SplitScreenType aType)
        {
            mIsFullScreen = false;
            switch (aType)
            {
            case SplitScreenType.Full:
                SetFullScreen();
                break;

            case SplitScreenType.Four:
            case SplitScreenType.Nine:
            case SplitScreenType.Sixteen:
                SetMatrixScreen(aType);
                break;

            case SplitScreenType.Six:
            case SplitScreenType.Eight:
                SetMasterSlaveScreen(aType);
                break;

            default:
                break;
            }
        }
Example #6
0
 public void SwapSplitScreen()
 {
     splitScreenType = splitScreenType == SplitScreenType.Horizontal ? SplitScreenType.Vertical : SplitScreenType.Horizontal;
     _controllers[0].SetCameraViewport(0, splitScreenType);
     _controllers[1].SetCameraViewport(1, splitScreenType);
 }