-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from emoacht/develop
Added notification area icon
- Loading branch information
Showing
11 changed files
with
647 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
using System.Reactive.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Data; | ||
using Reactive.Bindings; | ||
using Reactive.Bindings.Extensions; | ||
using Reactive.Bindings.Helpers; | ||
|
||
using WlanProfileViewer.Common; | ||
using WlanProfileViewer.Views; | ||
|
||
namespace WlanProfileViewer.ViewModels | ||
{ | ||
public class NotifyWindowViewModel : BindableDisposableBase | ||
{ | ||
private readonly MainWindow _mainWindow; | ||
|
||
private ReadOnlyReactiveCollection<ProfileItemViewModel> Profiles { get; } | ||
|
||
public ListCollectionView ProfilesView | ||
{ | ||
get | ||
{ | ||
if (_profilesView == null) | ||
{ | ||
_profilesView = new ListCollectionView(Profiles); | ||
_profilesView.Filter = x => ((ProfileItemViewModel)x).IsConnected.Value; | ||
_profilesView.SortDescriptions.Add(new SortDescription(nameof(ProfileItemViewModel.InterfaceDescription), ListSortDirection.Ascending)); | ||
} | ||
|
||
return _profilesView; | ||
} | ||
} | ||
private ListCollectionView _profilesView; | ||
|
||
public ReadOnlyReactiveProperty<bool> IsAnyConnected { get; } | ||
|
||
public NotifyWindowViewModel(Window ownerWindow) | ||
{ | ||
this._mainWindow = ownerWindow as MainWindow; | ||
if (this._mainWindow == null) | ||
throw new ArgumentException(nameof(ownerWindow)); | ||
|
||
var mainWindowViewModel = this._mainWindow.DataContext as MainWindowViewModel; | ||
|
||
this.Profiles = mainWindowViewModel.Profiles; | ||
|
||
IsAnyConnected = this.Profiles | ||
.ObserveElementObservableProperty(x => x.IsConnected) | ||
.ObserveOnUIDispatcher() | ||
.Select(_ => | ||
{ | ||
this.ProfilesView.Refresh(); | ||
return (this.ProfilesView.Count > 0); | ||
}) | ||
.ToReadOnlyReactiveProperty() | ||
.AddTo(this.Subscription); | ||
|
||
mainWindowViewModel.ReloadCommand.Execute(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<Window x:Class="WlanProfileViewer.Views.NotifyWindow" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" | ||
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" | ||
xmlns:ma="clr-namespace:MonitorAware.Views;assembly=MonitorAware" | ||
xmlns:controls="clr-namespace:WlanProfileViewer.Views.Controls" | ||
Width="120" Height="120" | ||
MinWidth="120" | ||
SizeToContent="WidthAndHeight" ResizeMode="NoResize" | ||
WindowStyle="None"> | ||
<i:Interaction.Behaviors> | ||
<ma:MonitorAwareBehavior/> | ||
</i:Interaction.Behaviors> | ||
|
||
<Grid Background="{StaticResource App.Background}"> | ||
<StackPanel> | ||
<!-- Connected --> | ||
<Grid Height="30"> | ||
<TextBlock x:Name="Connected" | ||
HorizontalAlignment="Center" VerticalAlignment="Center" | ||
Foreground="{StaticResource App.Foreground}" | ||
FontWeight="Bold" | ||
Text="Connected" | ||
Visibility="{Binding IsAnyConnected.Value, Converter={StaticResource BooleanToVisibilityConverterKey}}"/> | ||
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" | ||
Foreground="{StaticResource App.Foreground}" | ||
FontWeight="Bold" | ||
Text="Disconnected" | ||
Visibility="{Binding ElementName=Connected, Path=Visibility, Converter={StaticResource VisibilityInverseConverterKey}}"/> | ||
</Grid> | ||
|
||
<ListView ItemsSource="{Binding ProfilesView}"> | ||
<ListView.Template> | ||
<ControlTemplate TargetType="{x:Type ListView}"> | ||
<Border BorderThickness="1"> | ||
<ScrollViewer> | ||
<VirtualizingStackPanel IsItemsHost="True"/> | ||
</ScrollViewer> | ||
</Border> | ||
</ControlTemplate> | ||
</ListView.Template> | ||
<ListView.ItemTemplate> | ||
<DataTemplate> | ||
<Border Background="{StaticResource Profile.Connected.Background}" | ||
BorderBrush="{StaticResource App.Background}" | ||
BorderThickness="1"> | ||
<StackPanel> | ||
<Grid Height="30"> | ||
<Grid Margin="4,0"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="24"/> | ||
<ColumnDefinition Width="*"/> | ||
</Grid.ColumnDefinitions> | ||
|
||
<!-- Signal --> | ||
<controls:SignalProgressBar | ||
Grid.Column="0" | ||
Style="{StaticResource BarStyle}" | ||
Background="{StaticResource Profile.Signal.Background}" | ||
Foreground="{StaticResource Profile.Signal.Foreground}" | ||
Value="{Binding Signal.Value, Mode=OneWay}"> | ||
<Control.ToolTip> | ||
<ToolTip DataContext="{Binding PlacementTarget, RelativeSource={RelativeSource Self}}" | ||
Content="{Binding Value}" | ||
ContentStringFormat="{} {0}%"/> | ||
</Control.ToolTip> | ||
</controls:SignalProgressBar> | ||
|
||
<!-- Profile name --> | ||
<TextBlock Grid.Column="1" | ||
Margin="4,0,0,0" VerticalAlignment="Center" | ||
Foreground="{StaticResource App.Foreground}" | ||
FontSize="14" | ||
Text="{Binding Name, Mode=OneTime}"/> | ||
</Grid> | ||
</Grid> | ||
</StackPanel> | ||
</Border> | ||
</DataTemplate> | ||
</ListView.ItemTemplate> | ||
<ListView.ItemContainerStyle> | ||
<Style TargetType="{x:Type ListViewItem}"> | ||
<Setter Property="Margin" Value="0"/> | ||
<Setter Property="OverridesDefaultStyle" Value="True"/> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type ContentControl}"> | ||
<ContentPresenter/> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
</ListView.ItemContainerStyle> | ||
</ListView> | ||
</StackPanel> | ||
</Grid> | ||
</Window> |
Oops, something went wrong.