System.Collections.ObjectModel.Collection.RemoveAt(int)

Here are the examples of the csharp api System.Collections.ObjectModel.Collection.RemoveAt(int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

622 Examples 7

19 Source : ObserveAddRemoveCollection.cs
with MIT License
from Abdesol

protected override void Sereplacedem(int index, T item)
		{
			if (onRemove != null)
				onRemove(this[index]);
			try {
				if (onAdd != null)
					onAdd(item);
			} catch {
				// When adding the new item fails, just remove the old one
				// (we cannot keep the old item since we already successfully called onRemove for it)
				base.RemoveAt(index);
				throw;
			}
			base.Sereplacedem(index, item);
		}

19 Source : SciTraderViewModel.cs
with MIT License
from ABTSoftware

private void UpdateSeriesNames(string priceName)
        {
            if (!AllSeriesNames.First().Contains("SMA"))
                AllSeriesNames.RemoveAt(0);
            
            AllSeriesNames.Insert(0, priceName);
            SelectedSeriesToSnap = priceName;
        }

19 Source : ZoomHistoryMvvmViewModel.cs
with MIT License
from ABTSoftware

private void OnRangeHistoryChanged(object sender, HistoryChangedEventArgs args)
        {
            if (args.OldRanges != null)
            {
                for (int i = 0; i < args.DisposedAmount; i++)
                {
                    RangesHistory.RemoveAt(RangesHistory.Count - 1);
                }
            }

            if (args.NewRanges != null && args.NewRanges.Count > 0)
            {
                var newRanges = args.NewRanges;

                if (newRanges.Count < AxisAmount)
                {
                    newRanges = FillRanges(newRanges);
                }

                var item = new ChartRangeHistory(newRanges, Guid.NewGuid().ToString());
                RangesHistory.Add(item);
                while (RangesHistory.Count > ZoomHistoryManager.HistoryDepth)
                {
                    RangesHistory.RemoveAt(0);
                }
                OnPropertyChanged("RangesHistory");

                _selectedRange = item;
                OnPropertyChanged("SelectedRange");
            }

            RaiseUndoRedoCanExecute();
        }

19 Source : AudioDeviceSource.cs
with MIT License
from ABTSoftware

private void RefreshDevices()
        {
            if (!_dispatcher.CheckAccess())
            {
                _dispatcher.BeginInvoke((Action)RefreshDevices);
                return;
            }
            DefaultDevice = GetDefaultDevice();

            var deviceMap = Devices.ToDictionary(d => d.ID, d => d);
            var presentDevices = new HashSet<string>();

            foreach (var d in _enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active))
            {
                presentDevices.Add(d.ID);
                if(deviceMap.TryGetValue(d.ID, out var device))
                {
                    device.Update(d);
                }
                else
                {
                    Devices.Add(new AudioDeviceInfo(d));
                }
                d.Dispose();
            }

            for (int i = Devices.Count - 1; i >=0; i--)
            {
                if (!presentDevices.Contains(Devices[i].ID))
                {
                    Devices.RemoveAt(i);
                }
            }

            DevicesChanged?.Invoke(this, EventArgs.Empty);
        }

19 Source : ObservableSortedCollection.cs
with MIT License
from Accelerider

protected override void Inserreplacedem(int index, T item)
        {
            index = GetAppropriateIndex(item);
            if (index == InvalidIndex) return;

            var previousIndex = Items.IndexOf(item);
            if (previousIndex == index) return;

            if (previousIndex != InvalidIndex)
                RemoveAt(previousIndex);

            base.Inserreplacedem(index, item);
        }

19 Source : NodeComponentCollection.cs
with GNU General Public License v3.0
from Adam-Wilkinson

protected virtual void ProtectedRemoveAt(int index)
        {
            if (GetIndex(index) < _childComponents.Count)
            {
                _childComponents.RemoveAt(index);
            }
        }

19 Source : ObservableCollectionMapper.cs
with GNU General Public License v3.0
from Adam-Wilkinson

private void RemoveRange(int index, int count)
            {
                index = index == -1 ? _mapTo.Count - 1 : index;
                for (int i = 0; i < count; i++)
                {
                    _mapTo.RemoveAt(index + count - 1 - i);
                }
            }

19 Source : Notifiaction.xaml.cs
with GNU General Public License v3.0
from aduskin

