/// <summary> /// /// </summary> public WindowVolume() { main = ((App)System.Windows.Application.Current).main; model = main.model; this.DataContext = model; InitializeComponent(); viewmodel.SetBinding(this); // タイマーの生成 OpacityAnimationTimer.Interval = new TimeSpan(OPACITY_ANIMATION_RENDER_INTERVAL); OpacityAnimationTimer.Tick += OnOpacityAnimation; // Stopwatch stopwatch.Reset(); // ease. ease.addFrame(showDuration); ease.addFrame(visibleDuration); ease.addFrame(hideDuration); this.NoActiveWindow(); }
/// <summary> /// /// </summary> /// <param name="window"></param> /// <param name="main"></param> public void SetBinding(WindowOption window, VolumeWatcherMain main) { // 参照モデルの設定 model = main.model; // Command初期化 KeyboardHookCommand = new KeyboardHookCommand(main); RegisterStartupCommand.StartupName = model.StartupName; // Binding初期化 IsKeyHook = model.IsKeyHook; // ピークメータ表示用タイマ StatusTimer.Interval = new TimeSpan(PEAKMETER_RENDER_INTERVAL); StatusTimer.Tick += (o, el) => { var renderMeter = main.VolumeMonitor1.AudioDevice?.AudioMeterInformation; var captureMeter = main.CaptureMonitor.AudioDevice?.AudioMeterInformation; if (StatusTimer.IsEnabled) { RenderPeakValue = (int)Math.Round((renderMeter?.PeakValue ?? 0) * 100); CapturePeakValue = (int)Math.Round((captureMeter?.PeakValue ?? 0) * 100); } }; }
public KeyboardHookCommand(VolumeWatcherMain main) { this.main = main; this.KeyboardHooker = main.trayComponent.KeyboardHooker; var dict = new Dictionary <System.Windows.Input.Key, Action>() { { Key.OemComma, () => { // 音量- var device = main.VolumeMonitor1.AudioDevice; if (device == null || device.AudioEndpointVolume == null) { return; } device.AudioEndpointVolume.MasterVolumeLevelScalar -= Step; } }, { Key.OemPeriod, () => { // 音量+ var device = main.VolumeMonitor1.AudioDevice; if (device == null || device.AudioEndpointVolume == null) { return; } device.AudioEndpointVolume.MasterVolumeLevelScalar += Step; } }, { Key.M, () => { // Mute var device = main.VolumeMonitor1.AudioDevice; if (device == null || device.AudioEndpointVolume == null) { return; } device.AudioEndpointVolume.Mute = !device.AudioEndpointVolume.Mute; } }, { Key.K, () => { // 音量- var device = main.CaptureMonitor.AudioDevice; if (device == null || device.AudioEndpointVolume == null) { return; } device.AudioEndpointVolume.MasterVolumeLevelScalar -= Step; } }, { Key.L, () => { // 音量+ var device = main.CaptureMonitor.AudioDevice; if (device == null || device.AudioEndpointVolume == null) { return; } device.AudioEndpointVolume.MasterVolumeLevelScalar += Step; } }, { Key.J, () => { // Mute var device = main.CaptureMonitor.AudioDevice; if (device == null || device.AudioEndpointVolume == null) { return; } device.AudioEndpointVolume.Mute = !device.AudioEndpointVolume.Mute; } } }; foreach (var key in dict.Keys) { KeyboardHooker.AddShortcut(KeyboardHookComponent.GetMixedKeyFromKey(key, false, false, true), dict[key]); } }