private void PianoWindow_TrackMouseDown(object sender, VocalUtau.DirectUI.PianoMouseEventArgs e) { if (!_HandleEvents) { PitchDragingStatus = PitchDragingType.None; PitchStP1 = null; PitchTmpP0 = null; return; } if (_PitchToolsStatus == PitchDragingType.None) { return; } if (PitchDragingStatus != PitchDragingType.None) { return; } if (e.MouseEventArgs.Button != MouseButtons.Left) { return; } PitchStP1 = new PitchObject(e.Tick, e.PitchValue.PitchValue); PitchDragingStatus = _PitchToolsStatus; if (PitchActionBegin != null) { PitchActionBegin(PitchDragingStatus); } }
private void PianoWindow_TrackMouseDown(object sender, VocalUtau.DirectUI.PianoMouseEventArgs e) { if (!_HandleEvents) { return; } if (e.MouseEventArgs.Button != MouseButtons.Left) { return; } if (CurrentNoteIndex != -1) { if (e.Tick > NoteList[CurrentNoteIndex].Tick + NoteList[CurrentNoteIndex].Length - 20) { NoteDragingWork = NoteDragingType.NoteLength; } else { NoteDragingWork = NoteDragingType.NoteMove; NoteTempTick = e.Tick - NoteList[CurrentNoteIndex].Tick; } } else { if (NoteToolsStatus == NoteToolsType.Add) { NoteDragingWork = NoteDragingType.NoteAdd; NoteDias.Clear(); BlockDia NoteDia = new BlockDia(); NoteDia.setStartPoint(e.Tick, e.PitchValue.NoteNumber); NoteDia.setEndPoint(e.Tick, e.PitchValue.NoteNumber); NoteDias.Add(NoteDia); } else if (NoteToolsStatus == NoteToolsType.Select) { NoteDragingWork = NoteDragingType.AreaSelect; BlockDia NoteDia = new BlockDia(); NoteDia.setStartPoint(e.Tick, e.PitchValue.NoteNumber); NoteDia.setEndPoint(e.Tick, e.PitchValue.NoteNumber); NoteDias.Add(NoteDia); } } if (NoteDragingWork != NoteDragingType.AreaSelect) { if (NoteActionBegin != null) { if (NoteDragingWork == NoteDragingType.NoteMove) { NoteActionBegin(NoteDragingWork, true); } else { NoteActionBegin(NoteDragingWork); } } } }
private void d2DPainterBox1_MouseDoubleClick(object sender, MouseEventArgs e) { // if (DisableMouse) return; pme_cache = RiseMouseHandle(sender, e, RollMouseDoubleClick, TitleMouseDoubleClick, TrackMouseDoubleClick); this.OnMouseDoubleClick(e); }
internal void CalcAxis(PianoProperties pprops, RollConfigures rconf, PianoMouseEventArgs cache) { if (cache != null && cache.MouseEventArgs.X == _me.X && cache.MouseEventArgs.Y == _me.Y) { _tick = cache.Tick; _pitchvp = cache.PitchValue; _area = cache.Area; } else { CalcAxis(pprops, rconf); } }
private void d2DPainterBox1_MouseUp(object sender, MouseEventArgs e) { if (DisableMouse) { return; } if (isMUp) { return; } isMUp = true; pme_cache = RiseMouseHandle(sender, e, RollMouseUp, TitleMouseUp, TrackMouseUp); this.OnMouseUp(e); isMUp = false; }
private void PianoWindow_TrackMouseUp(object sender, VocalUtau.DirectUI.PianoMouseEventArgs e) { if (!_HandleEvents) { return; } if (PitchDragingStatus == PitchDragingType.None) { return; } PitchObject PitchEdP2 = new PitchObject(e.Tick, e.PitchValue.PitchValue); switch (PitchDragingStatus) { case PitchDragingType.DrawLine: PartsObject.PitchCompiler.ReplaceRealPitchLine(PitchMathUtils.CalcLineSilk(PitchStP1, PitchEdP2)); break; case PitchDragingType.DrawGraphJ: PartsObject.PitchCompiler.ReplaceRealPitchLine(PitchMathUtils.CalcGraphJ(PitchStP1, PitchEdP2)); break; case PitchDragingType.DrawGraphR: PartsObject.PitchCompiler.ReplaceRealPitchLine(PitchMathUtils.CalcGraphR(PitchStP1, PitchEdP2)); break; case PitchDragingType.DrawGraphS: PartsObject.PitchCompiler.ReplaceRealPitchLine(PitchMathUtils.CalcGraphS(PitchStP1, PitchEdP2)); break; case PitchDragingType.EarseArea: if (PitchStP1 != null && PitchTmpP0 != null) { PitchView.BlockDia PitchDia = new PitchView.BlockDia(); PitchDia.setStartPoint(PitchStP1.Tick, PitchStP1.PitchValue.NoteNumber); PitchDia.setEndPoint(PitchTmpP0.Tick, PitchTmpP0.PitchValue.NoteNumber); earsePitchLine(PitchDia, _EarseModeV2); } break; } PitchDragingType EDStatus = PitchDragingStatus; PitchDragingStatus = PitchDragingType.None; PitchStP1 = null; PitchTmpP0 = null; if (PitchActionEnd != null) { PitchActionEnd(EDStatus); } }
private PianoMouseEventArgs RiseMouseHandle(object sender, MouseEventArgs e, OnMouseEventHandler Roll, OnMouseEventHandler Title, OnMouseEventHandler Track) { PianoMouseEventArgs pme = new PianoMouseEventArgs(e); pme.CalcAxis(pprops, rconf, pme_cache); OnMouseEventHandler Handle = null; switch (pme.Area) { case PianoMouseEventArgs.AreaType.Roll: Handle = Roll; break; case PianoMouseEventArgs.AreaType.Title: Handle = Title; break; case PianoMouseEventArgs.AreaType.Track: Handle = Track; break; } if (Handle != null) { Handle(sender, pme); } return(pme); }
private void PianoWindow_TrackMouseMove(object sender, VocalUtau.DirectUI.PianoMouseEventArgs e) { if (!_HandleEvents) { return; } if (PitchDragingStatus == PitchDragingType.None) { return; } if (e.Tick == PitchStP1.Tick) { return; } PitchTmpP0 = new PitchObject(e.Tick, e.PitchValue.PitchValue); if (_PitchToolsStatus == PitchDragingType.None) { PianoWindow.ParentForm.Cursor = Cursors.Arrow; } else { PianoWindow.ParentForm.Cursor = Cursors.Cross; } }
private void PianoWindow_TrackMouseMove(object sender, VocalUtau.DirectUI.PianoMouseEventArgs e) { if (!_HandleEvents) { NoteDragingWork = NoteDragingType.None; NoteDias.Clear(); return; } if (NoteDragingWork == NoteDragingType.AreaSelect) { NoteDias[0].setEndPoint(e.Tick, e.PitchValue.NoteNumber); } else if (NoteDragingWork == NoteDragingType.NoteAdd) { NoteDias[0].setEndPoint(e.Tick, e.PitchValue.NoteNumber); NoteDias[0].setStartPoint(NoteDias[0].TickStart == e.Tick ? NoteDias[0].TickEnd : NoteDias[0].TickStart, e.PitchValue.NoteNumber); } else if (NoteDragingWork == NoteDragingType.NoteMove) { long minTickChange = (long)PianoWindow.PianoProps.dertPixel2dertTick(AntiShakePixel); if (NoteSelectIndexs.IndexOf(CurrentNoteIndex) == -1) { long NewTick = e.Tick - NoteTempTick; NewTick = (long)(NewTick / _TickStepTick) * _TickStepTick; long TickDert = NoteList[CurrentNoteIndex].Tick - NewTick; if (NoteDias.Count == 0) { NoteDias.Add(new BlockDia()); } if (Math.Abs(TickDert) <= minTickChange) { TickDert = 0; } long CurNewTick = NoteList[CurrentNoteIndex].Tick - TickDert; NoteDias[0].setStartPoint(CurNewTick, e.PitchValue.NoteNumber); NoteDias[0].setEndPoint(CurNewTick + NoteList[CurrentNoteIndex].Length, e.PitchValue.NoteNumber); } else { long NewTick = e.Tick - NoteTempTick; NewTick = (long)(NewTick / _TickStepTick) * _TickStepTick; long TickDert = NoteList[CurrentNoteIndex].Tick - NewTick; if (Math.Abs(TickDert) <= minTickChange) { TickDert = 0; } long NoteDert = NoteList[CurrentNoteIndex].PitchValue.NoteNumber - e.PitchValue.NoteNumber; for (int i = 0; i < NoteSelectIndexs.Count; i++) { uint NewNoteNumber = (uint)(NoteList[NoteSelectIndexs[i]].PitchValue.NoteNumber - NoteDert); if (NoteDias.Count < NoteSelectIndexs.Count) { NoteDias.Add(new BlockDia()); } long CurNewTick = NoteList[NoteSelectIndexs[i]].Tick - TickDert; NoteDias[i].setStartPoint(CurNewTick, NewNoteNumber); NoteDias[i].setEndPoint(CurNewTick + NoteList[NoteSelectIndexs[i]].Length, NewNoteNumber); } } } else if (NoteDragingWork == NoteDragingType.NoteLength) { long NewSize = e.Tick - NoteList[CurrentNoteIndex].Tick; NewSize = (long)(NewSize / _TickStepTick) * _TickStepTick; if (NewSize >= 32) { if (NoteDias.Count == 0) { NoteDias.Add(new BlockDia()); } NoteDias[0].setStartPoint(NoteList[CurrentNoteIndex].Tick, e.PitchValue.NoteNumber); NoteDias[0].setEndPoint(NoteList[CurrentNoteIndex].Tick + NewSize, e.PitchValue.NoteNumber); } } else if (NoteDragingWork == NoteDragingType.None) { int cnn = -1; long mt = PianoWindow.MaxShownTick; long nt = PianoWindow.MinShownTick; if (e.Tick >= nt && e.Tick <= mt) { int Sfx = PartsObject.NoteCompiler.FindTickIndex(nt, 0, NoteList.Count); for (int i = Sfx; i < NoteList.Count; i++) { PianoWindow.ParentForm.Cursor = Cursors.Arrow; NoteObject PN = NoteList[i]; if (PN.Tick >= mt) { break; } if (PN.Tick + PN.Length < nt) { continue; } if (e.PitchValue.NoteNumber == PN.PitchValue.NoteNumber) { if (e.Tick >= PN.Tick && e.Tick <= PN.Tick + PN.Length) { Console.WriteLine("Mouse in Note " + PN.Lyric); cnn = i; if (e.Tick > PN.Tick + PN.Length - 20) { PianoWindow.ParentForm.Cursor = Cursors.SizeWE; } else { /* bool isVBL = false; * if (PN.VerbPrecent > 0 && PN.VerbPrecent<1) * { * long VBP = (long)(PN.Length * (1 - PN.VerbPrecent)); * if (e.Tick > PN.Tick + VBP - 5 && e.Tick < PN.Tick + VBP + 5) * { * isVBL = true; * } * } * if (isVBL) * { * PianoWindow.ParentForm.Cursor = Cursors.SizeWE; * } * else*/ { PianoWindow.ParentForm.Cursor = Cursors.SizeAll; } } break; } } } } CurrentNoteIndex = cnn; } }
private void PianoWindow_TrackMouseUp(object sender, VocalUtau.DirectUI.PianoMouseEventArgs e) { if (!_HandleEvents) { return; } bool NotMove = false; if (NoteDragingWork != NoteDragingType.None) { if (NoteDragingWork == NoteDragingType.NoteLength) { long NewSize = e.Tick - NoteList[CurrentNoteIndex].Tick; NewSize = (long)(NewSize / _TickStepTick) * _TickStepTick; if (NewSize >= 32) { NoteList[CurrentNoteIndex].Length = NewSize; int StartPX = Math.Max(0, CurrentNoteIndex); int EndPX = Math.Min(NoteList.Count - 1, CurrentNoteIndex + 1); PartsObject.PitchCompiler.SetupBasePitch_Aysnc(new Formats.Model.VocalObject.ParamTranslater.PitchCompiler.AsyncWorkCallbackHandler((F, L) => { this.PianoWindow.Invoke(new Action(() => { this.PianoWindow.RedrawPiano(); })); }), StartPX, EndPX); if (this.SingerDataFinder != null) { PartsObject po = PartsObject; this.SingerDataFinder.GetPhonemesDictionary(PartsObject).UpdateLyrics_Aysnc(new Formats.Model.Database.VocalDatabase.SplitDictionary.AsyncWorkCallbackHandler((P, F, L) => { }), ref po, CurrentNoteIndex, CurrentNoteIndex);; } } NoteDias.Clear(); } else if (NoteDragingWork == NoteDragingType.NoteMove) { long minTickChange = (long)PianoWindow.PianoProps.dertPixel2dertTick(AntiShakePixel); List <NoteObject> SelectingNoteCache = new List <NoteObject>(); for (int i = 0; i < NoteSelectIndexs.Count; i++) { SelectingNoteCache.Add(PartsObject.NoteList[NoteSelectIndexs[i]]); } bool TickChanged = false; if (NoteSelectIndexs.IndexOf(CurrentNoteIndex) == -1) { long NewTick = e.Tick - NoteTempTick; NewTick = (long)(NewTick / _TickStepTick) * _TickStepTick; long TickDert = NoteList[CurrentNoteIndex].Tick - NewTick; long NoteDert = NoteList[CurrentNoteIndex].PitchValue.NoteNumber - e.PitchValue.NoteNumber; if (NoteList[CurrentNoteIndex].PitchValue.NoteNumber != e.PitchValue.NoteNumber) { NoteList[CurrentNoteIndex].PitchValue = new PitchAtomObject(e.PitchValue.NoteNumber, NoteList[CurrentNoteIndex].PitchValue.PitchWheel); } TickChanged = Math.Abs(TickDert) >= minTickChange; NotMove = (NoteDert == 0 && Math.Abs(TickDert) < minTickChange); NoteObject OldNoteSt = NoteList[CurrentNoteIndex]; long oldStartTick = OldNoteSt.Tick; long oldEndTick = OldNoteSt.Tick + OldNoteSt.Length; if (Math.Abs(TickDert) > minTickChange) { NoteList[CurrentNoteIndex].Tick = NoteList[CurrentNoteIndex].Tick - TickDert; NoteList.Sort(); } long AStartTick = Math.Min(oldStartTick, OldNoteSt.Tick); long AEndTick = Math.Max(oldEndTick, OldNoteSt.Tick + OldNoteSt.Length); int ONI = NoteList.IndexOf(OldNoteSt); if (!NotMove) { int StartPX = ONI; int EndPX = ONI; List <NoteObject> PO = PartsObject.NoteList; int FSIdx = PartsObject.NoteCompiler.FindTickIndex(AStartTick, 0, PO.Count); int FEIdx = PartsObject.NoteCompiler.FindTickIndex(AEndTick, FSIdx, PO.Count); StartPX = Math.Min(StartPX, FSIdx); EndPX = Math.Max(EndPX, FEIdx); StartPX = Math.Max(0, StartPX); EndPX = Math.Min(NoteList.Count - 1, EndPX); PartsObject.PitchCompiler.SetupBasePitch_Aysnc(new Formats.Model.VocalObject.ParamTranslater.PitchCompiler.AsyncWorkCallbackHandler((F, L) => { this.PianoWindow.Invoke(new Action(() => { this.PianoWindow.RedrawPiano(); })); }), StartPX, EndPX); if (this.SingerDataFinder != null) { PartsObject po = PartsObject; this.SingerDataFinder.GetPhonemesDictionary(PartsObject).UpdateLyrics_Aysnc(new Formats.Model.Database.VocalDatabase.SplitDictionary.AsyncWorkCallbackHandler((P, F, L) => { }), ref po, ONI, ONI);; } } } else { long NewTick = e.Tick - NoteTempTick; NewTick = (long)(NewTick / _TickStepTick) * _TickStepTick; long TickDert = NoteList[CurrentNoteIndex].Tick - NewTick; long NoteDert = NoteList[CurrentNoteIndex].PitchValue.NoteNumber - e.PitchValue.NoteNumber; NotMove = (NoteDert == 0 && Math.Abs(TickDert) < minTickChange); TickChanged = Math.Abs(TickDert) >= minTickChange; NoteObject OldNoteSt = NoteList[NoteSelectIndexs[0]]; NoteObject LastNoteEd = NoteList[NoteSelectIndexs[NoteSelectIndexs.Count - 1]]; long oldStartTick = OldNoteSt.Tick; long oldEndTick = LastNoteEd.Tick + LastNoteEd.Length; for (int i = 0; i < SelectingNoteCache.Count; i++) { uint NewNoteNumber = (uint)(SelectingNoteCache[i].PitchValue.NoteNumber - NoteDert); if (SelectingNoteCache[i].PitchValue.NoteNumber != NewNoteNumber) { SelectingNoteCache[i].PitchValue = new PitchAtomObject(NewNoteNumber, SelectingNoteCache[i].PitchValue.PitchWheel); } if (Math.Abs(TickDert) > minTickChange) { SelectingNoteCache[i].Tick = SelectingNoteCache[i].Tick - TickDert; } } if (Math.Abs(TickDert) > minTickChange) { NoteList.Sort(); } long AStartTick = Math.Min(oldStartTick, OldNoteSt.Tick); long AEndTick = Math.Max(oldEndTick, LastNoteEd.Tick + LastNoteEd.Length); int First = Math.Min(NoteList.IndexOf(SelectingNoteCache[0]), NoteList.IndexOf(OldNoteSt)); int Last = Math.Max(NoteList.IndexOf(SelectingNoteCache[SelectingNoteCache.Count - 1]), NoteList.IndexOf(LastNoteEd)); if (First <= Last) { if (!NotMove) { int StartPX = First; int EndPX = Last; int FSIdx = PartsObject.NoteCompiler.FindTickIndex(AStartTick, 0, PartsObject.NoteList.Count); int FEIdx = PartsObject.NoteCompiler.FindTickIndex(AEndTick, FSIdx, PartsObject.NoteList.Count) + 1; StartPX = Math.Min(StartPX, FSIdx); EndPX = Math.Max(EndPX, FEIdx); StartPX = Math.Max(0, StartPX); EndPX = Math.Min(NoteList.Count - 1, EndPX); PartsObject.PitchCompiler.SetupBasePitch_Aysnc(new Formats.Model.VocalObject.ParamTranslater.PitchCompiler.AsyncWorkCallbackHandler((F, L) => { this.PianoWindow.Invoke(new Action(() => { this.PianoWindow.RedrawPiano(); })); }), StartPX, EndPX); if (this.SingerDataFinder != null) { PartsObject po = PartsObject; this.SingerDataFinder.GetPhonemesDictionary(PartsObject).UpdateOutboundsLyric_Aysnc(new Formats.Model.Database.VocalDatabase.SplitDictionary.AsyncWorkCallbackHandler((P, F, L) => { }), ref po, StartPX, EndPX);; } } } } if (TickChanged) { NoteSelectIndexs.Clear(); for (int i = 0; i < SelectingNoteCache.Count; i++) { NoteSelectIndexs.Add(PartsObject.NoteList.IndexOf(SelectingNoteCache[i])); } } NoteDias.Clear(); } else if (NoteDragingWork == NoteDragingType.NoteAdd) { NoteObject nPN = new NoteObject(NoteDias[0].TickStart, NoteDias[0].TickEnd - NoteDias[0].TickStart, NoteDias[0].TopNoteNum); if (nPN.Length >= 32) { nPN.InitNote(); NoteList.Add(nPN); NoteList.Sort(); NoteDias.Clear(); int NIndex = NoteList.IndexOf(nPN); PartsObject.PitchCompiler.SetupBasePitch_Aysnc(new Formats.Model.VocalObject.ParamTranslater.PitchCompiler.AsyncWorkCallbackHandler((F, L) => { this.PianoWindow.Invoke(new Action(() => { this.PianoWindow.RedrawPiano(); })); }), NIndex, NIndex); if (this.SingerDataFinder != null) { PartsObject po = PartsObject; this.SingerDataFinder.GetPhonemesDictionary(PartsObject).UpdateLyrics_Aysnc(new Formats.Model.Database.VocalDatabase.SplitDictionary.AsyncWorkCallbackHandler((P, F, L) => { }), ref po, NIndex, NIndex);; } } else { NoteDragingWork = NoteDragingType.AreaSelect; } } else if (NoteDragingWork == NoteDragingType.AreaSelect) { ClearSelect(); long mt = NoteDias[0].TickEnd; long nt = NoteDias[0].TickStart; if (e.Tick >= nt && e.Tick <= mt) { int Sfx = PartsObject.NoteCompiler.FindTickIndex(nt, 0, NoteList.Count); for (int i = Sfx; i < NoteList.Count; i++) { NoteObject PN = NoteList[i]; if (PN.Tick >= mt) { break; } if (PN.Tick + PN.Length < nt) { continue; } if (PN.PitchValue.NoteNumber >= NoteDias[0].BottomNoteNum && PN.PitchValue.NoteNumber <= NoteDias[0].TopNoteNum) { NoteSelectIndexs.Add(i); } } } if (NoteSelectListChange != null) { NoteSelectListChange(NoteSelectIndexs); } NoteDias.Clear(); } if (NoteDragingWork != NoteDragingType.AreaSelect && NoteActionEnd != null) { if (NotMove) { NoteActionEnd(NoteDragingWork, true); } else { NoteActionEnd(NoteDragingWork); } } } NoteDragingWork = NoteDragingType.None; }
private void d2DPainterBox1_MouseMove(object sender, MouseEventArgs e) { if (DisableMouse) { return; } if (isMMoving) { return; } isMMoving = true; d2DPainterBox1.Refresh(); PianoMouseEventArgs pme = new PianoMouseEventArgs(e); pme.CalcAxis(pprops, rconf, pme_cache); OnMouseEventHandler Handle = null; //Move事件 EventHandler HandleEnter = null; //Enter事件 EventHandler HandleLeave = null; //Leave事件 switch (pme.Area) { case PianoMouseEventArgs.AreaType.Roll: Handle = RollMouseMove; HandleEnter = RollMouseEnter; break; case PianoMouseEventArgs.AreaType.Title: Handle = TitleMouseMove; HandleEnter = TitleMouseEnter; break; case PianoMouseEventArgs.AreaType.Track: Handle = TrackMouseMove; HandleEnter = TrackMouseEnter; break; } if (pme_sendEnterEvent) { if (HandleEnter != null) { HandleEnter(sender, e); } } else if (pme_cache.Area != pme.Area) { switch (pme_cache.Area) { case PianoMouseEventArgs.AreaType.Roll: HandleLeave = RollMouseLeave; break; case PianoMouseEventArgs.AreaType.Title: HandleLeave = TitleMouseLeave; break; case PianoMouseEventArgs.AreaType.Track: HandleLeave = TrackMouseLeave; break; } if (HandleEnter != null) { HandleEnter(sender, e); } if (HandleLeave != null) { HandleLeave(sender, e); } } if (Handle != null) { Handle(sender, pme); //发送Move } pme_cache = pme; pme_sendEnterEvent = false; this.OnMouseMove(e); isMMoving = false; }