public void MoveItemUp(ServersModel server)
        {
            int currentIndex = Servers.IndexOf(server);

            if (currentIndex <= 0)
            {
                return;
            }

            Servers.Move(currentIndex, currentIndex - 1);
        }
Example #2
0
        public static void Sort <T>(this BindableCollection <T> collection, Func <T, object> order)
        {
            List <T> ordered = collection.OrderBy(order).ToList();

            for (int index = 0; index < ordered.Count; index++)
            {
                T dataBindingConditionViewModel = ordered[index];
                if (collection.IndexOf(dataBindingConditionViewModel) != index)
                {
                    collection.Move(collection.IndexOf(dataBindingConditionViewModel), index);
                }
            }
        }
Example #3
0
                void CloseItemCore(T item)
                {
                    if (item.Equals(ActiveItem))
                    {
                        var index = items.IndexOf(item);
                        var next  = DetermineNextItemToActivate(items, index);

                        ChangeActiveItem(next, true);
                    }
                    else
                    {
                        ScreenExtensions.TryDeactivate(item, true);
                    }

                    items.Remove(item);
                }
Example #4
0
        public override void Remove(RuleViewModelBase rule, bool showOnSnackbar = true)
        {
            var index = _rules.IndexOf(rule);

            if (index == -1)
            {
                return;
            }

            _model.Rules.Remove(rule.Rule);
            _rules.Remove(rule);

            if (!showOnSnackbar)
            {
                return;
            }

            _eventAggregator.PublishOnCurrentThread(new SnackbarMessage()
            {
                Action = smq => smq.Enqueue($"Rule \"{rule.Name}\" removed", "UNDO",
                                            () =>
                {
                    _rules.Insert(index, rule);
                    _model.Rules.Add(rule.Rule);
                }, true)
            });
        }
                private async Task CloseItemCoreAsync(T item, CancellationToken cancellationToken)
                {
                    if (item.Equals(ActiveItem))
                    {
                        var index = _items.IndexOf(item);
                        var next  = DetermineNextItemToActivate(_items, index);

                        await ChangeActiveItemAsync(next, true, cancellationToken);
                    }
                    else
                    {
                        await ScreenExtensions.TryDeactivateAsync(item, true, cancellationToken);
                    }

                    _items.Remove(item);
                }
        public void Connect()
        {
            var            nsv  = GetView() as NetworkSelectionView;
            List <Network> nets = nsv.NetworkList.SelectedItems.Cast <Network>().ToList <Network>();

            foreach (Network n in nets)
            {
                this.ConnectButtonPressed(this.Networks[networks.IndexOf(n)]);
            }
            SaveGlobalIdentity();
        }
        /// <summary>
        /// Сортировка коллекции BindableCollection
        /// </summary>
        /// <typeparam name="T">Коллекция BindableCollection</typeparam>
        /// <param name="collection">Коллекция</param>
        /// <param name="comparison">Выражение сравнения</param>
        public static void Sort <T>(this BindableCollection <T> collection, Comparison <T> comparison)
        {
            var sortableList = new List <T>(collection);

            sortableList.Sort(comparison);
            sortableList.Reverse();

            for (int i = 0; i < sortableList.Count; i++)
            {
                collection.Move(collection.IndexOf(sortableList[i]), i);
            }
        }
Example #8
0
        /* Handlers -----------------------------------------------------------------------------------------------*/

        public void Handle(refreshRoomsEvent message)
        {
            if (!message.joined)
            {
                foreach (SelectableRoom sR in _availableRooms)
                {
                    sR.resetColor();
                    sR.menuVisibility = "Collapsed";
                }

                int selectedRoomIndex = _availableRooms.IndexOf(_availableRooms.Single(i => i.id == message.selectedRoomId));
                _availableRooms[selectedRoomIndex].changeColor("Black");
                _availableRooms[selectedRoomIndex].menuVisibility = "Visible";
                _availableRooms.Refresh();
                _selectedAvailableRoom = message.selectedRoomId;
                NotifyOfPropertyChange(null);
            }
            else
            {
                foreach (SelectableRoom sR in _joinedRooms)
                {
                    sR.resetColor();
                    sR.menuVisibility = "Collapsed";
                }

                int selectedRoomIndex = 0;
                try
                {
                    selectedRoomIndex = _joinedRooms.IndexOf(_joinedRooms.Single(i => i.id == message.selectedRoomId));
                } catch {
                    selectedRoomIndex = _joinedRooms.IndexOf(_joinedRooms.Where(x => x.id == message.selectedRoomId).ToList()[0]);
                }

                _joinedRooms[selectedRoomIndex].changeColor("Black");
                _joinedRooms[selectedRoomIndex].menuVisibility = "Visible";
                _selectedJoinedRoom = message.selectedRoomId;
                _joinedRooms.Refresh();
                NotifyOfPropertyChange(null);
            }
        }
