/// <summary> /// Updates the texture information /// </summary> /// <param name="info"></param> private void UpdateInfo(Otter.UI.Resources.SoundInfo info) { if (info == null) { mDetailsGroupBox.Enabled = false; mReferencesListView.Groups.Clear(); mReferencesListView.Items.Clear(); mSizeTextBox.Text = ""; mFilenameTextBox.Text = ""; return; } mDetailsGroupBox.Enabled = true; System.IO.FileInfo fileInfo = new System.IO.FileInfo(GUIProject.CurrentProject.ProjectDirectory + "/" + info.Filename); mSizeTextBox.Text = fileInfo.Exists ? fileInfo.Length.ToString() : "(file not found)"; mFilenameTextBox.Text = info.Filename; mReferencesListView.Groups.Clear(); mReferencesListView.Items.Clear(); Reference[] references = GetReferences(info); foreach (Reference reference in references) { ListViewGroup group = new ListViewGroup(reference.View.Name); group.Tag = reference.View; mReferencesListView.Groups.Add(group); foreach (GUIAnimation animation in reference.Animations) { ListViewItem item = new ListViewItem(animation.Name); item.Tag = animation; item.Group = group; mReferencesListView.Items.Add(item); } } mPlayButton.Enabled = info.IsPlayable(); mRemoveButton.Enabled = (mReferencesListView.Groups.Count == 0); }
/// <summary> /// Called when the sound has stopped /// </summary> /// <param name="info"></param> void SoundInfo_OnStopped(SoundInfo info) { if (SelectedSound != info) return; mPlayButton.Text = "Play"; }
/// <summary> /// Retrieves an array of controls that reference a particular texture. /// </summary> /// <param name="info"></param> /// <returns></returns> private Reference[] GetReferences(SoundInfo info) { List<Reference> list = new List<Reference>(); if (info != null) { foreach (GUIView view in mScene.Views) { Reference reference = null; foreach (GUIAnimation animation in view.Animations) { bool bFound = false; foreach (MainChannelFrame mainChannelFrame in animation.MainChannelFrames) { foreach (SoundAction soundAction in mainChannelFrame.Actions.OfType<SoundAction>()) { if (soundAction.Sound == info.ID) { bFound = true; break; } } if (bFound) break; } if (bFound) { if (reference == null) { reference = new Reference(); reference.View = view; } reference.Animations.Add(animation); } } if (reference != null) list.Add(reference); } } return list.ToArray(); }