コード例 #1
0
        internal PianoRollPoint getPianoStartPoint()
        {
            //获取当前信息
            long BeatCountBefore       = PianoStartTick / BeatLength; //获取之前有几个整拍子
            long BeatDenominatolBefore = PianoStartTick % BeatLength; //获取余数拍子

            PianoRollPoint ret = new PianoRollPoint();

            ret.Tick                   = PianoStartTick;
            ret.BeatNumber             = BeatCountBefore;
            ret.DenominatolTicksBefore = BeatDenominatolBefore;
            ret.NextWholeBeatNumber    = ret.BeatNumber + 1;
            ret.NextWholeBeatDistance  = BeatLength - BeatDenominatolBefore;
            return(ret);
        }
コード例 #2
0
 private void d2DPainterBox1_D2DPaint(object sender, BalthasarLib.D2DPainter.D2DPaintEventArgs e)
 {
     if (isDrawing)
     {
         return;
     }
     isDrawing = true;
     try
     {
         PianoRollPoint sp = pprops.getPianoStartPoint();
         DrawPianoTrackArea(sender, e, sp);
         DrawPianoRollArea(sender, e);
         DrawPianoTitleArea(sender, e, sp);
     }
     catch {; }
     isDrawing = false;
 }
コード例 #3
0
 private void d2DPainterBox1_D2DPaint(object sender, BalthasarLib.D2DPainter.D2DPaintEventArgs e)
 {
     if (isDrawing)
     {
         return;
     }
     isDrawing = true;
     try
     {
         PianoRollPoint sp = pprops.getPianoStartPoint();
         DrawParameterLinesArea(sender, e, sp);
         DrawParameterButtonsArea(sender, e, sp);
         e.D2DGraphics.DrawLine(new Point(0, 1), new Point(d2DPainterBox1.Width, 1), SystemColors.Control);
     }
     catch {; }
     isDrawing = false;
 }
コード例 #4
0
        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));
            }
        }
コード例 #5
0
        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));
            }
        }
コード例 #6
0
        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));
            }
        }
コード例 #7
0
        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 VocalUtau.DirectUI.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);
        }
コード例 #8
0
        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 VocalUtau.DirectUI.DrawUtils.ParamBtnsDrawUtils(d2de, rconf));
            }
        }