public LoginModel(RootModel root, MainModel main, UpdateModel updateModel, LocalSettingsService settingsService, ConnectionService connectionService, NotificationService notificationService, IAppEnvironment environment, IdService idService) { Root = root; _settingsService = settingsService; _connectionService = connectionService; _notificationService = notificationService; _main = main; _updateModel = updateModel; _environment = environment; _idService = idService; var s = settingsService.Settings; SavePassword = s.SavePassword; UserName = s.UserName; Password = s.Password; UserRegistered = s.UserRegistered; Version = ClientVersionHelper.GetVersion(); DoLogin = async() => await LoginAsync(true); DoAnonymousLogin = async() => await LoginAsync(false); if (s.AutoLogon && s.SavePassword && s.UserRegistered) { _ = DoAutoLogin(); } }
public SourcesModel(ILocalVideoSourceManager localVideoSourceManager, ILocalAudioSourceManager localAudioSourceManager, CoreData coreData, LocalSettingsService localSettingsService, IWindowStateManager windowStateManager) { _localVideoSourceManager = localVideoSourceManager; _localAudioSourceManager = localAudioSourceManager; _coreData = coreData; _localSettingsService = localSettingsService; _windowStateManager = windowStateManager; _screenCaptureManager = ScreenCaptureManager.Instance; }
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(); } }); }
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(); }
/// <summary> /// Inject classes /// </summary> /// <param name="builder">Support chain</param> /// <returns></returns> public static AppBuilder SetupAppConfiguration(this AppBuilder builder, string[] args) { var serializerOption = new JsonSerializerOptions(); JsonExtension.GetAllConverters().ToList().ForEach(serializerOption.Converters.Add); serializerOption.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; var cfgService = new LocalSettingsService() { Options = serializerOption, OnLoad = data => { //decrypt }, OnSave = data => { //encrtypt } }; cfgService.Load(); Parser.Default.ParseArguments <StartupArgs>(args).WithParsed( opt => { cfgService.Config.RestAPIAddres = string.IsNullOrEmpty(opt.ServerAddres) ? cfgService.Config.RestAPIAddres : opt.ServerAddres; Console.WriteLine(cfgService.Config.RestAPIAddres); cfgService.Save(); }); Console.WriteLine(cfgService.Config.RestAPIAddres); var http = new RestClient(new HttpClientHandler()) { BaseAddress = new Uri(cfgService.Config.RestAPIAddres) }; //setup default factory ServiceFactory.Default.Client = http; ServiceFactory.Default.SerializerOptions = serializerOption; #region register services Locator.CurrentMutable.RegisterConstant(http, typeof(RestClient)); Locator.CurrentMutable.Register( ServiceFactory.Default.CreateService <AccountService>, typeof(IAccountService)); Locator.CurrentMutable.Register( ServiceFactory.Default.CreateService <TranslationService>, typeof(ITranslationService)); Locator.CurrentMutable.Register( ServiceFactory.Default.CreateService <LanguageService>, typeof(ILanguageService)); Locator.CurrentMutable.Register( ServiceFactory.Default.CreateService <ApiService>, typeof(ApiService)); Locator.CurrentMutable.RegisterConstant(cfgService, typeof(ILocalSettingsService)); #endregion Locator.CurrentMutable.RegisterViewsForViewModels(Assembly.GetExecutingAssembly()); cfgService.Save(); return(builder); }
public UpdateManager(IAppEnvironment environment, LocalSettingsService localSettingsService, IAppResources appResources) { _environment = environment; _localSettingsService = localSettingsService; _domain = appResources.AppData.Domain; }
public RandomAnimalModule(LocalSettingsService settings) { _catApiKey = settings.CatApiKey; _dogApiKey = settings.DogApiKey; }