日期:2014-05-18  浏览次数:21120 次

C#如何实现视频监控分屏


如图想做类似的分屏 动态的分屏 1,4,9,16,25,36,这样的动态分屏
  C# 急!!!!

------解决方案--------------------
分屏采用4个Panel,当放大时就分别隐藏其他Panel
参考

------解决方案--------------------
C# code

  /// <summary>
        /// 返回分割后的rectangle数组
        /// </summary>
        /// <param name="rt">待分割的矩形</param>
        /// <param name="rowCount">行数</param>
        /// <param name="colCount">列数</param>
        /// <returns></returns>
        public Rectangle[] GetSplittedRectangles(Rectangle rt, int rowCount,int colCount)
        {
            Rectangle[] rects = new Rectangle[rowCount * colCount];

            int width = rt.Width / colCount;
            int height = rt.Height / rowCount;

            for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
            {
                for (int colIndex = 0; colIndex < colCount; colIndex++)
                {
                    rects[rowIndex * colCount + colIndex] = new Rectangle(colIndex * width,
                        rowIndex * height, width, height);
                }
            }

            return rects;
        }