private MultiSelectCollectionView<ShortcutViewModel> CreateCollectionView(ReactiveList<ShortcutViewModel> shortcuts) { var view = new MultiSelectCollectionView<ShortcutViewModel>(shortcuts); view.Filter = ApplyFilter; view.SortDescriptions.Add(new SortDescription(nameof(ShortcutViewModel.Name), ListSortDirection.Ascending)); return view; }
public WebsiteReportsViewModel() { Title = String.Empty; //New report Title //ShowHospitalSelectionView = Visibility.Collapsed; //IsPreviewOpen = Visibility.Collapsed; ReportsCollectionView = new MultiSelectCollectionView <ReportViewModel>(new List <ReportViewModel>()); }
/** * La selezione singola non funziona: * esempio: * * https://stackoverflow.com/questions/4184243/wpf-listbox-selection-does-not-work * https://stackoverflow.com/questions/21748150/listbox-selectionchanged-not-getting-called * * Allora sono costretto a gestire "manualmente" questa situazione. * Invece la selezione multipla senmbra funzionare */ private void fotografiListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { ListBox listBox = (ListBox)sender; if (listBox.SelectionMode == SelectionMode.Single) { MultiSelectCollectionView <Fotografo> cw = (MultiSelectCollectionView <Fotografo>)listBox.ItemsSource; foreach (var obj in e.RemovedItems) { cw.deseleziona((Fotografo)obj); } foreach (var obj in e.AddedItems) { cw.seleziona((Fotografo)obj); } if (cw.SelectedItems.Count > 1) { if (System.Diagnostics.Debugger.IsAttached) { System.Diagnostics.Debugger.Break(); } } } }
private MultiSelectCollectionView <ShortcutViewModel> CreateCollectionView(ReactiveList <ShortcutViewModel> shortcuts) { var view = new MultiSelectCollectionView <ShortcutViewModel>(shortcuts); view.Filter = ApplyFilter; view.SortDescriptions.Add(new SortDescription(nameof(ShortcutViewModel.Name), ListSortDirection.Ascending)); return(view); }
public ControlTestViewModel(ViewBase parent) : base(parent) { _data = new ObservableCollection <TestData>(); Data = new MultiSelectCollectionView <TestData>(_data); _data.Add(new TestData()); _data.Add(new TestData()); _data.Add(new TestData()); ModalBackgroundTaskCommand = new SimpleCommand(ExecuteModalBackgroundTask); CancellableBackgroundTaskCommand = new SimpleCommand(ExecuteCancellableBackgroundTask); }
private void rileggereFotografi(object param) { // Decido se devo dare un avviso all'utente Boolean avvisami = false; if (param != null) { if (param is Boolean) { avvisami = (Boolean)param; } if (param is string) { Boolean.TryParse(param.ToString(), out avvisami); } } // --- IEnumerable <Fotografo> listaF = null; if (IsInDesignMode) { // genero dei dati casuali DataGen <Fotografo> dg = new DataGen <Fotografo>(); listaF = dg.generaMolti(5); } else { listaF = fotografiReporitorySrv.getAll(); } // purtoppo pare che rimpiazzare il reference con uno nuovo, causa dei problemi. // Non posso istanziare nuovamente la lista, ma la devo svuotare e ripopolare. fotografi.Clear(); foreach (Fotografo f in listaF) { if (f.attivo) { fotografi.Add(f); } } // Costriusco anche la collection view per la selezione multipla fotografiCW = new MultiSelectCollectionView <Fotografo>(fotografi); if (avvisami && dialogProvider != null) { dialogProvider.ShowMessage("Riletti " + fotografi.Count + " fotografi", "Successo"); } }
private void refreshScarichiCards(object param) { // Decido se devo dare un avviso all'utente Boolean avvisami = false; if (param != null) { if (param is Boolean) { avvisami = (Boolean)param; } if (param is string) { Boolean.TryParse(param.ToString(), out avvisami); } } // --- IEnumerable <ScaricoCard> lista; if (IsInDesignMode) { DataGen <ScaricoCard> dataGen = new DataGen <ScaricoCard>(); lista = dataGen.generaMolti(4); } else { lista = this.fotoExplorerSrv.loadUltimiScarichiCards(); } // Ho notato che è meglio non ri-istanziare le collezione. La pulisco e poi la ricarico scarichiCards = new ObservableCollection <ScaricoCard>(lista); scarichiCards.Clear(); foreach (ScaricoCard ev in lista) { scarichiCards.Add(ev); } // Costriusco anche la collection view per la selezione multipla scarichiCardsCW = new MultiSelectCollectionView <ScaricoCard>(scarichiCards); if (avvisami && dialogProvider != null) { dialogProvider.ShowMessage("Ricaricati " + scarichiCards.Count + " elementi", "Successo"); } }
/// <summary> /// Callback. Called when the RadicalLoader finishes loading radicals. /// Updates the radical list property. /// </summary> private void OnRadicalsLoaded() { Radicals = new MultiSelectCollectionView <FilteringRadical>( RadicalStore.Instance.CurrentSet .Select(r => new FilteringRadical() { Reference = r, IsRelevant = true, IsAvailable = FilteringRadicalAvailabilityEnum.Available }).ToArray()); DispatcherHelper.Invoke(() => { _radicals.CustomSort = (IComparer)_comparer; _radicals.SelectionChanged += OnRadicalSelectionChanged; }); }
public override async Task Refresh(bool clearFilterAndGroup = true) { Items.Clear(); if (Item.IsContainer) { _searchItemProvider = new SearchItemProvider(); _searchItemProvider.ItemAdded += SearchItemProvider_ItemAdded; await _searchItemProvider.GetItems(Path, ".dll"); } else { foreach (var refItem in GetReferenceItems(Item.GetPathResolved())) { Items.Add(refItem); } } ItemsView = new MultiSelectCollectionView <ReferenceItem>(Items); Title = PathName = ProtocolPrefix + "/" + Item.Name; }
private async Task LoadData() { Sides = new MultiSelectCollectionView <ComboboxSelector>(new List <ComboboxSelector> { new ComboboxSelector("CT", Properties.Resources.CounterTerrorists), new ComboboxSelector("T", Properties.Resources.Terrorists) }); if (IsInDesignMode) { DispatcherHelper.Initialize(); Demo = await _cacheService.GetDemoDataFromCache(string.Empty); } Rounds = new MultiSelectCollectionView <Round>(Demo.Rounds); Players = new MultiSelectCollectionView <Player>(Demo.Players); // Get the original overview image _mapService.InitMap(Demo); DispatcherHelper.CheckBeginInvokeOnUI(() => { OverviewLayer = _mapService.GetWriteableImage(Properties.Settings.Default.UseSimpleRadar); }); }
private async Task LoadData() { Sides = new MultiSelectCollectionView <ComboboxSelector>(new List <ComboboxSelector> { new ComboboxSelector("CT", "Counter-Terrorists"), new ComboboxSelector("T", "Terrorists") }); if (IsInDesignMode) { DispatcherHelper.Initialize(); CurrentDemo = await _cacheService.GetDemoDataFromCache(string.Empty); } Rounds = new MultiSelectCollectionView <Round>(CurrentDemo.Rounds); Players = new MultiSelectCollectionView <Player>(CurrentDemo.Players); // Get the original overview image _mapService.InitMap(CurrentDemo); DispatcherHelper.CheckBeginInvokeOnUI(() => { OverviewLayer = _mapService.GetWriteableImage(); }); }
/// <summary> /// Callback. Called when the RadicalLoader finishes loading radicals. /// Updates the radical list property. /// </summary> private void OnRadicalsLoaded() { Radicals = new MultiSelectCollectionView<FilteringRadical>( RadicalStore.Instance.CurrentSet .Select(r => new FilteringRadical() { Reference = r, IsRelevant = true, IsAvailable = FilteringRadicalAvailabilityEnum.Available }).ToArray()); DispatcherHelper.Invoke(() => { _radicals.CustomSort = (IComparer)_comparer; _radicals.SelectionChanged += OnRadicalSelectionChanged; }); }
private void _Initialize(FolderModel newFolder) { #region //Присваеваем анонимные функции коммандам SetRenameEnableCommand = new Command(arg => IsNameReadOnly = !Convert.ToBoolean(arg)); SetRenameEnableCommand.CanExecuteDelegate = arg => this.GetType() == typeof(FolderViewModel); CreateSubFolderCommand = new Command(arg => { string name = FullName + "\\" + "Новая папка"; string newName = name; for (int i = 1; Directory.Exists(newName); ++i) newName = name + " (" + i.ToString() + ")"; FileSystem.CreateDirectory(newName); }); DeleteCommand = new Command(arg => Task.Run(() => FileSystem.DeleteDirectory(FullName, UIOption.AllDialogs, RecycleOption.SendToRecycleBin, UICancelOption.DoNothing))); CopyCommand = new Command(arg => { foreach (var folder in DriveViewModel.CutedFolders) folder.IsCuted = false; DriveViewModel.CutedFolders.Clear(); StringCollection folderPath = new StringCollection(); folderPath.Add(FullName); Clipboard.SetFileDropList(folderPath); FileSystemViewModel.IsClipBoardItemsCuted = false; }); CopyCommand.CanExecuteDelegate = arg => this.GetType() == typeof(FolderViewModel); CutCommand = new Command(arg => { IsCuted = true; foreach (var folder in DriveViewModel.CutedFolders) folder.IsCuted = false; DriveViewModel.CutedFolders.Clear(); StringCollection folderPath = new StringCollection(); DriveViewModel.CutedFolders.Add(this); folderPath.Add(FullName); Clipboard.SetFileDropList(folderPath); FileSystemViewModel.IsClipBoardItemsCuted = true; }); CutCommand.CanExecuteDelegate = new Predicate<object>(arg => this.GetType() == typeof(FolderViewModel)); DeleteFilesCommand = new Command(arg => { foreach (var file in FolderFilesCollectionView.SelectedItems) file.Delete(); }); DeleteCommand.CanExecuteDelegate = new Predicate<object>(arg => this.GetType() == typeof(FolderViewModel)); OpenFilesCommand = new Command(arg => { foreach (var file in FolderFilesCollectionView.SelectedItems) file.Open(); }); CopyFilesCommand = new Command(arg => { foreach (var file in DriveViewModel.CutedFiles) file.IsCuted = false; DriveViewModel.CutedFiles.Clear(); StringCollection filePaths = new StringCollection(); foreach (var file in FolderFilesCollectionView.SelectedItems) filePaths.Add(file.FullName); Clipboard.SetFileDropList(filePaths); FileSystemViewModel.IsClipBoardItemsCuted = false; }); CutFilesCommand = new Command(arg => { foreach (var file in DriveViewModel.CutedFiles) file.IsCuted = false; DriveViewModel.CutedFiles.Clear(); StringCollection filePaths = new StringCollection(); foreach (var file in FolderFilesCollectionView.SelectedItems) { DriveViewModel.CutedFiles.Add(file); file.IsCuted = true; filePaths.Add(file.FullName); } Clipboard.SetFileDropList(filePaths); FileSystemViewModel.IsClipBoardItemsCuted = true; }); SortFilesCommand = new Command(arg => { if (_ListSortDirection == ListSortDirection.Descending) _ListSortDirection = ListSortDirection.Ascending; else _ListSortDirection = ListSortDirection.Descending; if (arg.ToString() == "Size") { FolderFilesCollectionView.CustomSort = new FileSizeSorter(_ListSortDirection); } else if (arg.ToString() == "LastWriteTime") { FolderFilesCollectionView.CustomSort = new DateTimeSorter(_ListSortDirection); } else { FolderFilesCollectionView.SortDescriptions.Clear(); FolderFilesCollectionView.CustomSort = null; FolderFilesCollectionView.SortDescriptions.Add(new SortDescription(arg.ToString(), _ListSortDirection)); } }); PasteCommand = new Command(arg => Paste(Clipboard.GetFileDropList(), FullName, FileSystemViewModel.IsClipBoardItemsCuted)); PasteCommand.CanExecuteDelegate = arg => Clipboard.ContainsFileDropList(); FindCommand = new Command(arg => FolderFilesCollectionView.Filter = new Predicate<object>(item => (((FileViewModel)item).Name.ToLower() + ((FileViewModel)item).Extension.ToLower()).Contains(arg.ToString().ToLower()))); RenameCommand = new Command(arg => { if (arg.ToString() != Name) try { FileSystem.RenameDirectory(FullName, arg.ToString()); } catch (ArgumentException) { NotifyPropertyChanged("Name"); IsWrongName = true; } catch (DirectoryNotFoundException) { } }); #endregion _SubFoldersClearTimer.Elapsed += _OnSubFoldersClearTimerElapsed; Name = newFolder.DirInfo.Name; FullName = newFolder.DirInfo.FullName; SubFolders = new ObservableRangeCollection<FolderViewModel>(); FolderFiles = new ObservableRangeCollection<FileViewModel>(); try { if (Directory.GetDirectories(FullName).Length != 0) SubFolders.Add(null); } catch { } FolderFilesCollectionView = new MultiSelectCollectionView<FileViewModel>(FolderFiles); }