1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using System;
- using System.Runtime.InteropServices;
- using NppChnConvPlugin.NppPluginInfrastructure;
- namespace NppChnConvPlugin
- {
- public class ManagedExportsBridge
- {
- private static IntPtr PtrPluginName = IntPtr.Zero;
- public static bool IsUnicode()
- {
- return true;
- }
- public static void SetInfo(NppData notepadPlusData)
- {
- PluginBase.nppData = notepadPlusData;
- AnyCpuBridgeMain.CommandMenuInit();
- }
- public static IntPtr GetFuncsArray(ref int nbF)
- {
- nbF = PluginBase._funcItems.Items.Count;
- return PluginBase._funcItems.NativePointer;
- }
- public static uint MessageProc(uint message, IntPtr wParam, IntPtr lParam)
- {
- return 1;
- }
- public static IntPtr GetName()
- {
- if (PtrPluginName == IntPtr.Zero)
- PtrPluginName = Marshal.StringToHGlobalUni(AnyCpuBridgeMain.PluginName);
- return PtrPluginName;
- }
- public static void BeNotified(IntPtr notifyCode)
- {
- var notification = (ScNotification)Marshal.PtrToStructure(notifyCode, typeof(ScNotification));
- if (notification.Header.Code == (uint)NppMsg.NPPN_TBMODIFICATION)
- {
- PluginBase._funcItems.RefreshItems();
- AnyCpuBridgeMain.SetToolBarIcon();
- }
- else if (notification.Header.Code == (uint)NppMsg.NPPN_SHUTDOWN)
- {
- AnyCpuBridgeMain.PluginCleanUp();
- Marshal.FreeHGlobal(PtrPluginName);
- }
- else
- {
- AnyCpuBridgeMain.OnNotification(notification);
- }
- }
- }
- }
|