public void ApplyConfig(IBlobTrackParamConfig blobTrackParamConfig) { if (blobTrackParamConfig != null) { blobTrackParamConfig.ImageWidth = shapeDrawCtrl_alarmarea.ShapeManager.ImageWidth; blobTrackParamConfig.ImageHeight = shapeDrawCtrl_alarmarea.ShapeManager.ImageHeight; Hashtable acTable = new Hashtable(); IAreaConfig[] acs = blobTrackParamConfig.GetAreaConfigs(); if (acs != null) { foreach (IAreaConfig ac in acs) { acTable.Add(ac.Id, ac); } } blobTrackParamConfig.ClearAreaConfig(); IShape[] shapes = shapeDrawCtrl_alarmarea.GetShapes(); if (shapes != null) { IAreaConfig oac, ac; foreach (IGuardArea area in shapes) { if (area != null) { ac = area.GetAreaConfig(); oac = acTable[ac.Id] as IAreaConfig; if (oac != null) { oac.CopyPointsTo(ac); } blobTrackParamConfig.AddAreaConfig(ac); } } } } }
private static void BuildAreaConfig(IBlobTrackParamConfig config, XmlNode xNode) { IAreaConfig areaConfig = null; foreach (XmlNode xSubNode in xNode.ChildNodes) { if (xSubNode.Name.Equals("Index")) { if (xSubNode.FirstChild != null && xSubNode.FirstChild.Value != null && !xSubNode.FirstChild.Value.Equals("")) { areaConfig = config.AddAreaConfig(Convert.ToInt32(xSubNode.FirstChild.Value)); } break; } } if (areaConfig == null) { areaConfig = config.AddAreaConfig(); } if (areaConfig != null) { foreach (XmlNode xSubNode in xNode.ChildNodes) { if (xSubNode.FirstChild != null) { if (xSubNode.Name.Equals("Index")) { areaConfig.Index = Convert.ToInt32(xSubNode.FirstChild.Value); } else if (xSubNode.Name.Equals("Desc")) { areaConfig.Desc = xSubNode.FirstChild.Value; } else if (xSubNode.Name.Equals("Type")) { areaConfig.AreaType = (TAreaType)Convert.ToInt32(xSubNode.FirstChild.Value); } else if (xSubNode.Name.Equals("Level")) { areaConfig.GuardLevel = (TGuardLevel)Convert.ToInt32(xSubNode.FirstChild.Value); } else if (xSubNode.Name.Equals("AlertOpt")) { areaConfig.AlertOpt = Convert.ToUInt16(xSubNode.FirstChild.Value); } else if (xSubNode.Name.Equals("Sensitivity")) { areaConfig.Sensitivity = Convert.ToUInt16(xSubNode.FirstChild.Value); } //else if (xSubNode.Name.Equals("AlertParam")) // areaConfig.AlertParam = Convert.ToInt32(xSubNode.FirstChild.Value); else if (xSubNode.Name.Equals("WanderCount")) { areaConfig.WanderCount = Convert.ToInt32(xSubNode.FirstChild.Value); } else if (xSubNode.Name.Equals("StayTime")) { areaConfig.StayTime = Convert.ToInt32(xSubNode.FirstChild.Value); } else if (xSubNode.Name.Equals("AssembleCount")) { areaConfig.AssembleCount = Convert.ToInt32(xSubNode.FirstChild.Value); } else if (xSubNode.Name.Equals("AlertInterval")) { areaConfig.AlertInterval = Convert.ToInt32(xSubNode.FirstChild.Value); } else if (xSubNode.Name.Equals("PointList")) { string[] data; foreach (XmlNode xPointNode in xSubNode.ChildNodes) { if (xPointNode.Name.Equals("Point") && xPointNode.FirstChild != null && xPointNode.FirstChild.Value != null) { data = xPointNode.FirstChild.Value.Split(','); if (data != null && data.Length == 2) { areaConfig.AddPoint(Convert.ToInt32(data[0]), Convert.ToInt32(data[1])); } } } } else if (xSubNode.Name.Equals("Rect")) { if (xSubNode.FirstChild.Value != null && !xSubNode.FirstChild.Value.Equals("")) { string[] data = xSubNode.FirstChild.Value.Split(','); if (data != null && data.Length == 4) { areaConfig.SetRect(Convert.ToInt32(data[0]), Convert.ToInt32(data[1]), Convert.ToInt32(data[2]), Convert.ToInt32(data[3])); } } } else if (xSubNode.Name.Equals("MinSize")) { if (xSubNode.FirstChild.Value != null && !xSubNode.FirstChild.Value.Equals("")) { string[] data = xSubNode.FirstChild.Value.Split(','); if (data != null && data.Length == 2) { areaConfig.SetMinSize(Convert.ToInt32(data[0]), Convert.ToInt32(data[1])); } } } else if (xSubNode.Name.Equals("MaxSize")) { if (xSubNode.FirstChild.Value != null && !xSubNode.FirstChild.Value.Equals("")) { string[] data = xSubNode.FirstChild.Value.Split(','); if (data != null && data.Length == 2) { areaConfig.SetMaxSize(Convert.ToInt32(data[0]), Convert.ToInt32(data[1])); } } } } } } }