public void openLocalFiles(string[] tracks, bool dropped) { trackList = new List <string>(); trackFullName = new List <artistTitle <string, string> >(); if (!dropped) { openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Audio File (*.mp3;*.wav)|*.mp3;*.wav;"; openFileDialog.Multiselect = true; if ((bool)openFileDialog.ShowDialog()) { filesApproved = true; foreach (String file in openFileDialog.FileNames) { trackList.Add(file); track = TagLib.File.Create(file); if (trackList[trackNo].EndsWith("mp3")) { if (track.Tag.Performers.Length > 0 || track.Tag.Title != null) { trackFullName.Add(new artistTitle <string, string>(track.Tag.Performers[0], track.Tag.Title)); } else { trackFullName.Add(new artistTitle <string, string>("", Path.GetFileName(file))); } } else { trackFullName.Add(new artistTitle <string, string>("", Path.GetFileName(file))); } } } else { filesApproved = false; } } else if (tracks != null) { filesApproved = true; foreach (String file in tracks) { trackList.Add(file); track = TagLib.File.Create(file); if (track.Tag.Performers.Length > 0 || track.Tag.Title != null) { trackFullName.Add(new artistTitle <string, string>(track.Tag.Performers[0], track.Tag.Title)); } else { trackFullName.Add(new artistTitle <string, string>("", Path.GetFileName(file))); } } } if (filesApproved) { playStateButtonTemplate = MainWindow.instance.playStateButton.Template; previousButtonTemplate = MainWindow.instance.previousPlayButton.Template; nextButtonTemplate = MainWindow.instance.nextPlayButton.Template; playStateButtonImage = (Image)playStateButtonTemplate.FindName("playStateButtonImage", MainWindow.instance.playStateButton); previousButtonImage = (Image)previousButtonTemplate.FindName("previousPlayButtonImage", MainWindow.instance.previousPlayButton); nextButtonImage = (Image)nextButtonTemplate.FindName("nextPlayButtonImage", MainWindow.instance.nextPlayButton); playStateButtonImage.Source = new BitmapImage(new Uri("Resources/pause_button.png", UriKind.RelativeOrAbsolute)); waveForm = new WaveForm(); disposeWaveDelegate = DisposeWave; setPositionDelegate = setPos; startPlayDelegate = StartPlay; trackNo = 0; MainWindow.instance.playStateButton.IsEnabled = true; } }
/// <summary> /// Binds the class instance methods to the dll functions. /// </summary> /// <param name="hDll">A dll to bind to.</param> private void BindToDll(IntPtr hDll) { IntPtr pProcPtr = GetProcAddress(hDll, "Initialize"); _initialize = (InitializeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(InitializeDelegate)); //pProcPtr = GetProcAddress(hDll, "Open"); //_open = // (OpenDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(OpenDelegate)); pProcPtr = GetProcAddress(hDll, "StartPlay"); _startPlayDelegate = (StartPlayDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StartPlayDelegate)); pProcPtr = GetProcAddress(hDll, "GetCurrentFrame"); _getCurrentFrame = (GetCurrentFrameDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(GetCurrentFrameDelegate)); pProcPtr = GetProcAddress(hDll, "GetFrameSize"); _getFrameSize = (GetFrameSizeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(GetFrameSizeDelegate)); pProcPtr = GetProcAddress(hDll, "Stop"); _stop = (StopDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StopDelegate)); pProcPtr = GetProcAddress(hDll, "Uninitialize"); _uninitialize = (UninitializeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(UninitializeDelegate)); }
/// <summary> /// Binds the class instance methods to the dll functions. /// </summary> /// <param name="hDll">A dll to bind to.</param> private void BindToDll(IntPtr hDll) { IntPtr pProcPtr = GetProcAddress(hDll, "Initialize"); _initialize = (InitializeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(InitializeDelegate)); pProcPtr = GetProcAddress(hDll, "StartPlay"); _startPlayDelegate = (StartPlayDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StartPlayDelegate)); pProcPtr = GetProcAddress(hDll, "StartPlayPiP"); _startPlayPiPDelegate = (StartPlayPiPDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StartPlayPiPDelegate)); pProcPtr = GetProcAddress(hDll, "GetCurrentFrame"); _getCurrentFrame = (GetCurrentFrameDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(GetCurrentFrameDelegate)); pProcPtr = GetProcAddress(hDll, "GetFrameSize"); _getFrameSize = (GetFrameSizeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(GetFrameSizeDelegate)); pProcPtr = GetProcAddress(hDll, "SetupPiP"); _setupPiP = (SetupPiPDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(SetupPiPDelegate)); pProcPtr = GetProcAddress(hDll, "SetupZoom"); _setupZoom = (SetupZoomDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(SetupZoomDelegate)); pProcPtr = GetProcAddress(hDll, "SetupCross"); _setupCross = (SetupCrossDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(SetupCrossDelegate)); pProcPtr = GetProcAddress(hDll, "Stop"); _stop = (StopDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StopDelegate)); pProcPtr = GetProcAddress(hDll, "Uninitialize"); _uninitialize = (UninitializeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(UninitializeDelegate)); }