Exemple #1
0
        internal void SetRecordingManager(RecordingManager recording)
        {
            _recording = recording;

            recording.RecordingStarted  += ClearPolygon;
            recording.AudioLevelChanged += Recording_AudioLevelChanged;
        }
        private void RefreshDeviceMenu()
        {
            DeviceMenu.Items.Clear();
            var devices = RecordingManager.GetDeviceNames();

            for (var i = 0; i < devices.Length; i++)
            {
                var localI = i;
                var item   = new MenuItem
                {
                    Header = devices[i],
                };
                item.Click += (object sender, RoutedEventArgs e) => { _recording.DeviceIndex = localI; RefreshDeviceMenu(); };

                if (i == _recording.DeviceIndex)
                {
                    item.FontWeight = FontWeights.Bold;
                }

                DeviceMenu.Items.Add(item);
            }
        }
        public MainWindow()
        {
            InitializeComponent();
            DataContext = this;

            _recording = new RecordingManager();
            _recording.AudioLevelChanged += l =>
            {
                AudioLevel = (int)(100 * l);
                OnPropertyChanged(nameof(AudioLevel));
            };
            _recording.RecordingStarted += () => OnPropertyChanged(nameof(RecordText));
            _recording.RecordingStopped += () => OnPropertyChanged(nameof(RecordText));
            _recording.PlaybackStarted  += () => OnPropertyChanged(nameof(PlayText));
            _recording.PlaybackStopped  += () => OnPropertyChanged(nameof(PlayText));

            _fileWatcher.NotifyFilter = NotifyFilters.LastWrite;
            _fileWatcher.Changed     += FileWatcher_Changed;


            waveFormControl.SetRecordingManager(_recording);

            RefreshDeviceMenu();
        }