/// <summary> /// Provides the <see cref="IDiffListSortService.DiffListSorting"/> immediately and then an element for each <see cref="IDiffListSortService.DiffListSortingChanged"/>. /// </summary> /// <param name="diffListSortService">The diff list service</param> /// <returns>A hot stream with one immediate cold element.</returns> public static IObservable <DiffListSortType> CurrentAndFutureSorting(this IDiffListSortService diffListSortService) { return(Observable.Return(diffListSortService.DiffListSorting) .Concat(Observable.FromEventPattern( h => diffListSortService.DiffListSortingChanged += h, h => diffListSortService.DiffListSortingChanged -= h) .Select(_ => diffListSortService.DiffListSorting)) .DistinctUntilChanged()); }
public SortDiffListContextMenuItem(IDiffListSortService sortService) { _sortService = sortService ?? throw new ArgumentNullException(nameof(sortService)); Image = Images.SortBy; Text = Strings.SortBy; _filePathSortItem = new ToolStripMenuItem() { Text = _filePathSortText.Text, ShowShortcutKeys = true, Image = null, Tag = DiffListSortType.FilePath }; _fileExtensionSortItem = new ToolStripMenuItem() { Text = _fileExtensionSortText.Text, ShowShortcutKeys = true, Image = null, Tag = DiffListSortType.FileExtension }; _fileStatusSortItem = new ToolStripMenuItem() { Text = _fileStatusSortText.Text, ShowShortcutKeys = true, Image = null, Tag = DiffListSortType.FileStatus }; _allItems = new[] { _filePathSortItem, _fileExtensionSortItem, _fileStatusSortItem, }; foreach (var item in AllItems()) { item.Click += Item_Click; DropDownItems.Add(item); } DropDownOpening += (s, e) => RequerySortingMethod(); RequerySortingMethod(); }
public void Setup() { _testingSortService = Substitute.For <IDiffListSortService>(); _testingSortService.DiffListSorting.Returns(DiffListSortType.FilePath); _itemUnderTest = new SortDiffListContextMenuItem(_testingSortService); }