示例#1
0
        public Lyric(string text, TimeMark timemark)
        {
            this.text     = text;
            this.timemark = timemark;

            using (TextLayout tl = new TextLayout(Global.Instance.factoryWrite, text, resources.Lyric_TextFormat, 100, 15, 1, false))
            {
                fixedSize = new Size2((int)(tl.Metrics.Width + 5), (int)tl.Metrics.Height);
            }
            EndPoint = StartPoint.Add(fixedSize);

            resetPoints();
        }
示例#2
0
        public TimeMark NormalizedTimeMark(int x)
        {
            if (x < 0)
            {
                return(null);
            }

            var   ndx = timePoints.FindFirstIndexGreaterThanOrEqualTo(x);
            float key = timePoints.Keys[ndx];

            if (x < key)
            {
                key = timePoints.Keys[--ndx];
            }
            var tm = new TimeMark(timePoints.Values[ndx], x - key);

            tm.Time = ToTime(tm) * Global.pxpersec;
            return(tm);
        }
示例#3
0
 public float ToTime(TimeMark tm) => ToTimeHelper(tm.Measure, tm.Beat, tm.PartialBeat, tm.Milliseconds);
示例#4
0
        public bool TimeMarkTryParse(string txt, out TimeMark value, int measureOffset = 0)
        {
            value = null;
            var match = regex.Match(txt);

            if (!match.Success)
            {
                return(false);
            }

            var tm = new TimeMark();

            if (!short.TryParse(match.Groups[regexGrpMeasure].Value, out tm.Measure))
            {
                return(false);
            }
            tm.Measure += (short)measureOffset;
            Measure curr = measures[tm.Measure];

            if (curr == null)
            {
                return(false);
            }

            if (!short.TryParse(match.Groups[regexGrpBeat].Value, out tm.Beat))
            {
                return(false);
            }
            if ((tm.Beat < 1) || (tm.Beat > curr.BeatsPerMeasure))
            {
                return(false);
            }

            if (match.Groups[regexGrpNum].Value.Length > 0)
            {
                short num, denom;
                if (!short.TryParse(match.Groups[regexGrpNum].Value, out num))
                {
                    return(false);
                }
                if (!short.TryParse(match.Groups[regexGrpDenom].Value, out denom))
                {
                    return(false);
                }
                if ((num == 2) && (denom == 4))
                {
                    tm.PartialBeat = PartialBeats.TwoOfFour;
                }
                else if ((num == 2) && (denom == 3))
                {
                    tm.PartialBeat = PartialBeats.TwoOfThree;
                }
                else if ((num == 2) && (denom == 2))
                {
                    tm.PartialBeat = PartialBeats.TwoOfTwo;
                }
                else if ((num == 3) && (denom == 3))
                {
                    tm.PartialBeat = PartialBeats.ThreeOfThree;
                }
                else if ((num == 3) && (denom == 4))
                {
                    tm.PartialBeat = PartialBeats.ThreeOfFour;
                }
                else if ((num == 4) && (denom == 4))
                {
                    tm.PartialBeat = PartialBeats.FourOfFour;
                }
                else
                {
                    return(false);
                }
            }

            if (match.Groups[regexGrpSecs].Value.Length > 0)
            {
                float milli;
                if (!float.TryParse(match.Groups[regexGrpSecs].Value, out milli))
                {
                    return(false);
                }
                tm.Milliseconds = (short)(milli * 1000);
            }
            tm.Time = ToTime(tm) * Global.pxpersec;
            value   = tm;

            return(true);
        }
示例#5
0
        private static IEnumerable <VizCmd> cmInsert(Viz viz, System.Drawing.Point MouseLocation)
        {
            TimeMark tm = Global.Instance.Song.NormalizedTimeMark(Global.Lft + MouseLocation.X);

            return(Lyric.AddDialog("", tm));
        }