private void Paste_Click(object sender, EventArgs e) { ScorePanel selectedPanel = (tabScore.SelectedTab as TabPageEx).ScorePanel; selectedPanel.PasteNotes(); selectedPanel.Refresh(); }
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; }
public MainForm() { InitializeComponent(); #region 譜面パネルの初期化 tabScore.TabPages.Clear(); tabScore.Font = new Font("Yu Gothic UI", 9); tabNoteButton.Font = tabScore.Font; for (int i = 0; i < tabPageCount; ++i) { TabPageEx tabPageEx = new TabPageEx("NewScore" + (i + 1)); tabScore.TabPages.Add(tabPageEx); // PictureBoxの追加と初期化 PictureBox pBox = new PictureBox { Size = tabScore.TabPages[i].Size }; // TabPageに初期化したPictureBoxを入れる tabScore.TabPages[i].Controls.Add(pBox); // ScrollBarの追加と初期化 HScrollBar hScroll = new HScrollBar { Size = new Size(pBox.Width, 17), Value = 0, Minimum = 0, Dock = DockStyle.Bottom }; VScrollBar vScroll = new VScrollBar { Size = new Size(17, pBox.Height), Value = 0, Minimum = 0, Maximum = 0, Dock = DockStyle.Right, Visible = false }; // HScrollBarをPictureBoxに入れる pBox.Controls.Add(hScroll); pBox.Controls.Add(vScroll); // 初期化したPictureBoxとHScrollBarを使用してScorePanelを追加 ScorePanel sPanel = new ScorePanel(pBox, hScroll, vScroll); sPanel.OperationManager.StatusChanged += (undo, redo) => { tsbUndo.Enabled = tsmiUndo.Enabled = undo; tsbRedo.Enabled = tsmiRedo.Enabled = redo; }; sPanel.OperationManager.Edited += () => { UpdateTextOfTabAndForm(true); sPanel.IsEdited = true; }; Status.CopyChanged += (b) => tsbCopy.Enabled = tsbCut.Enabled = b; Status.PasteChanged += (b) => tsbPaste.Enabled = b; tsbCut.Enabled = tsbCopy.Enabled = tsbPaste.Enabled = false; sPanel.SetScore(4, 4, 200); tabPageEx.ScorePanel = sPanel; // PictureBoxとHScrollBarの各種デリゲートの設定 pBox.MouseWheel += Score_MouseWheel; pBox.Paint += Score_Paint; pBox.MouseClick += Score_MouseClick; pBox.MouseDoubleClick += Score_MouseDoubleClick; pBox.MouseEnter += Score_MouseEnter; pBox.MouseDown += Score_MouseDown; pBox.MouseMove += Score_MouseMove; pBox.MouseUp += Score_MouseUp; hScroll.Scroll += Score_Scroll; vScroll.Scroll += Score_Scroll; } #endregion InitializeToolStrip(); #region ノーツボタン追加 NoteButtonManager noteButtonManager = new NoteButtonManager(); noteButtonManager.ButtonClicked += (s, e) => SetMode(Mode.Add); flpNotePanel.Size = tabNoteButton.TabPages[0].Size; flpNotePanel.Location = new Point(); foreach (NoteButton noteButton in noteButtonManager) { flpNotePanel.Controls.Add(noteButton); } #endregion #region 各種ボタンに対するイベント紐づけ tabScore.SelectedIndexChanged += (s, e) => { Text = tabScore.SelectedTab.Text; Text += " - M4ple Editor"; ScorePanel selectedPanel = (tabScore.SelectedTab as TabPageEx).ScorePanel; selectedPanel.OperationManager.OnStatusChanged(); }; #region ToolStripButton tsbAdd.Click += (s, e) => SetMode(Mode.Add); tsbEdit.Click += (s, e) => SetMode(Mode.Edit); tsbDelete.Click += (s, e) => SetMode(Mode.Delete); tsbInvisibleSlideTap.Click += TbsInvisibleSlideTap_Click; tscbBeat.SelectedIndexChanged += (s, e) => { Status.Beat = int.Parse(tscbBeat.Text); }; tscbGrid.SelectedIndexChanged += (s, e) => { Status.Grid = int.Parse(tscbGrid.Text); }; tsbNew.Click += New_Click; tsbOpen.Click += Open_Click; tsbSave.Click += Save_Click; tsbImport.Click += Import_Click; tsbExport.Click += (s, e) => { ScorePanel selectedPanel = (tabScore.SelectedTab as TabPageEx).ScorePanel; selectedPanel.Export(); }; tsbCopy.Click += Copy_Click; tsbCut.Click += Cut_Click; tsbPaste.Click += Paste_Click; tsbUndo.Click += Undo_Click; tsbRedo.Click += Redo_Click; tsbUndo.Enabled = tsbRedo.Enabled = false; tsbZoomIn.Click += ZoomIn_Click; tsbZoomOut.Click += ZoomOut_Click; #endregion #region ToolStripMenuItem(表示) tsmiIsShortNote.Click += (s, e) => { ToolStripMenuItem menuItem = (ToolStripMenuItem)s; Status.IsShortNoteVisible = menuItem.Checked = !menuItem.Checked; Refresh(); }; tsmiIsHold.Click += (s, e) => { ToolStripMenuItem menuItem = (ToolStripMenuItem)s; Status.IsHoldVisible = menuItem.Checked = !menuItem.Checked; Refresh(); }; tsmiIsSlide.Click += (s, e) => { ToolStripMenuItem menuItem = (ToolStripMenuItem)s; Status.IsSlideVisible = menuItem.Checked = !menuItem.Checked; Refresh(); }; tsmiIsSlideRelay.Click += (s, e) => { ToolStripMenuItem menuItem = (ToolStripMenuItem)s; Status.IsSlideRelayVisible = menuItem.Checked = !menuItem.Checked; Refresh(); }; tsmiIsSlideCurve.Click += (s, e) => { ToolStripMenuItem menuItem = (ToolStripMenuItem)s; Status.IsSlideCurveVisible = menuItem.Checked = !menuItem.Checked; Refresh(); }; tsmiIsAirHold.Click += (s, e) => { ToolStripMenuItem menuItem = (ToolStripMenuItem)s; Status.IsAirHoldVisible = menuItem.Checked = !menuItem.Checked; Refresh(); }; tsmiIsAir.Click += (s, e) => { ToolStripMenuItem menuItem = (ToolStripMenuItem)s; Status.IsAirVisible = menuItem.Checked = !menuItem.Checked; Refresh(); }; tsmiIsExTapDistinct.Click += (s, e) => { ToolStripMenuItem menuItem = (ToolStripMenuItem)s; Status.IsExTapDistinct = menuItem.Checked = !menuItem.Checked; Refresh(); }; tsmiIsEconomyMode.Click += (s, e) => { ToolStripMenuItem menuItem = (ToolStripMenuItem)s; Status.IsEconomyMode = menuItem.Checked = !menuItem.Checked; Refresh(); }; #endregion #region ToolStlipMenuItem(ファイル) tsmiNew.Click += New_Click; tsmiOpen.Click += Open_Click; tsmiSave.Click += Save_Click; tsmiSaveAs.Click += (s, e) => { ScorePanel selectedPanel = (tabScore.SelectedTab as TabPageEx).ScorePanel; bool isSaved = selectedPanel.SaveAs(); UpdateTextOfTabAndForm(!isSaved); }; tsmiImport.Click += Import_Click; tsmiExport.Click += (s, e) => { ScorePanel selectedPanel = (tabScore.SelectedTab as TabPageEx).ScorePanel; selectedPanel.ExportAs(); }; tsmiQuit.Click += (s, e) => { Close(); }; FormClosing += (s, e) => { e.Cancel = !IsExit(); Properties.Settings.Default.Save(); }; #endregion #region ToolStripMenuItem(編集) tsmiUndo.Click += Undo_Click; tsmiRedo.Click += Redo_Click; tsmiUndo.Enabled = tsmiRedo.Enabled = false; tsmiCopy.Click += Copy_Click; tsmiCut.Click += Cut_Click; tsmiPaste.Click += Paste_Click; tsmiPasteReverse.Click += (s, e) => { ScorePanel selectedPanel = (tabScore.SelectedTab as TabPageEx).ScorePanel; selectedPanel.PasteNotes(); selectedPanel.ReverseNotes(); Refresh(); }; tsmiDelete.Click += (s, e) => { ScorePanel selectedPanel = (tabScore.SelectedTab as TabPageEx).ScorePanel; selectedPanel.ClearAreaNotes(); Refresh(); }; tsmiReverse.Click += (s, e) => { ScorePanel selectedPanel = (tabScore.SelectedTab as TabPageEx).ScorePanel; selectedPanel.ReverseNotes(); Refresh(); }; #endregion #region ToolStripMenuItem(ウィンドウ) tsmiSizeSmall.Click += (s, e) => SetPanelSize(PanelSize.Small); tsmiSizeMiddle.Click += (s, e) => SetPanelSize(PanelSize.Middle); tsmiSizeBig.Click += (s, e) => SetPanelSize(PanelSize.Big); tsmiScaleHalf.Click += (s, e) => SetScoreScale(ScoreScale.Half); tsmiScaleDefault.Click += (s, e) => SetScoreScale(ScoreScale.Default); tsmiScaleDouble.Click += (s, e) => SetScoreScale(ScoreScale.Double); tsmiScaleQuad.Click += (s, e) => SetScoreScale(ScoreScale.Quad); #endregion #region ToolStripMenuItem(ヘルプ) tsmiShowHelp.Click += (s, e) => { System.Diagnostics.Process.Start("https://github.com/TinyTany/M4ple/wiki"); }; tsmiVersion.Click += (s, e) => { new VersionInfoForm().ShowDialog(); }; #endregion #endregion #region ショートカットキー KeyDown += (s, e) => { if (ModifierKeys == Keys.Alt) { return; } switch (e.KeyCode) { case Keys.A: tsbAdd.PerformClick(); break; case Keys.E: tsbEdit.PerformClick(); break; case Keys.D: tsbDelete.PerformClick(); break; case Keys.S: tsbInvisibleSlideTap.PerformClick(); break; case Keys.B: if (ModifierKeys == Keys.Shift) { tscbBeat.SelectedIndex = tscbBeat.SelectedIndex == 0 ? tscbBeat.Items.Count - 1 : --tscbBeat.SelectedIndex; } else { tscbBeat.SelectedIndex = (tscbBeat.SelectedIndex + 1) % tscbBeat.Items.Count; } break; case Keys.G: if (ModifierKeys == Keys.Shift) { tscbGrid.SelectedIndex = tscbGrid.SelectedIndex == 0 ? tscbGrid.Items.Count - 1 : --tscbGrid.SelectedIndex; } else { tscbGrid.SelectedIndex = (tscbGrid.SelectedIndex + 1) % tscbGrid.Items.Count; } break; case Keys.OemPeriod: noteButtonManager.SelectedButtonIncrease(); break; case Keys.Oemcomma: noteButtonManager.SelectedButtonDecrease(); break; } }; #endregion Resize += (s, e) => { // HACK: 16と42はマジックナンバー的なもの(なぜかこの値で調整しないと大きさが合わない) tabScore.Size = new Size( Width - tabScore.Location.X - tabScore.Margin.Right - 16, Height - tabScore.Location.Y - tabScore.Margin.Bottom - 42); foreach (TabPageEx tabPageEx in tabScore.TabPages) { tabPageEx.ScorePanel.ReSizePanel(tabScore.SelectedTab.Size); } tabNoteButton.Height = tabScore.Height; flpNotePanel.Height = tabNoteButton.TabPages[0].Height; }; #region tscbBeatの初期化 beatItemList = new List <ToolStripValueItem>() { new ToolStripValueItem(4), new ToolStripValueItem(8), new ToolStripValueItem(12), new ToolStripValueItem(16), new ToolStripValueItem(24), new ToolStripValueItem(32), new ToolStripValueItem(48), new ToolStripValueItem(64), new ToolStripValueItem(96), new ToolStripValueItem(128), new ToolStripValueItem(192), new ToolStripValueItem(256), new ToolStripValueItem(384), new ToolStripValueItem(512), new ToolStripValueItem(768), }; tscbBeat.Items.Clear(); beatItemList.ForEach(x => tscbBeat.Items.Add(x)); // NOTE: StatusでのBeatの初期値が16なのでそれに対応したインデックスにしておく var index = beatItemList.FindIndex(x => x.Value == Status.Beat); System.Diagnostics.Debug.Assert(index >= 0, "tscbBeatの初期インデックスが正しく設定されていません"); tscbBeat.SelectedIndex = index; #endregion SetPanelSize(PanelSize.Big); SetScoreScale(ScoreScale.Default); }