Example #1
0
        private void DoAppStartup()
        {
            ((Manager)Resources["ThemeManager"]).Load();

            _mixerWindow    = new WindowHolder(CreateMixerExperience);
            _settingsWindow = new WindowHolder(CreateSettingsExperience);

            PlaybackDevicesViewModel        = new DeviceCollectionViewModel(WindowsAudioFactory.Create(AudioDeviceKind.Playback));
            PlaybackDevicesViewModel.Ready += OnMainViewModelReady;

            FlyoutViewModel = new FlyoutViewModel(PlaybackDevicesViewModel);
            FlyoutWindow    = new FlyoutWindow(FlyoutViewModel);

            TrayViewModel              = new TrayViewModel(PlaybackDevicesViewModel);
            TrayViewModel.LeftClick    = new RelayCommand(() => FlyoutViewModel.OpenFlyout(FlyoutShowOptions.Pointer));
            TrayViewModel.OpenMixer    = new RelayCommand(_mixerWindow.OpenOrBringToFront);
            TrayViewModel.OpenSettings = new RelayCommand(_settingsWindow.OpenOrBringToFront);
            FlyoutWindow.DpiChanged   += (_, __) => TrayViewModel.Refresh();

            _trayIcon = new TrayIcon(TrayViewModel);

            SettingsService.RegisterHotkeys();
            HotkeyManager.Current.KeyPressed += OnHotKeyPressed;

            MaybeShowFirstRunExperience();
        }
Example #2
0
        public TrayIcon(TrayViewModel trayViewModel)
        {
            _trayIcon                       = new System.Windows.Forms.NotifyIcon();
            _trayIcon.ContextMenu           = new System.Windows.Forms.ContextMenu();
            _trayViewModel                  = trayViewModel;
            _trayViewModel.PropertyChanged += TrayViewModel_PropertyChanged;

            var aboutString = Properties.Resources.ContextMenuAboutTitle;
            var version     = Assembly.GetEntryAssembly().GetName().Version;

            var deviceSep = _trayIcon.ContextMenu.MenuItems.Add("-");

            deviceSep.Name = _deviceSeparatorName;

            var feedbackItem = _trayIcon.ContextMenu.MenuItems.Add(EarTrumpet.Properties.Resources.ContextMenuSendFeedback);

            feedbackItem.Click += Feedback_Click;

            var aboutItem = _trayIcon.ContextMenu.MenuItems.Add(String.Format("{0} EarTrumpet {1} ...", aboutString, version));

            aboutItem.Click += About_Click;

            var exitItem = _trayIcon.ContextMenu.MenuItems.Add(EarTrumpet.Properties.Resources.ContextMenuExitTitle);

            exitItem.Click += Exit_Click;

            _trayIcon.MouseClick        += TrayIcon_MouseClick;
            _trayIcon.ContextMenu.Popup += ContextMenu_Popup;

            _trayIcon.Icon = _trayViewModel.TrayIcon;
            _trayIcon.Text = string.Concat("EarTrumpet - ", EarTrumpet.Properties.Resources.TrayIconTooltipText);

            _trayIcon.Visible = true;
        }
Example #3
0
 public void SetUp()
 {
     _authorizationService = A.Fake <IAuthorizationService>();
     _windowFactory        = A.Fake <IWindowFactory>();
     _applicationService   = A.Fake <IApplicationService>();
     _windowService        = A.Fake <IWindowService>();
     _trayViewModel        = new TrayViewModel(_authorizationService, _windowFactory, _applicationService, _windowService);
 }
Example #4
0
        public TrayIcon(TrayViewModel trayViewModel)
        {
            _trayViewModel = trayViewModel;
            _trayViewModel.PropertyChanged += TrayViewModel_PropertyChanged;

            _trayIcon             = new System.Windows.Forms.NotifyIcon();
            _trayIcon.MouseClick += TrayIcon_MouseClick;
            _trayIcon.Icon        = _trayViewModel.TrayIcon;
            _trayIcon.Text        = _trayViewModel.ToolTip;

            App.Current.Exit += App_Exit;
        }