public void RemoveNotification(NotifiactionModel notification)
        {
            if (NotifiactionList.Contains(notification))
                NotifiactionList.Remove(notification);

            if (buffer.Count > 0)
            {
                NotifiactionList.Add(buffer[0]);
                buffer.RemoveAt(0);
            }

            //Close window if there's nothing to show
            if (NotifiactionList.Count < 1)
                Hide();
        }

19 Source : ServerViewModel.cs
with GNU General Public License v3.0
from ajmcateer

private void SyncService_OnMessageRecieved(object sender, MessageModel e)
        {
            if (_serverCache.ContainsKey(e.Appid))
            {
                if(_serverCache[e.Appid].Count == 1)
                {
                    if(_serverCache[e.Appid][0].Id == -1)
                    {
                        _serverCache[e.Appid].RemoveAt(0);
                    }
                }
                _serverCache[e.Appid].Insert(0, new RxMessageModel(e));
            }
            if(Applications != null)
            {
                var app = Applications.Where(x => x.Id == e.Appid).FirstOrDefault();
                if(SelectedItem != null)
                {
                    if(SelectedItem.Id != app.Id)
                    {
                        app.HasAlert = true;
                    }
                }
                else
                {
                    app.HasAlert = true;
                }
            }
        }

19 Source : ObservableCollectionExtensions.cs
with Apache License 2.0
from AKruimink

