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); }
public override bool Equals(ElementPosition obj) { FretLabelPosition flp = (obj as FretLabelPosition); return(null != flp && flp.Side == Side && flp.Fret == Fret); }
public DiagramElement(Diagram parent, ElementPosition position, string text) : this(parent, position) { Text = text; }
public DiagramElement(Diagram parent, ElementPosition position) : this(parent) { Position = position ?? throw new ArgumentNullException(nameof(position)); }
public ElementPositionOffFretboardException(ElementPosition position) : base(position) { }
public ElementAlreadyExistsAtPositionException(ElementPosition position) : base(position) { }
public override bool Equals(ElementPosition obj) { MarkPosition mp = (obj as MarkPosition); return(null != mp && mp.String == String && mp.Fret == Fret); }
public ElementPositionException(ElementPosition position) : base() { Position = position.Clone(); }
public ElementPositionException() : base() { Position = null; }
public override bool Equals(ElementPosition obj) { BarrePosition bp = (obj as BarrePosition); return(null != bp && bp.Fret == Fret && bp.StartString == StartString && bp.EndString == EndString); }
public bool HasElementAt(ElementPosition position) { return(null != ElementAt(position)); }