Ejemplo n.º 1
0
        private static IconKind IconKindFromDeviceCollection(DeviceCollectionViewModel collectionViewModel)
        {
            if (collectionViewModel.Default != null)
            {
                switch (collectionViewModel.Default.IconKind)
                {
                case DeviceViewModel.DeviceIconKind.Mute:
                    return(IconKind.Muted);

                case DeviceViewModel.DeviceIconKind.Bar0:
                    return(IconKind.SpeakerZeroBars);

                case DeviceViewModel.DeviceIconKind.Bar1:
                    return(IconKind.SpeakerOneBar);

                case DeviceViewModel.DeviceIconKind.Bar2:
                    return(IconKind.SpeakerTwoBars);

                case DeviceViewModel.DeviceIconKind.Bar3:
                    return(IconKind.SpeakerThreeBars);

                default: throw new NotImplementedException();
                }
            }
            return(IconKind.NoDevice);
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
0
        protected HardwareAppBinding(DeviceCollectionViewModel deviceViewModel, IAudioDeviceManager audioDeviceManager)
        {
            _deviceCollectionViewModel = deviceViewModel;
            _audioDeviceManager        = audioDeviceManager;
            _commandControlMappings    = new List <CommandControlMappingElement>();

            _settings = StorageFactory.GetSettings();
        }
Ejemplo n.º 4
0
        public HardwareManager(DeviceCollectionViewModel deviceCollectionViewModel,
                               IAudioDeviceManager audioDeviceManager)
        {
            bindings = new Dictionary <Type, HardwareAppBinding>();

            RegisterAppBinding(new MidiAppBinding(deviceCollectionViewModel, audioDeviceManager));
            RegisterAppBinding(new DeejAppBinding(deviceCollectionViewModel, audioDeviceManager));

            Current = this;
        }
Ejemplo n.º 5
0
        public TaskbarIconSource(DeviceCollectionViewModel collection, AppSettings settings)
        {
            _collection = collection;
            _settings   = settings;

            _settings.UseLegacyIconChanged += (_, __) => CheckForUpdate();
            collection.TrayPropertyChanged += OnTrayPropertyChanged;

            OnTrayPropertyChanged();
        }
        public DeejAppBinding(DeviceCollectionViewModel deviceViewModel, IAudioDeviceManager audioDeviceManager) :
            base(deviceViewModel, audioDeviceManager)
        {
            Current    = this;
            lastValues = new Dictionary <CommandControlMappingElement, int>();

            DeejIn.AddGeneralCallback(DeejCallback);

            LoadSettings(SAVEKEY);

            foreach (var command in _commandControlMappings)
            {
                var config = (DeejConfiguration)command.hardwareConfiguration;
                DeejIn._StartListening(config.Port);
            }
        }
        public MidiAppBinding(DeviceCollectionViewModel deviceCollectionViewModel,
                              IAudioDeviceManager audioDeviceManager) : base(deviceCollectionViewModel, audioDeviceManager)
        {
            Current = this;

            MidiIn.AddGeneralCallback(MidiCallback);

            LoadSettings(SAVEKEY);

            _deviceMapping = new ConcurrentDictionary <string, string>();

            foreach (var device in MidiIn.GetAllDevices())
            {
                _deviceMapping[device.Id] = device.Name;
            }

            SubscribeToDevices();
        }
Ejemplo n.º 8
0
        private void ContinueStartup()
        {
            ((UI.Themes.Manager)Resources["ThemeManager"]).Load();

            _settings = new AppSettings();
            _settings.FlyoutHotkeyTyped   += () => FlyoutViewModel.OpenFlyout(InputType.Keyboard);
            _settings.MixerHotkeyTyped    += () => _mixerWindow.OpenOrClose();
            _settings.SettingsHotkeyTyped += () => _settingsWindow.OpenOrBringToFront();
            _mixerWindow                    = new WindowHolder(CreateMixerExperience);
            _settingsWindow                 = new WindowHolder(CreateSettingsExperience);
            PlaybackDevicesViewModel        = new DeviceCollectionViewModel(DataModel.WindowsAudio.WindowsAudioFactory.Create(DataModel.WindowsAudio.AudioDeviceKind.Playback), _settings);
            PlaybackDevicesViewModel.Ready += (_, __) => CompleteStartup();
            PlaybackDevicesViewModel.TrayPropertyChanged += () => UpdateTrayTooltipAndIcon();
            FlyoutViewModel = new FlyoutViewModel(PlaybackDevicesViewModel, () => _trayIcon.SetFocus());
            FlyoutWindow    = new FlyoutWindow(FlyoutViewModel);

            CreateTrayExperience();
        }
        public EarTrumpetHardwareControlsPageViewModel() : base(null)
        {
            _settings = Addon.Current.Settings;
            _devices  = Addon.Current.DeviceCollection;
            Glyph     = "\xE9A1";
            Title     = Properties.Resources.HardwareControlsTitle;

            NewControlCommand             = new RelayCommand(NewControl);
            EditSelectedControlCommand    = new RelayCommand(EditSelectedControl);
            DeleteSelectedControlCommand  = new RelayCommand(DeleteSelectedControl);
            NewFromSelectedControlCommand = new RelayCommand(NewFromSelectedControl);

            _hardwareSettingsWindow = new WindowHolder(CreateHardwareSettingsExperience);

            UpdateCommandControlsList();

            // The command controls list should have no item selected on startup.
            SelectedIndex = -1;
        }
Ejemplo n.º 10
0
        private void ContinueStartup()
        {
            ((UI.Themes.Manager)Resources["ThemeManager"]).Load();

            var deviceManager = WindowsAudioFactory.Create(AudioDeviceKind.Playback);

            deviceManager.Loaded += (_, __) => CompleteStartup();
            CollectionViewModel   = new DeviceCollectionViewModel(deviceManager, _settings);

            _trayIcon = new ShellNotifyIcon(new TaskbarIconSource(CollectionViewModel, _settings));
            Exit     += (_, __) => _trayIcon.IsVisible = false;
            CollectionViewModel.TrayPropertyChanged += () => _trayIcon.SetTooltip(CollectionViewModel.GetTrayToolTip());

            _flyoutViewModel = new FlyoutViewModel(CollectionViewModel, () => _trayIcon.SetFocus());
            FlyoutWindow     = new FlyoutWindow(_flyoutViewModel);
            // Initialize the FlyoutWindow last because its Show/Hide cycle will pump messages, causing UI frames
            // to be executed, breaking the assumption that startup is complete.
            FlyoutWindow.Initialize();
        }
        public HardwareSettingsViewModel(DeviceCollectionViewModel devices, EarTrumpetHardwareControlsPageViewModel earTrumpetHardwareControlsPageViewModel)
        {
            // Set default commands.
            _commands.Add(Properties.Resources.AudioDeviceVolumeText);
            _commands.Add(Properties.Resources.AudioDeviceMuteText);
            _commands.Add(Properties.Resources.ApplicationVolumeText);
            _commands.Add(Properties.Resources.ApplicationMuteText);
            _commands.Add(Properties.Resources.CycleDefaultDevices);

            _devices          = devices;
            _hardwareControls = earTrumpetHardwareControlsPageViewModel;

            SelectControlCommand             = new RelayCommand(SelectControl);
            SaveCommandControlMappingCommand = new RelayCommand(SaveCommandControlMapping);

            switch (_hardwareControls.ItemModificationWay)
            {
            case EarTrumpetHardwareControlsPageViewModel.ItemModificationWays.NEW_EMPTY:

                // Set default command.
                SelectedCommand = Properties.Resources.AudioDeviceVolumeText;

                // Set default device type.
                SelectedDeviceType = "MIDI";

                // Set default selection.
                SelectedControl = Properties.Resources.NoControlSelectedMessage;

                break;

            case EarTrumpetHardwareControlsPageViewModel.ItemModificationWays.EDIT_EXISTING:
            case EarTrumpetHardwareControlsPageViewModel.ItemModificationWays.NEW_FROM_EXISTING:
                var selectedMappingElement = HardwareManager.Current.GetCommandControlMappings()[_hardwareControls.SelectedIndex];

                FillForm(selectedMappingElement);
                break;

            default:
                // Do not fill widgets.
                break;
            }
        }
Ejemplo n.º 12
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");
        }
        public void OnAddonEvent(AddonEventKind evt)
        {
            if (evt == AddonEventKind.InitializeAddon)
            {
                Current = this;

                DeviceCollection  = ((App)App.Current).CollectionViewModel;
                m_hardwareManager = new HardwareManager(DeviceCollection, WindowsAudioFactory.Create(AudioDeviceKind.Playback));


                // Monitor the EarTrumpet flyout so we don't show when the flyout is showing.
                _flyoutViewModel = (FlyoutViewModel)((App)Application.Current).FlyoutWindow.DataContext;
                _flyoutViewModel.StateChanged += OnFlyoutViewModelStateChanged;

                // Create a window to use as OSD.
                _osdWindowViewModel = new OSDWindowViewModel();
                _osdWindow          = new OSDWindow(_osdWindowViewModel);
                _osdWindow.Initialize();

                // Listen to events and then present the active ViewModel to the OSD window.
                PlaybackDataModelHost.Current.AppPropertyChanged    += OnAppPropertyChanged;
                PlaybackDataModelHost.Current.DevicePropertyChanged += OnDevicePropertyChanged;
            }
        }