private static void ExpandPlaylists <T>(IElementContainer <T> playlist, IList <T> elements, Action <String> errorHandler) where T : IContainerElement { int count = 0; foreach (T element in elements) { IElement inner = element.InnerElement; if (inner is IFileElement) { IFileElement fileElement = (IFileElement)inner; if (fileElement.FilePath.EndsWith(".m3u", StringComparison.InvariantCultureIgnoreCase) || fileElement.FilePath.EndsWith(".m3u8", StringComparison.InvariantCultureIgnoreCase) || fileElement.FilePath.EndsWith(".pls", StringComparison.InvariantCultureIgnoreCase)) { count += AddPlaylistElements(playlist, fileElement, element, errorHandler); } else { playlist.InsertGeneralElement(count, element); ++count; } } else { playlist.InsertGeneralElement(count, element); ++count; } } }
public FileElement(IScriptFile file, int line, IFileElement parentElement, string @namespace, string name, AccessModifier access, FileElementType type) { m_parentFile = file; m_line = line; m_baseElement = null; m_parentElement = parentElement; m_elementName = name; m_accessModifier = access; m_elementType = type; if (String.IsNullOrEmpty(@namespace)) { m_elementFullName = m_elementName; } else { m_elementFullName = @namespace + "." + m_elementName; } //if (m_parentElement != null) //{ // m_elementFullName = m_parentElement.FullName + "." + m_elementName; //} //else //{ //} }
public static IProcedureReference <T> GetPartnerReference <T>( IScriptCallContext context, IFileElement element, string partnerName) { Type t = typeof(T); var e = element; while (e != null) { var partner = e.ListPartners().FirstOrDefault(p => p.Name.Equals(partnerName, StringComparison.InvariantCulture)); if (partner != null) { System.Diagnostics.Debug.WriteLine("Expected type: " + typeof(T).FullName); System.Diagnostics.Debug.WriteLine("Found type: " + partner.ProcedureReference.ProcedureReference.GetType().GetGenericArguments()[0].FullName); if (partner.ProcedureReference.ProcedureReference is IProcedureReference <T> ) { return(partner.ProcedureReference.ProcedureReference as IProcedureReference <T>); } else { context.ReportError("The partner procedure is not the expected type."); return(null); } } e = e.BaseElement; } context.ReportError($"The element \"{element.FullName}\" has no partner named \"{partnerName}\"."); return(null); }
public FileElementPartner(IFileElement parent, string name, string referenceName, IFileProcedure procedure) { this.ParentElement = parent; this.Name = name; this.ProcedureName = referenceName; this.ProcedureReference = procedure; }
public int PlayFile(IFileElement fileElement, int fadeInTime, Action <bool> afterPlayed, bool loop) { SoundFile soundFile = new SoundFile(fileElement, m_PlayMusicOnAllSpeakers); FileStarted(fileElement); int handle = PlayingModule.FilePlayer.PlayFile(soundFile, fadeInTime, (id, handle2) => { FileFinished(id, fileElement.SoundFileType); lock (syncObject) { m_CurrentFiles.Remove(handle2); } afterPlayed(true); }, loop); if (handle != 0) { lock (syncObject) { m_CurrentFiles.Add(handle); } } else { FileFinished(soundFile.Id, fileElement.SoundFileType); afterPlayed(false); } return(handle); }
public void VisitFileElement(IFileElement fileElement) { if (!mElementsSet.Contains(fileElement)) { mFileElements.Add(fileElement); mElementsSet.Add(fileElement); } }
public void VisitMusicByTags(IMusicByTags musicByTags) { foreach (String file in musicByTags.GetAllMatchingFiles()) { IFileElement element = Ares.Data.DataModule.ElementFactory.CreateFileElement(file, SoundFileType.Music); element.Visit(this); } }
public ReverbDialog(IList <IFileElement> elements, IProject project) { InitializeComponent(); m_Project = project; m_Element = elements[0]; Action = new Actions.ReverbEffectChangeAction(elements, true); volumeUpDown.Value = m_Element.Effects.Reverb.Level; delayUpDown.Value = m_Element.Effects.Reverb.Delay; }
public void VisitFileElement(IFileElement fileElement) { if (m_CurrentModeElement != null) { if (m_SearchedPath.Equals(GetAbsolutePath(fileElement), StringComparison.CurrentCultureIgnoreCase)) { m_CurrentList.Add(m_CurrentModeElement); } } }
public IScriptExecution CreateFileElementExecution( IFileElement element, IPartner partner, params object[] arguments) { this.ExpectServiceStarted(); var scriptTask = new ScriptExecutionTask(m_logger, m_logSinkManager, m_loadedFilesManager, m_taskManager, element, arguments); m_tasks.Add(new WeakReference <ScriptExecutionTask>(scriptTask)); return(scriptTask); }
public FileVariable( IScriptFile file, AccessModifier access, int line, IFileElement parentElement, string @namespace, string name, IValueContainerOwnerAccess variableAccess, int id) : base(file, line, parentElement, @namespace, name, access, FileElementType.FileVariable) { m_variableAccess = variableAccess; m_id = id; }
public IExecutionResult ExecuteFileElement( IFileElement element, IPartner partner, params object[] arguments) { this.ExpectServiceStarted(); var exeTask = new ScriptExecutionTask(m_logger, m_logSinkManager, m_loadedFilesManager, m_taskManager, element, arguments); m_tasks.Add(new WeakReference <ScriptExecutionTask>(exeTask)); exeTask.ExecuteSynchronous(); throw new NotImplementedException(); }
public void SetElement(IFileElement element, IGeneralElementContainer container, IProject project) { ElementId = element.Id; m_Element = element; m_Project = project; fileVolumeControl.SetEffects(element); fileVolumeControl.SetContainer(container, project); fileEffectsControl.SetEffects(element); fileEffectsControl.SetContainer(container, project); cutControl.SetEffects(element, project); UpdateStaticInfo(); Update(m_Element.Id, Actions.ElementChanges.ChangeType.Renamed); Actions.ElementChanges.Instance.AddListener(ElementId, Update); }
//private void OnReadyForExecuteSelectedProcedure() //{ // if (StepBroMain.LastParsingErrorCount == 0) // { // this.ExecuteSelectedProcedure(); // } // else // { // MessageBox.Show( // this, // "Could not start execution because of one or more parsing errors.", // "Error starting execution", MessageBoxButtons.OK, MessageBoxIcon.Error); // } //} //private void OnReadyForExecuteProcedureUnderCursor() //{ // if (StepBroMain.LastParsingErrorCount == 0) // { // this.ExecuteProcedureUnderCursor(); // } // else // { // MessageBox.Show( // this, // "Could not start execution because of one or more parsing errors.", // "Error starting execution", MessageBoxButtons.OK, MessageBoxIcon.Error); // } //} private void ExecuteSelectedProcedure() { var selected = toolStripComboBoxExecutionTarget.SelectedItem as ComboboxItem; if (selected != null) { IFileElement element = Main.TryFindFileElement(selected.Value as string); if (element != null) { m_mainScriptExecution = StepBro.Core.Main.StartProcedureExecution(element as IFileProcedure); m_mainScriptExecution.Task.CurrentStateChanged += this.CurrentScriptExecution_CurrentStateChanged; } } }
private static int AddPlaylistElements <T>(IElementContainer <T> container, IFileElement playListElement, T origElement, Action <String> errorHandler) where T : IContainerElement { String playlistPath = Path.Combine(Ares.Settings.Settings.Instance.MusicDirectory, playListElement.FilePath); if (!File.Exists(playlistPath)) { errorHandler(String.Format(StringResources.PlaylistNotFound, playlistPath)); return(0); } int count = 0; try { List <String> filePaths = ReadPlaylist(playlistPath, errorHandler); if (filePaths == null) { return(0); } foreach (String filePath in filePaths) { IFileElement newElement = Ares.Data.DataModule.ElementFactory.CreateFileElement(filePath, SoundFileType.Music); newElement.SetsMusicVolume = playListElement.SetsMusicVolume; newElement.SetsSoundVolume = playListElement.SetsSoundVolume; newElement.MusicVolume = playListElement.MusicVolume; newElement.SoundVolume = playListElement.SoundVolume; if (origElement is IChoiceElement) { InsertElement((IElementContainer <IChoiceElement>)container, newElement, (IChoiceElement)origElement); ++count; } else if (origElement is ISequentialElement) { InsertElement((IElementContainer <ISequentialElement>)container, newElement, (ISequentialElement)origElement); ++count; } else { errorHandler("Internal error: Unknown music list type."); return(0); } } } catch (IOException e) { errorHandler(String.Format(StringResources.ErrorReadingPlaylist, playlistPath, e.Message)); } return(count); }
public static IRandomBackgroundMusicList CreateTagsMusicList(String title, IList <String> choices, int fadeTime) { var newMusicList = Ares.Data.DataModule.ElementFactory.CreateRandomBackgroundMusicList(title); foreach (String file in choices) { IFileElement fileElement = Ares.Data.DataModule.ElementFactory.CreateFileElement(file, Data.SoundFileType.Music); if (fadeTime > 0) { fileElement.Effects.FadeInTime = fadeTime / 2; fileElement.Effects.FadeOutTime = fadeTime / 2; } newMusicList.AddElement(fileElement); } return(newMusicList); }
public ScriptExecutionTask( ILogger logger, ILogSinkManager logSinkManager, ILoadedFilesManager filesManager, TaskManager taskManager, IFileElement targetElement, object[] arguments) { m_logger = logger; m_logSinkManager = logSinkManager; m_filesManager = filesManager; m_taskManager = taskManager; m_targetElement = targetElement; m_arguments = arguments; m_taskContext = new ScriptTaskContext(); m_statusUpdate = new ExecutionScopeStatusUpdaterMock(); }
private static IList <IFileElement> GetFileElements(HashSet <IXmlWritable> checkedReferences, IXmlWritable element) { if (element is IGeneralElementContainer) { return(GetFileElements(checkedReferences, (element as IGeneralElementContainer))); } else if (element is IContainerElement) { return(GetFileElements(checkedReferences, (element as IContainerElement).InnerElement)); } else if (element is IReferenceElement) { if (!checkedReferences.Contains(element)) { checkedReferences.Add(element); IElement referencedElement = DataModule.ElementRepository.GetElement((element as IReferenceElement).ReferencedId); IList <IFileElement> result; if (referencedElement != null) { result = GetFileElements(checkedReferences, referencedElement); } else { result = new List <IFileElement>(); } checkedReferences.Remove(element); return(result); } else { return(new List <IFileElement>()); } } else { IList <IFileElement> result = new List <IFileElement>(); IFileElement fileElement = element as IFileElement; if (fileElement != null) { result.Add(fileElement); } return(result); } }
public FileProcedure( IScriptFile file, AccessModifier access, int line, IFileElement parentElement, string @namespace, string name, ContextLogOption logOption = ContextLogOption.Normal, bool separateStateLevel = true) : base(file, line, parentElement, @namespace, name, access, FileElementType.ProcedureDeclaration) { m_callContextParameter = Expression.Parameter(typeof(ICallContext), "callcontext"); //var delegatetype = (m_runtimeProcedure != null) ? m_runtimeProcedure.GetType() : typeof(UnresolvedProcedureType); //m_parametersInternal.Add(new IdentifierInfo("callcontext", "callcontext", IdentifierType.Parameter, delegatetype, m_callContextParameter)); m_returnLabel = Expression.Label(); this.LogOption = logOption; this.Flags = (this.Flags & ProcedureFlags.SeparateStateLevel) | (separateStateLevel ? ProcedureFlags.SeparateStateLevel : ProcedureFlags.None); }
public static MusicInfo GetInfo(int musicElementId) { if (musicElementId != -1) { IElement musicElement = Ares.Data.DataModule.ElementRepository.GetElement(musicElementId); if (musicElement == null) { return(new MusicInfo(String.Empty, String.Empty)); } IFileElement fileElement = musicElement as IFileElement; String shortTitle = musicElement.Title; String longTitle = musicElement.Title; if (fileElement != null) { String path = Settings.Settings.Instance.MusicDirectory; path = System.IO.Path.Combine(path, fileElement.FilePath); Un4seen.Bass.AddOn.Tags.TAG_INFO tag = Un4seen.Bass.AddOn.Tags.BassTags.BASS_TAG_GetFromFile(path, true, false); if (tag != null) { StringBuilder musicInfoBuilder = new StringBuilder(); musicInfoBuilder.Append(tag.artist); if (musicInfoBuilder.Length > 0) { musicInfoBuilder.Append(" - "); } musicInfoBuilder.Append(tag.album); if (musicInfoBuilder.Length > 0) { musicInfoBuilder.Append(" - "); } musicInfoBuilder.Append(tag.title); longTitle = musicInfoBuilder.ToString(); } } return(new MusicInfo(longTitle, shortTitle)); } else { return(new MusicInfo(String.Empty, String.Empty)); } }
private static IElement CreateFileElement(DraggedItem item, String musicDirectory, String soundDirectory) { IFileElement element = Ares.Data.DataModule.ElementFactory.CreateFileElement(item.RelativePath, item.ItemType == FileType.Music ? SoundFileType.Music : SoundFileType.SoundEffect); String dir = item.ItemType == FileType.Music ? musicDirectory : soundDirectory; String path = System.IO.Path.Combine(dir, item.RelativePath); Un4seen.Bass.AddOn.Tags.TAG_INFO tag = Un4seen.Bass.AddOn.Tags.BassTags.BASS_TAG_GetFromFile(path, true, true); if (!String.IsNullOrEmpty(tag?.title)) { element.Title = tag.title; } else if (String.IsNullOrEmpty(item.Title)) { element.Title = System.IO.Path.GetFileNameWithoutExtension(path); } else { element.Title = item.Title; } return(element); }
public void VisitFileElement(IFileElement fileElement) { String basePath = fileElement.SoundFileType == SoundFileType.Music ? Ares.Settings.Settings.Instance.MusicDirectory : Ares.Settings.Settings.Instance.SoundDirectory; String fullPath = System.IO.Path.Combine(basePath, fileElement.FilePath); bool found = false; #if ANDROID if (fullPath.IsSmbFile()) { // don't check each file from a share; takes too long found = true; /* * try * { * var smbFile = new Jcifs.Smb.SmbFile(fullPath); * if (smbFile.Exists()) * { * found = true; * } * } * catch (Jcifs.Smb.SmbException) * { * } */ } else #endif if (System.IO.File.Exists(fullPath)) { found = true; } if (!found) { AddError(m_ModelErrors, ModelError.ErrorSeverity.Error, String.Format(StringResources.FileNotFound, fullPath), fileElement); } m_Ct.ThrowIfCancellationRequested(); }
public override void VisitFileElement(IFileElement fileElement) { CurrentPlayedHandle = Client.PlayFile(fileElement, m_MusicFadeInTime, (success) => { bool stop = false; lock (syncObject) { CurrentPlayedHandle = 0; CurrentFadeOut = 0; stop = shallStop; } if (stop || (!success && IsSingleFileList())) { if (PlayingModule.ThePlayer.ProjectCallbacks != null) { PlayingModule.ThePlayer.ProjectCallbacks.MusicPlaylistFinished(GetSingleFileListId()); } Client.SubPlayerFinished(this, stop, false); } else if (!success) { // must get out of current call stack m_PlayAfterErrorTimer = new System.Timers.Timer(5); m_PlayAfterErrorTimer.AutoReset = false; m_PlayAfterErrorTimer.Elapsed += new System.Timers.ElapsedEventHandler(playAfterErrorTimer_Elapsed); m_PlayAfterErrorTimer.Start(); } else { PlayNext(); } }, false); if (CurrentPlayedHandle != 0 && m_RepeatCurrentMusic) { ((FilePlayer)PlayingModule.FilePlayer).SetRepeatFile(CurrentPlayedHandle, true); } CurrentFadeOut = fileElement.Effects.FadeOutTime; PlayingModule.ThePlayer.ActiveMusicPlayer = this; }
public void VisitFileElement(IFileElement fileElement) { switch (m_RemoveDuplicates) { case DuplicateRemoval.PathBased: { String path; if (fileElement.SoundFileType == SoundFileType.Music) { path = Ares.Settings.Settings.Instance.MusicDirectory; } else { path = Ares.Settings.Settings.Instance.SoundDirectory; } path = System.IO.Path.Combine(path, fileElement.FilePath); path = System.IO.Path.GetFullPath(path).ToUpperInvariant(); if (!m_Files.ContainsKey(path)) { m_Files.Add(path, fileElement); } } break; case DuplicateRemoval.IdBased: { String key = "" + fileElement.Id; if (!m_Files.ContainsKey(key)) { m_Files.Add(key, fileElement); } } break; case DuplicateRemoval.None: default: m_Files.Add("" + m_Files.Count, fileElement); break; } }
private void ExecuteProcedureUnderCursor() { // Temporary solution !!!! // Get the file element closest to the current selection (or the cursor), and execute that. var active = dockPanel.ActiveDocument.DockHandler.Content; if (active != null && active is StepBroScriptDocView) { var view = active as StepBroScriptDocView; var file = view.ScriptFile; IFileElement element = null; var selectionLine = view.SelectionStartLine + 1; // Make line number 1-based foreach (var fe in file.ListElements()) { if (fe.Line <= selectionLine && (element == null || element.Line < fe.Line)) { element = fe; } } if (element != null) { if (element is IFileProcedure) { m_mainScriptExecution = StepBro.Core.Main.StartProcedureExecution(element as IFileProcedure); m_mainScriptExecution.Task.CurrentStateChanged += this.CurrentScriptExecution_CurrentStateChanged; } else { // TODO: Show comment in status bar } } else { // TODO: Show comment in status bar } } }
public void VisitFileElement(IFileElement fileElement) { }
public override void VisitFileElement(IFileElement fileElement) { }
public SingleMusicPlayer(IFileElement musicFile, WaitHandle stoppedEvent, IElementPlayerClient client) : base(stoppedEvent, client) { m_Element = musicFile; }
protected override IIntEffect GetEffect(IFileElement element) { return(element.Effects.VolumeDB); }
protected override IIntEffect GetEffect(IFileElement element) { return(element.Effects.Balance); }