Пример #1
0
        protected override void Dispose(bool isDisposing)
        {
            base.Dispose(isDisposing);
            component?.UnbindAdjustments(adjustments);

            if (disposeUnderlyingComponentOnDispose)
            {
                (component as IDisposable)?.Dispose();
            }

            parentAdjustment = null;
            parentMixer      = null;
        }
Пример #2
0
        private void refreshLayoutFromParent()
        {
            // because these components may be pooled, relying on DI is not feasible.
            // in the majority of cases the traversal should be quite short. may require later attention if a use case comes up which this is not true for.
            Drawable cursor = this;
            IAggregateAudioAdjustment newAdjustments = null;
            IAudioMixer newMixer = null;

            while ((cursor = cursor.Parent) != null)
            {
                if (newAdjustments == null && cursor is IAggregateAudioAdjustment candidateAdjustment)
                {
                    // components may be delegating the aggregates of a contained child.
                    // to avoid binding to one's self, check reference equality on an arbitrary bindable.
                    if (candidateAdjustment.AggregateVolume != adjustments.AggregateVolume)
                    {
                        newAdjustments = candidateAdjustment;
                    }
                }

                if (newMixer == null && cursor is IAudioMixer candidateMixer)
                {
                    newMixer = candidateMixer;
                }

                if (newAdjustments != null && newMixer != null)
                {
                    break;
                }
            }

            if (newAdjustments != parentAdjustment)
            {
                if (parentAdjustment != null)
                {
                    adjustments.UnbindAdjustments(parentAdjustment);
                }
                parentAdjustment = newAdjustments;
                if (parentAdjustment != null)
                {
                    adjustments.BindAdjustments(parentAdjustment);
                }
            }

            if (parentMixer != newMixer)
            {
                OnMixerChanged(new ValueChangedEvent <IAudioMixer>(parentMixer, newMixer));
            }

            parentMixer = newMixer;
        }