public MainForm() { InitializeComponent(); Size = new Size(420, 700); Icon = Resources.MainIcon; AllowDrop = true; ToolStripManager.RenderMode = ToolStripManagerRenderMode.System; OperationManager = new OperationManager(); OperationManager.ChangesCommitted += (s, e) => SetText(ScoreBook.Path); OperationManager.OperationHistoryChanged += (s, e) => { SetText(ScoreBook.Path); NoteView.Invalidate(); }; NoteView = new NoteView(OperationManager) { Dock = DockStyle.Fill }; NoteViewScrollBar = new VScrollBar() { Dock = DockStyle.Right }; NoteViewScrollBar.ValueChanged += (s, e) => { NoteView.HeadTick = -NoteViewScrollBar.Value / 60 * 60; // 60の倍数できれいに表示されるので… NoteView.Invalidate(); }; NoteViewScrollBar.Scroll += (s, e) => { if (e.Type == ScrollEventType.EndScroll) { ExtendScrollBarRange(NoteViewScrollBar); } }; NoteView.Resize += (s, e) => UpdateThumbHeight(); NoteView.MouseWheel += (s, e) => { int value = NoteViewScrollBar.Value - e.Delta / 120 * NoteViewScrollBar.SmallChange; NoteViewScrollBar.Value = Math.Min(Math.Max(value, NoteViewScrollBar.Minimum), NoteViewScrollBar.GetMaximumValue()); ExtendScrollBarRange(NoteViewScrollBar); }; NoteView.DragScroll += (s, e) => { NoteViewScrollBar.Value = Math.Max(-NoteView.HeadTick, NoteViewScrollBar.Minimum); ExtendScrollBarRange(NoteViewScrollBar); }; void ExtendScrollBarRange(ScrollBar bar) { if (bar.Value < bar.Minimum * 0.9f) { bar.Minimum = (int)(NoteViewScrollBar.Minimum * 1.2); } } PreviewManager = new SoundPreviewManager(NoteView) { ClapSource = SoundSettings.Default.ClapSource }; PreviewManager.TickUpdated += (s, e) => Invoke((MethodInvoker)(() => NoteView.CurrentTick = e.Tick)); PreviewManager.ExceptionThrown += (s, e) => MessageBox.Show(this, "プレビュー中にエラーが発生しました。", Program.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error); Menu = CreateMainMenu(); Controls.Add(NoteView); Controls.Add(NoteViewScrollBar); Controls.Add(CreateEditTargetToolStrip(NoteView)); Controls.Add(CreateMainToolStrip(NoteView)); NoteView.EditMode = EditMode.Edit; NoteView.EditTarget = EditTarget.Field; LoadEmptyBook(); if (!PreviewManager.IsSupported) { MessageBox.Show(this, "再生プレビューがサポートされていない環境です", Program.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information); } if (PluginManager.FailedFiles.Count > 0) { string message = "以下のプラグインの読み込みに失敗しました。DLLファイルがブロックされているか無効なファイルである可能性があります。"; MessageBox.Show(this, string.Join("\n", new[] { message }.Concat(PluginManager.FailedFiles)), Program.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public MainForm() { InitializeComponent(); Size = new Size(420, 700); Icon = Resources.MainIcon; ToolStripManager.RenderMode = ToolStripManagerRenderMode.System; OperationManager = new OperationManager(); OperationManager.OperationHistoryChanged += (s, e) => { SetText(ScoreBook.Path); NoteView.Invalidate(); }; OperationManager.ChangesCommitted += (s, e) => SetText(ScoreBook.Path); NoteView = new NoteView(OperationManager) { Dock = DockStyle.Fill, UnitBeatHeight = ApplicationSettings.Default.UnitBeatHeight, UnitLaneWidth = ApplicationSettings.Default.UnitLaneWidth, InsertAirWithAirAction = ApplicationSettings.Default.InsertAirWithAirAction }; PreviewManager = new SoundPreviewManager(this); PreviewManager.IsStopAtLastNote = ApplicationSettings.Default.IsPreviewAbortAtLastNote; PreviewManager.TickUpdated += (s, e) => NoteView.CurrentTick = e.Tick; PreviewManager.ExceptionThrown += (s, e) => MessageBox.Show(this, ErrorStrings.PreviewException, Program.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error); NoteViewScrollBar = new VScrollBar() { Dock = DockStyle.Right, Minimum = -NoteView.UnitBeatTick * 4 * 20, SmallChange = NoteView.UnitBeatTick }; void processScrollBarRangeExtension(ScrollBar s) { if (NoteViewScrollBar.Value < NoteViewScrollBar.Minimum * 0.9f) { NoteViewScrollBar.Minimum = (int)(NoteViewScrollBar.Minimum * 1.2); } } NoteView.Resize += (s, e) => UpdateThumbHeight(); NoteView.MouseWheel += (s, e) => { int value = NoteViewScrollBar.Value - e.Delta / 120 * NoteViewScrollBar.SmallChange; NoteViewScrollBar.Value = Math.Min(Math.Max(value, NoteViewScrollBar.Minimum), NoteViewScrollBar.GetMaximumValue()); processScrollBarRangeExtension(NoteViewScrollBar); }; NoteView.DragScroll += (s, e) => { NoteViewScrollBar.Value = Math.Max(-NoteView.HeadTick, NoteViewScrollBar.Minimum); processScrollBarRangeExtension(NoteViewScrollBar); }; NoteViewScrollBar.ValueChanged += (s, e) => { NoteView.HeadTick = -NoteViewScrollBar.Value / 60 * 60; // 60の倍数できれいに表示されるので… NoteView.Invalidate(); }; NoteViewScrollBar.Scroll += (s, e) => { if (e.Type == ScrollEventType.EndScroll) { processScrollBarRangeExtension(NoteViewScrollBar); } }; NoteView.NewNoteTypeChanged += (s, e) => NoteView.EditMode = EditMode.Edit; AllowDrop = true; DragEnter += (s, e) => { e.Effect = DragDropEffects.None; if (e.Data.GetDataPresent(DataFormats.FileDrop)) { var items = (string[])e.Data.GetData(DataFormats.FileDrop); if (items.Length == 1 && items.All(p => Path.GetExtension(p) == FileExtension && File.Exists(p))) { e.Effect = DragDropEffects.Copy; } } }; DragDrop += (s, e) => { string path = ((string[])e.Data.GetData(DataFormats.FileDrop)).Single(); if (!ConfirmDiscardChanges()) { return; } LoadFile(path); }; FormClosing += (s, e) => { if (!ConfirmDiscardChanges()) { e.Cancel = true; return; } ApplicationSettings.Default.Save(); }; using (var manager = this.WorkWithLayout()) { this.Menu = CreateMainMenu(NoteView); this.Controls.Add(NoteView); this.Controls.Add(NoteViewScrollBar); this.Controls.Add(CreateNewNoteTypeToolStrip(NoteView)); this.Controls.Add(CreateMainToolStrip(NoteView)); } NoteView.NewNoteType = NoteType.Tap; NoteView.EditMode = EditMode.Edit; LoadEmptyBook(); SetText(); if (!PreviewManager.IsSupported) { MessageBox.Show(this, ErrorStrings.PreviewNotSupported, Program.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information); } if (PluginManager.FailedFiles.Count > 0) { MessageBox.Show(this, string.Join("\n", new[] { ErrorStrings.PluginLoadError }.Concat(PluginManager.FailedFiles)), Program.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (PluginManager.InvalidFiles.Count > 0) { MessageBox.Show(this, string.Join("\n", new[] { ErrorStrings.PluginNotSupported }.Concat(PluginManager.InvalidFiles)), Program.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public MainForm() { InitializeComponent(); Size = new Size(420, 700); Icon = Resources.MainIcon; ToolStripManager.RenderMode = ToolStripManagerRenderMode.System; OperationManager = new OperationManager(); OperationManager.OperationHistoryChanged += (s, e) => SetText(ScoreBook.Path); OperationManager.ChangesCommited += (s, e) => SetText(ScoreBook.Path); NoteView = new NoteView(OperationManager) { Dock = DockStyle.Fill, UnitBeatHeight = Settings.Default.UnitBeatHeight }; PreviewManager = new SoundPreviewManager(NoteView); PreviewManager.Finished += (s, e) => NoteView.Editable = CanEdit; PreviewManager.TickUpdated += (s, e) => NoteView.CurrentTick = e.Tick; NoteViewScrollBar = new VScrollBar() { Dock = DockStyle.Right, Minimum = -NoteView.UnitBeatTick * 4 * 20, SmallChange = NoteView.UnitBeatTick }; Action <ScrollBar> processScrollBarRangeExtension = s => { if (NoteViewScrollBar.Value < NoteViewScrollBar.Minimum * 0.9f) { NoteViewScrollBar.Minimum = (int)(NoteViewScrollBar.Minimum * 1.2); } }; NoteView.Resize += (s, e) => UpdateThumbHeight(); NoteView.MouseWheel += (s, e) => { int value = NoteViewScrollBar.Value - e.Delta / 120 * NoteViewScrollBar.SmallChange; NoteViewScrollBar.Value = Math.Min(Math.Max(value, NoteViewScrollBar.Minimum), NoteViewScrollBar.GetMaximumValue()); processScrollBarRangeExtension(NoteViewScrollBar); }; NoteView.DragScroll += (s, e) => { NoteViewScrollBar.Value = Math.Max(-NoteView.HeadTick, NoteViewScrollBar.Minimum); processScrollBarRangeExtension(NoteViewScrollBar); }; NoteViewScrollBar.ValueChanged += (s, e) => { NoteView.HeadTick = -NoteViewScrollBar.Value / 60 * 60; // 60の倍数できれいに表示されるので… NoteView.Invalidate(); }; NoteViewScrollBar.Scroll += (s, e) => { if (e.Type == ScrollEventType.EndScroll) { processScrollBarRangeExtension(NoteViewScrollBar); } }; AllowDrop = true; DragEnter += (s, e) => { e.Effect = DragDropEffects.None; if (e.Data.GetDataPresent(DataFormats.FileDrop)) { var items = (string[])e.Data.GetData(DataFormats.FileDrop); if (items.Length == 1 && items.All(p => Path.GetExtension(p) == FileExtension && File.Exists(p))) { e.Effect = DragDropEffects.Copy; } } }; DragDrop += (s, e) => { string path = ((string[])e.Data.GetData(DataFormats.FileDrop)).Single(); if (OperationManager.IsChanged && !this.ConfirmDiscardChanges()) { return; } LoadFile(path); }; FormClosing += (s, e) => { if (OperationManager.IsChanged && !this.ConfirmDiscardChanges()) { e.Cancel = true; return; } Settings.Default.Save(); }; using (var manager = this.WorkWithLayout()) { this.Menu = CreateMainMenu(NoteView); this.Controls.Add(NoteView); this.Controls.Add(NoteViewScrollBar); this.Controls.Add(CreateNewNoteTypeToolStrip(NoteView)); this.Controls.Add(CreateMainToolStrip(NoteView)); } NoteView.NewNoteType = NoteType.Tap; NoteView.EditMode = EditMode.Edit; LoadBook(new ScoreBook()); SetText(); if (!PreviewManager.IsSupported) { MessageBox.Show(this, "簡易プレビューが利用できない環境です。", Program.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information); } }