Пример #1
0
            void SelectedTanks_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
            {
                _owner.PersistentInfo.TankKeys = this.SelectedTanks.Select(t => new TankUnikey(t.Repository, t.Model)).ToArray();

                switch (e.Action)
                {
                case NotifyCollectionChangedAction.Add:
                    _owner.AddRowOrColumns(e.NewItems.Cast <TankVM>(), e.NewStartingIndex);
                    break;

                case NotifyCollectionChangedAction.Remove:
                    _owner.RemoveRowOrColumns(e.OldItems.Cast <TankVM>());
                    break;

                case NotifyCollectionChangedAction.Replace:
                    _owner.ReplaceRowOrColumns(e.OldItems.Cast <TankVM>(), e.NewItems.Cast <TankVM>());
                    break;

                case NotifyCollectionChangedAction.Move:
                    _owner.MoveRowOrColumns(e.OldItems.Cast <TankVM>(), e.OldStartingIndex, e.NewStartingIndex);
                    break;

                case NotifyCollectionChangedAction.Reset:
                    _owner.ResetTanks();
                    break;
                }
            }
            void SelectedStats_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
            {
                _owner.PersistentInfo.StatKeys = this.SelectedStats.Select(s => s.Model.Key).ToArray();

                switch (e.Action)
                {
                case NotifyCollectionChangedAction.Add:
                    _owner.AddRowOrColumns(e.NewItems.Cast <StatInfoVM>(), e.NewStartingIndex);
                    break;

                case NotifyCollectionChangedAction.Remove:
                    _owner.RemoveRowOrColumns(e.OldItems.Cast <StatInfoVM>());
                    break;

                case NotifyCollectionChangedAction.Replace:
                    _owner.ReplaceRowOrColumns(e.OldItems.Cast <StatInfoVM>(), e.NewItems.Cast <StatInfoVM>());
                    break;

                case NotifyCollectionChangedAction.Move:
                    _owner.MoveRowOrColumns(e.OldItems.Cast <StatInfoVM>(), e.OldStartingIndex, e.NewStartingIndex);
                    break;

                case NotifyCollectionChangedAction.Reset:
                    _owner.ResetStats();
                    break;
                }

                _isStatPresetChanged = true;
            }