Exemple #1
0
        private void MusicStaff_Paint(object sender, PaintEventArgs e)
        {
            staffPictureBox.Width = ClientSize.Width - 17;
            staffPictureBox.Invalidate();
            BeatsPerBarLabel.Text = BeatsPerBar.ToString();
            NoteSizeLabel.Text    = NoteSize.ToString();

            BeatsPerBarLabel.Location =
                new Point(ScaleValue(TSLABEL_XOFFSET), staffPictureBox.Location.Y + staffPictureBox.Height / 2 - BeatsPerBarLabel.Height);

            NoteSizeLabel.Location =
                new Point(ScaleValue(TSLABEL_XOFFSET), BeatsPerBarLabel.Location.Y + BeatsPerBarLabel.Height + 1);

            BPMLabelVal.Text     = (60000 / m_beatPeriod).ToString("F1");
            BPMLabelVal.Location =
                new Point(BPMLabel.Location.X + BPMLabel.PreferredWidth + ScaleValue(LABEL_VAL_OFFSET), BPMLabel.Location.Y);

            BarPeriodLabel.Location =
                new Point(BPMLabelVal.Location.X + BPMLabelVal.PreferredWidth + ScaleValue(VAL_LABEL_OFFSET), BPMLabelVal.Location.Y);
            BarPeriodLabelVal.Location =
                new Point(BarPeriodLabel.Location.X + BarPeriodLabel.PreferredWidth + ScaleValue(LABEL_VAL_OFFSET), BarPeriodLabel.Location.Y);
            BarPeriodLabelVal.Text = (BarPeriod / 1000).ToString("F2");

            double divTime = splitBeatsCB.Checked ? m_beatPeriod / 2 : m_beatPeriod;

            DivTimeLabel.Location =
                new Point(BarPeriodLabelVal.Location.X + BarPeriodLabelVal.PreferredWidth + ScaleValue(VAL_LABEL_OFFSET), BarPeriodLabelVal.Location.Y);
            DivTimeLabelVal.Location =
                new Point(DivTimeLabel.Location.X + DivTimeLabel.PreferredWidth + ScaleValue(LABEL_VAL_OFFSET), DivTimeLabel.Location.Y);
            DivTimeLabelVal.Text = divTime.ToString("F0");
        }
Exemple #2
0
        /// <summary>
        /// nullを返すことがあります
        /// </summary>
        /// <param name="lane"></param>
        /// <param name="timing"></param>
        /// <param name="size"></param>
        /// <param name="noteType"></param>
        /// <returns></returns>
        public static ShortNote Factory(LanePotision lane, TimingPosition timing, NoteSize size, NoteType noteType)
        {
            switch (noteType)
            {
            case NoteType.Touch:
                return(new Touch(lane, timing, size));

            case NoteType.Chain:
                return(new Chain(lane, timing, size));

            case NoteType.SlideL:
                return(new SlideL(lane, timing, size));

            case NoteType.SlideR:
                return(new SlideR(lane, timing, size));

            case NoteType.SnapU:
                return(new SnapU(lane, timing, size));

            case NoteType.SnapD:
                return(new SnapD(lane, timing, size));

            default:
                Debug.Assert(false);
                return(null);
            }
        }
Exemple #3
0
        public ReSizeNoteOperation(NoteBase note, NoteSize before, NoteSize after)
        {
            Invoke = () =>
            {
                note.ReSize(after);
            };

            Undo = () =>
            {
                note.ReSize(before);
            };
        }
Exemple #4
0
        public static void InsertNote(IDrawingDoc draw, string text, NoteSize size)
        {
            int height = 0;

            switch (size)
            {
            case NoteSize.Small:
                height = 24;
                break;

            case NoteSize.Normal:
                height = 36;
                break;

            case NoteSize.Large:
                height = 64;
                break;
            }

            InsertNote(draw, text, height, 0, 0, null);
        }
Exemple #5
0
 public HoldRelay(LanePotision lane, TimingPosition timing, NoteSize size)
     : base(lane, timing, size)
 {
 }
Exemple #6
0
 public PreviewNote(LanePotision lane, TimingPosition timing, NoteSize size)
     : base(lane, timing, size)
 {
 }
Exemple #7
0
 protected ShortNote(LanePotision lane, TimingPosition timing, NoteSize size)
     : base(lane, timing, size)
 {
 }
Exemple #8
0
 public SnapD(LanePotision lane, TimingPosition timing, NoteSize size)
     : base(lane, timing, size)
 {
 }
Exemple #9
0
 public bool ReSize(NoteSize size)
 {
     NoteSize = new NoteSize(size);
     return(true);
 }
