コード例 #1
0
        public SpecialNotePointer AddSpecialNote(ScoreBar scoreBar, ScoreBarHitTestInfo info, bool isFromPrevBar, NoteType type)
        {
            if (!info.IsInNextBar)
            {
                var row = info.Row;
                if (isFromPrevBar && row < 0)
                {
                    row = 0;
                }
                return(AddSpecialNote(scoreBar, row, type));
            }
            if (isFromPrevBar)
            {
                return(null);
            }
            var nextBar = ScoreBars.FirstOrDefault(b => b.Bar.Index > scoreBar.Bar.Index);

            if (nextBar == null)
            {
                return(null);
            }
            var point = scoreBar.TranslatePoint(info.HitPoint, nextBar);

            return(AddSpecialNote(nextBar, nextBar.HitTest(point), true, type));
        }
コード例 #2
0
 private void RemoveScoreBar(ScoreBar scoreBar, bool modifiesModel, bool recalcLayout)
 {
     if (!ScoreBars.Contains(scoreBar))
     {
         throw new ArgumentException("Invalid ScoreBar.", nameof(scoreBar));
     }
     scoreBar.MouseUp   -= ScoreBar_MouseUp;
     scoreBar.MouseDown -= ScoreBar_MouseDown;
     if (modifiesModel)
     {
         Score.RemoveBarAt(scoreBar.Bar.Index);
     }
     EditableScoreBars.Remove(scoreBar);
     BarLayer.Children.Remove(scoreBar);
     TrimScoreNotes(scoreBar, modifiesModel);
     if (recalcLayout)
     {
         UpdateBarTexts();
         RecalcEditorLayout();
     }
     if (modifiesModel)
     {
         Project.IsChanged = true;
     }
 }
コード例 #3
0
        private ScoreNote AddScoreNote(ScoreBar scoreBar, ScoreBarHitTestInfo info, bool isFromPrevBar, Note dataTemplate)
        {
            if (info.IsInNextBar)
            {
                if (isFromPrevBar)
                {
                    return(null);
                }
                var nextBar = ScoreBars.FirstOrDefault(b => b.Bar.Index > scoreBar.Bar.Index);
                if (nextBar == null)
                {
                    return(null);
                }
                var point = scoreBar.TranslatePoint(info.HitPoint, nextBar);
                return(AddScoreNote(nextBar, nextBar.HitTest(point), true, dataTemplate));
            }
            var row = info.Row;

            if (isFromPrevBar && row < 0)
            {
                row = 0;
            }
            if (!info.IsValid || row < 0 || info.Column < 0)
            {
                return(null);
            }
            return(AddScoreNote(scoreBar, row, info.Column, dataTemplate));
        }
コード例 #4
0
        private void ResizeEditorHeight()
        {
            var height = -MinimumScrollOffset;

            if (ScoreBars.Count > 0)
            {
                height += ScoreBars.Sum(scoreBar => scoreBar.Height);
                height += ScoreBar.GridStrokeThickness;
            }
            Height = height;
        }
コード例 #5
0
        internal void UpdateBarTexts()
        {
            var startTime = ScoreBars?.FirstOrDefault()?.Bar?.StartTime ?? 0d;

            foreach (var scoreBar in ScoreBars)
            {
                scoreBar.UpdateBarIndexText();
                scoreBar.UpdateBarTimeText(TimeSpan.FromSeconds(startTime));
                startTime += scoreBar.Bar.TimeLength;
            }
        }
コード例 #6
0
        public SpecialNotePointer AddSpecialNote(ScoreBar scoreBar, ScoreBarHitTestInfo info, NoteType type)
        {
            if (!info.IsInNextBar)
            {
                return(AddSpecialNote(scoreBar, info.Row, type));
            }
            var nextBar = ScoreBars.FirstOrDefault(b => b.Bar.Index > scoreBar.Bar.Index);

            if (nextBar == null)
            {
                return(null);
            }
            var point = scoreBar.TranslatePoint(info.HitPoint, nextBar);

            return(AddSpecialNote(nextBar, nextBar.HitTest(point), type));
        }
コード例 #7
0
        private ScoreBar AddScoreBar(ScoreBar before, bool recalculateLayout, Bar dataTemplate)
        {
            var project = Project;

            Debug.Assert(project != null, "project != null");
            var score = Score;
            var bar   = dataTemplate ?? (before == null ? score.AddBar() : score.InsertBar(before.Bar.Index));

            if (bar == null)
            {
                return(null);
            }
            var scoreBar = new ScoreBar();

            scoreBar.Bar = bar;
            if (ScoreBars.Count == 0)
            {
                scoreBar.Height = ScoreBar.DefaultHeight;
            }
            else
            {
                scoreBar.Height = ScoreBars[0].Height;
            }
            scoreBar.MouseUp   += ScoreBar_MouseUp;
            scoreBar.MouseDown += ScoreBar_MouseDown;
            if (before == null)
            {
                BarLayer.Children.Add(scoreBar);
                EditableScoreBars.Add(scoreBar);
            }
            else
            {
                BarLayer.Children.Add(scoreBar);
                EditableScoreBars.Insert(ScoreBars.IndexOf(before), scoreBar);
            }
            if (recalculateLayout)
            {
                UpdateBarTexts();
                RecalcEditorLayout();
            }
            if (dataTemplate == null)
            {
                Project.IsChanged = true;
            }
            return(scoreBar);
        }
コード例 #8
0
 public ScoreBar GetSelectedScoreBar()
 {
     return(ScoreBars.FirstOrDefault(scoreBar => scoreBar.IsSelected));
 }
コード例 #9
0
        public double GetBarsTotalHeight()
        {
            var height = ScoreBars.Sum(scoreBar => scoreBar.ActualHeight);

            return(height);
        }
コード例 #10
0
 public IEnumerable <ScoreBar> GetSelectedScoreBars()
 {
     return(ScoreBars.Where(scoreBar => scoreBar.IsSelected));
 }