/// <summary> /// Initializes a new instance of the <see cref="ConfigurationViewModel"/> class. /// </summary> public ConfigurationViewModel(ISettingsService settingsService, IOpenHAB openHabsdk, ILogger <ConfigurationViewModel> logger, Settings settings) : base(new object()) { _settingsService = settingsService; _logger = logger; _settings = settings; _localConnection = new ConnectionDialogViewModel(_settings.LocalConnection, openHabsdk, OpenHABHttpClientType.Local); _localConnection.PropertyChanged += ConnectionPropertyChanged; _remoteConnection = new ConnectionDialogViewModel(_settings.RemoteConnection, openHabsdk, OpenHABHttpClientType.Remote); _remoteConnection.PropertyChanged += ConnectionPropertyChanged; _isRunningInDemoMode = _settings.IsRunningInDemoMode; _showDefaultSitemap = _settings.ShowDefaultSitemap; _useSVGIcons = _settings.UseSVGIcons; _startAppMinimized = _settings.StartAppMinimized; _notificationsEnable = _settings.NotificationsEnable; _appLanguages = InitalizeAppLanguages(); _selectedAppLanguage = _appLanguages.FirstOrDefault(x => string.Compare(x.Code, _settings.AppLanguage, StringComparison.InvariantCultureIgnoreCase) == 0); PropertyChanged += ConfigurationViewModel_PropertyChanged; }
/// <summary> /// Initializes a new instance of the <see cref="MainViewModel"/> class. /// </summary> /// <param name="openHabsdk">The OpenHAB SDK object.</param> /// <param name="settingsService">Setting service instance.</param> /// <param name="logger">Logger class instance.</param> public MainViewModel(IOpenHAB openHabsdk, ISettingsService settingsService, ILogger <MainViewModel> logger) : base(new object()) { _logger = logger; CurrentWidgets = new ObservableCollection <OpenHABWidget>(); _openHabsdk = openHabsdk; _settingsService = settingsService; _feedbackLauncher = StoreServicesFeedbackLauncher.GetDefault(); _cancellationTokenSource = new CancellationTokenSource(); Messenger.Default.Register <TriggerCommandMessage>(this, async msg => await TriggerCommand(msg).ConfigureAwait(false)); Messenger.Default.Register <WidgetClickedMessage>(this, msg => OnWidgetClicked(msg.Widget)); }
/// <summary> /// Initializes a new instance of the <see cref="MainViewModel"/> class. /// </summary> /// <param name="openHabsdk">The OpenHAB SDK object</param> public MainViewModel(IOpenHAB openHabsdk) { _openHabsdk = openHabsdk; MessengerInstance.Register <SettingsUpdatedMessage>(this, async msg => { await _openHabsdk.ResetConnection(); await LoadData(); }); MessengerInstance.Register <TriggerCommandMessage>(this, async msg => await TriggerCommand(msg)); #pragma warning disable 4014 LoadData(); #pragma warning restore 4014 }
/// <summary> /// Initializes a new instance of the <see cref="ConnectionDialogViewModel"/> class. /// </summary> /// <param name="connectionConfig">The connection configuration.</param> /// <param name="openHabsdk">OpenHABSDK class.</param> public ConnectionDialogViewModel(OpenHABConnection connectionConfig, IOpenHAB openHabsdk, OpenHABHttpClientType type) : base(connectionConfig) { _openHabsdk = openHabsdk; _type = type; List <ConnectionProfileViewModel> list = new List <ConnectionProfileViewModel>(Settings.ConnectionProfiles.Where(x => x.Type == _type).OrderBy(x => x.Id).Select(x => new ConnectionProfileViewModel(x))); _profiles = new ObservableCollection <ConnectionProfileViewModel>(list); if (Model != null) { _profile = list.FirstOrDefault(x => x.Id == Model.Profile.Id); } }
/// <summary> /// Initializes a new instance of the <see cref="MainViewModel"/> class. /// </summary> /// <param name="openHabsdk">The OpenHAB SDK object</param> public MainViewModel(IOpenHAB openHabsdk) { CurrentWidgets = new ObservableCollection <OpenHABWidget>(); _openHabsdk = openHabsdk; MessengerInstance.Register <SettingsUpdatedMessage>(this, async msg => { if (await _openHabsdk.ResetConnection()) { await LoadData(); } }); MessengerInstance.Register <TriggerCommandMessage>(this, async msg => await TriggerCommand(msg)); MessengerInstance.Register <WidgetClickedMessage>(this, msg => OnWidgetClicked(msg.Widget)); #pragma warning disable 4014 LoadData(); #pragma warning restore 4014 }
/// <summary> /// Initializes a new instance of the <see cref="ConnectionDialogViewModel"/> class. /// </summary> /// <param name="connectionConfig">The connection configuration.</param> /// <param name="openHabsdk">OpenHABSDK class.</param> /// <param name="type">Defines if openHAB instance is local or remote.</param> public ConnectionDialogViewModel(OpenHABConnection connectionConfig, IOpenHAB openHabsdk, OpenHABHttpClientType type) : base(connectionConfig) { _openHabsdk = openHabsdk; _type = type; _connectionState = OpenHABUrlState.Unknown; List <ConnectionProfileViewModel> list = new List <ConnectionProfileViewModel>(Settings.ConnectionProfiles.Where(x => x.Type == _type).OrderBy(x => x.Id).Select(x => new ConnectionProfileViewModel(x))); _profiles = new ObservableCollection <ConnectionProfileViewModel>(list); if (Model != null) { _profile = list.FirstOrDefault(x => x.Id == Model.Profile.Id); } if (!string.IsNullOrEmpty(Model?.Url)) { CheckConnectionSettings(Model.Url); } }
/// <summary> /// Initializes a new instance of the <see cref="SitemapViewModel"/> class. /// </summary> /// <param name="model">Model class for view model.</param> public SitemapViewModel(OpenHABSitemap model) : base(model) { _widgets = new ObservableCollection <OpenHABWidget>(); _openHabsdk = (IOpenHAB)DIService.Instance.Services.GetService(typeof(IOpenHAB)); }
/// <summary>Initializes a new instance of the <see cref="ItemManager" /> class.</summary> public ItemManager(IOpenHAB openHABClient) { _nameToStateDictionary = new Dictionary <string, OpenHABItem>(); _openHABClient = openHABClient; }