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); }
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); }
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); }