예제 #1
0
        static void Options_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            var enabledCanged = e.PropertyName == nameof(SettingsManager.Options.MonitorsEnabled);
            var en            = SettingsManager.Options.MonitorsEnabled;
            var isElevated    = JocysCom.ClassLibrary.Security.PermissionHelper.IsElevated;

            // UDP Monitor Properties.
            if (e.PropertyName == nameof(SettingsManager.Options.UdpMonitorPort))
            {
                _UdpMonitor.PortNumber = SettingsManager.Options.UdpMonitorPort;
            }
            if (e.PropertyName == nameof(SettingsManager.Options.UdpMonitorEnabled) || enabledCanged)
            {
                if (SettingsManager.Options.UdpMonitorEnabled && en)
                {
                    _UdpMonitor.Start();
                }
                else
                {
                    _UdpMonitor.Stop();
                }
            }
            // Clipboard Monitor Properties.
            if (e.PropertyName == nameof(SettingsManager.Options.ClipboardMonitorInterval))
            {
                _ClipboardMonitor.CopyInterval = SettingsManager.Options.ClipboardMonitorInterval;
            }
            if (e.PropertyName == nameof(SettingsManager.Options.ClipboardMonitorEnabled) || enabledCanged)
            {
                if (SettingsManager.Options.ClipboardMonitorEnabled && en)
                {
                    _ClipboardMonitor.Start();
                }
                else
                {
                    _ClipboardMonitor.Stop();
                }
            }
            // Network Monitor Properties.
            if (e.PropertyName == nameof(SettingsManager.Options.NetworkMonitorCapturingType))
            {
                _NetworkMonitor.CapturingType = SettingsManager.Options.NetworkMonitorCapturingType;
            }
            if (e.PropertyName == nameof(SettingsManager.Options.NetworkMonitorEnabled) || enabledCanged)
            {
                if (SettingsManager.Options.NetworkMonitorEnabled && en && isElevated)
                {
                    _NetworkMonitor.Start();
                }
                else
                {
                    _NetworkMonitor.Stop();
                }
            }
            // Display Monitor Properties.
            if (e.PropertyName == nameof(SettingsManager.Options.DisplayMonitorInterval))
            {
                _DisplayMonitor.ScanInterval = SettingsManager.Options.DisplayMonitorInterval;
            }
            if (e.PropertyName == nameof(SettingsManager.Options.DisplayMonitorPrefix))
            {
                var colors = DisplayMonitor.ColorsFromRgbs(SettingsManager.Options.DisplayMonitorPrefix);
                _DisplayMonitor.SetColorPrefix(Basic.ColorsToBytes(colors, false));
            }
            if (e.PropertyName == nameof(SettingsManager.Options.DisplayMonitorEnabled) || enabledCanged)
            {
                if (SettingsManager.Options.DisplayMonitorEnabled && en)
                {
                    _DisplayMonitor.Start();
                }
                else
                {
                    _DisplayMonitor.Stop();
                }
            }

            if (e.PropertyName == nameof(SettingsManager.Options.AudioBitsPerSample) ||
                e.PropertyName == nameof(SettingsManager.Options.CacheAudioChannels))
            {
                var blockAlignment = (SettingsManager.Options.AudioBitsPerSample / 8) * (int)SettingsManager.Options.CacheAudioChannels;
                if (blockAlignment != SettingsManager.Options.CacheAudioBlockAlign)
                {
                    SettingsManager.Options.CacheAudioBlockAlign = blockAlignment;
                }
            }
        }