private void PopulateFormWithMarkCollection(MarkCollection collection, bool forceUpdate = false) { if (_displayedCollection == collection && !forceUpdate) { return; } _displayedCollection = collection; if (collection == null) { textBoxCollectionName.Text = ""; numericUpDownWeight.Value = 1; panelColor.BackColor = SystemColors.Control; checkBoxEnabled.Checked = false; } else { textBoxCollectionName.Text = collection.Name; numericUpDownWeight.Value = collection.Level; panelColor.BackColor = collection.MarkColor; checkBoxEnabled.Checked = collection.Enabled; } PopulateMarkListFromMarkCollection(collection); groupBoxSelectedMarkCollection.Enabled = (collection != null); }
} // end convertMapping private void createTimedSequence() { Sequence = new TimedSequence() { SequenceData = new TimedSequenceData() }; // TODO: use this mark collection (maybe generate a grid?) //I am not sure what to do with this, but it looks like John had a plan. MarkCollection mc = new MarkCollection(); Sequence.Length = TimeSpan.FromMilliseconds(parsedV2Sequence.SeqLengthInMills); var songFileName = parsedV2Sequence.SongPath + Path.DirectorySeparatorChar + parsedV2Sequence.SongFileName; if (songFileName != null) { if (File.Exists(songFileName)) { Sequence.AddMedia(MediaService.Instance.GetMedia(songFileName)); } else { var message = string.Format("Could not locate the audio file '{0}'; please add it manually " + "after import (Under Tools -> Associate Audio).", Path.GetFileName(songFileName)); MessageBox.Show(message, "Couldn't find audio"); } } }
private void DeleteSelectedMarkCollections() { if (listViewMarkCollections.SelectedItems.Count > 0) { //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Question; //adds a system icon to the message form. var messageBox = new MessageBoxForm("Are you sure you want to delete the selected Marks in the Collection?", "Delete Mark Collection", true, false); messageBox.ShowDialog(); if (messageBox.DialogResult == DialogResult.OK) { foreach (ListViewItem item in listViewMarkCollections.SelectedItems) { listViewMarkCollections.SelectedItems[0].Remove(); MarkCollection mc = item.Tag as MarkCollection; Sequence.MarkCollections.Remove(mc); } OnChangedMarkCollection(new MarkCollectionArgs(null)); } } else { //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Error; //adds a system icon to the message form. var messageBox = new MessageBoxForm("Please select a Mark Collection to delete and press the delete button again.", "Delete Mark Collection", false, false); messageBox.ShowDialog(); } }
void populateStartOffsetCombo() { int lastIndex = startOffsetCombo.SelectedIndex; int lastCount = startOffsetCombo.Items.Count; startOffsetCombo.Items.Clear(); if (markCollectionCombo.SelectedIndex > -1) { MarkCollection mc = MarkCollections.Find(x => x.Name.Equals(markCollectionCombo.SelectedItem)); if (mc != null) { foreach (TimeSpan ts in mc.Marks) { startOffsetCombo.Items.Add(ts); } } if (startOffsetCombo.Items.Count > 0) { if (lastIndex < startOffsetCombo.Items.Count) { startOffsetCombo.SelectedIndex = (lastIndex == -1) ? 0 : lastIndex; } else { startOffsetCombo.SelectedIndex = startOffsetCombo.Items.Count - 1; } } } }
private void listViewMarkCollections_AfterLabelEdit(object sender, LabelEditEventArgs e) { MarkCollection mc = (listViewMarkCollections.Items[e.Item].Tag as MarkCollection); mc.Name = e.Label ?? mc.Name; OnChangedMarkCollection(new MarkCollectionArgs(mc)); }
ExtractAllMarksFromFeatureSet(ICollection <ManagedFeature> featureSet, BeatBarSettingsData settings) { MarkCollection mc = new MarkCollection(); mc.Name = settings.AllCollectionName; double lastFeatureMS = -1; double featureMS = -1; foreach (ManagedFeature feature in featureSet) { if (feature.hasTimestamp) { featureMS = feature.timestamp.totalMilliseconds(); if (lastFeatureMS != -1) { double interval = (featureMS - lastFeatureMS) / settings.Divisions; for (int j = 0; j < settings.Divisions; j++) { mc.AddMark(new Mark(TimeSpan.FromMilliseconds(lastFeatureMS + (interval * j)))); } } else { mc.AddMark(new Mark(TimeSpan.FromMilliseconds(featureMS))); } lastFeatureMS = featureMS; } } return(mc); }
ExtractBeatCollectionsFromFeatureSet(ICollection <ManagedFeature> featureSet, BeatBarSettingsData settings, List <MarkCollection> otherMarks = null) { List <MarkCollection> retVal = new List <MarkCollection>(); string[] collectionNames = settings.BeatCollectionNames(false); for (int j = 1; j <= collectionNames.Length; j++) { MarkCollection mc = new MarkCollection(); mc.Name = collectionNames[j - 1]; foreach (ManagedFeature feature in featureSet) { if ((feature.hasTimestamp) && (feature.label == j.ToString())) { var featureMS = feature.timestamp.totalMilliseconds(); mc.AddMark(new Mark(TimeSpan.FromMilliseconds(featureMS))); } } RemoveDuplicateMarks(ref mc, otherMarks); retVal.Add(mc); } return(retVal); }
} // end convertMapping private void createTimedSequence() { Sequence = new TimedSequence() { SequenceData = new TimedSequenceData() }; // TODO: use this mark collection (maybe generate a grid?) //I am not sure what to do with this, but it looks like John had a plan. MarkCollection mc = new MarkCollection(); Sequence.Length = TimeSpan.FromMilliseconds(parsedV2Sequence.SeqLengthInMills); var songFileName = parsedV2Sequence.SongPath + Path.DirectorySeparatorChar + parsedV2Sequence.SongFileName; if (songFileName != null) { if (File.Exists(songFileName)) { Sequence.AddMedia(MediaService.Instance.GetMedia(songFileName)); } else { var message = string.Format("Could not locate the audio file '{0}'; please add it manually " + "after import (Under Tools -> Associate Audio).", Path.GetFileName(songFileName)); //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form. var messageBox = new MessageBoxForm(message, "Couldn't find audio", false, false); messageBox.ShowDialog(); } } }
private void listViewMarkCollections_ItemCheck(object sender, ItemCheckEventArgs e) { ListViewItem item = listViewMarkCollections.Items[e.Index]; MarkCollection mc = item.Tag as MarkCollection; mc.Enabled = (e.NewValue == CheckState.Checked); OnMarkCollectionChecked(new MarkCollectionArgs(mc)); }
ExtractSplitCollectionsFromFeatureSet(ICollection <ManagedFeature> featureSet, BeatBarSettingsData settings, List <MarkCollection> otherMarks = null) { List <MarkCollection> retVal = new List <MarkCollection>(); string[] collectionNames = settings.BeatCollectionNames(true); KeyValuePair <int, double>[] tsValuePairs = new KeyValuePair <int, double> [(featureSet.Count * 2)]; int count = 0; double featureMS = -1; double lastFeatureMS = -1; int labelVal = 0; ManagedFeature lastFeature = null; foreach (ManagedFeature feature in featureSet) { if (lastFeature == null) { lastFeature = feature; continue; } labelVal = (Convert.ToInt32(lastFeature.label) * 2) - 1; lastFeatureMS = lastFeature.timestamp.totalMilliseconds(); tsValuePairs[count++] = new KeyValuePair <int, double>(labelVal, lastFeatureMS); featureMS = feature.timestamp.totalMilliseconds(); tsValuePairs[count] = new KeyValuePair <int, double>(labelVal + 1, lastFeatureMS + ((featureMS - lastFeatureMS) / settings.Divisions)); count++; lastFeature = feature; } for (int j = 1; j <= collectionNames.Length; j++) { MarkCollection mc = new MarkCollection(); mc.Enabled = true; mc.Name = collectionNames[j - 1]; foreach (KeyValuePair <int, double> tsValue in tsValuePairs) { if (tsValue.Key == j) { mc.Marks.Add(TimeSpan.FromMilliseconds(tsValue.Value)); } } RemoveDuplicateMarks(ref mc, otherMarks); retVal.Add(mc); } return(retVal); }
private static MarkCollection CreateNewCollection(Color color, string name = "New Collection") { MarkCollection newCollection = new MarkCollection(); newCollection.Name = name; newCollection.Decorator.Color = color; return(newCollection); }
private void listViewMarkCollections_ItemCheck(object sender, ItemCheckEventArgs e) { Point mousePoint = PointToClient(new Point(MousePosition.X, MousePosition.Y)); ListViewItem mouseItem = listViewMarkCollections.GetItemAt(mousePoint.X, mousePoint.Y); ListViewItem item = listViewMarkCollections.Items[e.Index]; MarkCollection mc = item.Tag as MarkCollection; mc.Enabled = (e.NewValue == CheckState.Checked); OnMarkCollectionChecked(new MarkCollectionArgs(mc)); }
/// <summary> /// Method to invoke when the AddCollection command is executed. /// </summary> private void AddCollection() { var mc = new MarkCollection(); if (!MarkCollections.Any()) { mc.IsDefault = true; } MarkCollections.Add(mc); }
private void RemoveDuplicateMarks(ref MarkCollection mcOrig, List <MarkCollection> otherCollections) { if (otherCollections != null) { foreach (var otherCollection in otherCollections) { mcOrig.Marks.RemoveAll(x => otherCollection.Marks.Contains(x)); } } }
private void RemoveDuplicateMarks(ref MarkCollection mcOrig, List <MarkCollection> otherCollections) { if (otherCollections != null) { foreach (var otherCollection in otherCollections) { mcOrig.RemoveAll(x => otherCollection.Marks.Any(m => m.StartTime == x.StartTime && m.Duration == x.Duration)); } } }
private void toolStripButtonAddMarkCollection_Click(object sender, EventArgs e) { MarkCollection mc = new MarkCollection(); mc.Name = "New Mark Collection"; mc.MarkColor = Color.White; Sequence.MarkCollections.Add(mc); OnChangedMarkCollection(new MarkCollectionArgs(mc)); PopulateMarkCollectionsList(mc); }
private void buttonAddCollection_Click(object sender, EventArgs e) { MarkCollection newCollection = new MarkCollection(); newCollection.Name = "New Collection"; MarkCollections.Add(newCollection); // populate the form with the new collection first, *then* update the collection list, // so that the displayed collection is remembered and selected in the list. PopulateFormWithMarkCollection(newCollection); PopulateMarkCollectionsList(); }
public MarkCollectionViewModel(MarkCollection markCollection) { MarkCollection = markCollection; var mgr = ServiceLocator.Default.ResolveType <IViewModelManager>(); var pvm = mgr.GetFirstOrDefaultInstance <MarkDockerViewModel>(); _markCollections = pvm.MarkCollections; _markCollections.CollectionChanged += ParentMarkCollections_CollectionChanged; SetupCollectionTypeCheckboxes(); SetupLevelCheckboxes(); SetupLinkedToCheckboxes(); }
private void BuildMarkCollections(ICollection <IMarkCollection> markCollection, BeatBarSettingsData settings) { List <MarkCollection> retVal = new List <MarkCollection>(); m_featureSet = GenerateFeatures(m_plugin, m_fSamplesAll); String[] beatCollectionNames = settings.BeatCollectionNames(false); String[] splitCollectionNames = settings.BeatCollectionNames(true); if (settings.BarsEnabled) { markCollection.RemoveAll(x => x.Name.Equals(settings.BarsCollectionName)); var mc = ExtractBarMarksFromFeatureSet(m_featureSet[1], settings); mc.Decorator.Color = settings.BarsColor; retVal.Add(mc); } if (settings.BeatCollectionsEnabled) { foreach (String name in beatCollectionNames) { markCollection.RemoveAll(x => x.Name.Equals(name)); } List <MarkCollection> mcl = ExtractBeatCollectionsFromFeatureSet(m_featureSet[2], settings, retVal); mcl.ForEach(x => x.Decorator.Color = settings.BeatCountsColor); retVal.AddRange(mcl); } if (settings.BeatSplitsEnabled) { foreach (String name in splitCollectionNames) { markCollection.RemoveAll(x => x.Name.Equals(name)); } List <MarkCollection> mcl = ExtractSplitCollectionsFromFeatureSet(m_featureSet[2], settings, retVal); mcl.ForEach(x => x.Decorator.Color = settings.BeatSplitsColor); retVal.AddRange(mcl); } if (settings.AllFeaturesEnabled) { markCollection.RemoveAll(x => x.Name.Equals(settings.AllCollectionName)); MarkCollection mc = ExtractAllMarksFromFeatureSet(m_featureSet[0], settings); mc.Decorator.Color = settings.AllFeaturesColor; retVal.Add(mc); } retVal.RemoveAll(x => x.Marks.Count == 0); markCollection.AddRange(retVal.OrderBy(x => x.Name)); }
/// <summary> /// Method to invoke when the OffsetTime command is executed. /// </summary> private void OffsetTime() { var dependencyResolver = this.GetDependencyResolver(); var mbs = dependencyResolver.Resolve <IMessageBoxService>(); var response = mbs.GetNumericUserInput("Time to offset (in milliseconds):", "Offset Mark Time", 1000, -30000, 30000); if (response.Result == Catel.Services.MessageResult.OK) { if (int.TryParse(response.Response, out int ms)) { MarkCollection.OffsetMarksByTime(TimeSpan.FromMilliseconds(ms)); } } }
private void UpdateMarkCollectionInList(MarkCollection collection) { foreach (ListViewItem item in listViewMarkCollections.Items) { if (item.Tag as MarkCollection == collection) { item.SubItems[0].Text = collection.Name; item.SubItems[1].Text = collection.Level.ToString(); item.SubItems[2].Text = collection.Marks.Count.ToString(); item.BackColor = (collection.Enabled) ? collection.MarkColor : SystemColors.Window; item.ForeColor = (collection.Enabled) ? ((GetGrayValueForColor(collection.MarkColor) > 128) ? Color.Black : Color.White) : SystemColors.InactiveCaptionText; } } }
public void PopulateMarkCollectionsList(MarkCollection selectedCollection) { listViewMarkCollections.Items.Clear(); foreach (MarkCollection mc in Sequence.MarkCollections) { ListViewItem item = new ListViewItem(); item.Text = mc.Name; item.ForeColor = mc.MarkColor; item.Tag = mc; item.Checked = mc.Enabled; listViewMarkCollections.Items.Add(item); item.Selected = (mc == selectedCollection); } ResizeColumnHeaders(); }
private void toolStripButtonDeleteMarkCollection_Click(object sender, EventArgs e) { if (listViewMarkCollections.SelectedItems.Count > 0) { MarkCollection mc = (listViewMarkCollections.SelectedItems[0].Tag as MarkCollection); if (MessageBox.Show("Are you sure you want to delete the selected Mark Collection?", "Delete Mark Collection", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { listViewMarkCollections.SelectedItems[0].Remove(); Sequence.MarkCollections.Remove(mc); OnChangedMarkCollection(new MarkCollectionArgs(null)); } } else { MessageBox.Show("Please select a Mark Collection to delete and press the delete button again.", "Delete Mark Collection", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } }
private Tuple <TimeSpan, TimeSpan> CalcPhonemeTimespans(MarkCollection mc, int index, int subelements) { TimeSpan duration; TimeSpan relStart; TimeSpan lastOffset; if (mc != null) { //Sort the Marklist by time. mc.Marks.Sort(); lastOffset = mc.Marks.Last(); } else { lastOffset = new TimeSpan(0, 0, 0, 0); } if ((mc != null) && (index < mc.MarkCount - 1)) { duration = new TimeSpan((mc.Marks[index + 1] - mc.Marks[index]).Ticks / subelements); } else { //Default Phoneme timing to 250ms duration = new TimeSpan(0, 0, 0, 0, 250); } if (index == 0) { unMarkedPhonemes = 0; } if ((mc != null) && (index < mc.MarkCount)) { relStart = mc.Marks[index] - mc.Marks[0]; unMarkedPhonemes = 0; } else { relStart = new TimeSpan(lastOffset.Ticks + (duration.Ticks * unMarkedPhonemes)); unMarkedPhonemes += subelements; } return(new Tuple <TimeSpan, TimeSpan>(relStart, duration)); }
private void buttonRemoveCollection_Click(object sender, EventArgs e) { if (listViewMarkCollections.SelectedItems.Count > 0) { foreach (ListViewItem item in listViewMarkCollections.SelectedItems) { MarkCollection mc = item.Tag as MarkCollection; MarkCollections.Remove(mc); } } if (!MarkCollections.Contains(_displayedCollection)) { PopulateFormWithMarkCollection(null); } PopulateMarkCollectionsList(); }
ExtractBarMarksFromFeatureSet(ICollection <ManagedFeature> featureSet, BeatBarSettingsData settings) { MarkCollection mc = new MarkCollection(); mc.Name = settings.BarsCollectionName; double featureMS = -1; foreach (ManagedFeature feature in featureSet) { if (feature.hasTimestamp) { featureMS = feature.timestamp.totalMilliseconds(); mc.AddMark(new Mark(TimeSpan.FromMilliseconds(featureMS))); } } return(mc); }
public void PopulateMarkCollectionsList(MarkCollection selectedCollection) { listViewMarkCollections.Items.Clear(); foreach (MarkCollection mc in Sequence.MarkCollections) { ListViewItem item = new ListViewItem(); item.Text = mc.Name; item.SubItems.Add(mc.Level.ToString()); item.SubItems.Add(mc.MarkCount.ToString()); item.BackColor = (mc.Enabled) ? mc.MarkColor : SystemColors.Window; item.ForeColor = (mc.Enabled) ? ((GetGrayValueForColor(mc.MarkColor) > 128) ? Color.Black : Color.White) : SystemColors.InactiveCaptionText; item.Tag = mc; item.Checked = mc.Enabled; listViewMarkCollections.Items.Add(item); item.Selected = (mc == selectedCollection); } }
public void PopulateMarkCollectionsList(MarkCollection selectedCollection) { listViewMarkCollections.Items.Clear(); foreach (MarkCollection mc in Sequence.MarkCollections) { ListViewItem item = new ListViewItem(); item.Text = mc.Name; item.ForeColor = mc.MarkColor; // : Color.FromArgb(221,221,221); //item.ForeColor = (mc.Enabled) // ? ((GetGrayValueForColor(mc.MarkColor) > 128) ? Color.Black : Color.White) // : SystemColors.InactiveCaptionText; item.Tag = mc; item.Checked = mc.Enabled; listViewMarkCollections.Items.Add(item); item.Selected = (mc == selectedCollection); } ResizeColumnHeaders(); }
private BeatBarPreviewData GeneratePreviewData() { BeatBarPreviewData previewData = new BeatBarPreviewData(1); QMBarBeatTrack plugin = new QMBarBeatTrack(m_audioModule.Frequency); plugin.SetParameter("bpb", 4); plugin.Initialise(1, (uint)plugin.GetPreferredStepSize(), (uint)plugin.GetPreferredBlockSize()); IDictionary <int, ICollection <ManagedFeature> > featureSet = GenerateFeatures(plugin, m_fSamplesPreview, false); previewData.BeatPeriod = EstimateBeatPeriod(featureSet[2]); BeatBarSettingsData settings = new BeatBarSettingsData("Preview"); settings.Divisions = 1; settings.BeatSplitsEnabled = false; settings.NoteSize = 4; settings.BeatsPerBar = 4; List <MarkCollection> collections = ExtractBeatCollectionsFromFeatureSet(featureSet[2], settings); MarkCollection allCollection = new MarkCollection(); allCollection.Name = "Beat Marks"; collections.ForEach(x => allCollection.AddMarks(x.Marks)); allCollection.EnsureOrder(); previewData.PreviewCollection = allCollection; settings.BeatSplitsEnabled = true; settings.Divisions = 2; collections = ExtractSplitCollectionsFromFeatureSet(featureSet[2], settings); allCollection = new MarkCollection(); allCollection.Name = "Beat Split Marks"; collections.ForEach(x => allCollection.AddMarks(x.Marks)); allCollection.EnsureOrder(); previewData.PreviewSplitCollection = allCollection; return(previewData); }
private void changeMarkCollection(object menuAction) { DialogResult result = DialogResult.Cancel; Common.Controls.ColorManagement.ColorPicker.ColorPicker picker = null; switch (menuAction.ToString()) { case "Change Color": picker = new Common.Controls.ColorManagement.ColorPicker.ColorPicker(); result = picker.ShowDialog(); break; } foreach (ListViewItem item in listViewMarkCollections.SelectedItems) { MarkCollection mc = item.Tag as MarkCollection; switch (menuAction.ToString()) { case "Normal/Bold Line": mc.Bold = !mc.Bold; break; case "Dotted/Solid Line": mc.SolidLine = !mc.SolidLine; break; case "Change Color": if (result == DialogResult.OK) { mc.MarkColor = picker.Color.ToRGB().ToArgb(); item.ForeColor = picker.Color.ToRGB().ToArgb(); } break; case "Delete Selected Marks": DeleteSelectedMarkCollections(); return; } OnMarkCollectionChecked(new MarkCollectionArgs(mc)); } }