Example #9
0
                /// <summary>
                /// Ensures that an item is ready to be activated.
                /// </summary>
                /// <param name="newItem">The item that is about to be activated.</param>
                /// <returns>The item to be activated.</returns>
                protected override T EnsureItem(T newItem)
                {
                    var index = _items.IndexOf(newItem);

                    if (index == -1)
                    {
                        _items.Add(newItem);
                    }
                    else
                    {
                        newItem = _items[index];
                    }

                    return(base.EnsureItem(newItem));
                }
        public ReportBookViewModel()
        {
            BookGenres = DictBookGenreServices.GetAll();
            DictBookGenre filterAll = new DictBookGenre()
            {
                BookGenreId = 0, Name = "All"
            };

            BookGenres.Add(filterAll);
            BookGenres.Move(BookGenres.IndexOf(filterAll), 0);
            numberOfBooks = BookServices.NumberOfBooks(null, new DictBookGenre()
            {
                BookGenreId = 0, Name = null
            });
            NumberOfBorrowsPerTitle = BorrowServices.NumberOfBorrowsPerTitle(SelectedTitle, SelectedBookGenre, FromDate, ToDate, ActualPage, PageSize);
        }
Example #11
0
        public void addModifiedProfile(PublicProfile profile)
        {
            if (profile.username == _userName)
            {
                _avatarName = profile.avatar;
            }

            IEnumerable <SelectableRoom>        enumSR = _selectableJoinedRooms.Where(x => x.id == "General");
            BindableCollection <SelectableRoom> sRs    = new BindableCollection <SelectableRoom>(enumSR);

            if (sRs.Count() != 1)
            {
                Console.WriteLine("il exite un doublon de general dans les rooms jointes");
            }

            _selectableJoinedRooms[_selectableJoinedRooms.IndexOf(sRs[0])].room.avatars[profile.username] = profile.avatar;
            _selectableJoinedRooms.Refresh();
        }
Example #12
0
        private static void AddItemsTo(BindableCollection <Node> newParentCollection, IFlatListItem insertPlace, IEnumerable <Node> items)
        {
            var newItems = new List <Node>();
            var position = newParentCollection.IndexOf(insertPlace as Node);

            if (position != -1)
            {
                newItems.AddRange(newParentCollection.Take(position));
                newItems.AddRange(items);
                newItems.AddRange(newParentCollection.Skip(position));
            }
            else
            {
                newItems.AddRange(newParentCollection);
                newItems.AddRange(items);
            }
            newParentCollection.IsNotifying = false;
            newParentCollection.Clear();
            newParentCollection.AddRange(newItems);
            newParentCollection.IsNotifying = true;
            newParentCollection.Refresh();
        }
Example #13
0
        public void Drop(IDropInfo dropInfo)
        {
            if (dropInfo.TargetItem == dropInfo.Data)
            {
                return;
            }

            ModuleOrderModuleViewModel viewModel = (ModuleOrderModuleViewModel)dropInfo.Data;
            BindableCollection <ModuleOrderModuleViewModel> targetCollection = (BindableCollection <ModuleOrderModuleViewModel>)dropInfo.TargetCollection;
            int insertIndex = dropInfo.InsertIndex;

            ModulePriorityCategory category;

            if (targetCollection == NormalModules)
            {
                category = ModulePriorityCategory.Normal;
            }
            else if (targetCollection == ApplicationModules)
            {
                category = ModulePriorityCategory.Application;
            }
            else
            {
                category = ModulePriorityCategory.Overlay;
            }

            // If moving down, take the removal of ourselves into consideration with the insert index
            if (targetCollection.Contains(viewModel) && targetCollection.IndexOf(viewModel) < insertIndex)
            {
                insertIndex--;
            }

            _moduleService.UpdateModulePriority(viewModel.Module, category, insertIndex);

            Update();
        }
Example #14
0
 public void UndoOrRedoTo(HistoryItemViewModel item)
 {
     TriggerInternalHistoryChange(() => UndoOrRedoToInternal(item));
     UpdateSelectedIndexOnly(_historyItems.IndexOf(_historyItems.First(x => x.Action == item.Action)) + 1);
 }