/// <summary>Converts the specified value.</summary> /// <param name="value">The value.</param> /// <param name="targetType">Type of the target.</param> /// <param name="parameter">The parameter.</param> /// <param name="language">The language.</param> /// <returns>Returns a glyph for an url state</returns> public object Convert(object value, Type targetType, object parameter, string language) { OpenHABUrlState state = (OpenHABUrlState)value; _stateToGlyphMapping.TryGetValue(state, out string glyph); return(glyph); }
/// <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); } }