Example #5
0
        private void closeViewModel(bool kill)
        {
            if (TrayIcon == null)
            {
                return;
            }

            TrayViewModel viewModel = TrayIcon.DataContext as TrayViewModel;

            if (viewModel == null)
            {
                return;
            }

            viewModel.DisconnectSessions(kill);
        }
Example #6
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            ErrorReportingService.Initialize();

            Trace.WriteLine("App Application_Startup");

            if (!SingleInstanceAppMutex.TakeExclusivity())
            {
                Trace.WriteLine("App Application_Startup TakeExclusivity failed");
                Current.Shutdown();
                return;
            }

            ((ThemeManager)Resources["ThemeManager"]).SetTheme(ThemeData.GetBrushData());

            PlaybackDevicesViewModel        = new DeviceCollectionViewModel(DataModelFactory.CreateAudioDeviceManager(AudioDeviceKind.Playback));
            PlaybackDevicesViewModel.Ready += MainViewModel_Ready;

            FlyoutViewModel = new FlyoutViewModel(PlaybackDevicesViewModel);
            FlyoutWindow    = new FlyoutWindow(FlyoutViewModel);

            TrayViewModel              = new TrayViewModel(PlaybackDevicesViewModel);
            TrayViewModel.LeftClick    = new RelayCommand(() => FlyoutViewModel.OpenFlyout(FlyoutShowOptions.Pointer));
            TrayViewModel.OpenMixer    = new RelayCommand(OpenMixer);
            TrayViewModel.OpenSettings = new RelayCommand(OpenSettings);

            _trayIcon = new TrayIcon(TrayViewModel);
            FlyoutWindow.DpiChanged += (_, __) => TrayViewModel.DpiChanged();

            HotkeyManager.Current.Register(SettingsService.Hotkey);
            HotkeyManager.Current.KeyPressed += (hotkey) =>
            {
                if (hotkey.Equals(SettingsService.Hotkey))
                {
                    FlyoutViewModel.OpenFlyout(FlyoutShowOptions.Keyboard);
                }
            };

            StartupUWPDialogDisplayService.ShowIfAppropriate();

            Trace.WriteLine($"App Application_Startup Exit");
        }
Example #7
0
        public MainWindow()
        {
            InitializeComponent();

            _deviceService     = new EarTrumpetAudioDeviceService();
            _viewModel         = new AudioMixerViewModel(new EarTrumpetAudioSessionService(), _deviceService);
            _trayViewModel     = new TrayViewModel(_deviceService);
            _trayIcon          = new TrayIcon(_trayViewModel);
            _trayIcon.Invoked += TrayIcon_Invoked;

            DataContext = _viewModel;

            CreateAndHideWindow();
            CheckandUpdateTray();

            // Move keyboard focus to the first element. Disabled this since it is ugly but not sure invisible
            // visuals are preferrable.
            // Activated += (s,e) => MoveFocus(new TraversalRequest(FocusNavigationDirection.First));

            SourceInitialized += (s, e) => UpdateTheme();
        }
Example #8
0
        public ActionResult Tray(TrayViewModel model)
        {
            if (ModelState.IsValid)
            {
                //编号条码不重复
                var db = new DbEntities <Tray>().SimpleClient;

                if (db.IsAny(tr => tr.TrayNo == model.TrayNo || tr.TrayCode == model.TrayCode))
                {
                    ModelState.AddModelError("TrayCode", "托盘编号或条码");
                }
                else
                {
                    //检验登录人身份,并获取对应ID
                    if (new IdentityAuth().GetCurUserID(HttpContext, out int curUserID))
                    {
                        Tray entity = model.InitAddTray(curUserID);

                        if (db.Insert(entity))
                        {
                            TempData["Msg"] = $"托盘 [{entity.TrayNo}] 添加成功";
                            return(RedirectToAction("Tray", "Warehouse"));
                        }
                        TempData["Msg"] = "添加失败";
                    }
                    else
                    {
                        TempData["Msg"] = "登录身份过期,请重新登录";
                    }
                }
            }

            SetSelectListItems.Container(this, model.Container);
            SetSelectListItems.TrayType(this, model.TrayType);

            return(View(model));
        }
