Exemplo n.º 1
0
        /// <summary>
        /// 注册抓图服务
        /// </summary>
        /// <param name="name">抓图服务名称</param>
        /// <param name="handle">窗口句柄</param>
        /// <param name="type">抓图类型</param>
        /// <returns>true成功,false失败</returns>
        public bool RegisterCapture(string name, IntPtr handle, CaptureType type = CaptureType.CreateDibSection)
        {
            if (string.IsNullOrEmpty(name) || _dicCaptureHelper.ContainsKey(name))
            {
                return(false);
            }

            ICaptureHelper helper;

            switch (type)
            {
            case CaptureType.CreateDibSection:
                helper = new DibCaptureHelper();
                break;

            case CaptureType.PrintWindow:
                helper = new PrintCaptureHelper();
                break;

            default:
                return(false);
            }

            if (!helper.Init(handle))
            {
                return(false);
            }

            _dicCaptureHelper.Add(name, helper);

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 注册抓图服务
        /// </summary>
        /// <param name="name">抓图服务名称</param>
        /// <param name="handle">窗口句柄</param>
        /// <param name="type">抓图类型</param>
        /// <returns>true成功,false失败</returns>
        public bool RegisterCapture(string name, IntPtr handle)
        {
            if (string.IsNullOrEmpty(name) || _dicCaptureHelper.ContainsKey(name))
            {
                return(false);
            }

            ICaptureHelper helper;

            helper = new DibCaptureHelper();

            if (!helper.Init(handle))
            {
                return(false);
            }

            _dicCaptureHelper.Add(name, helper);

            return(true);
        }