public void Draw(Graphics g, LaneBook laneBook, Point originLocation) { if (StartPosition == null || EndPosition == null) { return; } ScoreLane futureLane = laneBook.Find( x => x.StartTick <= TopLeftPosition.Tick && TopLeftPosition.Tick <= x.EndTick); ScoreLane pastLane = laneBook.Find( x => x.StartTick <= BottomRightPosition.Tick && BottomRightPosition.Tick <= x.EndTick); int passingLanes = futureLane != null ? futureLane.Index - pastLane.Index : laneBook.Count - pastLane.Index - 1; PointF topLeft = new PointF( pastLane.LaneRect.Left + TopLeftPosition.Lane * ScoreInfo.UnitLaneWidth - originLocation.X, pastLane.LaneRect.Bottom - (TopLeftPosition.Tick - pastLane.StartTick) * ScoreInfo.UnitBeatHeight - originLocation.Y - minHeight / 2); PointF topRight = new PointF( pastLane.LaneRect.Left + (BottomRightPosition.Lane + 1) * ScoreInfo.UnitLaneWidth - originLocation.X, pastLane.LaneRect.Bottom - (TopLeftPosition.Tick - pastLane.StartTick) * ScoreInfo.UnitBeatHeight - originLocation.Y - minHeight / 2); PointF bottomLeft = new PointF( pastLane.LaneRect.Left + TopLeftPosition.Lane * ScoreInfo.UnitLaneWidth - originLocation.X, pastLane.LaneRect.Bottom - (BottomRightPosition.Tick - pastLane.StartTick) * ScoreInfo.UnitBeatHeight - originLocation.Y + minHeight / 2); PointF bottomRight = new PointF( pastLane.LaneRect.Left + (BottomRightPosition.Lane + 1) * ScoreInfo.UnitLaneWidth - originLocation.X, pastLane.LaneRect.Bottom - (BottomRightPosition.Tick - pastLane.StartTick) * ScoreInfo.UnitBeatHeight - originLocation.Y + minHeight / 2); using (GraphicsPath graphicsPath = new GraphicsPath()) { var smoothingMode = g.SmoothingMode; g.SmoothingMode = SmoothingMode.Default; var itrLane = pastLane; for (int i = 0; i <= passingLanes; ++i, itrLane = laneBook.Next(itrLane)) { graphicsPath.AddLines(new PointF[] { topLeft, bottomLeft, bottomRight, topRight }); graphicsPath.CloseFigure(); if (itrLane.StartTick <= Status.DrawTickLast && itrLane.EndTick >= Status.DrawTickFirst) { using (Pen pen = new Pen(Color.White, 1)) { pen.DashPattern = new float[] { 4f, 4f }; RectangleF clipRect = new RectangleF( itrLane.LaneRect.X - originLocation.X, itrLane.LaneRect.Y - originLocation.Y, //HACK: 選択領域矩形が少し大きいので見切れないようにする itrLane.LaneRect.Width + 1, itrLane.LaneRect.Height + 5); g.Clip = new Region(clipRect); g.DrawPath(pen, graphicsPath); } } topLeft = topLeft.Add(ScoreLane.Width + ScorePanel.Margin.Left + ScorePanel.Margin.Right, itrLane.LaneRect.Height); topRight = topRight.Add(ScoreLane.Width + ScorePanel.Margin.Left + ScorePanel.Margin.Right, itrLane.LaneRect.Height); bottomLeft = bottomLeft.Add(ScoreLane.Width + ScorePanel.Margin.Left + ScorePanel.Margin.Right, itrLane.LaneRect.Height); bottomRight = bottomRight.Add(ScoreLane.Width + ScorePanel.Margin.Left + ScorePanel.Margin.Right, itrLane.LaneRect.Height); graphicsPath.ClearMarkers(); } g.SmoothingMode = smoothingMode; } g.ResetClip(); }
public void UpdateLocation(LaneBook laneBook) { ScoreLane lane = laneBook.Find(x => x.StartTick <= Position.Tick && Position.Tick <= x.EndTick); if (lane == null) { return; } PointF location = new PointF( lane.LaneRect.Left + Position.Lane * ScoreInfo.UnitLaneWidth, //HACK: Y座標が微妙にずれるので-1して調節する lane.HitRect.Bottom - (Position.Tick - lane.StartTick) * ScoreInfo.UnitBeatHeight - 1); RelocateOnly(location, lane.Index); }
private static void DrawHoldLine(Graphics g, Note past, Note future, Point drawLocation, LaneBook laneBook) { float distance = (future.Position.Tick - past.Position.Tick) * ScoreInfo.UnitBeatHeight; //グラデーション矩形 //x座標と幅は適当だけど動いてるはず。重要なのはy座標と高さ RectangleF gradientRect = new RectangleF(0, past.Location.Y - distance + drawOffset.Y - drawLocation.Y, 10, distance <= 0 ? 1 : distance); //相対位置 PointF pastRerativeLocation = new PointF(past.Location.X - drawLocation.X, past.Location.Y - drawLocation.Y); int passingLanes = future.LaneIndex - past.LaneIndex; float positionDistance = (future.Position.Tick - past.Position.Tick) * ScoreInfo.UnitBeatHeight; float diffX = (future.Position.Lane - past.Position.Lane) * ScoreInfo.UnitLaneWidth; //ノーツfutureの位置はノーツpastの位置に2ノーツの距離を引いて表す。またTopRightの水平位置はfutureのWidthを使うことに注意 PointF topLeft = pastRerativeLocation.Add(diffX, -positionDistance).Add(drawOffset); PointF topRight = pastRerativeLocation.Add(diffX, -positionDistance).Add(-drawOffset.X, drawOffset.Y).AddX(future.Width); //以下の2つはレーンをまたがないときと同じ PointF bottomLeft = pastRerativeLocation.Add(drawOffset); PointF bottomRight = pastRerativeLocation.Add(-drawOffset.X, drawOffset.Y).AddX(past.Width); using (GraphicsPath graphicsPath = new GraphicsPath()) { graphicsPath.AddLines(new PointF[] { topLeft, bottomLeft, bottomRight, topRight }); ScoreLane scoreLane = laneBook.Find(x => x.Contains(past)); for (int i = 0; i <= passingLanes && scoreLane != null; ++i) { if (Status.DrawTickFirst < scoreLane.EndTick && scoreLane.StartTick < Status.DrawTickLast) { RectangleF clipRect = new RectangleF( scoreLane.LaneRect.X - drawLocation.X, scoreLane.LaneRect.Y - drawLocation.Y, scoreLane.LaneRect.Width, scoreLane.LaneRect.Height); g.Clip = new Region(clipRect); using (LinearGradientBrush myBrush = new LinearGradientBrush(gradientRect, baseColor, baseColor, LinearGradientMode.Vertical)) { myBrush.InterpolationColors = colorBlend; g.FillPath(myBrush, graphicsPath); } } // インクリメント if (i != passingLanes) { graphicsPath.Translate(ScoreLane.Width + ScorePanel.Margin.Left + ScorePanel.Margin.Right, scoreLane.HitRect.Height); gradientRect.Y += scoreLane.HitRect.Height; scoreLane = laneBook.Next(scoreLane); } } } }
public void SetPanelSize(PanelSize panelSize) { // HACK: とりあえず決めうちにした int[] formHeight = { 558, 750, 940 }; switch (panelSize) { case PanelSize.Small: ScoreInfo.ScaleConstant = .25f; tsmiSizeSmall.Checked = true; tsmiSizeMiddle.Checked = false; tsmiSizeBig.Checked = false; Height = formHeight[0]; break; case PanelSize.Middle: ScoreInfo.ScaleConstant = .375f; tsmiSizeSmall.Checked = false; tsmiSizeMiddle.Checked = true; tsmiSizeBig.Checked = false; Height = formHeight[1]; break; case PanelSize.Big: ScoreInfo.ScaleConstant = .5f; tsmiSizeSmall.Checked = false; tsmiSizeMiddle.Checked = false; tsmiSizeBig.Checked = true; Height = formHeight[2]; break; } ScoreInfo.LaneMaxBar = ScoreInfo.ScaleConstant / ScoreInfo.UnitBeatHeight; ScoreLane.RefreshLaneSize(); foreach (TabPageEx tabPageEx in tabScore.TabPages) { tabPageEx.ScorePanel.RefreshLaneSize(); } }
/// <summary> /// SlideCurveの当たり判定 /// </summary> private bool ContainsInCurve(Note past, Note curve, Note future, LaneBook laneBook, PointF locationVirtual) { int passingLanes = future.LaneIndex - past.LaneIndex; using (GraphicsPath graphicsPath = MyUtil.CreateSlideCurvePath(past, curve, future, drawOffset)) { ScoreLane lane = laneBook.Find(x => x.Contains(past)); for (int i = 0; i <= passingLanes && lane != null; ++i) { if (graphicsPath.IsVisible(locationVirtual)) { return(true); } else { graphicsPath.Translate( ScoreLane.scoreWidth + ScoreLane.Margin.Left + ScorePanel.Margin.Right + ScorePanel.Margin.Left + ScoreLane.Margin.Right, lane.HitRect.Height); lane = laneBook.Next(lane); } } } return(false); }
public EditCMenu(ScorePanel sPanel, ScoreLane selectedLane, Score selectedScore, Position clickPosition) { barAddItems = new ToolStripItem[] { new ToolStripMenuItem("選択小節の1つ前", null, BarAddBackward), new ToolStripMenuItem("選択小節の1つ先", null, BarAddForward), new ToolStripMenuItem("カスタム...", null, BarAddCustom) }; barAddWithNoteItems = new ToolStripItem[] { new ToolStripMenuItem("選択小節の1つ前", null, BarAddBackwardWithNote), new ToolStripMenuItem("選択小節の1つ先", null, BarAddForwardWithNote), new ToolStripMenuItem("カスタム...", null, BarAddCustomWithNote) }; barDeleteItems = new ToolStripItem[] { new ToolStripMenuItem("選択小節", null, BarDeleteSelected), new ToolStripMenuItem("カスタム...", null, BarDeleteCustom) }; barDeleteWithNoteItems = new ToolStripItem[] { new ToolStripMenuItem("選択小節", null, BarDeleteSelectedWithNote), new ToolStripMenuItem("カスタム...", null, BarDeleteCustomWithNote) }; laneFillItems = new ToolStripItem[] { new ToolStripMenuItem("レーン全体", null, LaneFillAll), new ToolStripMenuItem("選択レーン以降", null, LaneFill) }; ToolStripMenuItem barAddWithNote = new ToolStripMenuItem("小節を挿入", null) { ToolTipText = "選択した小節の前後に新しい小節を追加します\nすでに配置されているノーツの相対座標は変更されます" }; barAddWithNote.DropDownItems.AddRange(barAddWithNoteItems); ToolStripMenuItem barAdd = new ToolStripMenuItem("小節を挿入(小節のみ)", null) { ToolTipText = "選択した小節の前後に新しい小節を追加します\nすでに配置されているノーツの相対座標は変更されません" }; barAdd.DropDownItems.AddRange(barAddItems); ToolStripMenuItem barDeleteWithNote = new ToolStripMenuItem("小節を削除", null) { ToolTipText = "選択した小節またはそれ以降の複数の小節を削除します\n削除対象の小節にノーツが配置されている場合、ノーツも削除されます" }; barDeleteWithNote.DropDownItems.AddRange(barDeleteWithNoteItems); ToolStripMenuItem barDelete = new ToolStripMenuItem("小節を削除(小節のみ)", null) { ToolTipText = "選択した小節またはそれ以降の複数の小節を削除します\n小節のみ削除するため、ノーツは削除されません" }; barDelete.DropDownItems.AddRange(barDeleteItems); ToolStripMenuItem laneFill = new ToolStripMenuItem("レーンを詰める", null); laneFill.DropDownItems.AddRange(laneFillItems); stripItems = new ToolStripItem[] { barAddWithNote, barAdd, barDeleteWithNote, barDelete, new ToolStripMenuItem("選択小節を改行", null, BarDivide), laneFill, new ToolStripSeparator(), new ToolStripMenuItem("貼り付け", null, (s, e) => sPanel.PasteNotes(clickPosition)) { Enabled = Status.IsPasteAvailable }, new ToolStripMenuItem("左右反転して貼り付け", null, (s, e) => { sPanel.PasteAndReverseNotes(clickPosition); }) { Enabled = Status.IsPasteAvailable } }; Items.AddRange(stripItems); this.sPanel = sPanel; this.selectedLane = selectedLane; this.selectedScore = selectedScore; }
/// <summary> /// ノーツ間を繋ぐ帯の描画(ベジェ) /// </summary> private static void DrawSlideCurve(Graphics g, Note past, Note curve, Note future, Point drawLocation, LaneBook laneBook, ref RectangleF gradientRect) { if (gradientRect.Width <= 0) { gradientRect.Width = 1; } if (gradientRect.Height <= 0) { gradientRect.Height = 1; } //相対位置 PointF pastRerativeLocation = new PointF(past.Location.X - drawLocation.X, past.Location.Y - drawLocation.Y); int passingLanes = future.LaneIndex - past.LaneIndex; float positionDistanceFuture = (future.Position.Tick - past.Position.Tick) * ScoreInfo.UnitBeatHeight; float positionDistanceCurve = (curve.Position.Tick - past.Position.Tick) * ScoreInfo.UnitBeatHeight; float diffXFuture = (future.Position.Lane - past.Position.Lane) * ScoreInfo.UnitLaneWidth; float diffXCurve = (curve.Position.Lane - past.Position.Lane) * ScoreInfo.UnitLaneWidth; //ノーツfutureの位置はノーツpastの位置に2ノーツの距離を引いて表す。またTopRightの水平位置はfutureのWidthを使うことに注意 PointF topLeft = pastRerativeLocation.Add(diffXFuture, -positionDistanceFuture).Add(drawOffset); PointF topRight = pastRerativeLocation.Add(diffXFuture, -positionDistanceFuture).Add(-drawOffset.X, drawOffset.Y).AddX(future.Width); //以下の2つはレーンをまたがないときと同じ PointF bottomLeft = pastRerativeLocation.Add(drawOffset).AddY(deltaHeight); PointF bottomRight = pastRerativeLocation.Add(-drawOffset.X, drawOffset.Y).AddX(past.Width).AddY(deltaHeight); //3つのそれぞれのノーツの中心の座標 PointF topCenter = topLeft.AddX(future.Width / 2f - drawOffset.X); PointF bottomCenter = bottomLeft.AddX(past.Width / 2f - drawOffset.X); PointF curveCenter = pastRerativeLocation.Add(diffXCurve, -positionDistanceCurve).AddX(curve.Width / 2f); // //下からアンカーまでの比率 float ratio = (curveCenter.Y - bottomCenter.Y) / (topCenter.Y - bottomCenter.Y); //カーブノーツのY座標で水平にスライドを切ったときのスライド幅 float widthAnchor = (topRight.X - topLeft.X) * ratio + (bottomRight.X - bottomLeft.X) * (1 - ratio); using (GraphicsPath graphicsPath = new GraphicsPath()) { graphicsPath.AddBezier(bottomLeft, curveCenter.AddX(-widthAnchor / 2f), topLeft); graphicsPath.AddLine(topLeft, topRight); graphicsPath.AddBezier(topRight, curveCenter.AddX(widthAnchor / 2f), bottomRight); graphicsPath.AddLine(bottomLeft, bottomRight); ScoreLane scoreLane = laneBook.Find(x => x.Contains(past)); RectangleF clipRect; for (int i = 0; i <= passingLanes && scoreLane != null; ++i) { if (Status.DrawTickFirst < scoreLane.EndTick && scoreLane.StartTick < Status.DrawTickLast) { clipRect = new RectangleF( scoreLane.LaneRect.X - drawLocation.X, scoreLane.LaneRect.Y - drawLocation.Y, scoreLane.LaneRect.Width, scoreLane.LaneRect.Height); g.Clip = new Region(clipRect); using (LinearGradientBrush myBrush = new LinearGradientBrush(gradientRect, baseColor, baseColor, LinearGradientMode.Vertical)) { myBrush.InterpolationColors = colorBlend; g.FillPath(myBrush, graphicsPath); } using (Pen myPen = new Pen(lineColor, 2)) { g.DrawBezier(myPen, bottomCenter, curveCenter, topCenter); } } // インクリメント bottomCenter = bottomCenter.Add(ScoreLane.Width + ScorePanel.Margin.Left + ScorePanel.Margin.Right, scoreLane.HitRect.Height); curveCenter = curveCenter.Add(ScoreLane.Width + ScorePanel.Margin.Left + ScorePanel.Margin.Right, scoreLane.HitRect.Height); topCenter = topCenter.Add(ScoreLane.Width + ScorePanel.Margin.Left + ScorePanel.Margin.Right, scoreLane.HitRect.Height); if (i != passingLanes) { graphicsPath.Translate(ScoreLane.Width + ScorePanel.Margin.Left + ScorePanel.Margin.Right, scoreLane.HitRect.Height); gradientRect.Y += scoreLane.HitRect.Height; scoreLane = laneBook.Next(scoreLane); } } } }
/// <summary> /// ノーツ間を繋ぐ帯の描画(直線) /// </summary> private static void DrawSlideLine(Graphics g, Note past, Note future, Point drawLocation, LaneBook laneBook, ref RectangleF gradientRect) { if (gradientRect.Width <= 0) { gradientRect.Width = 1; } if (gradientRect.Height <= 0) { gradientRect.Height = 1; } //相対位置 PointF pastRerativeLocation = new PointF(past.Location.X - drawLocation.X, past.Location.Y - drawLocation.Y); int passingLanes = future.LaneIndex - past.LaneIndex; float positionDistance = (future.Position.Tick - past.Position.Tick) * ScoreInfo.UnitBeatHeight; float diffX = (future.Position.Lane - past.Position.Lane) * ScoreInfo.UnitLaneWidth; //ノーツfutureの位置はノーツpastの位置に2ノーツの距離を引いて表す。またTopRightの水平位置はfutureのWidthを使うことに注意 PointF topLeft = pastRerativeLocation.Add(diffX, -positionDistance).Add(drawOffset); PointF topRight = pastRerativeLocation.Add(diffX, -positionDistance).Add(-drawOffset.X, drawOffset.Y).AddX(future.Width); //以下の2つはレーンをまたがないときと同じ PointF bottomLeft = pastRerativeLocation.Add(drawOffset).AddY(deltaHeight); PointF bottomRight = pastRerativeLocation.Add(-drawOffset.X, drawOffset.Y).AddX(past.Width).AddY(deltaHeight); using (GraphicsPath graphicsPath = new GraphicsPath()) { graphicsPath.AddPolygon(new PointF[] { topLeft, bottomLeft, bottomRight, topRight }); ScoreLane scoreLane = laneBook.Find(x => x.Contains(past)); RectangleF clipRect; for (int i = 0; i <= passingLanes && scoreLane != null; ++i) { if (Status.DrawTickFirst < scoreLane.EndTick && scoreLane.StartTick < Status.DrawTickLast) { clipRect = new RectangleF( scoreLane.LaneRect.X - drawLocation.X, scoreLane.LaneRect.Y - drawLocation.Y, scoreLane.LaneRect.Width, scoreLane.LaneRect.Height); g.Clip = new Region(clipRect); using (LinearGradientBrush myBrush = new LinearGradientBrush(gradientRect, baseColor, baseColor, LinearGradientMode.Vertical)) { myBrush.InterpolationColors = colorBlend; g.FillPath(myBrush, graphicsPath); } using (Pen myPen = new Pen(lineColor, 2)) { g.DrawLine( myPen, (graphicsPath.PathPoints[1].X + graphicsPath.PathPoints[2].X) / 2, graphicsPath.PathPoints[1].Y, (graphicsPath.PathPoints[0].X + graphicsPath.PathPoints[3].X) / 2, graphicsPath.PathPoints[0].Y); } } // インクリメント if (i != passingLanes) { graphicsPath.Translate(ScoreLane.Width + ScorePanel.Margin.Left + ScorePanel.Margin.Right, scoreLane.HitRect.Height); gradientRect.Y += scoreLane.HitRect.Height; scoreLane = laneBook.Next(scoreLane); } } } }
public void FillLane(ScoreLane begin) { LaneBook.FillLane(begin); }
private static void DrawAirHoldLine(Graphics g, Note past, Note future, Point drawLocation, LaneBook laneBook) { float distance = (future.Position.Tick - past.Position.Tick) * ScoreInfo.UnitBeatHeight; PointF drawOffset = new PointF(past.Width / 2f - lineWidth / 2f, LongNote.drawOffset.Y); //相対位置 PointF pastRerativeLocation = new PointF(past.Location.X - drawLocation.X, past.Location.Y - drawLocation.Y); PointF futureRerativeLocation = new PointF(future.Location.X - drawLocation.X, future.Location.Y - drawLocation.Y); int passingLanes = future.LaneIndex - past.LaneIndex; //スライドのノーツとノーツがレーンをまたがないとき if (passingLanes == 0) { PointF topLeft = futureRerativeLocation.Add(drawOffset); PointF topRight = futureRerativeLocation.Add(-drawOffset.X, drawOffset.Y).AddX(future.Width); PointF bottomLeft = pastRerativeLocation.Add(drawOffset); PointF bottomRight = pastRerativeLocation.Add(-drawOffset.X, drawOffset.Y).AddX(past.Width); using (GraphicsPath graphicsPath = new GraphicsPath()) { graphicsPath.AddLines(new PointF[] { topLeft, bottomLeft, bottomRight, topRight }); using (SolidBrush myBrush = new SolidBrush(lineColor)) { g.FillPath(myBrush, graphicsPath); } } } //スライドのノーツとノーツがレーンをまたぐとき else if (passingLanes >= 1) { float positionDistance = (future.Position.Tick - past.Position.Tick) * ScoreInfo.UnitBeatHeight; float diffX = (future.Position.Lane - past.Position.Lane) * ScoreInfo.UnitLaneWidth; #region 最初のレーンでの描画 //ノーツfutureの位置はノーツpastの位置に2ノーツの距離を引いて表す。またTopRightの水平位置はfutureのWidthを使うことに注意 PointF topLeft = pastRerativeLocation.Add(diffX, -positionDistance).Add(drawOffset); PointF topRight = pastRerativeLocation.Add(diffX, -positionDistance).Add(-drawOffset.X, drawOffset.Y).AddX(future.Width); //以下の2つはレーンをまたがないときと同じ PointF bottomLeft = pastRerativeLocation.Add(drawOffset); PointF bottomRight = pastRerativeLocation.Add(-drawOffset.X, drawOffset.Y).AddX(past.Width); using (GraphicsPath graphicsPath = new GraphicsPath()) { graphicsPath.AddLines(new PointF[] { topLeft, bottomLeft, bottomRight, topRight }); ScoreLane scoreLane = laneBook.Find(x => x.Contains(past)); if (scoreLane != null) { RectangleF clipRect = new RectangleF( scoreLane.LaneRect.X - drawLocation.X, scoreLane.LaneRect.Y - drawLocation.Y, scoreLane.LaneRect.Width, scoreLane.LaneRect.Height); g.Clip = new Region(clipRect); } using (SolidBrush myBrush = new SolidBrush(lineColor)) { g.FillPath(myBrush, graphicsPath); } } #endregion #region 以降最後までのレーンでの描画 { ScoreLane prevLane, curLane; for (prevLane = laneBook.Find(x => x.Contains(past)), curLane = laneBook.Next(prevLane); curLane != null && laneBook.IndexOf(curLane) <= future.LaneIndex; prevLane = curLane, curLane = laneBook.Next(curLane)) { topLeft.X = curLane.LaneRect.X + future.Position.Lane * ScoreInfo.UnitLaneWidth - drawLocation.X + drawOffset.X; topLeft.Y += prevLane.LaneRect.Height; topRight.X = topLeft.X + future.Width - 2 * drawOffset.X; topRight.Y += prevLane.LaneRect.Height; bottomLeft.X = curLane.LaneRect.X + past.Position.Lane * ScoreInfo.UnitLaneWidth - drawLocation.X + drawOffset.X; bottomLeft.Y += prevLane.LaneRect.Height; bottomRight.X = bottomLeft.X + past.Width - 2 * drawOffset.X; bottomRight.Y += prevLane.LaneRect.Height; using (GraphicsPath graphicsPath = new GraphicsPath()) { graphicsPath.AddLines(new PointF[] { topLeft, bottomLeft, bottomRight, topRight }); RectangleF clipRect = new RectangleF(curLane.LaneRect.Location.Sub(drawLocation), curLane.LaneRect.Size); g.Clip = new Region(clipRect); using (SolidBrush myBrush = new SolidBrush(lineColor)) { g.FillPath(myBrush, graphicsPath); } } } } #endregion } }