private void btnCommit_Click(object sender, EventArgs e) { if (panelEx4.Controls.Count > 0) { IAnalyseSetting item = panelEx4.Controls[0] as IAnalyseSetting; string anaparam = ""; if (item is ucMoveObjAnalyseSetting && ucSingleDrawImageWnd1.DrawImage == null) { anaparam = ""; } else if (ucSingleDrawImageWnd1.DrawImage == null) { DevComponents.DotNetBar.MessageBoxEx.Show("请先设置参考图片", Framework.Environment.PROGRAM_NAME, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else { anaparam = item.AnalyseParam; } try { if (m_viewModel.Submit(anaparam)) { this.Close(); } } catch (SDKCallException ex) { MessageBoxEx.Show("添加实时任务失败,[" + ex.ErrorCode + "]" + ex.Message, Framework.Environment.PROGRAM_NAME, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } }
private void buttonOutput_Click(object sender, EventArgs e) { if (panelEx4.Controls.Count > 0) { IAnalyseSetting item = panelEx4.Controls[0] as IAnalyseSetting; if (ucSingleDrawImageWnd1.DrawImage != null) { string xml = item.AnalyseParam; string time = DateTime.Now.ToString("yyyyMMddHHmmssfff"); string type = "AnalyseParam"; string fileName = type + time + ".xml"; bool needSave = true; System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog(); sfd.RestoreDirectory = true; sfd.Filter = "配置文件|*.xml"; sfd.FileName = fileName; if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { fileName = sfd.FileName; } else { needSave = false; } if (needSave) { System.IO.File.WriteAllText(fileName, xml); } } } }
private void buttonImport_Click(object sender, EventArgs e) { System.Windows.Forms.OpenFileDialog ofd = new OpenFileDialog(); ofd.RestoreDirectory = true; ofd.Filter = "配置文件|*.xml"; string fileName = ""; E_VIDEO_ANALYZE_TYPE type = E_VIDEO_ANALYZE_TYPE.E_ANALYZE_NOUSE; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { fileName = ofd.FileName; try { string xml = System.IO.File.ReadAllText(fileName); System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument(); xmldoc.LoadXml(xml); System.Xml.XmlNode typenode = xmldoc.SelectSingleNode("root/AlgorithmInitParam/AlgorithmType"); switch (typenode.InnerXml) { case "Behaviour": type = E_VIDEO_ANALYZE_TYPE.E_ANALYZE_BEHAVIOR_ALARM; break; case "CrowdAnalyse": type = E_VIDEO_ANALYZE_TYPE.E_ANALYZE_CROWD; break; case "Face": type = E_VIDEO_ANALYZE_TYPE.E_ANALYZE_FACE_DYNAMIC; break; case "PeopleCount": type = E_VIDEO_ANALYZE_TYPE.E_ANALYZE_PERSON_COUNT; break; case "Crossroad": type = E_VIDEO_ANALYZE_TYPE.E_ANALYZE_CROSSROAD; break; case "MoveObject": type = E_VIDEO_ANALYZE_TYPE.E_ANALYZE_MOVEOBJ_PLATFORM; break; default: break; } if (type != E_VIDEO_ANALYZE_TYPE.E_ANALYZE_NOUSE) { GetAnalyseSettingPanel(type); if (panelEx4.Controls.Count > 0) { IAnalyseSetting item = panelEx4.Controls[0] as IAnalyseSetting; if (ucSingleDrawImageWnd1.DrawImage != null) { SetSetAnalyseTypeBtnCheck(type); item.AnalyseParam = xml; } } } } catch (Exception ex) { DevComponents.DotNetBar.MessageBoxEx.Show("导入配置文件错误。" + ex.Message, Framework.Environment.PROGRAM_NAME, MessageBoxButtons.OK); } } }