private void buttonSaveCurveToLibrary_Click(object sender, EventArgs e) { Common.Controls.TextDialog dialog = new Common.Controls.TextDialog("Curve name?"); while (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (dialog.Response == string.Empty) { MessageBox.Show("Please enter a name."); continue; } if (Library.Contains(dialog.Response)) { DialogResult result = MessageBox.Show("There is already a curve with that name. Do you want to overwrite it?", "Overwrite curve?", MessageBoxButtons.YesNoCancel); if (result == System.Windows.Forms.DialogResult.Yes) { Library.AddCurve(dialog.Response, new Curve(Curve)); break; } else if (result == System.Windows.Forms.DialogResult.Cancel) { break; } } else { Library.AddCurve(dialog.Response, new Curve(Curve)); break; } } }
private void buttonGenerateGrid_Click(object sender, EventArgs e) { Common.Controls.TextDialog prompt = new Common.Controls.TextDialog("How often (in seconds) should the marks be generated?", "Mark Period", "0:00.050"); if (prompt.ShowDialog() == DialogResult.OK) { TimeSpan interval; bool conversionSuccess = TimeSpan.TryParseExact(prompt.Response, TimeFormats.PositiveFormats, null, out interval); if (conversionSuccess) { TimeSpan currentTime = interval; TimeSpan endTime = _timedSequenceEditorForm.Sequence.Length; while (currentTime <= endTime) { _displayedCollection.Marks.Add(currentTime); currentTime += interval; } if (_displayedCollection.Level < 8) { _displayedCollection.Level = 8; } _displayedCollection.Marks.Sort(); PopulateMarkListFromMarkCollection(_displayedCollection); UpdateMarkCollectionInList(_displayedCollection); } else { MessageBox.Show("Error parsing time: please use the format '<minutes>:<seconds>.<milliseconds>'", "Error parsing time"); } } }
private void buttonCopyAndOffsetMarks_Click(object sender, EventArgs e) { if (listViewMarks.SelectedItems.Count < 1) { MessageBox.Show("Select at least one mark duplicate and offset.", "Need more marks"); return; } Common.Controls.TextDialog prompt = new Common.Controls.TextDialog("Start time for copied marks (in seconds):"); if (prompt.ShowDialog() == DialogResult.OK) { TimeSpan offsetTime; if (TimeSpan.TryParseExact(prompt.Response, TimeFormats.PositiveFormats, null, out offsetTime)) { TimeSpan earliestTime = TimeSpan.MaxValue; foreach (ListViewItem item in listViewMarks.SelectedItems) { if ((TimeSpan)item.Tag < earliestTime) { earliestTime = (TimeSpan)item.Tag; } } foreach (ListViewItem item in listViewMarks.SelectedItems) { _displayedCollection.Marks.Add((TimeSpan)item.Tag + offsetTime - earliestTime); } _displayedCollection.Marks.Sort(); PopulateMarkListFromMarkCollection(_displayedCollection); UpdateMarkCollectionInList(_displayedCollection); } else { MessageBox.Show("Error parsing time: please use the format '<minutes>:<seconds>.<milliseconds>'", "Error parsing time"); } } }
private void buttonOffsetMarks_Click(object sender, EventArgs e) { Common.Controls.TextDialog prompt = new Common.Controls.TextDialog("Time to offset (in seconds):"); if (prompt.ShowDialog() == DialogResult.OK) { TimeSpan time; if (TimeSpan.TryParseExact(prompt.Response, TimeFormats.AllFormats, null, out time)) { // this is hackey as shit. if (prompt.Response.ToCharArray()[0] == '-') { time = -time; } List <TimeSpan> newMarks = new List <TimeSpan>(); foreach (ListViewItem item in listViewMarks.Items) { if (item.Selected) { newMarks.Add(((TimeSpan)item.Tag) + time); } else { newMarks.Add((TimeSpan)item.Tag); } newMarks.Sort(); _displayedCollection.Marks = newMarks; PopulateMarkListFromMarkCollection(_displayedCollection); } } else { MessageBox.Show("Error parsing time: please use the format '<minutes>:<seconds>.<milliseconds>'", "Error parsing time"); } } }
private void buttonNewColorGradient_Click(object sender, EventArgs e) { Common.Controls.TextDialog dialog = new Common.Controls.TextDialog("Gradient name?"); while (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (dialog.Response == string.Empty) { MessageBox.Show("Please enter a name."); continue; } if (Library.Contains(dialog.Response)) { DialogResult result = MessageBox.Show("There is already a gradient with that name. Do you want to overwrite it?", "Overwrite gradient?", MessageBoxButtons.YesNoCancel); if (result == System.Windows.Forms.DialogResult.Yes) { Library.AddColorGradient(dialog.Response, new ColorGradient()); Library.EditLibraryItem(dialog.Response); PopulateListWithColorGradients(); break; } else if (result == System.Windows.Forms.DialogResult.Cancel) { break; } } else { Library.AddColorGradient(dialog.Response, new ColorGradient()); Library.EditLibraryItem(dialog.Response); PopulateListWithColorGradients(); break; } } }
private void buttonNewCurve_Click(object sender, EventArgs e) { Common.Controls.TextDialog dialog = new Common.Controls.TextDialog("Curve name?"); while (dialog.ShowDialog() == DialogResult.OK) { if (dialog.Response == string.Empty) { MessageBox.Show("Please enter a name."); continue; } if (Library.Contains(dialog.Response)) { DialogResult result = MessageBox.Show("There is already a curve with that name. Do you want to overwrite it?", "Overwrite curve?", MessageBoxButtons.YesNoCancel); if (result == DialogResult.Yes) { Library.AddCurve(dialog.Response, new Curve()); Library.EditLibraryCurve(dialog.Response); PopulateListWithCurves(); break; } else if (result == DialogResult.Cancel) { break; } } else { Library.AddCurve(dialog.Response, new Curve()); Library.EditLibraryCurve(dialog.Response); PopulateListWithCurves(); break; } } }
private void buttonSaveToLibrary_Click(object sender, EventArgs e) { Common.Controls.TextDialog dialog = new Common.Controls.TextDialog("Gradient name?"); while (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (dialog.Response == string.Empty) { MessageBox.Show("Please enter a name."); continue; } if (Library.Contains(dialog.Response)) { DialogResult result = MessageBox.Show("There is already a gradient with that name. Do you want to overwrite it?", "Overwrite gradient?", MessageBoxButtons.YesNoCancel); if (result == System.Windows.Forms.DialogResult.Yes) { Library.AddColorGradient(dialog.Response, new ColorGradient(Gradient)); break; } else if (result == System.Windows.Forms.DialogResult.Cancel) { break; } } else { Library.AddColorGradient(dialog.Response, new ColorGradient(Gradient)); break; } } }
private void buttonOffsetMarks_Click(object sender, EventArgs e) { Common.Controls.TextDialog prompt = new Common.Controls.TextDialog("Time to offset (in seconds):"); if (prompt.ShowDialog() == DialogResult.OK) { TimeSpan time; if (TimeSpan.TryParseExact(prompt.Response, TimeFormats.AllFormats, null, out time)) { // this is hackey as shit. if (prompt.Response.ToCharArray()[0] == '-') time = -time; List<TimeSpan> newMarks = new List<TimeSpan>(); foreach (ListViewItem item in listViewMarks.Items) { if (item.Selected) { newMarks.Add(((TimeSpan) item.Tag) + time); } else { newMarks.Add((TimeSpan) item.Tag); } newMarks.Sort(); _displayedCollection.Marks = newMarks; PopulateMarkListFromMarkCollection(_displayedCollection); } } else { MessageBox.Show("Error parsing time: please use the format '<minutes>:<seconds>.<milliseconds>'", "Error parsing time"); } } }
private void buttonGenerateSubmarks_Click(object sender, EventArgs e) { if (listViewMarks.SelectedItems.Count < 2) { MessageBox.Show("Select at least two marks to generate times between.", "Need more marks"); return; } Common.Controls.TextDialog prompt = new Common.Controls.TextDialog("Break each interval into how many equal segments?"); if (prompt.ShowDialog() == DialogResult.OK) { int divisions; if (int.TryParse(prompt.Response, out divisions)) { DialogResult newCollectionResult = MessageBox.Show( "Do you want to put the new marks into a different collection?", "Add to new collection?", MessageBoxButtons.YesNoCancel); if (newCollectionResult == DialogResult.Cancel) { return; } List<TimeSpan> sourceTimes = new List<TimeSpan>(); foreach (ListViewItem item in listViewMarks.SelectedItems) { sourceTimes.Add((TimeSpan) item.Tag); } sourceTimes.Sort(); List<TimeSpan> newTimes = new List<TimeSpan>(); for (int i = 1; i < sourceTimes.Count; i++) { TimeSpan interval = TimeSpan.FromTicks((sourceTimes[i] - sourceTimes[i - 1]).Ticks/divisions); for (int j = 0; j < divisions; j++) { newTimes.Add(sourceTimes[i - 1] + TimeSpan.FromTicks(interval.Ticks*j)); } } newTimes.Add(sourceTimes.Last()); MarkCollection destination = _displayedCollection; if (newCollectionResult == DialogResult.Yes) { List<KeyValuePair<string, object>> options = new List<KeyValuePair<string, object>>(); foreach (MarkCollection mc in MarkCollections) { options.Add(new KeyValuePair<string, object>(mc.Name, mc)); } Common.Controls.ListSelectDialog selector = new Common.Controls.ListSelectDialog("Destination Mark Collection?", options); if (selector.ShowDialog() == DialogResult.OK) { destination = selector.SelectedItem as MarkCollection; } } foreach (TimeSpan time in newTimes) { if (!destination.Marks.Contains(time)) destination.Marks.Add(time); } destination.Marks.Sort(); if (destination == _displayedCollection) { PopulateMarkListFromMarkCollection(_displayedCollection); } UpdateMarkCollectionInList(destination); } else { MessageBox.Show("Error parsing number: please enter a whole number for the number of divisions.", "Error parsing number"); } } }
private void buttonGenerateBeatMarks_Click(object sender, EventArgs e) { if ( MessageBox.Show( "This operation will determine the average beat from the selected marks, and apply them for the rest of the song. Do you want to continue?", "Information", MessageBoxButtons.YesNo) == DialogResult.No) return; if (listViewMarks.SelectedItems.Count < 2) { MessageBox.Show("Select at least two marks to be able to determine an average time interval.", "Need more marks"); return; } Common.Controls.TextDialog prompt = new Common.Controls.TextDialog( "How long should the beats be generated for, in seconds? Leave blank to go to the end."); // the default prompt isn't enough to hold all the above text. Oops. prompt.Size = new Size(550, prompt.Size.Height); if (prompt.ShowDialog() == DialogResult.OK) { TimeSpan duration; bool conversionSuccess = TimeSpan.TryParseExact(prompt.Response, TimeFormats.PositiveFormats, null, out duration); if (!conversionSuccess && prompt.Response.Length == 0) { conversionSuccess = true; duration = TimeSpan.MaxValue; } if (conversionSuccess) { TimeSpan earlistMark = TimeSpan.MaxValue; TimeSpan latestMark = TimeSpan.MinValue; foreach (ListViewItem item in listViewMarks.SelectedItems) { if ((TimeSpan) item.Tag < earlistMark) { earlistMark = (TimeSpan) item.Tag; } if ((TimeSpan) item.Tag > latestMark) { latestMark = (TimeSpan) item.Tag; } } int sourcesCount = listViewMarks.SelectedItems.Count; TimeSpan interval = TimeSpan.FromTicks((latestMark - earlistMark).Ticks/(sourcesCount - 1)); double bpm = 60/interval.TotalSeconds; TimeSpan maxPossibleDuration = _timedSequenceEditorForm.Sequence.Length - latestMark; if (duration > maxPossibleDuration) duration = maxPossibleDuration; int generatedMarks = (int) (duration.Ticks/interval.Ticks) - 1; if (MessageBox.Show(string.Format("From the selected marks, a beat interval of {0:%s\\.ff} seconds was detected ({1:0.00} bpm). This will generate {2} marks. Do you want to continue?", interval, bpm, generatedMarks), "Confirmation", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } TimeSpan currentTime = latestMark + interval; TimeSpan endTime = latestMark + duration; while (currentTime <= endTime) { _displayedCollection.Marks.Add(currentTime); currentTime += interval; } _displayedCollection.Marks.Sort(); PopulateMarkListFromMarkCollection(_displayedCollection); UpdateMarkCollectionInList(_displayedCollection); } else { MessageBox.Show("Error parsing time: please use the format '<minutes>:<seconds>.<milliseconds>', or leave empty", "Error parsing time"); } } }
private void buttonCopyAndOffsetMarks_Click(object sender, EventArgs e) { if (listViewMarks.SelectedItems.Count < 1) { MessageBox.Show("Select at least one mark duplicate and offset.", "Need more marks"); return; } Common.Controls.TextDialog prompt = new Common.Controls.TextDialog("Start time for copied marks (in seconds):"); if (prompt.ShowDialog() == DialogResult.OK) { TimeSpan offsetTime; if (TimeSpan.TryParseExact(prompt.Response, TimeFormats.PositiveFormats, null, out offsetTime)) { TimeSpan earliestTime = TimeSpan.MaxValue; foreach (ListViewItem item in listViewMarks.SelectedItems) { if ((TimeSpan) item.Tag < earliestTime) earliestTime = (TimeSpan) item.Tag; } foreach (ListViewItem item in listViewMarks.SelectedItems) { _displayedCollection.Marks.Add((TimeSpan) item.Tag + offsetTime - earliestTime); } _displayedCollection.Marks.Sort(); PopulateMarkListFromMarkCollection(_displayedCollection); UpdateMarkCollectionInList(_displayedCollection); } else { MessageBox.Show("Error parsing time: please use the format '<minutes>:<seconds>.<milliseconds>'", "Error parsing time"); } } }
private void modifySequenceLengthToolStripMenuItem_Click(object sender, EventArgs e) { string oldLength = _sequence.Length.ToString("m\\:ss\\.fff"); Common.Controls.TextDialog prompt = new Common.Controls.TextDialog("Enter new sequence length:", "Sequence Length", oldLength, true); do { if(prompt.ShowDialog() != DialogResult.OK) break; TimeSpan time; bool success = TimeSpan.TryParseExact(prompt.Response, TimeFormats.PositiveFormats, null, out time); if(success) { SequenceLength = time; break; } else { MessageBox.Show("Error parsing time: please use the format '<minutes>:<seconds>.<milliseconds>'", "Error parsing time"); } } while(true); }
private void buttonGenerateBeatMarks_Click(object sender, EventArgs e) { if (MessageBox.Show("This operation will determine the average beat from the selected marks, and apply them for the rest of the song. Do you want to continue?", "Information", MessageBoxButtons.YesNo) == DialogResult.No) { return; } if (listViewMarks.SelectedItems.Count < 2) { MessageBox.Show("Select at least two marks to be able to determine an average time interval.", "Need more marks"); return; } Common.Controls.TextDialog prompt = new Common.Controls.TextDialog("How long should the beats be generated for, in seconds? Leave blank to go to the end."); // the default prompt isn't enough to hold all the above text. Oops. prompt.Size = new Size(550, prompt.Size.Height); if (prompt.ShowDialog() == DialogResult.OK) { TimeSpan duration; bool conversionSuccess = TimeSpan.TryParseExact(prompt.Response, TimeFormats.PositiveFormats, null, out duration); if (!conversionSuccess && prompt.Response.Length == 0) { conversionSuccess = true; duration = TimeSpan.MaxValue; } if (conversionSuccess) { TimeSpan earlistMark = TimeSpan.MaxValue; TimeSpan latestMark = TimeSpan.MinValue; foreach (ListViewItem item in listViewMarks.SelectedItems) { if ((TimeSpan)item.Tag < earlistMark) { earlistMark = (TimeSpan)item.Tag; } if ((TimeSpan)item.Tag > latestMark) { latestMark = (TimeSpan)item.Tag; } } int sourcesCount = listViewMarks.SelectedItems.Count; TimeSpan interval = TimeSpan.FromTicks((latestMark - earlistMark).Ticks / (sourcesCount - 1)); double bpm = 60 / interval.TotalSeconds; TimeSpan maxPossibleDuration = _timedSequenceEditorForm.Sequence.Length - latestMark; if (duration > maxPossibleDuration) { duration = maxPossibleDuration; } int generatedMarks = (int)(duration.Ticks / interval.Ticks) - 1; if (MessageBox.Show("From the selected marks, a beat interval of " + interval.ToString(@"s\.ff") + " seconds was detected (" + bpm.ToString(@"#####.##") + " bpm). This will generate " + generatedMarks + " marks. Do you " + "want to continue?", "Confirmation", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } TimeSpan currentTime = latestMark + interval; TimeSpan endTime = latestMark + duration; while (currentTime <= endTime) { _displayedCollection.Marks.Add(currentTime); currentTime += interval; } _displayedCollection.Marks.Sort(); PopulateMarkListFromMarkCollection(_displayedCollection); UpdateMarkCollectionInList(_displayedCollection); } else { MessageBox.Show("Error parsing time: please use the format '<minutes>:<seconds>.<milliseconds>', or leave empty", "Error parsing time"); } } }
private void buttonGenerateSubmarks_Click(object sender, EventArgs e) { if (listViewMarks.SelectedItems.Count < 2) { MessageBox.Show("Select at least two marks to generate times between.", "Need more marks"); return; } Common.Controls.TextDialog prompt = new Common.Controls.TextDialog("Break each interval into how many equal segments?"); if (prompt.ShowDialog() == DialogResult.OK) { int divisions; if (int.TryParse(prompt.Response, out divisions)) { DialogResult newCollectionResult = MessageBox.Show("Do you want to put the new marks into a different collection?", "Add to new collection?", MessageBoxButtons.YesNoCancel); if (newCollectionResult == DialogResult.Cancel) { return; } List <TimeSpan> sourceTimes = new List <TimeSpan>(); foreach (ListViewItem item in listViewMarks.SelectedItems) { sourceTimes.Add((TimeSpan)item.Tag); } sourceTimes.Sort(); List <TimeSpan> newTimes = new List <TimeSpan>(); for (int i = 1; i < sourceTimes.Count; i++) { TimeSpan interval = TimeSpan.FromTicks((sourceTimes[i] - sourceTimes[i - 1]).Ticks / divisions); for (int j = 0; j < divisions; j++) { newTimes.Add(sourceTimes[i - 1] + TimeSpan.FromTicks(interval.Ticks * j)); } } newTimes.Add(sourceTimes.Last()); MarkCollection destination = _displayedCollection; if (newCollectionResult == DialogResult.Yes) { List <KeyValuePair <string, object> > options = new List <KeyValuePair <string, object> >(); foreach (MarkCollection mc in MarkCollections) { options.Add(new KeyValuePair <string, object>(mc.Name, mc)); } Common.Controls.ListSelectDialog selector = new Common.Controls.ListSelectDialog("Destination Mark Collection?", options); if (selector.ShowDialog() == DialogResult.OK) { destination = selector.SelectedItem as MarkCollection; } } foreach (TimeSpan time in newTimes) { if (!destination.Marks.Contains(time)) { destination.Marks.Add(time); } } destination.Marks.Sort(); if (destination == _displayedCollection) { PopulateMarkListFromMarkCollection(_displayedCollection); } UpdateMarkCollectionInList(destination); } else { MessageBox.Show("Error parsing number: please enter a whole number for the number of divisions.", "Error parsing number"); } } }