Skip to content

Commit d58ef99

Browse files
committed
コメント投稿パネルの選択肢を接続状態のコネクションだけにした
1 parent a1328e9 commit d58ef99

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

MultiCommentViewer/ViewModels/MainViewModel.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,7 @@ private void Connection_MetadataReceived(object sender, IMetadata e)
10431043
public ObservableCollection<PluginMenuItemViewModel> PluginMenuItemCollection { get; } = new ObservableCollection<PluginMenuItemViewModel>();
10441044
private readonly ObservableCollection<IMcvCommentViewModel> _comments = new ObservableCollection<IMcvCommentViewModel>();
10451045
public ObservableCollection<ConnectionViewModel> Connections { get; } = new ObservableCollection<ConnectionViewModel>();
1046+
public ICollectionViewLiveShaping ConnectedConnections { get; }
10461047

10471048
private ConnectionViewModel _selectedConnection;
10481049
public ConnectionViewModel SelectedConnection
@@ -1705,6 +1706,28 @@ public MainViewModel(IIo io, ILogger logger, IOptions options, ISitePluginLoader
17051706
_browserLoader = browserLoader;
17061707

17071708
Comments = CollectionViewSource.GetDefaultView(_comments);
1709+
//ConnectedConnections = CollectionViewSource.GetDefaultView(Connections);
1710+
//ConnectedConnections.Filter = x =>
1711+
//{
1712+
// return x is ConnectionViewModel connVm && connVm.CanDisconnect;
1713+
//};
1714+
var view = new CollectionViewSource { Source = Connections }.View;
1715+
view.Filter = obj =>
1716+
{
1717+
if (!(obj is ConnectionViewModel connVm))
1718+
{
1719+
return false;
1720+
}
1721+
return connVm.CanDisconnect;
1722+
//return true;
1723+
};
1724+
ConnectedConnections = view as ICollectionViewLiveShaping;
1725+
if (ConnectedConnections.CanChangeLiveFiltering)
1726+
{
1727+
//ConnectedConnections.LiveFilteringProperties.Add("CanDisconnect");
1728+
ConnectedConnections.LiveFilteringProperties.Add(nameof(ConnectionViewModel.CanDisconnect));
1729+
ConnectedConnections.IsLiveFiltering = true;
1730+
}
17081731

17091732
MainViewContentRenderedCommand = new RelayCommand(ContentRendered);
17101733
MainViewClosingCommand = new RelayCommand<CancelEventArgs>(Closing);

MultiCommentViewer/Views/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@
494494
<ColumnDefinition Width="100" />
495495
<ColumnDefinition />
496496
</Grid.ColumnDefinitions>
497-
<ComboBox ItemsSource="{Binding Connections}" SelectedValue="{Binding SelectedConnection}" DisplayMemberPath="Name" Grid.Column="0" Margin="10" Height="30" />
497+
<ComboBox ItemsSource="{Binding ConnectedConnections}" SelectedValue="{Binding SelectedConnection}" DisplayMemberPath="Name" Grid.Column="0" Margin="10" Height="30" />
498498
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" x:Name="PostCommentPanelPlaceHolder" Grid.Column="2" />
499499
</Grid>
500500
</Grid>

0 commit comments

Comments
 (0)