private static void ScoreSourceChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { NoteViewer viewer = obj as NoteViewer; var oldScore = args.OldValue as Score; var score = args.NewValue as Score; if (oldScore != null) { oldScore.Safety.BoundControl = null; } Score.SanityCheck(score, viewer); viewer.RenderOnCanvas(score); }
private static void XmlSourceChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { NoteViewer viewer = obj as NoteViewer; string xmlSource = args.NewValue as string; XDocument xmlDocument = XDocument.Parse(xmlSource); //Apply transformations: if (viewer.XmlTransformations != null) { foreach (var transformation in viewer.XmlTransformations) { xmlDocument = transformation.Parse(xmlDocument); } } MusicXmlParser parser = new MusicXmlParser(); var score = parser.Parse(xmlDocument); viewer.RenderOnCanvas(score); }