コード例 #1
0
ファイル: TupletDef.cs プロジェクト: notator/MNXtoSVG
        private TupletNumberDisplay GetTupletNumberDisplay(string value)
        {
            TupletNumberDisplay rval = TupletNumberDisplay.inner; // default

            switch (value)
            {
            case "both":
                rval = TupletNumberDisplay.both;
                break;

            case "none":
                rval = TupletNumberDisplay.none;
                break;

            default:
                M.ThrowError("Error: unknown tuplet number display type.");
                break;
            }
            return(rval);
        }
コード例 #2
0
ファイル: TupletDef.cs プロジェクト: notator/MNXtoSVG
        public TupletDef(XmlReader r, bool isTopLevel)
        {
            M.Assert(r.Name == "tuplet");

            _isTopLevel = isTopLevel;

            int count = r.AttributeCount;

            for (int i = 0; i < count; i++)
            {
                r.MoveToAttribute(i);
                switch (r.Name)
                {
                case "outer":
                    OuterDuration = new MNXDurationSymbol(r.Value);
                    break;

                case "inner":
                    InnerDuration = new MNXDurationSymbol(r.Value);
                    break;

                case "orient":
                    Orient = GetMNXOrientation(r.Value);
                    break;

                case "staff":
                    int staff;
                    int.TryParse(r.Value, out staff);
                    if (staff > 0)
                    {
                        Staff = staff;
                    }
                    break;

                case "show-number":
                    ShowNumber = GetTupletNumberDisplay(r.Value);
                    break;

                case "show-value":
                    ShowValue = GetTupletNumberDisplay(r.Value);
                    break;

                case "bracket":
                    Bracket = GetTupletBracketDisplay(r.Value);
                    break;

                default:
                    throw new ApplicationException("Unknown attribute");
                }
            }

            M.ReadToXmlElementTag(r, "event", "grace", "forward", "tuplet");

            while (r.Name == "event" || r.Name == "grace" || r.Name == "forward" || r.Name == "tuplet")
            {
                if (r.Name == "tuplet" && r.NodeType == XmlNodeType.EndElement)
                {
                    break; //  pop 1 level
                }

                if (r.NodeType != XmlNodeType.EndElement)
                {
                    switch (r.Name)
                    {
                    case "event":
                        Event e = new Event(r);
                        Components.Add(e);
                        break;

                    case "grace":
                        Grace grace = new Grace(r);
                        Components.Add(grace);
                        break;

                    case "forward":
                        Forward forward = new Forward(r);
                        Components.Add(forward);
                        break;

                    case "tuplet":
                        TupletDef tuplet = new TupletDef(r, false);
                        Components.Add(tuplet);
                        break;
                    }
                }

                M.ReadToXmlElementTag(r, "event", "grace", "forward", "tuplet");
            }

            M.Assert(IEventsAndGraces.Count > 0);
            M.Assert(r.Name == "tuplet"); // end of (nested) tuplet content

            if (_isTopLevel)
            {
                int outerTicks = this.OuterDuration.GetDefaultTicks();
                this.OuterDuration.TicksDuration = outerTicks;
                SetTicksDurationsInContentIgnoringGraces(outerTicks);
            }
        }