protected virtual void NotifyBatch()
        {
            var changes = this.batch;

            this.batch = null;
            if (changes == null)
            {
                return;
            }

            var args = GetCollectionChangedEventArgs(changes);

            if (args != null)
            {
                switch (args.Action)
                {
                case NotifyCollectionChangedAction.Add:
                case NotifyCollectionChangedAction.Remove:
                case NotifyCollectionChangedAction.Reset:
                    this.OnPropertyChanged(CountPropertyChangedEventArgs);
                    this.OnPropertyChanged(IndexerPropertyChangedEventArgs);
                    break;

                case NotifyCollectionChangedAction.Replace:
                case NotifyCollectionChangedAction.Move:
                    this.OnPropertyChanged(IndexerPropertyChangedEventArgs);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                this.OnCollectionChanged(args);
            }
        }
Exemplo n.º 2
0
 public void EndBatch()
 {
     var tempBatch = batch;
     batch = null;
     if (tempBatch.Changes.Count > 0) //if batch is empty, ignore it
     {
         RecordChange(tempBatch);
     }
 }
Exemplo n.º 3
0
        private static string GetBatchDescription(SILayout layout, BatchChange batchChange)
        {
            switch (batchChange.Name)
            {
            case "NumberOfFrets":
            {
                var propChange = batchChange.ChangedProperties
                                 .FirstOrDefault(x => x.Property == nameof(SIString.NumberOfFrets));

                if (propChange != null && propChange.NewValue is int fretCount)
                {
                    return($"{Localizations.LayoutProperty_NumberOfFrets}: {fretCount}");
                }

                return(Localizations.LayoutProperty_NumberOfFrets);
            }

            case "AddStrings":
            case "RemoveStrings":
            {
                var lastChange = batchChange.LayoutChanges
                                 .OfType <CollectionChange>()
                                 .Where(x => x.ElementType == typeof(SIString))
                                 .LastOrDefault();

                if (lastChange != null)
                {
                    return($"{Localizations.LayoutProperty_NumberOfStrings}: {lastChange.CollectionCount}");
                }

                break;
            }
            }

            if (batchChange.Component != null)
            {
                var marginChange = batchChange.ChangedProperties.FirstOrDefault(x => x.Component is FingerboardMargin);
                if (marginChange != null)
                {
                    return(GetFingerboardMarginDescription(layout, batchChange.Name, marginChange));
                }
            }

            return(null);
        }
Exemplo n.º 4
0
 public IDisposable StartBatch(string changeDescription)
 {
     batch = new BatchChange(changeDescription, this);
     return batch;
 }