/// <summary> /// Trigger reloading the data from database for every control /// </summary> /// <param name="sender"></param> private void ReloadDevicesData(string sender) { ReloadFromDatabaseMessage message = new ReloadFromDatabaseMessage { subscribedCameras = subscribedCameras, subscribedLabels = subscribedLabels, subscribedSwitches = subscribedSwitches }; Messenger.Default.Send(message, "getLastDatabaseValue"); }
/// <summary> /// This function will load data from the database about all the elements so they will show the value after app reset /// </summary> /// <param name="elements">Elements whitch data should be loaded</param> void LoadLastDatabaseData(ReloadFromDatabaseMessage elements) { if (databaseData != null) { foreach (SubscribedLabel subscribedLabel in elements.subscribedLabels) { DatabaseData databaseEntry = databaseData.Where(x => x.Topic == subscribedLabel.Topic).OrderByDescending(d => d.Message_recieved).FirstOrDefault(); if (databaseEntry != null) { ChangeLabelValue(new UpdateLabelMessage { subscribedLabel = subscribedLabel, value = databaseEntry.Value }); } } } }