private void OnOpenButtonClick(object sender, RoutedEventArgs e)
        {
            editorReceiver.Clear();

            Editor.OpenFileCommand command = new Editor.OpenFileCommand(editorReceiver);

            editorInvoker.Invoke(command);

            // If nothing was opened it was not a lilypond file. In that case, throw it through the builder.
            if (editorReceiver.GetFilePath() == null || editorReceiver.GetFilePath() == "")
            {
                filePathTextBox.Text = command.selectedFilePath;

                currentScore = scoreBuilder.BuildScoreFromFile(filePathTextBox.Text);

                // If still nothing it was an invalid/unsupported file/file type.
                if (currentScore == null)
                {
                    MessageBox.Show("Invalid or unsupported file/file type.");
                    return;
                }
            }
            else
            {
                filePathTextBox.Text = editorReceiver.GetFilePath();

                currentScore = lilyPondScoreBuilder.BuildScoreFromString(editorReceiver.GetContent());
            }

            FillScoreViewer(currentScore);
        }
 private void OnEditorTextChanged()
 {
     try
     {
         currentScore = lilyPondScoreBuilder.BuildScoreFromString(editorReceiver.GetContent());
         FillScoreViewer(currentScore);
     }
     catch (Exception e)
     {
     }
 }
        private void FillScoreViewer(Model.Score score)
        {
            sheetTabControl.Items.Clear();

            double width = sheetTabControl.ActualWidth - 75;

            if (width > 0)
            {
                for (int i = 0; i < score.GetAmountOfStaves(); i++)
                {
                    Model.Staff staff = score.GetStaff(i);

                    ScrollViewer scrollViewer    = new ScrollViewer();
                    StackPanel   scoreStackPanel = new StackPanel(); // TODO fix width

                    scrollViewer.Content = scoreStackPanel;

                    PSAMWPFControlLibrary.IncipitViewerWPF incipitViewer = new PSAMWPFControlLibrary.IncipitViewerWPF();

                    Thickness margin = incipitViewer.Margin;
                    margin.Top          += 50;
                    incipitViewer.Margin = margin;
                    incipitViewer.Width  = width;

                    scoreStackPanel.Children.Add(incipitViewer);

                    Model.ScoreVisitor smVisitor = new Model.ScoreVisitor(staff, incipitViewer, scoreStackPanel, width);

                    for (int j = 0; j < staff.Symbols.Count; j++)
                    {
                        Model.StaffSymbol symbol = staff.Symbols[j];
                        smVisitor.CheckIfNewStaffNeeded();
                        symbol.Accept(smVisitor, j);
                    }

                    TabItem tab = new TabItem();
                    tab.Header  = staff.StaffName;
                    tab.Content = scrollViewer;
                    sheetTabControl.Items.Add(tab);
                }
            }

            sheetTabControl.SelectedIndex = 0;
        }