private void InitAnnоtation(VideoResolution resolution) { Func<double, double> scaleX = (x) => (1 + x) * resolution.width / 2.0; Func<double, double> scaleY = (y) => (1 - y) * resolution.height / 2.0; { // objects objects.Width = resolution.width; objects.Height = resolution.height; movingObjectsHolder = new VAEntitiesHolder<VAObject, VAObjectSnapshot>(scaleX, scaleY, null); var binding = new Binding("Objects") { ElementName = root.Name }; objects.SetBinding(ItemsControl.ItemsSourceProperty, binding); } { // alarms alarms.Width = resolution.width; alarms.Height = resolution.height; ((INotifyCollectionChanged)alarms.Items).CollectionChanged += (s, e) => { if (e.NewItems != null && e.NewItems.Count > 0) { var c = alarms.ItemContainerGenerator.ContainerFromItem(e.NewItems[e.NewItems.Count - 1]); if (c is FrameworkElement) ((FrameworkElement)c).BringIntoView(); } }; alarmsHolder = new VAEntitiesHolder<VAAlarm, VAEntitySnapshot>(scaleX, scaleY, null); var binding = new Binding("Alarms") { ElementName = root.Name }; alarms.SetBinding(ItemsControl.ItemsSourceProperty, binding); } }
private void InitAnnоtation(VideoResolution resolution) { // transform from onvif Func <double, double> scaleX = (x) => (1 + x) * resolution.width / 2.0; Func <double, double> scaleY = (y) => (1 - y) * resolution.height / 2.0; { // objects objects.Width = resolution.width; objects.Height = resolution.height; movingObjectsHolder = new VAEntitiesHolder <VAObject, VAObjectSnapshot>(scaleX, scaleY, null); var binding = new Binding("Objects") { ElementName = root.Name }; objects.SetBinding(ItemsControl.ItemsSourceProperty, binding); } { // alarms alarms.Width = resolution.width; alarms.Height = resolution.height; /*((INotifyCollectionChanged)alarms.Items).CollectionChanged += (s, e) => * { * if (e.NewItems != null && e.NewItems.Count > 0) * { * Dispatcher.BeginInvoke( * new Action(delegate { ((ListBox)alarms).ScrollIntoView(e.NewItems[e.NewItems.Count - 1]); }) * , DispatcherPriority.SystemIdle); * } * };*/ ((INotifyCollectionChanged)alarms.Items).CollectionChanged += (s, e) => { if (e.NewItems != null && e.NewItems.Count > 0) { var c = alarms.ItemContainerGenerator.ContainerFromItem(e.NewItems[e.NewItems.Count - 1]); if (c is FrameworkElement) { ((FrameworkElement)c).BringIntoView(); } } }; alarmsHolder = new VAEntitiesHolder <VAAlarm, VAEntitySnapshot>(scaleX, scaleY, null); var binding = new Binding("Alarms") { ElementName = root.Name }; alarms.SetBinding(ItemsControl.ItemsSourceProperty, binding); } }
private void InitAnnоtation(VideoResolution resolution) { Func <double, double> scaleX = (x) => (1 + x) * resolution.width / 2.0; Func <double, double> scaleY = (y) => (1 - y) * resolution.height / 2.0; { // objects objects.Width = resolution.width; objects.Height = resolution.height; movingObjectsHolder = new VAEntitiesHolder <VAObject, VAObjectSnapshot>(scaleX, scaleY, null); var binding = new Binding("Objects") { ElementName = root.Name }; objects.SetBinding(ItemsControl.ItemsSourceProperty, binding); } { // alarms alarms.Width = resolution.width; alarms.Height = resolution.height; ((INotifyCollectionChanged)alarms.Items).CollectionChanged += (s, e) => { if (e.NewItems != null && e.NewItems.Count > 0) { var c = alarms.ItemContainerGenerator.ContainerFromItem(e.NewItems[e.NewItems.Count - 1]); if (c is FrameworkElement) { ((FrameworkElement)c).BringIntoView(); } } }; alarmsHolder = new VAEntitiesHolder <VAAlarm, VAEntitySnapshot>(scaleX, scaleY, null); var binding = new Binding("Alarms") { ElementName = root.Name }; alarms.SetBinding(ItemsControl.ItemsSourceProperty, binding); } }