コード例 #1
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public WindowOption()
        {
            main  = ((App)System.Windows.Application.Current).main;
            model = main.model;

            InitializeComponent();

            viewmodel.SetBinding(this, main);

            RenderMeter.DataContext       = viewmodel;       // peakmeterはviewmodelを参照
            CaptureMeter.DataContext      = viewmodel;       // peakmeterはviewmodelを参照
            ScreenSaverToggle.DataContext = viewmodel;
            chkIsStartUp.DataContext      = viewmodel;
            chkIsKeyHook.DataContext      = viewmodel;

            //{
            //    chkIsKeyHook.CommandParameter = chkIsKeyHook;
            //    chkIsKeyHook.Command          = viewmodel.KeyboardHookCommand;
            //}


            this.DataContext = model;                        // それ以外はmodelを参照

            micPlayer.OnStateChanged += MicPlayter_StateChanged;

            // 高速化に寄与するかな
            //this.Descendants().OfType<Freezable>().ToList().Where(e => e.CanFreeze).ToList().ForEach(e => e.Freeze());
            this.Descendants().OfType <Freezable>().Where(e => e.CanFreeze).ForEach(e => e.Freeze());
        }
コード例 #2
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public VolumeWatcherMain()
        {
            var app = System.Windows.Application.Current;

            // Windowをクローズしてもアプリケーションが終了しないように設定しておく。
            app.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;  // Exitを明示的にCallすることでアプリケーションが終了するように設定

            // VolumeMonitor初期化
            VolumeMonitor1 = new VolumeMonitor(EDataFlow.eRender, ERole.eConsole);
            VolumeMonitor1.initDevice();

            CaptureMonitor = new VolumeMonitor(EDataFlow.eCapture, ERole.eConsole);
            CaptureMonitor.initDevice();

            // Model初期化
            model = new VolumeWatcherModel();
            model.LoadSettings();
            if (model.IsMicMute)
            {
                if (CaptureMonitor.AudioDevice != null && CaptureMonitor.AudioDevice.AudioEndpointVolume != null)
                {
                    CaptureMonitor.AudioDevice.AudioEndpointVolume.Mute = true;
                }
            }

            var VolumeMonitorViewModel1 = new VolumeMonitorViewModel(VolumeMonitor1, CaptureMonitor, model);
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        public void Initialize()
        {
            main         = ((App)System.Windows.Application.Current).main;
            model        = main.model;
            this.ToolTip = model.StartupName;

            this.DataContext = model;
        }
コード例 #4
0
        public VolumeMonitorViewModel(VolumeMonitor renderMonitor, VolumeMonitor captureMonitor, VolumeWatcherModel model)
        {
            Model = model;

            renderMonitor.OnVolumeNotification   += OnVolumeChanged;
            renderMonitor.OnDefaultDeviceChanged += OnDeviceChanged;

            captureMonitor.OnVolumeNotification   += OnRecVolumeChanged;
            captureMonitor.OnDefaultDeviceChanged += OnRecDeviceChanged;

            Model.SetDeviceInfo(renderMonitor.AudioDevice);
            Model.SetRecDeviceInfo(captureMonitor.AudioDevice);
        }
コード例 #5
0
        /// <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();
        }
コード例 #6
0
        /// <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);
                }
            };
        }