Пример #1
0
 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);
 }
Пример #2
0
 public bool IsElementPlaying(Ares.Data.IElement element)
 {
     lock (syncObject)
     {
         return(m_PlayedElements.ContainsKey(element.Id));
     }
 }
Пример #3
0
 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);
 }
Пример #4
0
 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;
 }
Пример #5
0
 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);
 }
Пример #6
0
 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);
 }
Пример #7
0
 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);
         }
     }
 }
Пример #8
0
 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();
     });
 }
Пример #9
0
 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);
 }
Пример #10
0
 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);
             }
         }
     }
 }
Пример #11
0
 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);
 }
Пример #12
0
        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);
                    }
                }
            }
        }
Пример #13
0
 private void NotifyEnd(Ares.Data.IElement element)
 {
     NotifyEnd(new HashSet <Ares.Data.IElement>(), element);
 }
Пример #14
0
        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));
        }
Пример #15
0
 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);
 }
Пример #16
0
 public bool IsElementOrSubElementPlaying(Ares.Data.IElement element)
 {
     return(IsElementOrSubElementPlaying(new HashSet <Ares.Data.IElement>(), element));
 }
Пример #17
0
 public void StopElement(Ares.Data.IElement element)
 {
     Ares.Playing.PlayingModule.ElementPlayer.StopElement(element);
 }