상속: IDisposable
예제 #1
0
        public ShellView(ShellViewModel vm, EventAggregator eventAggregator, ProcessMonitor processMonitor)
        {
            this.DataContext = vm;
            this.eventAggregator = eventAggregator;
            this.processMonitor = processMonitor;

            // Register all windows show/hide hotkey
            HotkeyCommands.ToggleAllWindowsCommand.RegisterCommand(new DelegateCommand(this.ToggleVisibility));

            // Register for events that could make us show/hide all windows
            Properties.Settings.Default.PropertyChanged += this.OnSettingsPropertyChanged;
            this.eventAggregator.GetEvent<GW2ProcessStarted>().Subscribe(o =>
                {
                    if (Settings.Default.AutoHideAllWindowsWhenGw2NotRunning)
                        this.SetAllOverlayWindowsVisibility(Visibility.Visible);
                });
            this.eventAggregator.GetEvent<GW2ProcessClosed>().Subscribe(o =>
                {
                    if (Settings.Default.AutoHideAllWindowsWhenGw2NotRunning)
                        this.SetAllOverlayWindowsVisibility(Visibility.Hidden);
                });
            this.eventAggregator.GetEvent<GW2ProcessFocused>().Subscribe(o =>
                {
                    if (Settings.Default.AutoHideAllWindowsWhenGw2LosesFocus)
                        this.SetAllOverlayWindowsVisibility(Visibility.Visible);
                });
            this.eventAggregator.GetEvent<GW2ProcessLostFocus>().Subscribe(o =>
                {
                    if (Settings.Default.AutoHideAllWindowsWhenGw2LosesFocus)
                        this.SetAllOverlayWindowsVisibility(Visibility.Hidden);
                });

            // All overlay windows created will be children of this window
            OverlayWindow.OwnerWindow = this;

            InitializeComponent();

            this.Left = Properties.Settings.Default.OverlayIconX;
            this.Top = Properties.Settings.Default.OverlayIconY;

            this.Loaded += ShellView_Loaded;

            Commands.ApplicationShutdownCommand.RegisterCommand(new DelegateCommand(this.CleanupTrayIcon));
            Commands.CleanupTrayIcon.RegisterCommand(new DelegateCommand(this.CleanupTrayIcon));

            this.eventAggregator.GetEvent<InsufficientPrivilegesEvent>().Subscribe((o) =>
                {
                    this.TrayIcon.ShowBalloonTip(Properties.Resources.Warning, Properties.Resources.NotRunningAsAdmin, BalloonIcon.Warning);
                });

            this.Closing += ShellView_Closing;
        }
예제 #2
0
        public ShellViewModel(
            ISystemService systemService,
            ISettingsViewController settingsViewController,
            GeneralSettingsViewModel generalSettingsVm,
            HotkeySettingsViewModel hotkeySettingsVm,
            CompositionContainer container,
            EventAggregator eventAggregator,
            ProcessMonitor processMonitor)
        {
            this.MainMenu = new ObservableCollection<IMenuItem>();
            this.container = container;

            generalSettingsVm.InitializeHotkeyCommandHandlers();

            this.hotkeySettingsVm = hotkeySettingsVm;
            this.hotkeySettingsVm.InitializeHotkeys();

            this.settingsViewController = settingsViewController;
            this.settingsViewController.Initialize();

            // Initialize the process monitor
            GW2PAO.Views.OverlayWindow.EventAggregator = eventAggregator;

            // Initialize shutdown handling
            Commands.ApplicationShutdownCommand.RegisterCommand(new DelegateCommand(this.Shutdown));

            // Start the game type monitor to monitor for player entering PvE/WvW
            this.processMonitor = processMonitor;
            this.processMonitor.Start();

            Properties.Settings.Default.PropertyChanged += (o, e) => this.OnPropertyChanged(() => this.IsOverlayMenuIconVisible);
            eventAggregator.GetEvent<GW2ProcessStarted>().Subscribe(o => this.OnPropertyChanged(() => this.IsOverlayMenuIconVisible));
            eventAggregator.GetEvent<GW2ProcessClosed>().Subscribe(o => this.OnPropertyChanged(() => this.IsOverlayMenuIconVisible));
            eventAggregator.GetEvent<GW2ProcessFocused>().Subscribe(o => this.OnPropertyChanged(() => this.IsOverlayMenuIconVisible));
            eventAggregator.GetEvent<GW2ProcessLostFocus>().Subscribe(o => this.OnPropertyChanged(() => this.IsOverlayMenuIconVisible));
        }