Ejemplo n.º 1
0
 public override async Task Execute(object parameter)
 {
     if (Library.IsAvaible)
     {
         await Library.ThreadAction(Library.Update(view.OfType <MangaModel>().Select(m => m.Id).ToList())).ConfigureAwait(true);
     }
 }
        public override async void Execute(object parameter)
        {
            base.Execute(parameter);

            if (Library.IsAvaible)
            {
                await Library.ThreadAction(() => Library.Update(view.OfType <MangaModel>().Select(m => m.Id).ToList()));
            }
        }
        private void InitItemComboBox()
        {
            IDataLayerAccessor dataLayerAccessor = new XmlDataLayerAccessor();

            dataLayerAccessor.LoadDataLayer();

            ComboBoxItems = new ListCollectionView(dataLayerAccessor.GetItems(SelectedComboBoxItemType).ToList());
            ComboBoxItems.GroupDescriptions.Add(new PropertyGroupDescription("ItemNodeCategory"));

            SelectedComboBoxItem = ComboBoxItems.OfType <EveItem>().ElementAt(0);
        }
        public static void Replace <T>(this ListCollectionView collectionView, T itemToRemove, T itemToAdd)
            where T : class, IEntity <int>
        {
            var itemIndex = collectionView.IndexOf(itemToRemove);

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

            var items = collectionView.OfType <T>().ToList();

            if (items.Any(o => o.Id == itemToRemove.Id))
            {
                items.RemoveAt(itemIndex);
                items.Insert(itemIndex, itemToAdd);
                collectionView = new ListCollectionView(items);
            }
            else
            {
                collectionView.AddNewItem(itemToAdd);
                collectionView.CommitEdit();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 選択中のモジュールを削除
        /// </summary>
        /// <param name="dataGrid"></param>
        private void DeleteModules(DataGrid dataGrid)
        {
            var currPos = _CollectionView.CurrentPosition;

            // モジュール数を編集した後に削除するとcurrPosが-1になる場合があるため、
            // ここで最初に選択されている表示上のモジュールの要素番号を取得する
            if (currPos == -1)
            {
                var cnt = 0;
                foreach (var module in _CollectionView.OfType <ModulesGridItem>())
                {
                    if (module.IsSelected)
                    {
                        currPos = cnt;
                        break;
                    }
                    cnt++;
                }
            }

            var items = CollectionViewSource.GetDefaultView(_CollectionView)
                        .Cast <ModulesGridItem>()
                        .Where(x => x.IsSelected);

            _ModulesInfo.Modules.RemoveRange(items);

            // 削除後に全部の選択状態を外さないと余計なものまで選択される
            foreach (var module in _ModulesInfo.Modules)
            {
                module.IsSelected = false;
            }

            // 選択行を設定
            if (currPos < 0)
            {
                // 先頭行を削除した場合
                _CollectionView.MoveCurrentToFirst();
            }
            else if (_CollectionView.Count <= currPos)
            {
                // 最後の行を消した場合、選択行を最後にする
                _CollectionView.MoveCurrentToLast();
            }
            else
            {
                // 中間行の場合
                _CollectionView.MoveCurrentToPosition(currPos);
            }

            // 再度選択
            if (_CollectionView.CurrentItem is ModulesGridItem item)
            {
                item.IsSelected = true;
            }

            // セルフォーカス
            if (dataGrid.CurrentCell.Column is not null)
            {
                CellFocusCommand?.Execute(new Tuple <DataGrid, int, int>(dataGrid, _CollectionView.CurrentPosition, dataGrid.CurrentCell.Column.DisplayIndex));
            }
        }