16
Плагины-дополнения / Addons / Re: AIMP Tray Control x64 by Keannad
« on: April 02, 2009, 20:39:18 »
По просьбам - бета версия исходных кодов.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
using System;
using System.Drawing;
using System.Runtime.InteropServices;
namespace AIMP_SDK.Struct
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 4)]
public struct TAIMP2FileInfo
{
public int cbSizeOf;
//
public bool nActive;
public int nBitRate;
public int nChannels;
public int nDuration;
public long nFileSize;
public int nRating;
public int nSampleRate;
public int nTrackID;
//
public int nAlbumLen;
public int nArtistLen;
public int nDateLen;
public int nFileNameLen;
public int nGenreLen;
public int nTitleLen;
//
public string sAlbum;
public string sArtist;
public string sDate;
public string sFileName;
public string sGenre;
public string sTitle;
} // end TAIMP2FileInfo
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 4)]
public unsafe struct TPLSInfo
{
public string PLSName;
public int FileCount;
public int PLSDuration;
public long PLSSize;
public int PlaylistID;
} // end TPLSInfo
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 4)]
public unsafe struct TAIMPMenuInfo
{
public bool CheckBox;
public bool RadioItem;
public bool Checked;
public bool Enabled;
public object Proc; // TAIMPMenuProc;
public Bitmap Bitmap; // 0 - no bmp
public string Caption;
public int User;
} // end TAIMPMenuInfo
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 4)]
public unsafe struct TAIMPAddonHeader
{
public byte Version;
public int DllInstance;
public object GetPlgName; //Proc;
public object GetAuthor; //Proc;
public object Init; //Proc;
public object Config; //Proc;
public object Free; //Proc;
} // end TAIMPAddonHeader
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 4)]
public unsafe struct TInputInfo
{
public int SampleRate;
public int Bits;
public int Channels;
} // end TInputInfo
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 4)]
public unsafe struct TVisualData
{
public int LevelR;
public int LevelL;
public byte[,] Spectrum;
public sbyte[,] WaveForm;
} // end TVisualData
}
А вот здесь уже сложнее. Почему? Потому что C# создаёт так называемый управляемый код. Типа безопасная работа с памятью, доступ к обьектам, а вот Дельфи, как говориться, работает по старинке, напрямую.public object Proc; <--
public object GetPlgName; <--
public object GetAuthor; <--
public object Init; <--
public object Config; <--
public object Free; <--
using System;
using System.Drawing;
namespace AIMP_SDK.Units
{
public class Units
{
public static readonly int WM_USER = 0x0400;
public static readonly int AIMP_PLUGIN_NAME = 1;
public static readonly int AIMP_PLUGIN_INFO = 2;
public static readonly int AIMP_PLUGIN_AUTHOR = 3;
public static readonly int AIMP_PLUGIN_EXTS = 4;
// ==============================================================================
// R E M O T E I N F O
// ==============================================================================
public static readonly string AIMP2_RemoteClass = "AIMP2_RemoteInfo";
public static readonly int AIMP2_RemoteFileSize = 2048;
public static readonly object WM_AIMP_COMMAND = WM_USER + 0x75;
// WParam = One of Command, LPARAM - Parameter
// see parameters for AIMP_Status_Get/AIMP_Status_Set
public static readonly int WM_AIMP_STATUS_GET = 1;
public static readonly int WM_AIMP_STATUS_SET = 2;
// HiWord of LParam - Command, LoWord of LParam - Parameter
public static readonly int WM_AIMP_CALLFUNC = 3;
// LPARAM - Func ID (see below Func ID for Addons)
public static readonly int WM_AIMP_GET_VERSION = 4;
public static readonly int WM_AIMP_STATUS_CHANGE = 5;
public static readonly object WM_LANG = WM_USER + 101;
// CallBack types
public static readonly int AIMP_STATUS_CHANGE = 1;
public static readonly int AIMP_PLAY_FILE = 2;
public static readonly int AIMP_INFO_UPDATE = 5;
// Update Info for current track
public static readonly int AIMP_PLAYER_STATE = 11;
// Play/Pause/Stop
public static readonly int AIMP_EFFECT_CHANGED = 12;
// Balance, Speed, Tempo, Pitch, Flanger and etc.
public static readonly int AIMP_EQ_CHANGED = 13;
// Sliders changed
public static readonly int AIMP_TRACK_POS_CHANGED = 14;
// AIMP_Status_Set / AIMP_Status_Get
public static readonly int AIMP_STS_VOLUME = 1;
public static readonly int AIMP_STS_BALANCE = 2;
public static readonly int AIMP_STS_SPEED = 3;
public static readonly int AIMP_STS_Player = 4;
public static readonly int AIMP_STS_MUTE = 5;
public static readonly int AIMP_STS_REVERB = 6;
public static readonly int AIMP_STS_ECHO = 7;
public static readonly int AIMP_STS_CHORUS = 8;
public static readonly int AIMP_STS_Flanger = 9;
public static readonly int AIMP_STS_EQ_STS = 10;
public static readonly int AIMP_STS_EQ_SLDR01 = 11;
public static readonly int AIMP_STS_EQ_SLDR02 = 12;
public static readonly int AIMP_STS_EQ_SLDR03 = 13;
public static readonly int AIMP_STS_EQ_SLDR04 = 14;
public static readonly int AIMP_STS_EQ_SLDR05 = 15;
public static readonly int AIMP_STS_EQ_SLDR06 = 16;
public static readonly int AIMP_STS_EQ_SLDR07 = 17;
public static readonly int AIMP_STS_EQ_SLDR08 = 18;
public static readonly int AIMP_STS_EQ_SLDR09 = 19;
public static readonly int AIMP_STS_EQ_SLDR10 = 20;
public static readonly int AIMP_STS_EQ_SLDR11 = 21;
public static readonly int AIMP_STS_EQ_SLDR12 = 22;
public static readonly int AIMP_STS_EQ_SLDR13 = 23;
public static readonly int AIMP_STS_EQ_SLDR14 = 24;
public static readonly int AIMP_STS_EQ_SLDR15 = 25;
public static readonly int AIMP_STS_EQ_SLDR16 = 26;
public static readonly int AIMP_STS_EQ_SLDR17 = 27;
public static readonly int AIMP_STS_EQ_SLDR18 = 28;
public static readonly int AIMP_STS_REPEAT = 29;
public static readonly int AIMP_STS_ON_STOP = 30;
public static readonly int AIMP_STS_POS = 31;
public static readonly int AIMP_STS_LENGTH = 32;
public static readonly int AIMP_STS_REPEATPLS = 33;
public static readonly int AIMP_STS_REP_PLS_1 = 34;
public static readonly int AIMP_STS_KBPS = 35;
public static readonly int AIMP_STS_KHZ = 36;
public static readonly int AIMP_STS_MODE = 37;
public static readonly int AIMP_STS_RADIO = 38;
public static readonly int AIMP_STS_STREAM_TYPE = 39;
// Music / CDA / Radio
public static readonly int AIMP_STS_TIMER = 40;
// Reverse / Normal
public static readonly int AIMP_STS_SHUFFLE = 41;
public static readonly int AIMP_STS_MAIN_HWND = 42;
public static readonly int AIMP_STS_TC_HWND = 43;
public static readonly int AIMP_STS_APP_HWND = 44;
public static readonly int AIMP_STS_PL_HWND = 45;
public static readonly int AIMP_STS_EQ_HWND = 46;
public static readonly int AIMP_STS_TRAY = 47;
// Support Exts Flags
public static readonly int AIMP_PLS_EXTS = 1;
public static readonly int AIMP_AUDIO_EXTS = 2;
// Menu IDs
public static readonly int AIMP_MAIN_MENU_OPN = 0;
public static readonly int AIMP_MAIN_MENU_UTILS = 1;
public static readonly int AIMP_MAIN_MENU_FNC = 2;
public static readonly int AIMP_MAIN_MENU_CFG = 3;
public static readonly int AIMP_UTILS_MENU = 4;
public static readonly int AIMP_PLS_MENU_ADD = 5;
public static readonly int AIMP_PLS_MENU_JUMP = 6;
public static readonly int AIMP_PLS_MENU_FNC = 7;
public static readonly int AIMP_PLS_MENU_SEND = 8;
public static readonly int AIMP_PLS_MENU_DEL = 9;
public static readonly int AIMP_ADD_MENU = 10;
public static readonly int AIMP_DEL_MENU = 11;
public static readonly int AIMP_FND_MENU = 12;
public static readonly int AIMP_SRT_MENU = 13;
public static readonly int AIMP_MSC_MENU = 14;
public static readonly int AIMP_PLS_MENU = 15;
public static readonly int AIMP_TRAY_UTILS = 16;
public static readonly int AIMP_TRAY = 17;
public static readonly int AIMP_EQ_LIB = 18;
// AIMP_CallFunction
public static readonly int AIMP_OPEN_FILES = 0;
public static readonly int AIMP_OPEN_DIR = 1;
public static readonly int AIMP_ABOUT = 2;
public static readonly int AIMP_SLEEP_TIMER = 3;
public static readonly int AIMP_UTILS_AC = 4;
public static readonly int AIMP_UTILS_SR = 5;
public static readonly int AIMP_UTILS_TE = 6;
public static readonly int AIMP_UTILS_CDB = 7;
public static readonly int AIMP_OPTIONS = 8;
public static readonly int AIMP_PLUGINS = 9;
public static readonly int AIMP_QUIT = 10;
public static readonly int AIMP_NEXT_VIS = 11;
public static readonly int AIMP_PREV_VIS = 12;
public static readonly int AIMP_EQ_ANALOG = 13;
public static readonly int AIMP_TO_TRAY = 14;
public static readonly int AIMP_PLAY = 15;
public static readonly int AIMP_PAUSE = 16;
public static readonly int AIMP_STOP = 17;
public static readonly int AIMP_NEXT = 18;
public static readonly int AIMP_PREV = 19;
public static readonly int AIMP_ADD_FILES = 20;
public static readonly int AIMP_ADD_DIR = 21;
public static readonly int AIMP_ADD_PLS = 22;
public static readonly int AIMP_ADD_URL = 23;
public static readonly int AIMP_DEL_FILES = 24;
public static readonly int AIMP_DEL_BAD = 25;
public static readonly int AIMP_DEL_FROMHDD = 26;
public static readonly int AIMP_DEL_OFF = 27;
public static readonly int AIMP_DEL_OFF_HDD = 28;
public static readonly int AIMP_RESCAN_PLS = 29;
public static readonly int AIMP_SHOW_CURFILE = 30;
public static readonly int AIMP_SORT_INVERT = 31;
public static readonly int AIMP_SORT_RANDOM = 32;
public static readonly int AIMP_SORT_TITLE = 33;
public static readonly int AIMP_SORT_ARTIST = 34;
public static readonly int AIMP_SORT_FOLDER = 35;
public static readonly int AIMP_SORT_LENGTH = 36;
public static readonly int AIMP_SORT_RATING = 37;
public static readonly int AIMP_SEARCH = 38;
public static readonly int AIMP_OPEN_PLS = 39;
public static readonly int AIMP_SAVE_PLS = 40;
public static readonly int AIMP_PLAY_LAST = 41;
public static readonly int AIMP_OFF_SELECTED = 42;
public static readonly int AIMP_ON_SELECTED = 43;
public static readonly int AIMP_ADD2BOOKMARK = 44;
public static readonly int AIMP_EDITBOOKMARK = 45;
// For AIMP_GetPath
public static readonly int AIMP_CFG_DATA = 0;
public static readonly int AIMP_CFG_PLS = 1;
public static readonly int AIMP_CFG_LNG = 2;
public static readonly int AIMP_CFG_SKINS = 3;
public static readonly int AIMP_CFG_PLUGINS = 4;
public static readonly int AIMP_CFG_ICONS = 5;
public static readonly int AIMP_CFG_ML = 6;
// For AIMP_QueryObject
public static readonly int IAIMP2PlayerID = 0x0001;
public static readonly int IAIMP2PlaylistManagerID = 0x0003;
public static readonly int IAIMP2ExtendedID = 0x0004;
// For AIMP_ObjectClass
public static readonly int AIMP_EXT_LC_MESSAGE = 100;
public static readonly int AIMP_EXT_ML_MESSAGE = 101;
// Option Frame Position Flags
public static readonly int AIMP_FRAME_POS_PLAY = 1;
public static readonly int AIMP_FRAME_POS_PLAYLIST = 2;
public static readonly int AIMP_FRAME_POS_PLAYER = 3;
public static readonly int AIMP_FRAME_POS_TEMPLATE = 4;
public static readonly int AIMP_FRAME_POS_SYSTEM = 5;
public static readonly int AIMP_FRAME_POS_SKINS = 6;
public static readonly int AIMP_FRAME_POS_LANGS = 7;
// PluginFlags
public static readonly int VIS_RQD_DATA_WAVE = 1;
public static readonly int VIS_RQD_DATA_SPECTRUM = 2;
public static readonly int VIS_RQD_NOT_SUSPEND = 4;
} // end AIMP_SDK
}
В принципе в переводе с Делфи нет ничего сложного. Static они для того, чтобы не требовалось создавать экземпляр класса Units при каждом их использовании.using System;
using System.Drawing;
using AIMP_SDK.Struct;
namespace AIMP_SDK
{
public interface IPLSStrings
{
bool AddFile(string FileName, TAIMP2FileInfo FileInfo);
bool DelFile(int ID);
string GetFileName(int ID);
bool GetFileInfo(int ID, TAIMP2FileInfo AInfo);
int GetFileObj(int ID);
int GetCount();
} // end IPLSStrings
// User option frame
public interface IAIMP2OptionFrame
{
IntPtr FrameCreate(IntPtr AParent);
object FrameData();
// reserved
int FrameFlags();
// See FramePositionFlags
string FrameName();
void FrameFree(IntPtr AWindow);
void FrameLoadConfigNotify();
void FrameSaveConfigNotify();
} // end IAIMP2OptionFrame
// See IAIMPPlayerID
public interface IAIMP2Player
{
int Version();
bool PlayTrack(int ID, int ATrackIndex);
void PlayOrResume();
void Pause();
void Stop();
void NextTrack();
void PrevTrack();
} // end IAIMP2Player
// See IAIMP2PlaylistManagerID
public interface IAIMP2PlaylistManager
{
int AIMP_PLS_CreateFromFile(string AFile, bool AActivate, bool AStartPlay);
int AIMP_PLS_ID_ActiveGet();
bool AIMP_PLS_ID_ActiveSet(int ID);
int AIMP_PLS_ID_PlayingGet();
int AIMP_PLS_ID_PlayingGetTrackIndex(int ID);
int AIMP_PLS_NewEx(string AName, bool AActivate);
bool AIMP_PLS_PlayFile(string AFileName, bool AFailIfNotExists);
// Playlist Processing
bool AIMP_PLS_DeleteByFilter(int ID, object AFilterProc, int AUserData);
bool AIMP_PLS_SortByFilter(int ID, object AFilterProc, int AUserData);
// Entries
bool AIMP_PLS_Entry_Delete(int ID, int AEntryIndex);
bool AIMP_PLS_Entry_DeleteAll(int ID);
bool AIMP_PLS_Entry_FileNameGet(int ID, int AEntryIndex, string PBuf, int ABufLen);
bool AIMP_PLS_Entry_FileNameSet(int ID, int AEntryIndex, string PBuf);
int AIMP_PLS_Entry_FocusedGet(int ID);
bool AIMP_PLS_Entry_FocusedSet(int ID, int AEntryIndex);
bool AIMP_PLS_Entry_InfoGet(int ID, int AEntryIndex, TAIMP2FileInfo PFileInfo);
bool AIMP_PLS_Entry_InfoSet(int ID, int AEntryIndex, TAIMP2FileInfo PFileInfo);
bool AIMP_PLS_Entry_PlayingSwitchGet(int ID, int AEntryIndex);
bool AIMP_PLS_Entry_PlayingSwitchSet(int ID, int AEntryIndex, bool ASwitch);
bool AIMP_PLS_Entry_ReloadInfo(int ID, int AEntryIndex);
// Load/Save Playlists
bool AIMP_PM_DestroyStream(int AHandle);
int AIMP_PM_ReadItem(int AHandle, TAIMP2FileInfo PItem);
int AIMP_PM_ReadStream(string AFileName, ref int Count);
int AIMP_PM_SaveStream(string AFileName);
int AIMP_PM_WriteItem(int AHandle, TAIMP2FileInfo PItem);
// added in 2.50 B295
bool AIMP_PLS_ID_PlayingSetTrackIndex(int ID, int AEntryIndex);
} // end IAIMP2PlaylistManager
// See IAIMP2ExtendedID
public interface IAIMP2Extended
{
int AIMP_GetPath(int ID, string ABuffer, int ACount);
bool AIMP_ObjectClass(int ID, object AData, bool ARegister);
// User Option Dialogs
int AIMP_Options_FrameAdd(IAIMP2OptionFrame AFrame);
int AIMP_Options_FrameRemove(IAIMP2OptionFrame AFrame);
int AIMP_Options_ModifiedChanged(IAIMP2OptionFrame AFrame);
} // end IAIMP2Extended
public interface IAIMP2Controller
{
bool IsUnicodeVersion();
// Must be True CallBack
bool AIMP_CallBack_Set(int dwCBType, object Proc, int User);
bool AIMP_CallBack_Remove(int dwCBType, object Proc);
// Status
int AIMP_Status_Get(int StatusType);
bool AIMP_Status_Set(int StatusType, int Value);
// Playlist
bool AIMP_PLS_Clear(int ID);
bool AIMP_PLS_Delete(int ID);
int AIMP_PLS_New(string Name);
bool AIMP_PLS_Info(int Index, out TPLSInfo PLSInfo);
ushort AIMP_PLS_Count();
bool AIMP_PLS_GetFiles(int ID, out IPLSStrings Strings);
bool AIMP_PLS_GetSelFiles(int ID, out IPLSStrings Strings);
bool AIMP_PLS_AddFiles(int ID, IPLSStrings Strings);
bool AIMP_PLS_SetPLS(int ID);
// System
bool AIMP_NewStrings(out IPLSStrings Strings);
bool AIMP_GetCurrentTrack(TAIMP2FileInfo AInfo);
bool AIMP_QueryInfo(string Filename, TAIMP2FileInfo AInfo);
int AIMP_GetSystemVersion();
bool AIMP_CallFunction(int FuncID);
int AIMP_GetLanguage(string Str, int ACount);
int AIMP_GetCfgPath(string Str, int ACount);
int AIMP_GetSupportExts(int Flags, string Str, int BufSize);
// Menu
object AIMP_Menu_CreateEx(object Parent, TAIMPMenuInfo MenuInfo);
object AIMP_Menu_Create(int MenuID, TAIMPMenuInfo MenuInfo);
bool AIMP_Menu_Update(object Handle, TAIMPMenuInfo MenuInfo);
bool AIMP_Menu_Remove(object Handle);
// extantion
bool AIMP_QueryObject(int ObjectID, ref object Obj);
} // end IAIMP2Controller
public interface IAIMP2InputStream
{
bool GetPositions(ref long ALength, ref long APosition);
bool GetStreamInfo(TInputInfo AInputInfo);
long SetPosition(long APosition);
bool ReadData(object ABuffer, ref int ALength);
} // end IAIMP2InputStream
public interface IAIMP2InputPlugin
{
string AuthorName();
string PluginName();
string PluginSupportExts();
bool GetFileInfo(string AFile, TAIMP2FileInfo ATags);
bool IsOurFile(string AFile);
IAIMP2InputStream StreamCreate(string AFile, TAIMP2FileInfo ATags);
void ConfigWindow(IntPtr AParent);
void Deinitialize();
void Initialize(IAIMP2Controller AIMPClassic);
} // end IAIMP2InputPlugin
public interface IAIMP2VisualPlugin
{
string AuthorName();
string PluginName();
string PluginInfo();
int PluginFlags();
bool Initialize();
void Deinitialize();
void DisplayClick(int X, int Y);
//void DisplayRender(HDC DC, TVisualData AData);
//void DisplayResize(int AWidth, int AHeight);
} // end IAIMP2VisualPlugin
}
В принципе тоже ничего сложного. Благо дело интерфейсы присутствуют в C#. В структурах HWND от дельфи заменяется на IntPtr, TBitmap на Bitmap из библиотеки System.Drawing. И ещё пришлось убрать 2 функции из структуры IAIMP2InputPlugin (void DisplayRender(HDC DC, TVisualData AData) и void DisplayResize(int AWidth, int AHeight)) потому как я не совсем понимаю какие в них передаются параметры и чем их заменить. Больше это относиться к void DisplayRender(HDC DC, TVisualData AData).private void tsbOptions_Click(object sender, EventArgs e)
{
Options opt = new Options();
opt.Show();
}
this.ShowInTaskbar = false;