public ShellView() { InitializeComponent(); Container.Initialize(new List <string>() { "SourceControlMonitor.exe", "Infrastructure.dll", "DataServices.dll" }); this.DataContext = ViewModelLocator.GetSharedViewModel <IShellViewModel>(); this.notifyIcon.DataContext = ViewModelLocator.GetSharedViewModel <ITaskBarIconViewModel>(); _mediator = MediatorLocator.GetSharedMediator(); _mediator.Subscribe <ShowApplicationEvent>(ignore => OnDoubleClick(null, null)); this.StateChanged += (s, e) => { if (this.WindowState == WindowState.Minimized) { _mediator.NotifyColleaguesAsync <ApplicationHiddenEvent>(null); Hide(); notifyIcon.Visibility = Visibility.Visible; } else { notifyIcon.HideBalloonTip(); notifyIcon.Visibility = Visibility.Collapsed; } }; }
private void OnDoubleClick(object sender, RoutedEventArgs e) { Application.Current.Dispatcher.BeginInvoke(new Action(() => { if (this.WindowState == WindowState.Minimized) { Show(); _mediator.NotifyColleaguesAsync <ApplicationRestoredEvent>(null); this.WindowState = WindowState.Normal; } })); }