Ejemplo n.º 1
0
        public MainIndicatorsModel(CoreData coreData,
                                   StreamSettingsModel streamSettings,
                                   ICpuService cpuService // for precreation
                                   )
        {
            _coreData       = coreData;
            _streamSettings = streamSettings;

            _coreData.Subscriptions.SubscribeForProperties <IIndicatorCpu>(s => s.Load, (o, c, p) => Refresh(o, (d, i) => d.Cpu.ChartModel.AddValue(i.Load, 100)));
            _coreData.Subscriptions.SubscribeForAnyProperty <IIndicatorCpu>((o, c, p, _) => Refresh(o, RefreshCpu));

            _coreData.Subscriptions.SubscribeForProperties <IIndicatorCloudOut>(s => s.Bitrate, (o, c, p) => Refresh(o, (d, i) => d.CloudOut.ChartModel.AddValue(i.Bitrate / 1000.0, _coreData.Settings.Bitrate / 1000.0)));
            _coreData.Subscriptions.SubscribeForAnyProperty <IIndicatorCloudOut>((o, c, p, _) => Refresh(o, RefreshCloudOut));


            _coreData.Subscriptions.SubscribeForProperties <IIndicatorCloudIn>(s => s.Bitrate, (o, c, p) => Refresh(o, (d, i) => d.CloudIn.ChartModel.AddValue(i.Bitrate / 1000.0, _coreData.Settings.Bitrate / 1000.0)));
            _coreData.Subscriptions.SubscribeForAnyProperty <IIndicatorCloudIn>((o, c, p, _) => Refresh(o, RefreshCloudIn));

            _coreData.Subscriptions.SubscribeForProperties <IIndicatorEncoder>(s => s.State, (o, c, p) => Refresh(o, RefreshEncoderState));
            _coreData.Subscriptions.SubscribeForProperties <IIndicatorEncoder>(s => s.Data, (o, c, p) => Refresh(o, RefreshEncoderData));

            _coreData.Subscriptions.SubscribeForProperties <IChannel>(s => s.Bitrate, (o, c, p) => RefreshChannel(o));
            _coreData.Subscriptions.SubscribeForProperties <IChannel>(s => s.State, (o, c, p) => RefreshChannel(o));

            _coreData.Subscriptions.SubscribeForProperties <IDevice>(s => s.State, (o, c, p) => RefreshDevicesStates(o));

            _coreData.Subscriptions.SubscribeForProperties <IIndicatorVpn>(s => s.Sent, (o, c, p) => Refresh(o, (m, i) => m.Vpn.ChartModel.AddValue(i.Sent / 1000.0, 10)));
            _coreData.Subscriptions.SubscribeForProperties <IIndicatorVpn>(s => s.Received, (o, c, p) => Refresh(o, (m, i) => m.Vpn.Received.AddValue(i.Received / 1000.0, 10)));
            _coreData.Subscriptions.SubscribeForProperties <IIndicatorVpn>(s => s.State, (o, c, p) => Refresh(o, RefreshVpnState));
        }
 public TranscodingModel(CoreData coreData, StreamSettingsModel streamSettings, ConnectionService connectionService, IAppResources appResources)
 {
     CoreData           = coreData;
     StreamSettings     = streamSettings;
     _connectionService = connectionService;
     _appResources      = appResources;
 }
        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();
                }
            });
        }
Ejemplo n.º 4
0
        public MainModel(RootModel root,
                         MainTargetsModel targets,
                         MainSettingsModel settings,
                         SourcesModel sources,
                         StreamSettingsModel streamSettings,
                         MainStreamerModel streamer,
                         MainIndicatorsModel indicators,
                         MainVpnModel vpn,
                         MainAboutModel about,
                         AudioModel audio,
                         HubConnectionService hubConnectionService,
                         IWindowStateManager windowStateManager,
                         IAppEnvironment environment,
                         CoreData coreData,
                         StateLoggerService stateLoggerService,
                         LocalSettingsService localSettingsService,
                         IUpdateManager updateManager,
                         TransientMessageModel transientMessageModel,
                         IAppResources appResources,
                         SceneEditingModel sceneEditingModel,
                         ResourceService resourceService)
        {
            Root                  = root;
            Targets               = targets;
            Settings              = settings;
            Sources               = sources;
            StreamSettings        = streamSettings;
            Streamer              = streamer;
            Indicators            = indicators;
            Vpn                   = vpn;
            About                 = about;
            Audio                 = audio;
            _hubConnectionService = hubConnectionService;
            _windowStateManager   = windowStateManager;
            _environment          = environment;
            _coreData             = coreData;
            _stateLoggerService   = stateLoggerService;
            _localSettingsService = localSettingsService;
            _updateManager        = updateManager;
            TransientMessage      = transientMessageModel;
            _appResources         = appResources;
            SceneEditing          = sceneEditingModel;
            _resourceService      = resourceService;
            _serverClient         = new ModelClient {
                Filter = new FilterConfigurator(true).Build()
            };
            _coreData.GetManager().Register(_serverClient);
            _serverClient.SerializeAndClearChanges();

            _coreData.Subscriptions.OnChangeForSubscriptions = async() => await ProcessLocalOrRemoteChange();

            _coreData.Subscriptions.OnLocalChange = async() => await ProcessLocalChange();
        }
Ejemplo n.º 5
0
        public SceneEditingModel(CoreData coreData, SourcesModel sources, IAppEnvironment environment, ResourceService resourceService, IImageHelper imageHelper, StreamSettingsModel streamSettings)
        {
            CoreData        = coreData;
            Sources         = sources;
            Environment     = environment;
            ResourceService = resourceService;
            ImageHelper     = imageHelper;
            _streamSettings = streamSettings;
            AddLayer        = SelectAddLayer;

            Close = DoClose;
        }