private void NotificationNotif(object sender, EventArgs e) { if (DahuNotification != null) { switch (DahuNotification.Type) { case NotificationType.Info: items.Add(CreateToastNotif("#FF01cfe9", "icon")); break; case NotificationType.Negative: items.Add(CreateToastNotif("#FFF13C4F", "icon")); break; case NotificationType.Positive: items.Add(CreateToastNotif("#FF01bb55", "icon")); break; case NotificationType.Warning: items.Add(CreateToastNotif("#FFfabd51", "icon")); break; } DahuNotification = null; DahuNotificationTextBox.Text = ""; DahuNotificationsList.ItemsSource = null; DahuNotificationsList.ItemsSource = items; } }
//TODO : detecter le language pour pouvoir charger le bon xml selon la langue // XML tuto: http://www.c-sharpcorner.com/article/read-xml-file-in-windows-10-universal-app/ static private void InitUserInterfaceStatusDico() { UserInterfaceStatusDico = new Dictionary <string, DahuNotification>(); string pathToXml = Path.Combine(Package.Current.InstalledLocation.Path, "Strings\\" + Languages.French.Value + "\\UserInterfaceStatus.xml"); XDocument UserInterfaceStatusXML = XDocument.Load(pathToXml); foreach (XElement elem in UserInterfaceStatusXML.Descendants("status")) { NotificationType elemType = new NotificationType(); switch (elem.Attribute("type").Value) { case "Positive": elemType = NotificationType.Positive; break; case "Negative": elemType = NotificationType.Negative; break; case "Info": elemType = NotificationType.Info; break; case "Warning": elemType = NotificationType.Warning; break; } DahuNotification notif = new DahuNotification { Value = elem.Attribute("value").Value, PropertyName = elem.Attribute("varName").Value, Type = elemType }; UserInterfaceStatusDico.Add(elem.Attribute("key").Value, notif); } }