コード例 #1
0
        public MainSettingsModel(LocalSettingsService localSettings, CoreData coreData, StreamSettingsModel streamSettings, ConnectionService connectionService,
                                 TranscodingModel transcoding)
        {
            CoreData              = coreData;
            StreamSettings        = streamSettings;
            Transcoding           = transcoding;
            _connectionService    = connectionService;
            AutoLogon.SilentValue = localSettings.Settings.AutoLogon; // TODO: what is is not registred and not save password
            AutoLogon.OnChange    = async(o, n) => await localSettings.ChangeSettingsUnconditionally(s => s.AutoLogon = n);

            CurrentStreamingToCloudBehavior.Value = StreamingToCloudBehaviors.First(s => s.Value == default);
            CurrentEncoderType.Value     = EncoderTypes.First(s => s.Value == default);
            CurrentEncoderQuality.Value  = EncoderQualities.First(s => s.Value == default);
            CurrentTopMostMode.Value     = TopMostModes.First(s => s.Value == TopMostMode.WhenCompact);
            CurrentVpnBehavior.Value     = VpnBehaviors.First(s => s.Value == default);
            CurrentRendererType.Value    = RendererTypes.First(s => s.Value == default);
            CurrentBlenderType.Value     = BlenderTypes.First(s => s.Value == default);
            CurrentRecordingFormat.Value = RecordingFormats.First(s => s.Value == default);

            CurrentStreamingToCloudBehavior.OnChange = (o, n) => coreData.Settings.StreamingToCloud = n.Value;
            CurrentEncoderType.OnChange    = (o, n) => coreData.Settings.EncoderType = n.Value;
            CurrentEncoderQuality.OnChange = (o, n) => coreData.Settings.EncoderQuality = n.Value;
            CurrentTopMostMode.OnChange    = (o, n) =>
            {
                coreData.ThisDevice.DeviceSettings.DisableTopMost      = TopMostModeConverter.GetDisableTopMost(n.Value);
                coreData.ThisDevice.DeviceSettings.TopMostExtendedMode = TopMostModeConverter.GetTopMostExtendedMode(n.Value);
            };
            CurrentRecordingFormat.OnChange    = (o, n) => coreData.Settings.RecordingFormat = n.Value;
            CurrentVpnBehavior.OnChange        = (o, n) => coreData.ThisDevice.DeviceSettings.VpnBehavior = n.Value;
            CurrentRendererType.OnChange       = (o, n) => coreData.ThisDevice.DeviceSettings.RendererType = n.Value;
            CurrentBlenderType.OnChange        = (o, n) => coreData.ThisDevice.DeviceSettings.BlenderType = n.Value;
            HardwareAdapter.OnChange           = (o, n) => coreData.ThisDevice.DeviceSettings.RendererAdapter = n;
            PreferNalHdr.OnChange              = (o, n) => coreData.Settings.PreferNalHdr = n;
            EnableQsvNv12Optimization.OnChange = (o, n) => coreData.Settings.DisableQsvNv12Optimization = !n;

            CoreData.Subscriptions.SubscribeForProperties <ISettings>(s => s.StreamingToCloud, (s, c, p) => CurrentStreamingToCloudBehavior.SilentValue = StreamingToCloudBehaviors.FirstOrDefault(r => r.Value == CoreData.Settings.StreamingToCloud));
            CoreData.Subscriptions.SubscribeForProperties <ISettings>(s => s.EncoderType, (s, c, p) => CurrentEncoderType.SilentValue       = EncoderTypes.FirstOrDefault(r => r.Value == CoreData.Settings.EncoderType));
            CoreData.Subscriptions.SubscribeForProperties <ISettings>(s => s.EncoderQuality, (s, c, p) => CurrentEncoderQuality.SilentValue = EncoderQualities.FirstOrDefault(r => r.Value == CoreData.Settings.EncoderQuality));
            CoreData.Subscriptions.SubscribeForProperties <ISettings>(s => s.PreferNalHdr, (s, c, p) => PreferNalHdr.SilentValue            = CoreData.Settings.PreferNalHdr);
            CoreData.Subscriptions.SubscribeForProperties <ISettings>(s => s.DisableQsvNv12Optimization, (s, c, p) => EnableQsvNv12Optimization.SilentValue = !CoreData.Settings.DisableQsvNv12Optimization);
            CoreData.Subscriptions.SubscribeForProperties <ISettings>(s => s.RecordingFormat, (s, c, p) => CurrentRecordingFormat.SilentValue = RecordingFormats.FirstOrDefault(r => r.Value == CoreData.Settings.RecordingFormat));

            CoreData.Subscriptions.SubscribeForProperties <IDeviceSettings>(s => s.DisableTopMost, (s, c, p) => UpdateTopMost());
            CoreData.Subscriptions.SubscribeForProperties <IDeviceSettings>(s => s.TopMostExtendedMode, (s, c, p) => UpdateTopMost());
            CoreData.Subscriptions.SubscribeForProperties <IDeviceSettings>(s => s.VpnBehavior, (s, c, p) => CurrentVpnBehavior.SilentValue   = VpnBehaviors.FirstOrDefault(r => r.Value == CoreData.ThisDevice.DeviceSettings.VpnBehavior));
            CoreData.Subscriptions.SubscribeForProperties <IDeviceSettings>(s => s.RendererType, (s, c, p) => CurrentRendererType.SilentValue = RendererTypes.FirstOrDefault(r => r.Value == CoreData.ThisDevice.DeviceSettings.RendererType));
            CoreData.Subscriptions.SubscribeForProperties <IDeviceSettings>(s => s.BlenderType, (s, c, p) => CurrentBlenderType.SilentValue   = BlenderTypes.FirstOrDefault(r => r.Value == CoreData.ThisDevice.DeviceSettings.BlenderType));
            CoreData.Subscriptions.SubscribeForProperties <IDeviceSettings>(s => s.RendererAdapter, (s, c, p) =>
            {
                if (HardwareAdapters != null)
                {
                    HardwareAdapter.SilentValue = HardwareAdapters.Contains(CoreData.ThisDevice.DeviceSettings.RendererAdapter) ? CoreData.ThisDevice.DeviceSettings.RendererAdapter : HardwareAdapters.FirstOrDefault();
                }
            });
        }
コード例 #2
0
        public MainTargetsModel(StaticFilesCacheService staticFilesCacheService, CoreData coreData, ConnectionService connectionService, IAppResources resources,
                                TranscodingModel transcoding)
        {
            _staticFilesCacheService = staticFilesCacheService;
            CoreData           = coreData;
            _connectionService = connectionService;
            _resources         = resources;

            AppData     = resources.AppData;
            Transcoding = transcoding;

            CustomTarget = CoreData.Create <ITarget>(s =>
            {
                s.Flags  = TargetFlags.Key | TargetFlags.Url;
                s.Name   = "Custom";
                s.WebUrl = "";
            });
        }