Exemple #1
0
 internal static void RegisterForm(Form form, Icon icon, int id, string name, Notepad.WindowOptions options, string plugin_name)
 {
     try
     {
         Notepad.Window data = new Notepad.Window
         {
             Handle = form.Handle,
             Icon = icon == null ? 0 : (uint)icon.Handle,
             ID = id,
             Name = name,
             Options = options,
             PluginName = plugin_name
         };
         IntPtr pointer = Marshal.AllocHGlobal(Marshal.SizeOf(data));
         Marshal.StructureToPtr(data, pointer, false);
         Windows.SendMessage(Notepad.Handles._nppHandle, (uint)Notepad.Messages.DMMREGASDCKDLG, 0, pointer);
     }
     catch (Exception e)
     {
         // TODO: implement exception handling
     }
     return;
 }
Exemple #2
0
 private static Notepad.FuncItem SetCommand(int item, string command_name,
     Notepad.delOnClick function_pointer, Notepad.ShortcutKey shortcut = new Notepad.ShortcutKey(),
     bool start_checked = false)
 {
     Notepad.FuncItem func_item = new Notepad.FuncItem
     {
         _cmdID = (int)item,
         _itemName = command_name
     };
     if (function_pointer != null)
         func_item._pFunc = new Notepad.delOnClick(function_pointer);
     if (shortcut._key != 0)
         func_item._pShKey = shortcut;
     func_item._init2Check = start_checked;
     return func_item;
 }
Exemple #3
0
 internal static Notepad.FuncItem AllocateCommandID(string command_name,
     Notepad.delOnClick functionPointer, Notepad.ShortcutKey shortcut = new Notepad.ShortcutKey(),
     bool start_checked = false)
 {
     // do some pointer magic
     int[] handle_value = new int[1];
     GCHandle handle = GCHandle.Alloc(handle_value, GCHandleType.Pinned);
     IntPtr pointer = IntPtr.Zero;
     try
     {
         pointer = handle.AddrOfPinnedObject();
     }
     finally
     {
         if (handle.IsAllocated)
         {
             handle.Free();
         }
     }
     Windows.SendMessage(Notepad.Handles._nppHandle, (uint)Notepad.Messages.ALLOCATECMDID, 1, pointer);
     return Notepad.SetCommand(handle_value[0], command_name, functionPointer, shortcut, start_checked);
 }