From 5cba900d916bf3429a696eccfb8956e46257df11 Mon Sep 17 00:00:00 2001 From: Sean McArdle Date: Tue, 15 Nov 2016 14:04:48 -0800 Subject: [PATCH] TrayIconControl is a hidden window launched by default that hosts the tray icon and stores viewmodel state for the MainWindow. --- WifiSitterGui/App.xaml | 2 +- WifiSitterGui/MainWindow.xaml | 7 +------ WifiSitterGui/MainWindowViewModel.cs | 30 ++++++++++++++++++++++++++++++ WifiSitterGui/MvvmObservable.cs | 32 ++++++++++++++++++++++++++++++++ WifiSitterGui/TrayIconControl.xaml | 25 +++++++++++++++++++++++++ WifiSitterGui/TrayIconControl.xaml.cs | 33 +++++++++++++++++++++++++++++++++ WifiSitterGui/WifiSitterGui.csproj | 9 +++++++++ 7 files changed, 131 insertions(+), 7 deletions(-) create mode 100644 WifiSitterGui/MainWindowViewModel.cs create mode 100644 WifiSitterGui/MvvmObservable.cs create mode 100644 WifiSitterGui/TrayIconControl.xaml create mode 100644 WifiSitterGui/TrayIconControl.xaml.cs diff --git a/WifiSitterGui/App.xaml b/WifiSitterGui/App.xaml index ecfd46c..a254313 100644 --- a/WifiSitterGui/App.xaml +++ b/WifiSitterGui/App.xaml @@ -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"> diff --git a/WifiSitterGui/MainWindow.xaml b/WifiSitterGui/MainWindow.xaml index 0c11e07..3bc204c 100644 --- a/WifiSitterGui/MainWindow.xaml +++ b/WifiSitterGui/MainWindow.xaml @@ -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"> - - - diff --git a/WifiSitterGui/MainWindowViewModel.cs b/WifiSitterGui/MainWindowViewModel.cs new file mode 100644 index 0000000..a63200e --- /dev/null +++ b/WifiSitterGui/MainWindowViewModel.cs @@ -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 + } +} diff --git a/WifiSitterGui/MvvmObservable.cs b/WifiSitterGui/MvvmObservable.cs new file mode 100644 index 0000000..b738297 --- /dev/null +++ b/WifiSitterGui/MvvmObservable.cs @@ -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 + } +} diff --git a/WifiSitterGui/TrayIconControl.xaml b/WifiSitterGui/TrayIconControl.xaml new file mode 100644 index 0000000..0fb5188 --- /dev/null +++ b/WifiSitterGui/TrayIconControl.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + diff --git a/WifiSitterGui/TrayIconControl.xaml.cs b/WifiSitterGui/TrayIconControl.xaml.cs new file mode 100644 index 0000000..d422894 --- /dev/null +++ b/WifiSitterGui/TrayIconControl.xaml.cs @@ -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 +{ + /// + /// Interaction logic for TrayIconControl.xaml + /// + public partial class TrayIconControl : Window + { + private MainWindowViewModel _windowVm; + + public TrayIconControl() { + InitializeComponent(); + + _windowVm = new MainWindowViewModel(); + + var statusGui = new MainWindow(); + statusGui.DataContext = _windowVm; + statusGui.Show(); + } + } +} diff --git a/WifiSitterGui/WifiSitterGui.csproj b/WifiSitterGui/WifiSitterGui.csproj index bf47cff..8913f77 100644 --- a/WifiSitterGui/WifiSitterGui.csproj +++ b/WifiSitterGui/WifiSitterGui.csproj @@ -54,6 +54,9 @@ MSBuild:Compile Designer + + TrayIconControl.xaml + MSBuild:Compile Designer @@ -66,8 +69,14 @@ MainWindow.xaml Code + + Designer + MSBuild:Compile + + + Code