public static void UpdateCollection<T>(this ObservableCollection<T> collection, IList<T> newCollection)
        {
            if (newCollection == null || newCollection.Count == 0)
            {
                collection.Clear();
                return;
            }

            var i = 0;
            foreach (var item in newCollection)
            {
                if (collection.Count > i)
                {
                    var itemIndex = collection.IndexOf(collection.Where(i => Comparer<T>.Default.Compare(i, item) == 0).FirstOrDefault());

                    if (itemIndex < 0)
                    {
                        // Item doesn't exist
                        collection.Insert(i, item);
                    }
                    else if (itemIndex > i || itemIndex < i)
                    {
                        // Item exists, but has moved up or down
                        collection.Move(itemIndex, i);
                    }
                    else
                    {
                        if ((!collection[i]?.Equals(item)) ?? false)
                        {
                            // Item has changed, replace it
                            if (item != null)
                            {
                                foreach (var sourceProperty in item.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
                                {
                                    var targetProperty = collection[i]?.GetType().GetProperty(sourceProperty.Name);

                                    if (targetProperty != null && targetProperty.CanWrite)
                                    {
                                        targetProperty.SetValue(collection[i], sourceProperty.GetValue(item, null), null);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    // Item doesn't exist
                    collection.Add(item);
                }

                i++;
            }

            // Remove all old items
            while (collection.Count > newCollection.Count)
            {
                collection.RemoveAt(i);
            }
        }

19 Source : ReorderActionButtonsDialog.xaml.cs
with GNU Affero General Public License v3.0
from akshinmustafayev

private void ActionButtonsRedorderDown_Click(object sender, RoutedEventArgs e)
        {
            if (MainWindowActionButtonsList.SelectedIndex == -1)
            {
                MessageBox.Show("Please select item to reorder");
                return;
            }

            var selectedIndex = MainWindowActionButtonsList.SelectedIndex;
            
            if (selectedIndex + 1 < ActionButtons.Count)
            {
                var itemToMoveDown = ActionButtons[selectedIndex];
                ActionButtons.RemoveAt(selectedIndex);
                ActionButtons.Insert(selectedIndex + 1, itemToMoveDown);
                MainWindowActionButtonsList.SelectedIndex = selectedIndex + 1;

                List<ActionButton> myList = new List<ActionButton>(ActionButtons);
                TabItems[currentTabIndex].TabActionButtons = myList;
            }

            changesOccured = true;

            SaveConfig();
        }

19 Source : ReorderActionButtonsDialog.xaml.cs
with GNU Affero General Public License v3.0
from akshinmustafayev

private void ActionButtonsReorderUp_Click(object sender, RoutedEventArgs e)
        {
            if (MainWindowActionButtonsList.SelectedIndex == -1)
            {
                MessageBox.Show("Please select item to reorder");
                return;
            }

            var selectedIndex = MainWindowActionButtonsList.SelectedIndex;

            if (selectedIndex > 0)
            {
                var itemToMoveUp = ActionButtons[selectedIndex];
                ActionButtons.RemoveAt(selectedIndex);
                ActionButtons.Insert(selectedIndex - 1, itemToMoveUp);
                MainWindowActionButtonsList.SelectedIndex = selectedIndex - 1;
                List<ActionButton> myList = new List<ActionButton>(ActionButtons);
                TabItems[currentTabIndex].TabActionButtons = myList;
            }

            changesOccured = true;

            SaveConfig();
        }

19 Source : ReorderTabsDialog.xaml.cs
with GNU Affero General Public License v3.0
from akshinmustafayev

private void TabsRedorderDown_Click(object sender, RoutedEventArgs e)
        {
            if(MainWindowTabsList.SelectedIndex == -1)
            {
                MessageBox.Show("Please select item to reorder");
                return;
            }

            var selectedIndex = MainWindowTabsList.SelectedIndex;

            if (selectedIndex + 1 < TabItems.Count)
            {
                var itemToMoveDown = TabItems[selectedIndex];
                TabItems.RemoveAt(selectedIndex);
                TabItems.Insert(selectedIndex + 1, itemToMoveDown);
                MainWindowTabsList.SelectedIndex = selectedIndex + 1;
            }

            changesOccured = true;

            SaveConfig();
        }

19 Source : ReorderTabsDialog.xaml.cs
with GNU Affero General Public License v3.0
from akshinmustafayev

private void TabsReorderUp_Click(object sender, RoutedEventArgs e)
        {
            if (MainWindowTabsList.SelectedIndex == -1)
            {
                MessageBox.Show("Please select item to reorder");
                return;
            }

            changesOccured = true;

            var selectedIndex = MainWindowTabsList.SelectedIndex;

            if (selectedIndex > 0)
            {
                var itemToMoveUp = TabItems[selectedIndex];
                TabItems.RemoveAt(selectedIndex);
                TabItems.Insert(selectedIndex - 1, itemToMoveUp);
                MainWindowTabsList.SelectedIndex = selectedIndex - 1;
            }

            SaveConfig();
        }

19 Source : ToastHolderViewModel.cs
with GNU General Public License v3.0
from alexdillon

public void DisplayNewToast(ToastNotificationViewModel notification)
        {
            notification.CloseAction = new RelayCommand<ToastNotificationViewModel>(this.CloseToast);
            this.DismissalTasks.Add(this.DelayedDismissal(notification));

            App.Current.Dispatcher.Invoke(() =>
            {
                this.Notifications.Insert(0, notification);

                while (this.Notifications.Count > this.MaximumNotifications)
                {
                    this.Notifications.RemoveAt(this.Notifications.Count - 1);
                }
            });
        }

19 Source : SendImageControlViewModel.cs
with GNU General Public License v3.0
from alexdillon

private void DeleteSelectedImage()
        {
            int removeIndex = this.ImagesCollection.IndexOf(this.SelectedImage);
            this.ImagesCollection.RemoveAt(removeIndex);

            if (removeIndex > 0)
            {
                this.SelectedImage = this.ImagesCollection[removeIndex - 1];
            }
            else
            {
                this.SelectedImage = this.ImagesCollection[0];
            }
        }

19 Source : ToastHolderViewModel.cs
with GNU General Public License v3.0
from alexdillon

public void DisplayNewToast(ToastNotificationViewModel notification)
        {
            notification.CloseAction = new RelayCommand<ToastNotificationViewModel>(this.CloseToast);
            this.DismissalTasks.Add(this.DelayedDismissal(notification));

            Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(() =>
            {
                this.Notifications.Insert(0, notification);

                while (this.Notifications.Count > this.MaximumNotifications)
                {
                    this.Notifications.RemoveAt(this.Notifications.Count - 1);
                }
            });
        }

19 Source : MessageControlViewModel.cs
with GNU General Public License v3.0
from alexdillon

private void LoadAttachments()
        {
            int totalAttachedImages = this.Message.Attachments.OfType<ImageAttachment>().Count();

            // Check if this is a replied message, and if it's GM Native Reply or GMDC Extension reply
            var (repliedMessageId, isGroupMeNativeReply) = this.CheckReplyStatus();

            if (!string.IsNullOrEmpty(repliedMessageId) && !isGroupMeNativeReply)
            {
                // GMDC Extension replies include a screenshot of the replied image
                // for non-GMDC clients to see the original quoted message. Decrement the count
                // of attached images to adjust for this.
                totalAttachedImages--;
            }

            // Load GroupMe Image and Video Attachments
            var doneWithAttachments = this.HandleGroupMeAttachments(totalAttachedImages);

            // Handle if this is a reply message
            if (!string.IsNullOrEmpty(repliedMessageId))
            {
                var container = (IMessageContainer)this.Message.Group ?? this.Message.Chat;
                var repliedMessageAttachment = new RepliedMessageControlViewModel(repliedMessageId, container, this.NestLevel);

                // If the reply type is GMDC-extension,
                // replace the photo of the original message that is included for non-GMDC clients with the real message
                if (this.AttachedItems.Count > 0 && !isGroupMeNativeReply)
                {
                    var lastIndexOfPhoto = -1;
                    for (int i = 0; i < this.AttachedItems.Count; i++)
                    {
                        if (this.AttachedItems[i] is GroupMeImageAttachmentControlViewModel)
                        {
                            lastIndexOfPhoto = i;
                        }
                    }

                    if (lastIndexOfPhoto >= 0)
                    {
                        this.AttachedItems.RemoveAt(lastIndexOfPhoto);
                    }
                }

                this.RepliedMessage = repliedMessageAttachment;
            }

            if (!doneWithAttachments)
            {
                // If this message type is allowed to have additional attachments,
                // scan the message body for supported link types.
                this.HandleLinkBasedAttachments();
            }
        }

19 Source : Node.cs
with MIT License
from AlexGyver

protected override void ClearItems() {
        while (this.Count != 0)
          this.RemoveAt(this.Count - 1);
      }

19 Source : Node.cs
with MIT License
from AlexGyver

protected override void Sereplacedem(int index, Node item) {
        if (item == null)
          throw new ArgumentNullException("item");

        RemoveAt(index);
        Inserreplacedem(index, item);
      }

19 Source : NodeControlsCollection.cs
with MIT License
from AlexGyver

protected override void ClearItems()
		{
			_tree.BeginUpdate();
			try
			{
				while (this.Count != 0)
					this.RemoveAt(this.Count - 1);
			}
			finally
			{
				_tree.EndUpdate();
			}
		}

19 Source : NodeControlsCollection.cs
with MIT License
from AlexGyver

protected override void Sereplacedem(int index, NodeControl item)
		{
			if (item == null)
				throw new ArgumentNullException("item");

			_tree.BeginUpdate();
			try
			{
				RemoveAt(index);
				Inserreplacedem(index, item);
			}
			finally
			{
				_tree.EndUpdate();
			}
		}

19 Source : Node.cs
with MIT License
from AlexGyver

protected override void ClearItems()
			{
				while (this.Count != 0)
					this.RemoveAt(this.Count - 1);
			}

19 Source : Node.cs
with MIT License
from AlexGyver

protected override void Sereplacedem(int index, Node item)
			{
				if (item == null)
					throw new ArgumentNullException("item");

				RemoveAt(index);
				Inserreplacedem(index, item);
			}

19 Source : TreeNodeAdv.cs
with MIT License
from AlexGyver

protected override void Sereplacedem(int index, TreeNodeAdv item)
			{
				if (item == null)
					throw new ArgumentNullException("item");
				RemoveAt(index);
				Inserreplacedem(index, item);
			}

19 Source : ConfigurationViewModel.cs
with MIT License
from ambleside138

public void EditFavoriteTask(FavoriteWorkTask favoriteWorkTask)
        {
            var editDialogVm = new TaskConfigEditDialogViewModel("ボタンタイトル", favoriteWorkTask.Buttonreplacedle, favoriteWorkTask.ConvertToDomainModel());
            editDialogVm.ShowQuickStartButton.Value = false;
            editDialogVm.ShowDeleteButton.Value = true;

            var result = TransitionHelper.Current.TransitionModal<TaskConfigEditDialog>(editDialogVm);

            if (result == ModalTransitionResponse.Yes)
            {
                if (editDialogVm.NeedDelete)
                {
                    FavoriteWorkTasks.Remove(favoriteWorkTask);
                    RegistFavoriteWorkTasksConfig();
                }
                else
                {
                    var inputValue = editDialogVm.TaskCardViewModel.DomainModel;

                    // 変更通知機能がないのでdelete-insert方式で無理やりViewに変更通知する
                    var targetIndex = FavoriteWorkTasks.IndexOf(favoriteWorkTask);
                    FavoriteWorkTasks.RemoveAt(targetIndex);

                    var favTask = FavoriteWorkTask.FromDomainObject(inputValue);
                    favTask.Buttonreplacedle = editDialogVm.Configreplacedle.Value;
                    FavoriteWorkTasks.Insert(targetIndex, favTask);

                    RegistFavoriteWorkTasksConfig();
                }

            }
        }

19 Source : ConfigurationViewModel.cs
with MIT License
from ambleside138

public void EditSchedulereplacedleMap(SchedulereplacedleMap favoriteWorkTask)
        {
            var editDialogVm = new TaskConfigEditDialogViewModel("取込時のタイトル", favoriteWorkTask.Mapreplacedle, favoriteWorkTask.ConvertToDomainModel());
            editDialogVm.ShowQuickStartButton.Value = false;
            editDialogVm.ShowDeleteButton.Value = true;

            var result = TransitionHelper.Current.TransitionModal<TaskConfigEditDialog>(editDialogVm);

            if (result == ModalTransitionResponse.Yes)
            {
                if (editDialogVm.NeedDelete)
                {
                    SchedulereplacedleMaps.Remove(favoriteWorkTask);
                    RegistSchedulereplacedleMapsConfig();
                }
                else
                {
                    var inputValue = editDialogVm.TaskCardViewModel.DomainModel;

                    // 変更通知機能がないのでdelete-insert方式で無理やりViewに変更通知する
                    var targetIndex = SchedulereplacedleMaps.IndexOf(favoriteWorkTask);
                    SchedulereplacedleMaps.RemoveAt(targetIndex);

                    var favTask = SchedulereplacedleMap.FromDomainObject(inputValue);
                    favTask.Mapreplacedle = editDialogVm.Configreplacedle.Value;
                    SchedulereplacedleMaps.Insert(targetIndex, favTask);

                    RegistSchedulereplacedleMapsConfig();
                }

            }
        }

19 Source : TodoModel.cs
with MIT License
from ambleside138

private async Task LoadTodoListAsync()
        {
            for (int i = TodoListCollection.Count - 1; i >= 0; i--)
            {
                if(TodoListCollection[i].Id.IsFixed == false
                    || TodoListCollection[i].Id == TodoListIdenreplacedy.Divider)
                {
                    TodoListCollection.RemoveAt(i);
                }
            }

            var list = await _TodoListUseCase.SelectAsync();
            if(list?.Length > 0)
            {
                TodoListCollection.Add(new TodoList(TodoListIdenreplacedy.Divider));
                TodoListCollection.AddRange(list);
            }
        }

19 Source : ObservableViewModelCollection.cs
with MIT License
from Aminator

protected virtual void OnModelCollectionChanged(NotifyCollectionChangedEventArgs e)
        {
            CollectionChanged -= OnViewModelCollectionChanged;

            Task collectionChangeTask = Task.Factory.StartNew(() =>
            {
                switch (e.Action)
                {
                    case NotifyCollectionChangedAction.Add:
                        for (int i = 0; i < e.NewItems.Count; i++)
                        {
                            Insert(e.NewStartingIndex + i, CreateViewModel((TModel)e.NewItems[i], e.NewStartingIndex + i));
                        }
                        break;
                    case NotifyCollectionChangedAction.Move:
                        if (e.OldItems.Count == 1)
                        {
                            Move(e.OldStartingIndex, e.NewStartingIndex);
                        }
                        else
                        {
                            List<TViewModel> items = this.Skip(e.OldStartingIndex).Take(e.OldItems.Count).ToList();

                            for (int i = 0; i < e.OldItems.Count; i++)
                            {
                                RemoveAt(e.OldStartingIndex);
                            }

                            for (int i = 0; i < items.Count; i++)
                            {
                                Insert(e.NewStartingIndex + i, items[i]);
                            }
                        }
                        break;
                    case NotifyCollectionChangedAction.Remove:
                        for (int i = 0; i < e.OldItems.Count; i++)
                        {
                            RemoveAt(e.OldStartingIndex);
                        }
                        break;
                    case NotifyCollectionChangedAction.Replace:
                        for (int i = 0; i < e.OldItems.Count; i++)
                        {
                            RemoveAt(e.OldStartingIndex);
                        }

                        goto case NotifyCollectionChangedAction.Add;
                    case NotifyCollectionChangedAction.Reset:
                        Clear();
                        break;
                }
            }, default, TaskCreationOptions.None, originalTaskScheduler);

            collectionChangeTask.Wait();

            CollectionChanged += OnViewModelCollectionChanged;
        }

19 Source : ObservableViewModelCollection.cs
with MIT License
from Aminator

protected virtual void OnModelCollectionChanged(NotifyCollectionChangedEventArgs e)
        {
            CollectionChanged -= OnViewModelCollectionChanged;

            switch (e.Action)
            {
                case NotifyCollectionChangedAction.Add:
                    for (int i = 0; i < e.NewItems.Count; i++)
                    {
                        Insert(e.NewStartingIndex + i, CreateViewModel(e.NewItems[i], e.NewStartingIndex + i));
                    }
                    break;
                case NotifyCollectionChangedAction.Move:
                    if (e.OldItems.Count == 1)
                    {
                        Move(e.OldStartingIndex, e.NewStartingIndex);
                    }
                    else
                    {
                        List<TViewModel> items = this.Skip(e.OldStartingIndex).Take(e.OldItems.Count).ToList();

                        for (int i = 0; i < e.OldItems.Count; i++)
                        {
                            RemoveAt(e.OldStartingIndex);
                        }

                        for (int i = 0; i < items.Count; i++)
                        {
                            Insert(e.NewStartingIndex + i, items[i]);
                        }
                    }
                    break;
                case NotifyCollectionChangedAction.Remove:
                    for (int i = 0; i < e.OldItems.Count; i++)
                    {
                        RemoveAt(e.OldStartingIndex);
                    }
                    break;
                case NotifyCollectionChangedAction.Replace:
                    for (int i = 0; i < e.OldItems.Count; i++)
                    {
                        RemoveAt(e.OldStartingIndex);
                    }

                    goto case NotifyCollectionChangedAction.Add;
                case NotifyCollectionChangedAction.Reset:
                    Clear();
                    break;
            }

            CollectionChanged += OnViewModelCollectionChanged;
        }

19 Source : PlottingGraphData.cs
with MIT License
from Analogy-LogViewer

private void RefreshDataTimerTick(object sender, EventArgs e)
        {
            try
            {
                sync.EnterReadLock();
                for (int i = Math.Max(lastRawDataIndex, rawData.Count - DataWindow); i < rawData.Count; i++)
                {
                    ViewportData.Add(rawData[i]);
                }
                lastRawDataIndex = rawData.Count;
                while (ViewportData.Count > DataWindow)
                {
                    ViewportData.RemoveAt(0);
                }

            }
            finally
            {
                sync.ExitReadLock();

            }

        }

19 Source : Settings.cs
with Mozilla Public License 2.0
from amrali-eg

protected override void Inserreplacedem(int index, string item)
        {
            for (int i = Count - 1; i >= 0; i--)
            {
                if (this[i].Equals(item, StringComparison.OrdinalIgnoreCase))
                    RemoveAt(i);
            }

            base.Inserreplacedem(0, item);

            if (Count > 10)
            {
                for (int i = Count - 1; i >= 10; i--)
                    RemoveAt(i);
            }
        }

19 Source : EventsTreeView.cs
with GNU General Public License v3.0
from AndreiFedarets

internal void RemoveRange(int index, int count)
        {
            for (int i = 0; i < count && _board.Count > index; i++)
            {
                _board.RemoveAt(index);
            }
        }

19 Source : Xam.Plugin.TabView.cs
with MIT License
from AndreiMisiukevich

public void RemoveTab(int position = 0)
		{
			ItemSource.RemoveAt(position);

			if (position > 0)
			{
				_position = position - 1;
			}
		}

19 Source : SampleDataSource.cs
with GNU General Public License v3.0
from andysal

private void ItemsCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            // Provides a subset of the full items collection to bind to from a GroupedItemsPage
            // for two reasons: GridView will not virtualize large items collections, and it
            // improves the user experience when browsing through groups with large numbers of
            // items.
            //
            // A maximum of 12 items are displayed because it results in filled grid columns
            // whether there are 1, 2, 3, 4, or 6 rows displayed

            switch (e.Action)
            {
                case NotifyCollectionChangedAction.Add:
                    if (e.NewStartingIndex < 12)
                    {
                        TopItems.Insert(e.NewStartingIndex,Items[e.NewStartingIndex]);
                        if (TopItems.Count > 12)
                        {
                            TopItems.RemoveAt(12);
                        }
                    }
                    break;
                case NotifyCollectionChangedAction.Move:
                    if (e.OldStartingIndex < 12 && e.NewStartingIndex < 12)
                    {
                        TopItems.Move(e.OldStartingIndex, e.NewStartingIndex);
                    }
                    else if (e.OldStartingIndex < 12)
                    {
                        TopItems.RemoveAt(e.OldStartingIndex);
                        TopItems.Add(Items[11]);
                    }
                    else if (e.NewStartingIndex < 12)
                    {
                        TopItems.Insert(e.NewStartingIndex, Items[e.NewStartingIndex]);
                        TopItems.RemoveAt(12);
                    }
                    break;
                case NotifyCollectionChangedAction.Remove:
                    if (e.OldStartingIndex < 12)
                    {
                        TopItems.RemoveAt(e.OldStartingIndex);
                        if (Items.Count >= 12)
                        {
                            TopItems.Add(Items[11]);
                        }
                    }
                    break;
                case NotifyCollectionChangedAction.Replace:
                    if (e.OldStartingIndex < 12)
                    {
                        TopItems[e.OldStartingIndex] = Items[e.OldStartingIndex];
                    }
                    break;
                case NotifyCollectionChangedAction.Reset:
                    TopItems.Clear();
                    while (TopItems.Count < Items.Count && TopItems.Count < 12)
                    {
                        TopItems.Add(Items[TopItems.Count]);
                    }
                    break;
            }
        }

19 Source : ObservableCollectionAutoResize.cs
with Apache License 2.0
from AnkiUniversal

protected override void Inserreplacedem(int index, T item)
        {
            base.Inserreplacedem(index, item);

            if (MaxCollectionSize > 0 && MaxCollectionSize < Count)
            {
                int trimCount = Count - MaxCollectionSize;
                for (int i = 0; i < trimCount; i++)
                {
                    if (IsRemoveAtZero)
                        RemoveAt(0);
                    else
                        RemoveAt(Count - i - 1);
                }
            }            
        }

19 Source : ImageObjectDisplayViewModel.cs
with Apache License 2.0
from anmcgrath

private void removeImage(DicomImageObject img)
        {
            for(int i = 0; i< Images.Count; i++)
            {
                if (Images[i].Value.Image == img)
                    Images.RemoveAt(i);
            }
        }

19 Source : RecentlyUsedFolders.cs
with MIT License
from AntonyCorbett

private void TrimList()
        {
            while (_recentlyUsedFolders.Count >= MaxCount)
            {
                _recentlyUsedFolders.RemoveAt(MaxCount - 1);
            }
        }

19 Source : PagesViewModel.cs
with GNU General Public License v3.0
from AnyStatus

internal void CloseLastPage() => _pages.RemoveAt(_pages.Count - 1);

19 Source : ActivityLogger.cs
with GNU General Public License v3.0
from AnyStatus

public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
        {
            if (Messages.Count == _settings.MaxActivity)
            {
                _dispatcher.InvokeAsync(() => Messages.RemoveAt(0));
            }

            var message = new ActivityMessage
            {
                Time = DateTime.Now,
                LogLevel = logLevel,
                Exception = exception,
                ThreadId = Thread.CurrentThread.ManagedThreadId,
                Message = formatter(state, exception)
            };

            _dispatcher.InvokeAsync(() => Messages.Add(message));
        }

19 Source : HealthReporterCollection.cs
with Apache License 2.0
from AppMetrics

public void RemoveType(Type reporterType)
        {
            for (var i = Count - 1; i >= 0; i--)
            {
                var reporter = this[i];
                if (reporter.GetType() == reporterType)
                {
                    RemoveAt(i);
                }
            }
        }

19 Source : HealthFormatterCollection.cs
with Apache License 2.0
from AppMetrics

public void RemoveType(Type formatterType)
        {
            for (var i = Count - 1; i >= 0; i--)
            {
                var formatter = this[i];
                if (formatter.GetType() == formatterType)
                {
                    RemoveAt(i);
                }
            }
        }

19 Source : HealthFormatterCollection.cs
with Apache License 2.0
from AppMetrics

public void RemoveType(HealthMediaTypeValue mediaTypeValue)
        {
            for (var i = Count - 1; i >= 0; i--)
            {
                var formatter = this[i];
                if (formatter.MediaType == mediaTypeValue)
                {
                    RemoveAt(i);
                }
            }
        }

19 Source : ModelList.cs
with GNU General Public License v3.0
from arition

public void AddOriginalMovie(IEnumerable<string> files)
        {
            var fileList = files.OrderBy(t => t);
            var i = 0;
            foreach (var selectFileFileName in fileList)
            {
                if (i == Models.Count)
                {
                    Models.Add(new Model
                    {
                        OriginalMovieFile = new FileInfo(selectFileFileName)
                    });
                }
                else
                {
                    Models[i].OriginalMovieFile = new FileInfo(selectFileFileName);
                }
                i++;
            }
            while (i < Models.Count) Models.RemoveAt(i);
        }

19 Source : ModelList.cs
with GNU General Public License v3.0
from arition

public void AddMovie(IEnumerable<string> files)
        {
            var fileList = files.OrderBy(t => t);
            var i = 0;
            foreach (var selectFileFileName in fileList)
            {
                if (i == Models.Count)
                {
                    Models.Add(new Model
                    {
                        MovieFile = new FileInfo(selectFileFileName)
                    });
                }
                else
                {
                    Models[i].MovieFile = new FileInfo(selectFileFileName);
                }
                i++;
            }
            while (i < Models.Count) Models.RemoveAt(i);
        }

19 Source : ModelList.cs
with GNU General Public License v3.0
from arition

public void AddSub(IEnumerable<string> files)
        {
            var fileList = files.Select(t => new
            {
                file = new FileInfo(t),
                name = new FileInfo(t).Name
            }).Select(t => new
            {
                t.file,
                t.name,
                nameOnly = t.name.Substring(0,
                    t.name.Substring(t.name.Length - 15 >= 0 ? t.name.Length - 15 : 0)
                        .IndexOf(".", StringComparison.Ordinal) + (t.name.Length - 15 >= 0 ? t.name.Length - 15 : 0))
            }).OrderBy(t => t.nameOnly).ToList();

            var i = -1;
            var lastSubNameOnly = "";

            foreach (var selectFileFileName in fileList)
            {
                if (lastSubNameOnly != selectFileFileName.nameOnly)
                {
                    i++;
                    if (i < Models.Count)
                    {
                        Models[i].SubFiles.Clear();
                    }
                }
                if (i == Models.Count)
                {
                    var model = new Model();
                    model.SubFiles.Add(selectFileFileName.file);
                    Models.Add(model);
                }
                else
                {
                    Models[i].SubFiles.Add(selectFileFileName.file);
                }
                lastSubNameOnly = selectFileFileName.nameOnly;
            }
            i++;
            while (i < Models.Count) Models.RemoveAt(i);
        }

19 Source : eliteColorCollection.cs
with MIT License
from arqueror

public void RemoveColorShape(int index)
        {
            if (this.ColorShapes.Count > index)
            {
                ObservableCollection<string> shapes = new ObservableCollection<string>(this.ColorShapes);
                shapes.RemoveAt(index);

                this.ColorShapes = shapes;
            }
        }

19 Source : Themes.cs
with MIT License
from Assistant

public static void ApplyTheme(string theme, bool sendMessage = true)
        {
            if (loadedThemes.TryGetValue(theme, out Theme newTheme))
            {
                LoadedTheme = theme;
                MainWindow.Instance.BackgroundVideo.Pause();
                MainWindow.Instance.BackgroundVideo.Visibility = Visibility.Hidden;

                if (newTheme.ThemeDictionary != null)
                {
                    // TODO: Search by name
                    Application.Current.Resources.MergedDictionaries.RemoveAt(LOADED_THEME_INDEX);
                    Application.Current.Resources.MergedDictionaries.Insert(LOADED_THEME_INDEX, newTheme.ThemeDictionary);
                }

                Properties.Settings.Default.SelectedTheme = theme;
                Properties.Settings.Default.Save();

                if (sendMessage)
                {
                    MainWindow.Instance.MainText = string.Format((string)Application.Current.FindResource("Themes:ThemeSet"), theme);
                }

                ApplyWaifus();

                if (File.Exists(newTheme.VideoLocation))
                {
                    Uri videoUri = new Uri(newTheme.VideoLocation, UriKind.Absolute);
                    MainWindow.Instance.BackgroundVideo.Visibility = Visibility.Visible;

                    // Load the source video if it's not the same as what's playing, or if the theme is loading for the first time.
                    if (!sendMessage || MainWindow.Instance.BackgroundVideo.Source?.AbsoluteUri != videoUri.AbsoluteUri)
                    {
                        MainWindow.Instance.BackgroundVideo.Stop();
                        MainWindow.Instance.BackgroundVideo.Source = videoUri;
                    }

                    MainWindow.Instance.BackgroundVideo.Play();
                }

                ReloadIcons();
            }
            else
            {
                throw new ArgumentException(string.Format((string)Application.Current.FindResource("Themes:ThemeMissing"), theme));
            }
        }

19 Source : TMap.cs
with MIT License
from atenfyr

public void RemoveAt(int index)
        {
            if (index < 0 || index >= _keyedCollection.Count)
            {
                throw new ArgumentException("The index was outside the bounds of the dictionary: {0}".FormatWith(index));
            }
            _keyedCollection.RemoveAt(index);
        }

19 Source : ModuleInfoGroup.cs
with MIT License
from AvaloniaCommunity

public void RemoveAt(int index) => modules.RemoveAt(index);

See More Examples