Exemplo n.º 1
0
 private void InitForm()
 {
     Trace.TraceInformation(" 动态加载预览控件,axPlatformPreview1");
     try
     {
         // 动态加载预览控件,axPlatformPreview1
         this.axPlatformPreview1 = new AxPlatformPreviewLib.AxPlatformPreview()
         {
             Dock = DockStyle.Fill
         };
         this.axPlatformPreview1.Enabled  = true;
         this.axPlatformPreview1.Location = new System.Drawing.Point(0, 0);
         this.axPlatformPreview1.Name     = "axPlatformPreview1";
         this.axPlatformPreview1.Size     = new System.Drawing.Size(917, 529);
         //this.axPlatformPreview1.TabIndex = 4;
         //this.Load += PreviewForm_Shown;
         //CrusisNumber.Text = "1";
         //Program.SetRegisCamState(0, UpdateCamState);//订阅监控点实时在线状态
         //SetCamStateInfoCallback();
         axPlatformPreview1.EventNotify += axPlatformPreview1_EventNotify;
         this.panel1.Controls.Add(axPlatformPreview1);
         //StrParam param = PreviewGlobalParam.GetParam();
         //PreviewGlobalParam.SetParam(axPlatformPreview1, param);
         //axPlatformPreview1.SetLayoutType(2);
     }
     catch (Exception ex)
     {
         Trace.TraceInformation(" 动态加载预览控件失败:" + ex.Message + ex.ToString());
     }
 }
Exemplo n.º 2
0
        public static bool SetParam(AxPlatformPreviewLib.AxPlatformPreview axPlatformPreview1, StrParam param)
        {
            string curPath = System.Windows.Forms.Application.StartupPath;
            string sPath   = curPath + @"\GlobalParam";

            if (!Directory.Exists(sPath))
            {
                Directory.CreateDirectory(sPath);
            }
            string tempPath = curPath + @"\GlobalParam\PreviewParam.ini";
            //组成xml报文
            XmlDocument    xmldoc = new XmlDocument();
            XmlDeclaration dec    = xmldoc.CreateXmlDeclaration("1.0", "utf-8", null);

            xmldoc.AppendChild(dec);
            XmlElement root = xmldoc.CreateElement("global");
            XmlElement child;

            child = xmldoc.CreateElement("snap");
            child.SetAttribute("picture", param.m_snapType);
            child.SetAttribute("save", param.m_snapPath);
            root.AppendChild(child);
            child = xmldoc.CreateElement("record");
            child.SetAttribute("packSize", param.m_recordSizeIdx);
            child.SetAttribute("save", param.m_recordPath);
            root.AppendChild(child);
            child = xmldoc.CreateElement("performance");
            child.SetAttribute("decode", param.m_decode);
            root.AppendChild(child);
            xmldoc.AppendChild(root);
            string strxml = xmldoc.InnerXml;

            //调用控件接口
            int ret = axPlatformPreview1.SetGlobalParam(strxml);

            if (ret == 0) //成功
            {
                Trace.TraceInformation("全局参数设置 PlatformPreview.ocx!SetGlobalParam 成功({0}):成功", ret);
                NativeMethods.WritePrivateProfileString("snap", "picture", param.m_snapType, tempPath);
                NativeMethods.WritePrivateProfileString("snap", "save", param.m_snapPath, tempPath);
                NativeMethods.WritePrivateProfileString("record", "packSize", param.m_recordSizeIdx, tempPath);
                NativeMethods.WritePrivateProfileString("record", "save", param.m_recordPath, tempPath);
                NativeMethods.WritePrivateProfileString("performance", "decode", param.m_decode, tempPath);
                return(true);
            }
            else          //失败
            {
                Trace.TraceInformation("全局参数设置 PlatformPreview.ocx!SetGlobalParam 失败({0}):失败", ret);
                return(false);
            }
        }