TrayIconControl is a hidden window launched by default that hosts the tray icon and stores viewmodel state for the MainWindow.
parent
c24df811c5
commit
5cba900d91
|
@ -2,7 +2,7 @@
|
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:WifiSitterGui"
|
||||
StartupUri="MainWindow.xaml">
|
||||
StartupUri="TrayIconControl.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
|
|
|
@ -6,13 +6,8 @@
|
|||
xmlns:local="clr-namespace:WifiSitterGui"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="350" Width="525">
|
||||
Title="WifiSitter Config" Height="350" Width="525">
|
||||
<Grid>
|
||||
<tb:TaskbarIcon
|
||||
IconSource="pack://application:,,,/wifisitter-icon.ico"
|
||||
ToolTipText="hello world" />
|
||||
|
||||
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace WifiSitterGui
|
||||
{
|
||||
class MainWindowViewModel : MvvmObservable
|
||||
{
|
||||
#region fields
|
||||
#endregion // fields
|
||||
|
||||
#region constructor
|
||||
|
||||
public MainWindowViewModel () {
|
||||
|
||||
}
|
||||
|
||||
#endregion // constructor
|
||||
|
||||
#region properties
|
||||
#endregion // properties
|
||||
|
||||
#region methods
|
||||
#endregion // methods
|
||||
|
||||
#region eventhandlers
|
||||
#endregion // methods
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
using System.ComponentModel;
|
||||
|
||||
namespace WifiSitterGui
|
||||
{
|
||||
public class MvvmObservable : INotifyPropertyChanged, INotifyPropertyChanging
|
||||
{
|
||||
#region INotifyPropertyChanging Members
|
||||
|
||||
public event PropertyChangingEventHandler PropertyChanging;
|
||||
|
||||
internal virtual void OnPropertyChanging(string propertyName) {
|
||||
PropertyChangingEventHandler handler = this.PropertyChanging;
|
||||
if (handler != null)
|
||||
handler(this, new PropertyChangingEventArgs(propertyName));
|
||||
}
|
||||
|
||||
#endregion // INotifyPropertyChanging Members
|
||||
|
||||
|
||||
#region INotifyPropertyChanged Members
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
internal virtual void OnPropertyChanged(string propertyName) {
|
||||
PropertyChangedEventHandler handler = this.PropertyChanged;
|
||||
if (handler != null)
|
||||
handler(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
#endregion // INotifyPropertyChanged Members
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<Window x:Class="WifiSitterGui.TrayIconControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:WifiSitterGui"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Visibility="Hidden"
|
||||
mc:Ignorable="d"
|
||||
Title="TrayIconControl" Height="300" Width="300">
|
||||
<Grid>
|
||||
|
||||
<tb:TaskbarIcon
|
||||
IconSource="pack://application:,,,/wifisitter-icon.ico"
|
||||
ToolTipText="hello world" >
|
||||
<tb:TaskbarIcon.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="Pause for 5 minutes"
|
||||
ToolTip="Restores interfaces to original status."/>
|
||||
</ContextMenu>
|
||||
</tb:TaskbarIcon.ContextMenu>
|
||||
</tb:TaskbarIcon>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace WifiSitterGui
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for TrayIconControl.xaml
|
||||
/// </summary>
|
||||
public partial class TrayIconControl : Window
|
||||
{
|
||||
private MainWindowViewModel _windowVm;
|
||||
|
||||
public TrayIconControl() {
|
||||
InitializeComponent();
|
||||
|
||||
_windowVm = new MainWindowViewModel();
|
||||
|
||||
var statusGui = new MainWindow();
|
||||
statusGui.DataContext = _windowVm;
|
||||
statusGui.Show();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -54,6 +54,9 @@
|
|||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="TrayIconControl.xaml.cs">
|
||||
<DependentUpon>TrayIconControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
@ -66,8 +69,14 @@
|
|||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Page Include="TrayIconControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MainWindowViewModel.cs" />
|
||||
<Compile Include="MvvmObservable.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
|
Loading…
Reference in New Issue