Example #9
0
 public TrayWindow(TrayViewModel viewModel)
 {
     DataContext = viewModel;
     InitializeComponent();
 }
Example #10
0
 public ShellViewModel(UserContext userContext, ServersContainerViewModel serversContainerViewModel, LoadingViewModel loadingViewModel, LoginViewModel logingViewModel, RegistrationViewModel registerViewModel, HeaderBarViewModel headerViewModel, SettingsTabViewModel settingsViewModel, P2PModalViewModel p2PModalViewModel, CyberSecReconnectViewModel cyberSectReconnectViewModel, CyberSecModalViewModel cyberSecModalViewModel, AppSelectViewModel appSelectViewModel, IPersistedSettings settings, P2PTrafficStatusObserver p2PTrafficStatusObserver, MapViewModel mapViewModel, TrayViewModel trayViewModel, ExpiredMembershipViewModel expiredMembershipViewModel, ExpiredMembershipObserver expiredMembershipObserver, SubHeaderStripViewModel subHeaderStripViewModel, HeaderBarViewModel headerBarViewModel, AppWindowManager windowManager)
 {
     this._userContext                 = userContext;
     this._headerViewModel             = headerViewModel;
     this._settingsViewModel           = settingsViewModel;
     this._p2PModalViewModel           = p2PModalViewModel;
     this._cyberSectReconnectViewModel = cyberSectReconnectViewModel;
     this._cyberSecModalViewModel      = cyberSecModalViewModel;
     this._appSelectViewModel          = appSelectViewModel;
     this._settings = settings;
     this._serversContainerViewModel = serversContainerViewModel;
     this._mapViewModel      = mapViewModel;
     this._loadingViewModel  = loadingViewModel;
     this._loginViewModel    = logingViewModel;
     this._registerViewModel = registerViewModel;
     this.< SubHeaderStrip > k__BackingField                 = subHeaderStripViewModel;
     this.< HeaderBar > k__BackingField                      = headerBarViewModel;
     p2PTrafficStatusObserver.P2PTrafficRerouted            += new EventHandler(this.OnP2PTrafficRerouted);
     this._expiredMembershipViewModel                        = expiredMembershipViewModel;
     expiredMembershipObserver.ForegroundNotificationNeeded += new EventHandler(this.OnForegroundNotificationNeeded);
     this._windowManager = windowManager;
     this._userContext.add_UserAuthenticated(new EventHandler <UserEventArgs>(this.OnUserAuthenticated));
     this._userContext.add_UserLoggedIn(new EventHandler <UserEventArgs>(this.OnUserLoggedIn));
     this._userContext.add_UserLoggedOut(new EventHandler <UserEventArgs>(this.OnUserLoggedOut));
     this.< Tray > k__BackingField   = trayViewModel;
     this.Tray.ActivateAppRequested += new EventHandler(this.TrayOnActivateAppRequested);
     base.get_Items().AddRange(new Screen[]
     {
         serversContainerViewModel,
         mapViewModel,
         settingsViewModel
     });
 }
 public AddTrayWindow()
 {
     InitializeComponent();
     TrayViewModel = new TrayViewModel();
     DataContext   = TrayViewModel;
 }
Example #12
0
 public void SetViewModel(TrayViewModel viewModel)
 {
     this._viewModel = viewModel;
 }
Example #13
0
 public Session(TrayViewModel viewModel)
     : this()
 {
     SetViewModel(viewModel);
 }