public void Add(FuncItem funcItem) { int oldSize = _funcItems.Count * _sizeFuncItem; _funcItems.Add(funcItem); int newSize = _funcItems.Count * _sizeFuncItem; IntPtr newPointer = Marshal.AllocHGlobal(newSize); if (_nativePointer != IntPtr.Zero) { RtlMoveMemory(newPointer, _nativePointer, oldSize); Marshal.FreeHGlobal(_nativePointer); } IntPtr ptrPosNewItem = (IntPtr)((int)newPointer + oldSize); byte[] aB = Encoding.Unicode.GetBytes(funcItem._itemName + "\0"); Marshal.Copy(aB, 0, ptrPosNewItem, aB.Length); ptrPosNewItem = (IntPtr)((int)ptrPosNewItem + 128); IntPtr p = (funcItem._pFunc != null) ? Marshal.GetFunctionPointerForDelegate(funcItem._pFunc) : IntPtr.Zero; Marshal.WriteIntPtr(ptrPosNewItem, p); ptrPosNewItem = (IntPtr)((int)ptrPosNewItem + IntPtr.Size); Marshal.WriteInt32(ptrPosNewItem, funcItem._cmdID); ptrPosNewItem = (IntPtr)((int)ptrPosNewItem + 4); Marshal.WriteInt32(ptrPosNewItem, Convert.ToInt32(funcItem._init2Check)); ptrPosNewItem = (IntPtr)((int)ptrPosNewItem + 4); if (funcItem._pShKey._key != 0) { IntPtr newShortCutKey = Marshal.AllocHGlobal(4); Marshal.StructureToPtr(funcItem._pShKey, newShortCutKey, false); Marshal.WriteIntPtr(ptrPosNewItem, newShortCutKey); } else Marshal.WriteIntPtr(ptrPosNewItem, IntPtr.Zero); _nativePointer = newPointer; }
internal static void SetCommand(int index, string commandName, NppFuncItemDelegate functionPointer, ShortcutKey shortcut, bool checkOnInit) { FuncItem funcItem = new FuncItem(); funcItem._cmdID = index; funcItem._itemName = commandName; if (functionPointer != null) funcItem._pFunc = new NppFuncItemDelegate(functionPointer); if (shortcut._key != 0) funcItem._pShKey = shortcut; funcItem._init2Check = checkOnInit; _funcItems.Add(funcItem); }
public IEnumerable <FuncItem> GetFunctions(string searchString) { var items = new List <FuncItem>(); var fcm = _dte.ActiveDocument.ProjectItem.FileCodeModel as FileCodeModel; #region CodeElements foreach (var ns in fcm.CodeElements) { if (ns is CodeNamespace) { var @namespace = ns as CodeNamespace; foreach (var cl in @namespace.Children) { if (cl is CodeClass) { var @class = cl as CodeClass; foreach (var f in @class.Children) { if (f is CodeFunction) { var @function = f as CodeFunction; if (!string.IsNullOrEmpty(searchString) && [email protected]().Contains(searchString.ToLower())) { continue; } var fi = new FuncItem { Name = @function.Name, Namespace = @namespace.Name, Class = @class.Name, Location = @function.StartPoint.Line }; var parms = new List <ParamItem>(); foreach (CodeParameter param in @function.Parameters) { parms.Add(new ParamItem { Name = param.Name, FullType = param.Type.AsFullName }); } fi.Parameters = parms; items.Add(fi); } } } } } } #endregion return(items); }
internal static void SetCommand(int index, string commandName, Action functionPointer, ShortcutKey shortcut, bool checkOnInit) { FuncItem funcItem = new FuncItem(); funcItem._cmdID = index; funcItem._itemName = commandName; if (functionPointer != null) { funcItem._pFunc = new Action(functionPointer); } if (shortcut._key != 0) { funcItem._pShKey = shortcut; } funcItem._init2Check = checkOnInit; FuncItems.Add(funcItem); }
/// <summary> /// Creates entry in the FuncItems list, which list the menu entry displayed in Npp's plugin menu /// </summary> public static void SetCommand(int index, string commandName, Action functionPointer, ShortcutKey shortcut = new ShortcutKey(), bool checkOnInit = false) { var funcItem = new FuncItem { _cmdID = index, _itemName = commandName }; if (functionPointer != null) { funcItem._pFunc = functionPointer; } if (shortcut._key != 0) { funcItem._pShKey = shortcut; } funcItem._init2Check = checkOnInit; UnmanagedExports.NppFuncItems.Add(funcItem); }
internal static void toggleCheckMenuItem(int funcItemID, bool isChecked) { IntPtr menu = Win32.GetMenu(nppData._nppHandle); Win32.CheckMenuItem(menu, _funcItems.Items[funcItemID]._cmdID, Win32.MF_BYCOMMAND | (isChecked ? Win32.MF_CHECKED : Win32.MF_UNCHECKED)); FuncItem itemToUpdate = new FuncItem(); itemToUpdate._cmdID = _funcItems.Items[funcItemID]._cmdID; itemToUpdate._init2Check = isChecked; itemToUpdate._itemName = _funcItems.Items[funcItemID]._itemName; itemToUpdate._pFunc = _funcItems.Items[funcItemID]._pFunc; itemToUpdate._pShKey = _funcItems.Items[funcItemID]._pShKey; _funcItems.UpdateItem(itemToUpdate); savePluginParams(); }
private void SetCommand(int index, string commandName, NppFuncItemDelegate functionPointer, ShortcutKey shortcut = new ShortcutKey(), bool checkOnInit = false) { FuncItem funcItem = new FuncItem(); funcItem._cmdID = index; funcItem._itemName = commandName; if (functionPointer != null) { funcItem._pFunc = functionPointer; } if (shortcut._key != 0) { funcItem._pShKey = shortcut; } funcItem._init2Check = checkOnInit; _funcItems.Add(funcItem); }
public static void SetCommand(int index, string commandName, NppFuncItemDelegate functionPointer, ShortcutKey shortcut, bool checkOnInit) { FuncItem funcItem = new FuncItem { _cmdID = index, _itemName = commandName }; if (functionPointer != null) { funcItem._pFunc = new NppFuncItemDelegate(functionPointer); } if (shortcut._key != 0) { funcItem._pShKey = shortcut; } funcItem._init2Check = checkOnInit; _funcItems.Add(funcItem); }
public void RefreshItems() { IntPtr ptrPosItem = _nativePointer; for (int i = 0; i < _funcItems.Count; i++) { FuncItem updatedItem = new FuncItem(); updatedItem._itemName = _funcItems[i]._itemName; ptrPosItem = (IntPtr)(ptrPosItem.ToInt64() + 128); updatedItem._pFunc = _funcItems[i]._pFunc; ptrPosItem = (IntPtr)(ptrPosItem.ToInt64() + IntPtr.Size); updatedItem._cmdID = Marshal.ReadInt32(ptrPosItem); ptrPosItem = (IntPtr)(ptrPosItem.ToInt64() + 4); updatedItem._init2Check = _funcItems[i]._init2Check; ptrPosItem = (IntPtr)(ptrPosItem.ToInt64() + 4); updatedItem._pShKey = _funcItems[i]._pShKey; ptrPosItem = (IntPtr)(ptrPosItem.ToInt64() + IntPtr.Size); _funcItems[i] = updatedItem; } }
public void Add(FuncItem funcItem) { int oldSize = _funcItems.Count * _sizeFuncItem; _funcItems.Add(funcItem); int newSize = _funcItems.Count * _sizeFuncItem; IntPtr newPointer = Marshal.AllocHGlobal(newSize); if (_nativePointer != IntPtr.Zero) { RtlMoveMemory(newPointer, _nativePointer, oldSize); Marshal.FreeHGlobal(_nativePointer); } IntPtr ptrPosNewItem = (IntPtr)(newPointer.ToInt64() + oldSize); byte[] aB = Encoding.Unicode.GetBytes(funcItem._itemName + "\0"); Marshal.Copy(aB, 0, ptrPosNewItem, aB.Length); ptrPosNewItem = (IntPtr)(ptrPosNewItem.ToInt64() + 128); IntPtr p = (funcItem._pFunc != null) ? Marshal.GetFunctionPointerForDelegate(funcItem._pFunc) : IntPtr.Zero; Marshal.WriteIntPtr(ptrPosNewItem, p); ptrPosNewItem = (IntPtr)(ptrPosNewItem.ToInt64() + IntPtr.Size); Marshal.WriteInt32(ptrPosNewItem, funcItem._cmdID); ptrPosNewItem = (IntPtr)(ptrPosNewItem.ToInt64() + 4); Marshal.WriteInt32(ptrPosNewItem, Convert.ToInt32(funcItem._init2Check)); ptrPosNewItem = (IntPtr)(ptrPosNewItem.ToInt64() + 4); if (funcItem._pShKey._key != 0) { IntPtr newShortCutKey = Marshal.AllocHGlobal(4); Marshal.StructureToPtr(funcItem._pShKey, newShortCutKey, false); Marshal.WriteIntPtr(ptrPosNewItem, newShortCutKey); } else { Marshal.WriteIntPtr(ptrPosNewItem, IntPtr.Zero); } _nativePointer = newPointer; }
public GoToFuncViewModelDesign() { FuncList = new FuncItemObservableCollection() { new Model.FuncItem { Name = "DoSearch", Class = "DoClass", Namespace = "DoNamespace", Parameters = new List <Model.ParamItem> { new Model.ParamItem { Name = "SomeParameter", FullType = "System.String" } }, Location = 10 }, new Model.FuncItem { Name = "Render", Class = "DoClass", Namespace = "DoNamespace", Parameters = new List <Model.ParamItem> { new Model.ParamItem { Name = "phoneNumber", FullType = "System.String" } }, Location = 1120 } }; _selectedItem = FuncList[0]; }