private void DrawParameterButtonsArea(object sender, BalthasarLib.D2DPainter.D2DPaintEventArgs e, PianoRollPoint startPoint) { D2DGraphics g = e.D2DGraphics; Rectangle BlackRect = new Rectangle( 0, 0, rconf.Const_RollWidth, e.ClipRectangle.Height ); g.FillRectangle(BlackRect, Color.Black); //绘制分割线 g.DrawLine(new Point(rconf.Const_RollWidth, 0), new Point(rconf.Const_RollWidth, e.ClipRectangle.Height), Color.White, 1); Rectangle CurrentRect = new Rectangle( 0, 0, rconf.Const_RollWidth, e.ClipRectangle.Height );//可绘制区域 if (ParamBtnsPaint != null) { D2DPaintEventArgs d2de = new D2DPaintEventArgs( e.D2DGraphics, CurrentRect, e.MousePoint ); ParamBtnsPaint(sender, new BalthasarLib.PianoRollWindow.DrawUtils.ParamBtnsDrawUtils(d2de, rconf)); } }
private void DrawParameterLinesArea(object sender, BalthasarLib.D2DPainter.D2DPaintEventArgs e, PianoRollPoint startPoint) { D2DGraphics g = e.D2DGraphics; Rectangle BlackRect = new Rectangle( rconf.Const_RollWidth, 0, e.ClipRectangle.Width - rconf.Const_RollWidth, e.ClipRectangle.Height ); // g.FillRectangle(BlackRect, Color.Black); if (ParamAreaPaint != null) { D2DPaintEventArgs d2de = new D2DPaintEventArgs( e.D2DGraphics, BlackRect, e.MousePoint ); ParamAreaPaint(sender, new BalthasarLib.PianoRollWindow.DrawUtils.ParamAreaDrawUtils(d2de, rconf, pprops)); } //绘制分节符 //初始化 double x = rconf.Const_RollWidth; //起点画线 long BeatNumber = startPoint.BeatNumber; //获取起点拍号 double BeatPixelLength = pprops.dertTick2dertPixel(pprops.BeatLength); //一拍长度 if (startPoint.DenominatolTicksBefore != 0) //非完整Beats { //起点不在小节线 BeatNumber = startPoint.NextWholeBeatNumber; x = x + pprops.dertTick2dertPixel(startPoint.NextWholeBeatDistance); } while (x <= e.ClipRectangle.Width) { if (BeatNumber % pprops.BeatsCountPerSummery == 0) { g.DrawLine( new Point((int)Math.Round(x, 0), 0), new Point((int)Math.Round(x, 0), BlackRect.Height), rconf.TitleColor_Marker); long SummeryId = BeatNumber / pprops.BeatsCountPerSummery; } BeatNumber = BeatNumber + 1; x = x + BeatPixelLength; } g.DrawLine( new Point(BlackRect.Left, BlackRect.Height / 2), new Point(BlackRect.Width + BlackRect.Left, BlackRect.Height / 2), rconf.TitleColor_Marker); }
private void DrawTrackPartsArea(object sender, BalthasarLib.D2DPainter.D2DPaintEventArgs e, PianoRollPoint startPoint) { D2DGraphics g = e.D2DGraphics; int y = rconf.Const_TitleHeight; //绘制点纵坐标 int w = e.ClipRectangle.Width - rconf.Const_VScrollBarWidth; //绘制分节符 //初始化 double x = rconf.Const_GridWidth; //起点画线 long BeatNumber = startPoint.BeatNumber; //获取起点拍号 double BeatPixelLength = pprops.dertTick2dertPixel(pprops.BeatLength); //一拍长度 if (startPoint.DenominatolTicksBefore != 0) //非完整Beats { //起点不在小节线 BeatNumber = startPoint.NextWholeBeatNumber; x = x + pprops.dertTick2dertPixel(startPoint.NextWholeBeatDistance); } while (x <= w) { g.DrawLine( new Point((int)Math.Round(x, 0), rconf.Const_TitleHeight), new Point((int)Math.Round(x, 0), e.ClipRectangle.Height), BeatNumber % pprops.BeatsCountPerSummery == 0 ? Color.White : rconf.TitleColor_Marker ); BeatNumber = BeatNumber + 1; x = x + BeatPixelLength; } //Rise 绘制Note等//传递事件 Rectangle CurrentRect = new Rectangle( rconf.Const_GridWidth, rconf.Const_TitleHeight, w - rconf.Const_GridWidth, e.ClipRectangle.Height - rconf.Const_TitleHeight);//可绘制区域 if (TPartsPaint != null) { D2DPaintEventArgs d2de = new D2DPaintEventArgs( e.D2DGraphics, CurrentRect, e.MousePoint ); TPartsPaint(sender, new DrawUtils.TrackerPartsDrawUtils(d2de, rconf, pprops)); } }
protected override void OnPaint(PaintEventArgs e) { try { if (RenderTarget2D != null) { RenderTarget2D.BeginDraw(); g.Clear(); if (D2DPaint != null) { D2DPaintEventArgs d2de = new D2DPaintEventArgs(g, new Rectangle(0, 0, this.Width, this.Height), MousePoint); D2DPaint(this, d2de); } RenderTarget2D.EndDraw(); } } catch {; } }
private void DrawTrackGrideArea(object sender, BalthasarLib.D2DPainter.D2DPaintEventArgs e) { D2DGraphics g = e.D2DGraphics; Rectangle CurrentRect = new Rectangle( 0, rconf.Const_TitleHeight, rconf.Const_GridWidth, e.ClipRectangle.Height - rconf.Const_TitleHeight);//可绘制区域 g.FillRectangle(CurrentRect, Color.Black); g.DrawLine(new Point(rconf.Const_GridWidth, rconf.Const_TitleHeight), new Point(rconf.Const_GridWidth, e.ClipRectangle.Height), Color.White, 2); if (TGridePaint != null) { D2DPaintEventArgs d2de = new D2DPaintEventArgs( e.D2DGraphics, CurrentRect, e.MousePoint ); TGridePaint(sender, new DrawUtils.TrackerGridesDrawUtils(d2de, rconf, pprops)); } }
private void DrawPianoRollArea(object sender, BalthasarLib.D2DPainter.D2DPaintEventArgs e) { D2DGraphics g = e.D2DGraphics; int y = rconf.Const_TitleHeight; //绘制点纵坐标 int cNote = (int)pprops.PianoTopNote; //绘制区域第一个阶的音符 int MyNotePx = (int)((e.MousePoint.Y - rconf.Const_TitleHeight) / rconf.Const_RollNoteHeight); //获取当前琴键 int MyNote = (int)pprops.PianoTopNote - MyNotePx; //获取坐标 while (y < e.ClipRectangle.Height) //若未画超界 { //计算绘制区域 Point LT = new Point(0, y); //矩形左上角 Point LB = new Point(0, y + rconf.Const_RollNoteHeight); //矩形左下角 Point RT = new Point(rconf.Const_RollWidth, y); //矩形右上角 Point RB = new Point(rconf.Const_RollWidth, y + rconf.Const_RollNoteHeight); //矩形右下角 Rectangle WhiteRect = new Rectangle(LT, new Size(rconf.Const_RollWidth, rconf.Const_RollNoteHeight)); //矩形区域 Rectangle BlackRect = new Rectangle(LT, new Size(rconf.Const_RollBlackWidth, rconf.Const_RollNoteHeight)); //矩形区域 Rectangle WordRect = new Rectangle(new Point(LT.X + rconf.Const_RollBlackWidth, LT.Y), new Size(rconf.Const_RollWidth - rconf.Const_RollBlackWidth, rconf.Const_RollNoteHeight)); //矩形区域 //绘制基础矩形 g.FillRectangle(WhiteRect, rconf.PianoColor_WhiteKey); g.DrawRectangle(WhiteRect, rconf.PianoColor_Line); //绘制黑键 PitchAtomObject NoteValue = new PitchAtomObject((uint)cNote, 0); NoteValue.OctaveType = pprops.OctaveType; int Octave = NoteValue.Octave; int Key = NoteValue.Key; bool isBlackKey = NoteValue.IsBlackKey; if (isBlackKey) { g.FillRectangle(BlackRect, rconf.PianoColor_BlackKey); } //获取鼠标位置琴键 //绘制符号 if (MyNote == cNote) { g.FillRectangle(WordRect, rconf.PianoColor_MouseKey); g.DrawText(" " + NoteValue.NoteChar + Octave.ToString(), WordRect, rconf.PianoColor_BlackKey, new System.Drawing.Font("Tahoma", 10)); } else if (Key == 0) { g.DrawText(" " + NoteValue.NoteChar + Octave.ToString(), WordRect, rconf.PianoColor_BlackKey, new System.Drawing.Font("Tahoma", 10)); } //递归 y = y + rconf.Const_RollNoteHeight; cNote = cNote - 1; } //Rise 绘制Note等//传递事件 // e.ClipRectangle.Width - rconf.Const_RollWidth, rconf.Const_RollNoteHeight Rectangle CurrentRect = new Rectangle( 0, rconf.Const_TitleHeight, rconf.Const_RollWidth, e.ClipRectangle.Height - rconf.Const_TitleHeight);//可绘制区域 if (RollPaint != null) { D2DPaintEventArgs d2de = new D2DPaintEventArgs( e.D2DGraphics, CurrentRect, e.MousePoint ); RollPaint(sender, new VocalUtau.DirectUI.DrawUtils.RollDrawUtils(d2de, rconf, pprops)); } }
private void DrawPianoTitleArea(object sender, BalthasarLib.D2DPainter.D2DPaintEventArgs e, PianoRollPoint startPoint) { D2DGraphics g = e.D2DGraphics; Rectangle BlackRect = new Rectangle( 0, 0, e.ClipRectangle.Width, rconf.Const_TitleHeight ); g.FillRectangle(BlackRect, Color.Black); Rectangle TitleSpliterRect = new Rectangle( 0, rconf.Const_TitleHeight - rconf.Const_TitleHeightSpliter - 1, e.ClipRectangle.Width, rconf.Const_TitleHeightSpliter ); g.DrawLine(new Point(0, rconf.Const_TitleLineTop), new Point(e.ClipRectangle.Width, rconf.Const_TitleLineTop), rconf.TitleColor_Line, 2); g.DrawLine(new Point(0, rconf.Const_TitleRulerTop), new Point(e.ClipRectangle.Width, rconf.Const_TitleRulerTop), rconf.TitleColor_Ruler, 2); //绘制分节符 //初始化 double x = rconf.Const_RollWidth; //起点画线 long BeatNumber = startPoint.BeatNumber; //获取起点拍号 double BeatPixelLength = pprops.dertTick2dertPixel(pprops.BeatLength); //一拍长度 if (startPoint.DenominatolTicksBefore != 0) //非完整Beats { //起点不在小节线 BeatNumber = startPoint.NextWholeBeatNumber; x = x + pprops.dertTick2dertPixel(startPoint.NextWholeBeatDistance); } int My1 = (rconf.Const_TitleRulerTop * 2 / 3); int My2 = rconf.Const_TitleRulerTop + 1; while (x <= e.ClipRectangle.Width) { if (BeatNumber % pprops.BeatsCountPerSummery == 0) { g.DrawLine( new Point((int)Math.Round(x, 0), 0), new Point((int)Math.Round(x, 0), rconf.Const_TitleHeight), Color.White); long SummeryId = BeatNumber / pprops.BeatsCountPerSummery; g.DrawText(" " + SummeryId.ToString(), new Rectangle(new Point((int)Math.Round(x, 0), rconf.Const_TitleLineTop), new Size((int)pprops.BeatLength, rconf.Const_TitleRulerTop - rconf.Const_TitleLineTop)), Color.White, new Font("宋体", 12)); } else { g.DrawLine( new Point((int)Math.Round(x, 0), My1), new Point((int)Math.Round(x, 0), My2), rconf.TitleColor_Marker); } BeatNumber = BeatNumber + 1; x = x + BeatPixelLength; } //绘制分割线 g.DrawLine(new Point(rconf.Const_RollWidth, 0), new Point(rconf.Const_RollWidth, rconf.Const_TitleHeight), Color.White, 2); g.FillRectangle(TitleSpliterRect, rconf.PianoColor_WhiteKey); Rectangle CurrentRect = new Rectangle( 0, 0, e.ClipRectangle.Width, rconf.Const_TitleHeight );//可绘制区域 if (TitlePaint != null) { D2DPaintEventArgs d2de = new D2DPaintEventArgs( e.D2DGraphics, CurrentRect, e.MousePoint ); TitlePaint(sender, new VocalUtau.DirectUI.DrawUtils.TitleDrawUtils(d2de, rconf, pprops)); } }
private void DrawPianoTrackArea(object sender, BalthasarLib.D2DPainter.D2DPaintEventArgs e, PianoRollPoint startPoint) { D2DGraphics g = e.D2DGraphics; int y = rconf.Const_TitleHeight;//绘制点纵坐标 int w = e.ClipRectangle.Width - rconf.Const_VScrollBarWidth; //绘制钢琴窗 int cNote = (int)pprops.PianoTopNote; //绘制区域第一个阶的音符 while (y < e.ClipRectangle.Height) //若未画超界 { //计算绘制区域 Point LT = new Point(rconf.Const_RollWidth, y); //矩形左上角 Point LB = new Point(rconf.Const_RollWidth, y + rconf.Const_RollNoteHeight); //矩形左下角 Point RT = new Point(w, y); //矩形右上角 Point RB = new Point(w, y + rconf.Const_RollNoteHeight); //矩形右下角 Rectangle Rect = new Rectangle(LT, new Size(w - rconf.Const_RollWidth, rconf.Const_RollNoteHeight)); //矩形区域 //计算色域 PitchAtomObject NoteValue = new PitchAtomObject((uint)cNote, 0); NoteValue.OctaveType = pprops.OctaveType; int Octave = NoteValue.OctaveType == PitchAtomObject.OctaveTypeEnum.Voice ? NoteValue.Octave : NoteValue.Octave - 1; int Key = NoteValue.Key; bool isBlackKey = NoteValue.IsBlackKey; Color KeyColor = isBlackKey ? rconf.RollColor_BlackKey_NormalSound : rconf.RollColor_WhiteKey_NormalSound; Color LineColor = rconf.RollColor_LineKey_NormalSound; Color OLineColor = rconf.RollColor_LineOctive_NormalSound; switch (rconf.getVoiceArea(cNote)) { case RollConfigures.VoiceKeyArea.OverSound: KeyColor = isBlackKey ? rconf.RollColor_BlackKey_OverSound : rconf.RollColor_WhiteKey_OverSound; LineColor = rconf.RollColor_LineKey_OverSound; OLineColor = rconf.RollColor_LineOctive_OverSound; break; case RollConfigures.VoiceKeyArea.NoSound: KeyColor = isBlackKey ? rconf.RollColor_BlackKey_NoSound : rconf.RollColor_WhiteKey_NoSound; LineColor = rconf.RollColor_LineKey_NoSound; OLineColor = rconf.RollColor_LineOctive_OverSound; break; } //绘制矩形 g.FillRectangle(Rect, KeyColor); //绘制边线 g.DrawLine(LB, RB, (Key == 5 || Key == 0) ? OLineColor : LineColor, 2);//isB ? LineL : LineB); //递归 y = y + rconf.Const_RollNoteHeight; cNote = cNote - 1; } //绘制分节符 //初始化 double x = rconf.Const_RollWidth; //起点画线 long BeatNumber = startPoint.BeatNumber; //获取起点拍号 double BeatPixelLength = pprops.dertTick2dertPixel(pprops.BeatLength); //一拍长度 if (startPoint.DenominatolTicksBefore != 0) //非完整Beats { //起点不在小节线 BeatNumber = startPoint.NextWholeBeatNumber; x = x + pprops.dertTick2dertPixel(startPoint.NextWholeBeatDistance); } while (x <= w) { g.DrawLine( new Point((int)Math.Round(x, 0), rconf.Const_TitleHeight), new Point((int)Math.Round(x, 0), e.ClipRectangle.Height), BeatNumber % pprops.BeatsCountPerSummery == 0 ? Color.Black : rconf.RollColor_LineOctive_NormalSound ); BeatNumber = BeatNumber + 1; x = x + BeatPixelLength; } //Rise 绘制Note等//传递事件 Rectangle CurrentRect = new Rectangle( rconf.Const_RollWidth, rconf.Const_TitleHeight, w - rconf.Const_RollWidth, e.ClipRectangle.Height - rconf.Const_TitleHeight);//可绘制区域 if (TrackPaint != null) { D2DPaintEventArgs d2de = new D2DPaintEventArgs( e.D2DGraphics, CurrentRect, e.MousePoint ); TrackPaint(sender, new VocalUtau.DirectUI.DrawUtils.TrackDrawUtils(d2de, rconf, pprops)); } }