Exemple #1
0
 public FingerboardMargin(SILayout layout) : base(layout)
 {
     _LastFret   = Measure.Empty;
     _NutMargins = new ArrayProperty <Measure, FingerboardSide>(
         (s) => s == FingerboardSide.Treble ? _NutTrebleMargin : _NutBassMargin,
         (s, m) => {
         if (s == FingerboardSide.Treble)
         {
             SetFieldValue(ref _NutTrebleMargin, m, nameof(_NutTrebleMargin));
         }
         else
         {
             SetFieldValue(ref _NutBassMargin, m, nameof(_NutBassMargin));
         }
     }
         );
     _BridgeMargins = new ArrayProperty <Measure, FingerboardSide>(
         (s) => s == FingerboardSide.Treble ? _BridgeTrebleMargin : _BridgeBassMargin,
         (s, m) => {
         if (s == FingerboardSide.Treble)
         {
             SetFieldValue(ref _BridgeTrebleMargin, m, nameof(_BridgeTrebleMargin));
         }
         else
         {
             SetFieldValue(ref _BridgeBassMargin, m, nameof(_BridgeBassMargin));
         }
     }
         );
     _TrebleMargins = new ArrayProperty <Measure, FingerboardEnd>(
         (s) => s == FingerboardEnd.Nut ? _NutTrebleMargin : _BridgeTrebleMargin,
         (s, m) => {
         if (s == FingerboardEnd.Nut)
         {
             SetFieldValue(ref _NutTrebleMargin, m, nameof(_NutTrebleMargin));
         }
         else
         {
             SetFieldValue(ref _BridgeTrebleMargin, m, nameof(_BridgeTrebleMargin));
         }
     }
         );
     _BassMargins = new ArrayProperty <Measure, FingerboardEnd>(
         (s) => s == FingerboardEnd.Nut ? _NutBassMargin : _BridgeBassMargin,
         (s, m) => {
         if (s == FingerboardEnd.Nut)
         {
             SetFieldValue(ref _NutBassMargin, m, nameof(_NutBassMargin));
         }
         else
         {
             SetFieldValue(ref _BridgeBassMargin, m, nameof(_BridgeBassMargin));
         }
     }
         );
 }
Exemple #2
0
 public LayoutComponent(SILayout layout)
 {
     if (!isDisposed)
     {
         Layout = layout;
         if (layout != null)
         {
             Layout._Components.Add(this);
         }
     }
 }
Exemple #3
0
        internal void SetLayout(SILayout layout)
        {
            var oldLayout = Layout;

            Layout = layout;

            if (oldLayout != null && oldLayout._Components.Contains(this))
            {
                oldLayout._Components.Add(this);
            }

            if (layout != null && !layout._Components.Contains(this))
            {
                layout._Components.Add(this);
            }
        }
Exemple #4
0
        public static void EstimateStringsGauges(SILayout layout)
        {
            var minGauge = Measure.Inches(0.01);
            var maxGauge = Measure.Inches(0.1);

            if (layout.NumberOfStrings >= 20)
            {
                maxGauge = Measure.Inches(0.06);
            }

            var gaugeStep = (maxGauge - minGauge) / (layout.NumberOfStrings - 1);

            for (int i = 0; i < layout.NumberOfStrings; i++)
            {
                layout.Strings[i].Gauge = GetNearestGuitarGauge(minGauge + gaugeStep * i);
            }
        }
Exemple #5
0
 public DualScaleManager(SILayout layout) : base(layout)
 {
     _Treble = Measure.Inches(25.5);
     _Bass   = Measure.Inches(27);
     _PerpendicularFretRatio = 0.5;
 }
Exemple #6
0
 public ActivableLayoutComponent(SILayout layout) : base(layout)
 {
 }
 public SingleScaleManager(SILayout layout) : base(layout)
 {
     _LengthCalculationMethod = LengthFunction.AlongFingerboard;
     _Length = Measure.Inches(25.5);
 }
Exemple #8
0
 public ScaleLengthManager(SILayout layout) : base(layout)
 {
     _LengthCalculationMethod = LengthFunction.AlongString;
 }
Exemple #9
0
        public static SILayout Load(XDocument document)
        {
            var root = document.Root;

            var layout = new SILayout()
            {
                IsLoading = true
            };

            layout.LayoutVersion            = root.ReadAttribute("Version", 1);
            EnumHelper.CurrentLayoutVersion = layout.LayoutVersion;

            layout._NumberOfStrings = root.Element("Strings").GetIntAttribute("Count");
            for (int i = 0; i < layout.NumberOfStrings; i++)
            {
                layout._Strings.Add(new SIString(layout, i));
            }
            layout.RebuildComponentStringData();

            if (root.ContainsAttribute("Name"))
            {
                layout.LayoutName = root.Attribute("Name").Value;
            }

            if (root.HasElement("LeftHanded", out XElement lhElem))
            {
                layout.LeftHanded = lhElem.ReadAttribute("Value", false);
            }

            if (root.HasElement("ScaleLength", out XElement slElem))
            {
                layout.ScaleLengthMode = slElem.ReadAttribute("Type", ScaleLengthType.Single);
                layout.CurrentScaleLength.Deserialize(slElem);
            }

            layout.Margins.Deserialize(root.Element("FingerboardMargins"));

            for (int i = 0; i < layout.NumberOfStrings; i++)
            {
                var stringElem = root.Element("Strings").Elements("String").First(s => s.Attribute("Index").Value == i.ToString());
                layout._Strings[i].Deserialize(stringElem);
            }

            if (root.ContainsElement("Temperament"))
            {
                layout.FretsTemperament = DeserializeProperty <Temperament>(root.Element("Temperament"));
            }

            if (root.ContainsElement("FretCompensation"))
            {
                layout.CompensateFretPositions = DeserializeProperty <bool>(root.Element("FretCompensation"));
            }

            if (root.ContainsElement("StringSpacings"))
            {
                layout.StringSpacingMode = DeserializeProperty <StringSpacingType>(root.Element("StringSpacings").Attribute("Mode"));
                layout.StringSpacing.Deserialize(root.Element("StringSpacings"));
            }

            layout.FillDefaultValues();
            layout.IsLoading     = false;
            layout.isLayoutDirty = true;

            return(layout);
        }
Exemple #10
0
 public MultipleScaleManager(SILayout layout) : base(layout)
 {
     StringLengthCache = new Dictionary <SIString, Measure>();
 }
Exemple #11
0
 public StringSpacingManual(SILayout layout) : base(layout)
 {
 }