private TimeUnit AggregateTime(Func <BlockViewModel, float> valueSelector, Action <BlockViewModel, float> valueSetter, Func <float?, Model.MusicSegment, Action <float>, TimeUnit> timeUnitFactory)
        {
            float[]            values       = selectedBlocks.Select(valueSelector).Distinct().Take(2).ToArray();
            Model.MusicSegment musicSegment = AggregateGet(b => b.GetModel().SegmentContext, sequencer.ActiveMusicSegment.GetModel());

            return(timeUnitFactory((values.Length == 1 ? values[0] : (float?)null), musicSegment, v =>
            {
                foreach (BlockViewModel b in selectedBlocks)
                {
                    valueSetter(b, v);
                }
            }));
        }
Exemplo n.º 2
0
        public MusicSegmentViewModel(SequencerViewModel sequencer, Model.MusicSegment model)
        {
            this.sequencer = sequencer;
            this.model     = model;

            ReferringBlocksDummies = sequencer.GetModel().Blocks.Where(b => b.SegmentContext == model).Select(b => (object)null);

            ForwardPropertyEvents(nameof(model.Label), model, nameof(Label));
            ForwardPropertyEvents(nameof(model.Bpm), model, nameof(Bpm));
            ForwardPropertyEvents(nameof(model.BeatsPerBar), model, nameof(BeatsPerBar));
            ForwardPropertyEvents(nameof(model.TimeOrigin), model, nameof(TimeOrigin), nameof(TimeOriginSeconds));
            ForwardPropertyEvents(nameof(model.IsReadOnly), model, nameof(IsReadOnly));
            ForwardPropertyEvents(nameof(model.IsDefault), model, nameof(IsDefault));

            ForwardPropertyEvents(nameof(Bpm), this, () => sequencer.NotifyGridInterval());
        }