public FaceResult(NLAttributes attributes) { Age = attributes.Age; Gender = attributes.Gender; Glasses = (attributes.Properties & NLProperties.Glasses) == NLProperties.Glasses; Beard = (attributes.Properties & NLProperties.Beard) == NLProperties.Beard; }
private void OnObjectCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (!IsDisposed && IsHandleCreated) { if (e.Action == NotifyCollectionChangedAction.Add) { BeginInvoke(new Action <object, NLAttributes>((s, a) => { if (object.Equals(((NFace.ObjectCollection)s).Owner, _face)) { if (_attributes != null) { _attributes.PropertyChanged -= OnAttributesPropertyChanged; } _attributes = a; _attributes.PropertyChanged += OnAttributesPropertyChanged; } }), sender, (NLAttributes)e.NewItems[0]); } } else if (e.Action == NotifyCollectionChangedAction.Remove || e.Action == NotifyCollectionChangedAction.Reset) { BeginInvoke(new Action <object>(s => { if (object.Equals(s, _face)) { if (_attributes != null) { _attributes.PropertyChanged -= OnAttributesPropertyChanged; } _attributes = null; } }), sender); } }
protected override void Dispose(bool disposing) { UnsubscribeFromFaceEvents(); _face = null; _attributes = null; if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); }
private void SubscribeToFaceEvents() { if (_face != null) { _face.Objects.CollectionChanged += OnObjectCollectionChanged; _attributes = _face.Objects.ToArray().FirstOrDefault(); if (_attributes != null) { _attributes.PropertyChanged += OnAttributesPropertyChanged; } } }