public DataLoadedEventArgs(Model datamodel) { DataModel = datamodel; }
private void HandleDataResponse(string data) { try { var xml = XDocument.Parse(data); var rootNode = xml.Root; var active = (rootNode.Descendants("ACTIVE").ToList().Count > 0) ? rootNode.Descendants("ACTIVE").ToList()[0].Value : string.Empty; var mountNodes = rootNode.Descendants("MOUNT").ToList(); var aboutNode = rootNode.Descendants("ABOUT").ToList()[0]; var gui = int.Parse(rootNode.Element("GUISTATE").Value); var emergancy = int.Parse(rootNode.Element("EMERGENCY").Value); var tray = int.Parse(rootNode.Element("TRAYSTATE").Value); var m = new Model(gui, emergancy, tray); m.Active = active; foreach (var mountNode in mountNodes) { var name = mountNode.Attribute("NAME").Value; var mount = m.AddMount(name); var isoNodes = mountNode.Elements(); foreach (var isoNode in isoNodes) { var title = isoNode.Element("TITLE").Value; var id = isoNode.Element("ID").Value; mount.AddIso(title, id, (!string.IsNullOrEmpty(active) && id == active)); } } foreach (var element in aboutNode.Elements()) { var name = element.Attribute("NAME").Value; var value = element.Value; m.AddAbout(name, value); } OnDataLoaded(m); } catch (Exception e) { HandleError(ErrorState.ParseError, e.Message); } }
private void OnDataLoaded(Model datamodel) { EventHandler<DataLoadedEventArgs> handler = DataLoaded; if (handler != null) handler(this, new DataLoadedEventArgs(datamodel)); }