Beispiel #1
0
        public bool ValidPosition(ElementPosition position)
        {
            if (null == position)
            {
                throw new ArgumentNullException(nameof(position));
            }

            if (position.GetType() == typeof(MarkPosition))
            {
                MarkPosition mp = (MarkPosition)position;
                return((mp.Fret <= NumFrets + 1) && (mp.String <= NumStrings));
            }
            else if (position.GetType() == typeof(FretLabelPosition))
            {
                FretLabelPosition flp = (FretLabelPosition)position;
                return(flp.Fret <= NumFrets);
            }
            else if (position.GetType() == typeof(BarrePosition))
            {
                BarrePosition bp = (BarrePosition)position;
                return(bp.Fret <= NumFrets && bp.StartString <= NumStrings && bp.EndString <= NumStrings);
            }

            return(false);
        }
Beispiel #2
0
        public bool CanPositionElementAt(DiagramElement element, ElementPosition position)
        {
            if (null == element)
            {
                throw new ArgumentNullException(nameof(element));
            }

            if (null == position)
            {
                throw new ArgumentNullException(nameof(position));
            }

            // Warning: Do not use element.Position as this method can be called during
            // element creation before element.Position is defined

            if (position.GetType() == typeof(MarkPosition))
            {
                foreach (DiagramMark mark in Marks)
                {
                    if (mark.Position == position && element != mark)
                    {
                        return(false);
                    }
                }
            }
            else if (position.GetType() == typeof(FretLabelPosition))
            {
                foreach (DiagramFretLabel fretLabel in FretLabels)
                {
                    if (fretLabel.Position == position && element != fretLabel)
                    {
                        return(false);
                    }
                }
            }
            else if (position.GetType() == typeof(BarrePosition))
            {
                foreach (DiagramBarre barre in Barres)
                {
                    if (barre.Position.Overlaps((BarrePosition)position) && element != barre)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Beispiel #3
0
        public DiagramElement ElementAt(ElementPosition position)
        {
            if (null == position)
            {
                throw new ArgumentNullException(nameof(position));
            }

            if (position.GetType() == typeof(MarkPosition))
            {
                foreach (DiagramMark mark in Marks)
                {
                    if (mark.Position == position)
                    {
                        return(mark);
                    }
                }
            }
            else if (position.GetType() == typeof(FretLabelPosition))
            {
                foreach (DiagramFretLabel fretLabel in FretLabels)
                {
                    if (fretLabel.Position == position)
                    {
                        return(fretLabel);
                    }
                }
            }
            else if (position.GetType() == typeof(BarrePosition))
            {
                foreach (DiagramBarre barre in Barres)
                {
                    if (barre.Position == position)
                    {
                        return(barre);
                    }
                }
            }

            return(null);
        }
Beispiel #4
0
        public override bool Equals(ElementPosition obj)
        {
            FretLabelPosition flp = (obj as FretLabelPosition);

            return(null != flp && flp.Side == Side && flp.Fret == Fret);
        }
Beispiel #5
0
 public DiagramElement(Diagram parent, ElementPosition position, string text) : this(parent, position)
 {
     Text = text;
 }
Beispiel #6
0
 public DiagramElement(Diagram parent, ElementPosition position) : this(parent)
 {
     Position = position ?? throw new ArgumentNullException(nameof(position));
 }
Beispiel #7
0
 public ElementPositionOffFretboardException(ElementPosition position) : base(position)
 {
 }
Beispiel #8
0
 public ElementAlreadyExistsAtPositionException(ElementPosition position) : base(position)
 {
 }
Beispiel #9
0
        public override bool Equals(ElementPosition obj)
        {
            MarkPosition mp = (obj as MarkPosition);

            return(null != mp && mp.String == String && mp.Fret == Fret);
        }
Beispiel #10
0
 public ElementPositionException(ElementPosition position) : base()
 {
     Position = position.Clone();
 }
Beispiel #11
0
 public ElementPositionException() : base()
 {
     Position = null;
 }
Beispiel #12
0
        public override bool Equals(ElementPosition obj)
        {
            BarrePosition bp = (obj as BarrePosition);

            return(null != bp && bp.Fret == Fret && bp.StartString == StartString && bp.EndString == EndString);
        }
Beispiel #13
0
 public bool HasElementAt(ElementPosition position)
 {
     return(null != ElementAt(position));
 }