示例#1
0
        public SILayout()
        {
            _Components = new List <LayoutComponent>();
            _Strings    = new LayoutItemCollection <SIString>(this);
            _Strings.CollectionChanged += Strings_CollectionChanged;

            Margins = new FingerboardMargin(this);

            _StringSpacingMode  = StringSpacingType.Simple;
            SimpleStringSpacing = new StringSpacingSimple(this);
            ManualStringSpacing = new StringSpacingManual(this);

            SingleScaleConfig = new SingleScaleManager(this);
            DualScaleConfig   = new DualScaleManager(this);
            MultiScaleConfig  = new MultipleScaleManager(this);

            VisualElements = new List <VisualElement>();

            _ScaleLengthMode   = ScaleLengthType.Single;
            _FretsTemperament  = Temperament.Equal;
            _FretInterpolation = FretInterpolationMethod.Spline;
            _CachedBounds      = RectangleM.Empty;
            LayoutName         = string.Empty;

            LayoutChanges = new List <ILayoutChange>();

            LayoutVersion = CURRENT_LAYOUT_VERSION;
            //_InstrumentType = InstrumentType.Guitar;
        }
示例#2
0
 public void UpdateInfos()
 {
     _Length = Measure.Zero;
     for (int i = 0; i < Points.Count - 1; i++)
     {
         _Length += PointM.Distance(Points[i], Points[i + 1]);
     }
     _Bounds = RectangleM.BoundingRectangle(_Points);
     isDirty = false;
 }
示例#3
0
 private void UpdateInfos()
 {
     _Direction = ((Vector)P2 - (Vector)P1).Normalized;
     _Equation  = Line.FromPoints((Vector)P1, (Vector)P2);
     _Bounds    = RectangleM.FromLTRB(
         Measure.Min(P1.X, P2.X),
         Measure.Max(P1.Y, P2.Y),
         Measure.Max(P1.X, P2.X),
         Measure.Min(P1.Y, P2.Y));
     _Length = Measure.FromNormalizedValue(((Vector)P2 - (Vector)P1).Length, P1.Unit ?? P2.Unit);
     isDirty = false;
 }
示例#4
0
        public RectangleM GetLayoutBounds()
        {
            if (VisualElements.Count == 0)
            {
                return(RectangleM.Empty);
            }

            if (!_CachedBounds.IsEmpty)
            {
                return(_CachedBounds);
            }

            Measure minX = Measure.Zero;
            Measure maxX = Measure.Zero;
            Measure minY = Measure.Zero;
            Measure maxY = Measure.Zero;

            foreach (var elem in VisualElements)
            {
                if (elem.Bounds.IsEmpty)
                {
                    continue;
                }
                if (elem.Bounds.Left < minX)
                {
                    minX = elem.Bounds.Left;
                }
                if (elem.Bounds.Bottom < minY)
                {
                    minY = elem.Bounds.Bottom;
                }
                if (elem.Bounds.Right > maxX)
                {
                    maxX = elem.Bounds.Right;
                }
                if (elem.Bounds.Top > maxY)
                {
                    maxY = elem.Bounds.Top;
                }
            }
            _CachedBounds = RectangleM.FromLTRB(minX, maxY, maxX, minY);
            return(_CachedBounds);
        }
示例#5
0
        protected override void InitializeDocument()
        {
            Document = new SvgDocument();

            if (!string.IsNullOrEmpty(Layout.LayoutName))
                Document.CustomAttributes.Add("LayoutName", Layout.LayoutName);

            LayoutBounds = Layout.GetLayoutBounds();

            Document.X = new SvgUnit(0);
            Document.Y = new SvgUnit(0);
            Document.Width = GetDocumentUnit(LayoutBounds.Width);
            Document.Height = GetDocumentUnit(LayoutBounds.Height);

            if (Options.InkscapeCompatible)
            {
                Document.CustomAttributes.Add("xmlns:inkscape", "http://www.inkscape.org/namespaces/inkscape");
                //The Svg library serializes the viewbox with comma and space, but this combination is not handled by the Inkscape DXF exporter
                Document.CustomAttributes.Add("viewBox",
                    string.Format(NumberFormatInfo.InvariantInfo, "0,0,{0},{1}",
                    LayoutBounds.Width[Options.ExportUnit].DoubleValue,
                    LayoutBounds.Height[Options.ExportUnit].DoubleValue));
            }
            else
            {
                Document.ViewBox = new SvgViewBox(0, 0, Document.Width, Document.Height);
            }

            OriginOffset = new PointM(LayoutBounds.Location.X * -1, LayoutBounds.Location.Y);
            OriginOffestVec = OriginOffset.ToVector(Options.ExportUnit);

            LineDashPattern = new SvgUnitCollection
            {
                GetRelativeUnit(6, SvgUnitType.Point),
                GetRelativeUnit(4, SvgUnitType.Point),
                GetRelativeUnit(2, SvgUnitType.Point),
                GetRelativeUnit(4, SvgUnitType.Point)
            };
        }