private bool IsSubElementOfElements(HashSet <Ares.Data.IElement> checkedReferences, Ares.Data.IElement parent, Ares.Data.IElement element) { if (parent == element) { return(true); } else if (parent is Ares.Data.IGeneralElementContainer) { foreach (Ares.Data.IContainerElement containerElement in (parent as Ares.Data.IGeneralElementContainer).GetGeneralElements()) { if (IsSubElementOfElements(checkedReferences, containerElement.InnerElement, element)) { return(true); } } } else if (parent is Ares.Data.IReferenceElement) { if (checkedReferences.Contains(parent)) { return(false); } checkedReferences.Add(parent); Ares.Data.IElement referencedElement = Ares.Data.DataModule.ElementRepository.GetElement((parent as Ares.Data.IReferenceElement).ReferencedId); if (referencedElement != null && IsSubElementOfElements(checkedReferences, referencedElement, element)) { return(true); } } return(false); }
public bool IsElementPlaying(Ares.Data.IElement element) { lock (syncObject) { return(m_PlayedElements.ContainsKey(element.Id)); } }
private void HandlePlayingError(Ares.Data.IElement element, String errorMessage) { if (element is Ares.Data.IFileElement) { errorMessage += "\n"; errorMessage += String.Format(StringResources.FilePlayed, (element as Ares.Data.IFileElement).FilePath); } MessageBox.Show(this, errorMessage, StringResources.Ares, MessageBoxButtons.OK, MessageBoxIcon.Error); }
public void SetElement(Ares.Data.IElement element, Ares.Data.IProject project) { m_Element = element; m_Project = project; listen = false; UpdateData(); Actions.ElementChanges.Instance.AddListener(m_Element.Id, Update); listen = true; }
private bool IsSubElementOfPlayedElement(Ares.Data.IElement element) { foreach (int elementID in m_PlayedElements.Keys) { if (IsSubElementOfElement(Ares.Data.DataModule.ElementRepository.GetElement(elementID), element)) { return(true); } } return(false); }
private bool IsElementOrSubElementPlaying(HashSet <Ares.Data.IElement> checkedReferences, Ares.Data.IElement element) { lock (syncObject) { if (m_PlayedElements.ContainsKey(element.Id)) { return(true); } } if (element is Ares.Data.IGeneralElementContainer) { foreach (Ares.Data.IContainerElement subElement in (element as Ares.Data.IGeneralElementContainer).GetGeneralElements()) { if (IsElementOrSubElementPlaying(checkedReferences, subElement)) { return(true); } } } else if (element is Ares.Data.IContainerElement) { Ares.Data.IElement inner = (element as Ares.Data.IContainerElement).InnerElement; if (inner != element && IsElementOrSubElementPlaying(checkedReferences, inner)) { return(true); } } else if (element is Ares.Data.IReferenceElement) { if (checkedReferences.Contains(element)) { return(false); } checkedReferences.Add(element); Ares.Data.IElement referencedElement = Ares.Data.DataModule.ElementRepository.GetElement((element as Ares.Data.IReferenceElement).ReferencedId); if (referencedElement != null && IsElementOrSubElementPlaying(checkedReferences, referencedElement)) { return(true); } } else { lock (syncObject) { if (IsSubElementOfPlayedElement(element)) { return(true); } } } return(false); }
public void ErrorOccurred(int elementID, String errorMessage) { StopAll(); if (ErrorHandling != null) { Ares.Data.IElement element = null; if (elementID != -1) { element = Ares.Data.DataModule.ElementRepository.GetElement(elementID); } if (ErrorHandling.Control.InvokeRequired) { ErrorHandling.Control.BeginInvoke(new System.Windows.Forms.MethodInvoker(() => ErrorHandling.ErrorHandlingMethod(element, errorMessage))); } else { ErrorHandling.ErrorHandlingMethod(element, errorMessage); } } }
public void PlayElement(Ares.Data.IElement element, System.Windows.Forms.Control guiControl, System.Action finishAction) { m_PlayedElements[element.Id] = true; IsPlaying = true; NotifyStart(element); if (Actions.Instance.UpdateGUI != null) { Actions.Instance.UpdateGUI(); } DoPlayElement(element, guiControl, () => { m_PlayedElements.Remove(element.Id); IsPlaying = m_PlayedElements.Count != 0; NotifyEnd(element); if (Actions.Instance.UpdateGUI != null) { Actions.Instance.UpdateGUI(); } finishAction(); }); }
private void DoPlayElement(Ares.Data.IElement element, System.Windows.Forms.Control guiControl, System.Action finishAction) { lock (syncObject) { m_FinishedActions[element.Id] = () => { if (guiControl.IsDisposed) { return; } if (guiControl.InvokeRequired) { guiControl.BeginInvoke(new System.Windows.Forms.MethodInvoker(() => { finishAction(); })); } else { finishAction(); } }; } Ares.Playing.PlayingModule.ElementPlayer.PlayElement(element); }
private void NotifyEnd(HashSet <Ares.Data.IElement> references, Ares.Data.IElement element) { ElementChanges.Instance.ElementStopped(element.Id); if (element is Ares.Data.IGeneralElementContainer) { foreach (Ares.Data.IContainerElement e in (element as Ares.Data.IGeneralElementContainer).GetGeneralElements()) { NotifyEnd(references, e.InnerElement); } } else if (element is Ares.Data.IReferenceElement) { if (!references.Contains(element)) { references.Add(element); Ares.Data.IElement referencedElement = Ares.Data.DataModule.ElementRepository.GetElement((element as Ares.Data.IReferenceElement).ReferencedId); if (referencedElement != null) { NotifyEnd(references, referencedElement); } } } }
public static void ShowEditor(Ares.Data.IElement element, Ares.Data.IGeneralElementContainer container, Ares.Data.IProject project, WeifenLuo.WinFormsUI.Docking.DockPanel parent) { ShowEditor(element, container, null, project, parent); }
private static void ShowEditor(Ares.Data.IElement element, Ares.Data.IGeneralElementContainer container, Ares.Data.IModeElement modeElement, Ares.Data.IProject project, WeifenLuo.WinFormsUI.Docking.DockPanel parent) { if (element == null) { return; } EditorBase existing = EditorRegistry.Instance.GetEditor(element.Id); if (existing != null) { existing.Activate(); } else { if (element is Ares.Data.IRandomBackgroundMusicList) { RandomPlaylistOrBGSoundChoiceEditor editor = new RandomPlaylistOrBGSoundChoiceEditor(); editor.SetPlaylist(element as Ares.Data.IRandomBackgroundMusicList, project); ShowEditor(editor, parent); } else if (element is Ares.Data.IBackgroundSoundChoice) { RandomPlaylistOrBGSoundChoiceEditor editor = new RandomPlaylistOrBGSoundChoiceEditor(); editor.SetBGSoundChoice(element as Ares.Data.IBackgroundSoundChoice, project); ShowEditor(editor, parent); } else if (element is Ares.Data.ISequentialBackgroundMusicList) { SequentialPlaylistEditor editor = new SequentialPlaylistEditor(); editor.SetPlaylist(element as Ares.Data.ISequentialBackgroundMusicList, project); ShowEditor(editor, parent); } else if (element is Ares.Data.IMacro) { MacroEditor editor = new MacroEditor(); editor.SetContainer(element as Ares.Data.IMacro, project); ShowEditor(editor, parent); } else if (element is Ares.Data.IElementContainer <Ares.Data.IChoiceElement> ) { ChoiceContainerEditor editor = new ChoiceContainerEditor(); editor.SetContainer(element as Ares.Data.IElementContainer <Ares.Data.IChoiceElement>, project, false); ShowEditor(editor, parent); } else if (element is Ares.Data.ISequentialContainer) { SequentialContainerEditor editor = new SequentialContainerEditor(); editor.SetContainer(element as Ares.Data.ISequentialContainer, project); ShowEditor(editor, parent); } else if (element is Ares.Data.IElementContainer <Ares.Data.IParallelElement> ) { ParallelContainerEditor editor = new ParallelContainerEditor(); editor.SetContainer(element as Ares.Data.IElementContainer <Ares.Data.IParallelElement>, project); ShowEditor(editor, parent); } else if (element is Ares.Data.IMusicByTags) { MusicByTagsEditor editor = new MusicByTagsEditor(); editor.SetElement(element as Ares.Data.IMusicByTags, project); ShowEditor(editor, parent); } else if (element is Ares.Data.IReferenceElement) { Ares.Data.IElement referencedElement = Ares.Data.DataModule.ElementRepository.GetElement((element as Ares.Data.IReferenceElement).ReferencedId); if (referencedElement != null) { ShowEditor(referencedElement, container, project, parent); } } else if (element is Ares.Data.IWebRadioElement) { WebRadioEditor editor = new WebRadioEditor(); editor.SetElement(element as Ares.Data.IWebRadioElement, project, modeElement); ShowEditor(editor, parent); } else if (element is Ares.Data.IFileElement) { Ares.Data.IFileElement fileElement = (Ares.Data.IFileElement)element; if (fileElement.FilePath.EndsWith(".m3u", StringComparison.InvariantCultureIgnoreCase) || fileElement.FilePath.EndsWith(".m3u8", StringComparison.InvariantCultureIgnoreCase) || fileElement.FilePath.EndsWith(".pls", StringComparison.InvariantCultureIgnoreCase)) { String basePath = fileElement.SoundFileType == Data.SoundFileType.Music ? Ares.Settings.Settings.Instance.MusicDirectory : Ares.Settings.Settings.Instance.SoundDirectory; String filePath = System.IO.Path.Combine(basePath, fileElement.FilePath); System.Diagnostics.Process.Start(filePath); } else { FileElementEditor editor = new FileElementEditor(); editor.SetElement(element as Ares.Data.IFileElement, container, project); ShowEditor(editor, parent); } } } }
private void NotifyEnd(Ares.Data.IElement element) { NotifyEnd(new HashSet <Ares.Data.IElement>(), element); }
private bool IsSubElementOfElement(Ares.Data.IElement parent, Ares.Data.IElement element) { HashSet <Ares.Data.IElement> checkedReferences = new HashSet <Data.IElement>(); return(IsSubElementOfElements(checkedReferences, parent, element)); }
public static void ShowEditor(Ares.Data.IElement element, Ares.Data.IModeElement modeElement, Ares.Data.IProject project, WeifenLuo.WinFormsUI.Docking.DockPanel parent) { ShowEditor(element, null, modeElement, project, parent); }
public bool IsElementOrSubElementPlaying(Ares.Data.IElement element) { return(IsElementOrSubElementPlaying(new HashSet <Ares.Data.IElement>(), element)); }
public void StopElement(Ares.Data.IElement element) { Ares.Playing.PlayingModule.ElementPlayer.StopElement(element); }