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 View Source File : PagesViewModel.cs
License : GNU General Public License v3.0
Project Creator : AnyStatus

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

19 View Source File : eliteColorCollection.cs
License : MIT License
Project Creator : 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 View Source File : Node.cs
License : MIT License
Project Creator : AlexGyver

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

19 View Source File : SampleDataSource.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : ConfigurationViewModel.cs
License : MIT License
Project Creator : 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 View Source File : Node.cs
License : MIT License
Project Creator : AlexGyver

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

19 View Source File : HealthFormatterCollection.cs
License : Apache License 2.0
Project Creator : AppMetrics

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

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 View Source File : ModuleInfoGroup.cs
License : MIT License
Project Creator : AvaloniaCommunity

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

19 View Source File : ReorderTabsDialog.xaml.cs
License : GNU Affero General Public License v3.0
Project Creator : 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 View Source File : EventsTreeView.cs
License : GNU General Public License v3.0
Project Creator : AndreiFedarets

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

19 View Source File : ObservableViewModelCollection.cs
License : MIT License
Project Creator : 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 View Source File : ToastHolderViewModel.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : ImageObjectDisplayViewModel.cs
License : Apache License 2.0
Project Creator : anmcgrath

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

19 View Source File : ServerViewModel.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : HealthReporterCollection.cs
License : Apache License 2.0
Project Creator : 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 View Source File : NodeControlsCollection.cs
License : MIT License
Project Creator : AlexGyver

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

19 View Source File : ModelList.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : ObservableSortedCollection.cs
License : MIT License
Project Creator : 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 View Source File : TMap.cs
License : MIT License
Project Creator : 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 View Source File : TreeNodeAdv.cs
License : MIT License
Project Creator : AlexGyver

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

19 View Source File : ConfigurationViewModel.cs
License : MIT License
Project Creator : 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 View Source File : NodeComponentCollection.cs
License : GNU General Public License v3.0
Project Creator : Adam-Wilkinson

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

19 View Source File : TodoModel.cs
License : MIT License
Project Creator : 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 View Source File : ReorderTabsDialog.xaml.cs
License : GNU Affero General Public License v3.0
Project Creator : 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 View Source File : Settings.cs
License : Mozilla Public License 2.0
Project Creator : 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 View Source File : ObservableViewModelCollection.cs
License : MIT License
Project Creator : 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 View Source File : SendImageControlViewModel.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : Xam.Plugin.TabView.cs
License : MIT License
Project Creator : AndreiMisiukevich

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

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

19 View Source File : Notifiaction.xaml.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : ObservableCollectionAutoResize.cs
License : Apache License 2.0
Project Creator : 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 View Source File : MessageControlViewModel.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : RecentlyUsedFolders.cs
License : MIT License
Project Creator : AntonyCorbett

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

19 View Source File : AudioDeviceSource.cs
License : MIT License
Project Creator : 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 View Source File : ActivityLogger.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : Node.cs
License : MIT License
Project Creator : AlexGyver

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

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

19 View Source File : HealthFormatterCollection.cs
License : Apache License 2.0
Project Creator : 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 View Source File : ObservableCollectionExtensions.cs
License : Apache License 2.0
Project Creator : 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 View Source File : ModelList.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : NodeControlsCollection.cs
License : MIT License
Project Creator : 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 View Source File : ModelList.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : SciTraderViewModel.cs
License : MIT License
Project Creator : ABTSoftware

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

19 View Source File : Themes.cs
License : MIT License
Project Creator : 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 View Source File : Node.cs
License : MIT License
Project Creator : AlexGyver

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

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

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 View Source File : ObserveAddRemoveCollection.cs
License : MIT License
Project Creator : 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 View Source File : ZoomHistoryMvvmViewModel.cs
License : MIT License
Project Creator : 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 View Source File : ObservableCollectionMapper.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : ToastHolderViewModel.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : PlottingGraphData.cs
License : MIT License
Project Creator : 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();

            }

        }

See More Examples