Exemple #10
0
 protected NoteBase(LanePotision lane, TimingPosition timing, NoteSize size)
 {
     Lane     = new LanePotision(lane);
     Timing   = new TimingPosition(timing);
     NoteSize = new NoteSize(size);
 }
Exemple #11
0
 protected HoldStepNote(LanePotision lane, TimingPosition timing, NoteSize size)
     : base(lane, timing, size)
 {
 }
Exemple #12
0
 public Hold(LanePotision lane, TimingPosition timingBegin, TimingPosition timingEnd, NoteSize size)
 {
     System.Diagnostics.Debug.Assert(timingBegin < timingEnd);
     HoldBegin = new HoldBegin(lane, timingBegin, size);
     HoldBegin.PositionChanging += (begin, beginLane, beginTiming) =>
     {
         if (stepNotes.Where(x => x.Timing <= beginTiming).Any())
         {
             return(false);
         }
         if (!(beginTiming < HoldEnd.Timing))
         {
             return(false);
         }
         return(true);
     };
     HoldEnd = new HoldEnd(lane, timingEnd, size);
     HoldEnd.PositionChanging += (end, endLane, endTiming) =>
     {
         if (stepNotes.Where(x => x.Timing >= endTiming).Any())
         {
             return(false);
         }
         if (!(HoldBegin.Timing < endTiming))
         {
             return(false);
         }
         return(true);
     };
     stepNotes = new List <HoldStepNote>();
 }
Exemple #13
0
        private static void SetEventToReSizeNote(
            MadcaDisplay display, NoteBook noteBook, IReadOnlyList <IReadOnlyScore> scores, OperationManager opManager, IReadOnlyEditorStatus status)
        {
            var box    = display.PictureBox;
            var env    = display.EditorLaneEnvironment;
            var holder = display.KeyTokenHolder;

            var              key        = new KeyToken();
            NoteBase         note       = null;
            Position         prevPos    = null;
            NoteSize         prevSize   = null;
            Position         mouseBegin = null;
            SelectedNoteArea noteArea   = SelectedNoteArea.None;

            box.MouseDown += (s, e) =>
            {
                if (holder.Locked || status.EditorMode != EditorMode.Edit)
                {
                    return;
                }
                var area = env.GetEditorLaneRegion(e.Location);
                if (area == EditorLaneRegion.Lane && e.Button == MouseButtons.Left)
                {
                    if (!GetSelectedNote(e.Location, display, noteBook, out note))
                    {
                        return;
                    }
                    noteArea = note.SelectedNoteArea(e.Location, env);
                    if (!(noteArea == SelectedNoteArea.Left || noteArea == SelectedNoteArea.Right))
                    {
                        return;
                    }
                    prevPos  = new Position(note.Lane, note.Timing);
                    prevSize = new NoteSize(note.NoteSize);
                    var res = PositionConverter.ConvertRealToVirtual(env, e.Location, status.BeatStride, scores, out mouseBegin);
                    if (!res)
                    {
                        return;
                    }
                    holder.Lock(key);
                }
            };

            box.MouseMove += (s, e) =>
            {
                if (!holder.CanUnLock(key))
                {
                    return;
                }
                var res = PositionConverter.ConvertRealToVirtual(env, e.Location, status.BeatStride, scores, out Position position);
                if (!res)
                {
                    return;
                }
                var lane = position.Lane.RawLane - mouseBegin.Lane.RawLane;
                switch (noteArea)
                {
                case SelectedNoteArea.Left:
                {
                    var diff = prevSize.Size - lane;
                    if (1 <= diff && diff <= MadcaEnv.LaneCount)
                    {
                        note.ReLocate(new LanePotision(prevPos.Lane.RawLane + lane), note.Timing);
                    }
                    note.ReSize(new NoteSize(prevSize.Size - lane));
                    return;
                }

                case SelectedNoteArea.Right:
                {
                    note.ReSize(new NoteSize(prevSize.Size + lane));
                    return;
                }

                default: return;
                }
            };

            box.MouseUp += (s, e) =>
            {
                if (!holder.UnLock(key))
                {
                    return;
                }
                var ops = new List <Operation>();
                // TODO: 条件式要検討
                if (prevPos.Lane.RawLane != note.Lane.RawLane || prevPos.Timing != note.Timing)
                {
                    ops.Add(new ReLocateNoteOperation(note, prevPos, new Position(note.Lane, note.Timing)));
                }
                if (prevSize != note.NoteSize)
                {
                    ops.Add(new ReSizeNoteOperation(note, prevSize, note.NoteSize));
                }
                if (ops.Any())
                {
                    opManager.AddOperation(new CompositeOperation(ops.ToArray()));
                }
                note = null;
            };
        }