Exemple #1
0
        public static StrParam GetParam()
        {
            StrParam param    = new StrParam();
            string   curPath  = System.Windows.Forms.Application.StartupPath;
            string   tempPath = curPath + @"\GlobalParam\PreviewParam.ini";

            if (System.IO.File.Exists(tempPath))//从本地配置文件读取上一次设置的参数
            {
                StringBuilder picPath = new StringBuilder(255);
                NativeMethods.GetPrivateProfileString("snap", "save", "", picPath, 255, tempPath);
                param.m_snapPath = picPath.ToString();

                StringBuilder type = new StringBuilder(255);
                NativeMethods.GetPrivateProfileString("snap", "picture", "", type, 255, tempPath);
                param.m_snapType = type.ToString();

                StringBuilder VdPath = new StringBuilder(255);
                NativeMethods.GetPrivateProfileString("record", "save", "", VdPath, 255, tempPath);
                param.m_recordPath = VdPath.ToString();

                StringBuilder sizeIdx = new StringBuilder(255);
                NativeMethods.GetPrivateProfileString("record", "packSize", "", sizeIdx, 255, tempPath);
                param.m_recordSizeIdx = sizeIdx.ToString();

                StringBuilder decode = new StringBuilder(255);
                NativeMethods.GetPrivateProfileString("performance", "decode", "", decode, 255, tempPath);
                param.m_decode = decode.ToString();
            }
            else
            {
                param.m_snapPath      = curPath + @"\snap";
                param.m_snapType      = "jpeg";
                param.m_recordPath    = curPath + @"\clip";
                param.m_recordSizeIdx = "256";
                param.m_decode        = "5";
            }
            return(param);
        }
        private void LoadSrc(string CameraCode)
        {
            try
            {
                StrParam param = PreviewGlobalParam.GetParam();
                PreviewGlobalParam.SetParam(axPlatformPreview1, param);
                axPlatformPreview1.SetLayoutType(2);
                //TreeNode node = treeViewDevice.SelectedNode;
                //if (node.Nodes.Count > 0)//表明是父节点
                //{
                //    return;
                //}
                //treeViewDevice.BackColor = Color.White;
                //node.BackColor = Color.Blue;
                ////buttonStopPlay.Enabled = false;

                //SourceInfo nodeinfo = (SourceInfo)(node.Tag);
                string indexCode = CameraCode;

                //获取网域id
                int netID = Program.LoginInfo.NetZoneID;

                //获取预览XML
                //string strXml = Program.Service.Interface.getStreamInfo(strToken,indexCode,netID);
                string vmsIp = Program.LoginInfo.ServiceIP;
                Trace.TraceInformation("获取平台服务资源Code::" + indexCode + vmsIp);
                string      strXml = PlatformService.getPreviewOcxOptions(indexCode, vmsIp);
                XmlDocument xmldoc = new XmlDocument();
                try
                {
                    Trace.TraceInformation("从指定字符串" + strXml + "加载xml");
                    xmldoc.LoadXml(strXml);//从指定字符串加载xml
                }
                catch (Exception ex)
                {
                    MessageBox.Show("获取预览xml失败" + ex.Message);
                    return;
                }
                Trace.TraceInformation("获取当前空闲窗口");
                int wndIdx = axPlatformPreview1.GetCurrentSelectWindow();
                Trace.TraceInformation("开始预览");
                int ret = axPlatformPreview1.StartPreview(strXml, -1);

                if (ret == 0) //成功
                {
                    if (m_CameraIndexMap.ContainsKey(wndIdx))
                    {
                        m_CameraIndexMap[wndIdx] = indexCode;
                    }
                    else
                    {
                        m_CameraIndexMap.Add(wndIdx, indexCode);
                    }
                    Trace.TraceInformation("开始预览 PlatformPreview.ocx!StartPreview 成功({0}):成功", ret);
                }
                else          //失败
                {
                    Trace.TraceInformation("开始预览 PlatformPreview.ocx!StartPreview 失败({0}):失败", ret);
                }
            }
            catch (Exception ex)
            {
                Trace.TraceInformation("资源加载失败:" + ex.Message);
            }
        }