void toggleOutputDialog() { if (frmOutput == null) { frmOutput = new Forms.Output(this); var _nppTbData = new NppTbData(); _nppTbData.hClient = frmOutput.Handle; _nppTbData.pszName = "Ruby. Wow! (Output)"; _nppTbData.dlgID = idOutputDlg; _nppTbData.uMask = NppTbMsg.DWS_DF_CONT_BOTTOM; _nppTbData.pszModuleName = _pluginModuleName; IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData)); Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false); Win32.SendMessage(nppData._nppHandle, NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData); } else { if (frmOutput.Visible) { Win32.SendMessage(nppData._nppHandle, NppMsg.NPPM_DMMHIDE, 0, frmOutput.Handle); } else { Win32.SendMessage(nppData._nppHandle, NppMsg.NPPM_DMMSHOW, 0, frmOutput.Handle); } } }
internal static void ShowConfigWindow() { if (_configWindow == null) { _configWindow = new ConfigWindow(_settings); var nppTbData = new NppTbData { hClient = _configWindow.Handle, pszName = $"{PluginName} Configuration", dlgID = _idConfigWindow, uMask = NppTbMsg.DWS_DF_CONT_RIGHT | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR, hIconTab = (uint)ConfigWindowToolBarIcon.Handle, pszModuleName = PluginName }; var ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(nppTbData)); Marshal.StructureToPtr(nppTbData, ptrNppTbData, false); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMREGASDCKDLG, 0, ptrNppTbData); } else { Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMSHOW, 0, _configWindow.Handle); } }
public void ShowPropertiesWindow(object obj) { if (propertiesWindow == null) { propertiesWindow = new Window { Title = "Inspect Properties", Content = new ShowPropertiesView(), }; propertiesWindow.Show(); NppTbData nppTbData = new NppTbData { hClient = new WindowInteropHelper(propertiesWindow).Handle, pszName = "Inspect Properties", dlgID = 2, uMask = NppTbMsg.DWS_DF_CONT_RIGHT, pszModuleName = Main.PluginName }; IntPtr ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(nppTbData)); Marshal.StructureToPtr(nppTbData, ptrNppTbData, false); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMREGASDCKDLG, 0, ptrNppTbData); } else { Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMSHOW, 0, new WindowInteropHelper(propertiesWindow).Handle); } propertiesWindow.DataContext = obj; }
public void ShowResultsWindow() { if (resultWindow == null) { resultWindow = new Window { Title = "Evaluations Results", Content = new EvaluationsResultsPanel(), DataContext = this, }; resultWindow.Show(); NppTbData nppTbData = new NppTbData { hClient = new WindowInteropHelper(resultWindow).Handle, pszName = "Evaluations Results", dlgID = 1, uMask = NppTbMsg.DWS_DF_CONT_BOTTOM, pszModuleName = Main.PluginName }; IntPtr ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(nppTbData)); Marshal.StructureToPtr(nppTbData, ptrNppTbData, false); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMREGASDCKDLG, 0, ptrNppTbData); } else { Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMSHOW, 0, new WindowInteropHelper(resultWindow).Handle); } }
internal static void settingsDialog() { if (frmMyDlg == null) { frmMyDlg = new settingsDlg(); using (Bitmap newBmp = new Bitmap(16, 16)) { Graphics g = Graphics.FromImage(newBmp); ColorMap[] colorMap = new ColorMap[1]; colorMap[0] = new ColorMap(); colorMap[0].OldColor = Color.Fuchsia; colorMap[0].NewColor = Color.FromKnownColor(KnownColor.ButtonFace); ImageAttributes attr = new ImageAttributes(); attr.SetRemapTable(colorMap); tbIcon = Icon.FromHandle(newBmp.GetHicon()); } NppTbData _nppTbData = new NppTbData(); _nppTbData.hClient = frmMyDlg.Handle; _nppTbData.pszName = "SPTNPP Settings"; _nppTbData.dlgID = idMyDlg; _nppTbData.uMask = NppTbMsg.DWS_DF_CONT_RIGHT | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR; _nppTbData.hIconTab = (uint)tbIcon.Handle; _nppTbData.pszModuleName = PluginName; IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData)); Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData); } else { Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMSHOW, 0, frmMyDlg.Handle); } }
/// <summary> /// This message passes the necessary data dockingData to Notepad++ in order to make your dialog dockable /// </summary> public static void RegisterDockableDialog(NppTbData nppTbData) { IntPtr ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(nppTbData)); Marshal.StructureToPtr(nppTbData, ptrNppTbData, false); Win32Api.SendMessage(Handle, NppMsg.NPPM_DMMREGASDCKDLG, 0, ptrNppTbData); }
/// <summary> /// /// </summary> protected virtual void Init() { // using (Bitmap newBmp = new Bitmap(16, 16)) { Graphics g = Graphics.FromImage(newBmp); ColorMap[] colorMap = new ColorMap[1]; colorMap[0] = new ColorMap(); colorMap[0].OldColor = Color.Fuchsia; colorMap[0].NewColor = Color.FromKnownColor(KnownColor.ButtonFace); ImageAttributes attr = new ImageAttributes(); attr.SetRemapTable(colorMap); g.DrawImage(Resources.markdown_16x16_solid_bmp, new Rectangle(0, 0, 16, 16), 0, 0, 16, 16, GraphicsUnit.Pixel, attr); toolbarIcon = Icon.FromHandle(newBmp.GetHicon()); } //Get the AssemblyTitle this.assemblyTitle = ((AssemblyTitleAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyTitleAttribute), false)).Title; // NppTbData _nppTbData = new NppTbData(); _nppTbData.hClient = this.Handle; _nppTbData.pszName = this.assemblyTitle; _nppTbData.dlgID = this.markdownViewer.commandId; _nppTbData.uMask = NppTbMsg.DWS_DF_CONT_RIGHT | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR; _nppTbData.hIconTab = (uint)toolbarIcon.Handle; _nppTbData.pszModuleName = Main.PluginName; IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData)); Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false); //Register dockable window and hide initially (TODO: Add to settings to restore) Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMHIDE, 0, this.Handle); }
internal static void ShowExecuteWindow() { if (_executeWindow == null) { _executeWindow = new ExecuteWindow(_settings); var nppTbData = new NppTbData { hClient = _executeWindow.Handle, pszName = $"{PluginName} Execute", dlgID = _idExecuteWindow, uMask = NppTbMsg.CONT_BOTTOM, hIconTab = (uint)ConfigWindowToolBarIcon.Handle, pszModuleName = PluginName }; var ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(nppTbData)); Marshal.StructureToPtr(nppTbData, ptrNppTbData, false); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMREGASDCKDLG, 0, ptrNppTbData); _executeWindow.Execute(); } else { Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMSHOW, 0, _executeWindow.Handle); _executeWindow.Execute(); } }
internal static void myDockableDialog() { if (frmMyDlg == null) { frmMyDlg = new frmMyDlg(); NppTbData _nppTbData = new NppTbData { hClient = frmMyDlg.Handle, pszName = "My dockable dialog", dlgID = idMyDlg, uMask = NppTbMsg.DWS_DF_CONT_RIGHT | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR, hIconTab = (uint)frmMyDlg.Icon.Handle, pszModuleName = PluginName }; IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData)); Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData); } else { Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMSHOW, 0, frmMyDlg.Handle); } }
private void TogglePanelVisible() { if (!initDialog) { NppTbData _nppTbData = new NppTbData(); _nppTbData.hClient = markdownPreviewForm.Handle; _nppTbData.pszName = Main.PluginTitle; _nppTbData.dlgID = idMyDlg; _nppTbData.uMask = NppTbMsg.DWS_DF_CONT_RIGHT | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR; _nppTbData.hIconTab = (uint)ConvertBitmapToIcon(Properties.Resources.markdown_16x16_solid_bmp).Handle; _nppTbData.pszModuleName = Main.PluginName; IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData)); Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData); initDialog = true; } else { Win32.SendMessage(PluginBase.nppData._nppHandle, !isPanelVisible ? (uint)NppMsg.NPPM_DMMSHOW : (uint)NppMsg.NPPM_DMMHIDE, 0, markdownPreviewForm.Handle); } isPanelVisible = !isPanelVisible; if (isPanelVisible) { RenderMarkdown(); } }
internal static void ShowNppLogList() { if (FrmMain == null) { ShowNppPIALexer2View(); } if (FrmLogList == null) { FrmLogList = new frmLogList(); NppTbData _nppTbData = new NppTbData(); _nppTbData.hClient = FrmLogList.Handle; _nppTbData.pszName = "NppPIALexer2 LogList"; _nppTbData.uMask = NppTbMsg.DWS_DF_CONT_BOTTOM;// | NppTbMsg.DWS_ICONTAB;// | NppTbMsg.DWS_ICONBAR; _nppTbData.pszModuleName = "NppPIALexer2 LogList"; IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData)); Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false); Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData); } else { if (FrmLogList.Visible) { Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DMMHIDE, 0, FrmLogList.Handle); } else { Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DMMSHOW, 0, FrmLogList.Handle); } } }
private void ToggleDBManager() { if (_frmDBExplorer == null) { _frmDBExplorer = new FrmDatabaseExplore(); _frmDBExplorer.AddNotifyHandler( //toogle menu item and toolbar button when docking dialog's close button click (ref Message msg) => { SCNotification nc = (SCNotification)Marshal.PtrToStructure(msg.LParam, typeof(SCNotification)); if (nc.nmhdr.code != (uint)DockMgrMsg.DMN_CLOSE) { return; } Win32.SendMessage(nppData._nppHandle, NppMsg.NPPM_SETMENUITEMCHECK, _funcItems.Items[_cmdFrmDBExplorerIdx]._cmdID, 0); }); using (Bitmap newBmp = new Bitmap(16, 16)) { Graphics g = Graphics.FromImage(newBmp); ColorMap[] colorMap = new ColorMap[1]; colorMap[0] = new ColorMap(); colorMap[0].OldColor = Color.Fuchsia; colorMap[0].NewColor = Color.FromKnownColor(KnownColor.ButtonFace); ImageAttributes attr = new ImageAttributes(); attr.SetRemapTable(colorMap); g.DrawImage(_imgMan, new Rectangle(0, 0, 16, 16), 0, 0, 16, 16, GraphicsUnit.Pixel, attr); tbIcon = Icon.FromHandle(newBmp.GetHicon()); } NppTbData nppTbData = new NppTbData(); nppTbData.hClient = _frmDBExplorer.Handle; nppTbData.pszName = _funcItems.Items[_cmdFrmDBExplorerIdx]._itemName; nppTbData.dlgID = _cmdFrmDBExplorerIdx; //default docking nppTbData.uMask = NppTbMsg.DWS_DF_CONT_RIGHT | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR; nppTbData.hIconTab = (uint)tbIcon.Handle; nppTbData.pszModuleName = PluginName; IntPtr ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(nppTbData)); Marshal.StructureToPtr(nppTbData, ptrNppTbData, false); Win32.SendMessage(nppData._nppHandle, NppMsg.NPPM_DMMREGASDCKDLG, 0, ptrNppTbData); //toogle both menu item and toolbar button Win32.SendMessage(nppData._nppHandle, NppMsg.NPPM_SETMENUITEMCHECK, _funcItems.Items[_cmdFrmDBExplorerIdx]._cmdID, 1); } else { var nppMsg = NppMsg.NPPM_DMMSHOW; var toggleStatus = 1; if (_frmDBExplorer.Visible) { nppMsg = NppMsg.NPPM_DMMHIDE; toggleStatus = 0; } Win32.SendMessage(nppData._nppHandle, nppMsg, 0, _frmDBExplorer.Handle); Win32.SendMessage(nppData._nppHandle, NppMsg.NPPM_SETMENUITEMCHECK, _funcItems.Items[_cmdFrmDBExplorerIdx]._cmdID, toggleStatus); } }
public static void QueryWindowVisible(bool?show = null, bool supressAnalysis = false) { if (QueryWindow == null) { QueryWindow = new QueryWindow(); Icon queryWindowIcon; using (var newBmp = new Bitmap(16, 16)) { var g = Graphics.FromImage(newBmp); ColorMap[] colorMap = { new ColorMap { OldColor = Color.Fuchsia, NewColor = Color.FromKnownColor(KnownColor.ButtonFace) } }; var attr = new ImageAttributes(); attr.SetRemapTable(colorMap); g.DrawImage(Properties.Resources.cq, new Rectangle(0, 0, 16, 16), 0, 0, 16, 16, GraphicsUnit.Pixel, attr); queryWindowIcon = Icon.FromHandle(newBmp.GetHicon()); } var queryWindowData = new NppTbData { hClient = QueryWindow.Handle, pszName = "CSV Query", dlgID = PluginBase.GetMenuItemId("Toggle query window"), uMask = NppTbMsg.DWS_DF_CONT_BOTTOM | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR, hIconTab = (uint)queryWindowIcon.Handle, pszModuleName = PluginName }; var queryWindowPointer = Marshal.AllocHGlobal(Marshal.SizeOf(queryWindowData)); Marshal.StructureToPtr(queryWindowData, queryWindowPointer, false); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMREGASDCKDLG, 0, queryWindowPointer); // Analyze current file if (!supressAnalysis) { QueryWindow.StartAnalysis(true); } } else { if (show ?? !QueryWindow.Visible) { Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMSHOW, 0, QueryWindow.Handle); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_SETMENUITEMCHECK, PluginBase.GetMenuItemId("Toggle query window"), 1); } else { Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMHIDE, 0, QueryWindow.Handle); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_SETMENUITEMCHECK, PluginBase.GetMenuItemId("Toggle query window"), 0); } } }
static void DockableDlgDemo() { // Dockable Dialog Demo // // This demonstration shows you how to do a dockable dialog. // You can create your own non dockable dialog - in this case you don't nedd this demonstration. if (frmGoToLine == null) { frmGoToLine = new frmGoToLine(editor); using (Bitmap newBmp = new Bitmap(16, 16)) { Graphics g = Graphics.FromImage(newBmp); ColorMap[] colorMap = new ColorMap[1]; colorMap[0] = new ColorMap(); colorMap[0].OldColor = Color.Fuchsia; colorMap[0].NewColor = Color.FromKnownColor(KnownColor.ButtonFace); ImageAttributes attr = new ImageAttributes(); attr.SetRemapTable(colorMap); g.DrawImage(tbBmp_tbTab, new Rectangle(0, 0, 16, 16), 0, 0, 16, 16, GraphicsUnit.Pixel, attr); tbIcon = Icon.FromHandle(newBmp.GetHicon()); } NppTbData _nppTbData = new NppTbData(); _nppTbData.hClient = frmGoToLine.Handle; _nppTbData.pszName = "Go To Line #"; // the dlgDlg should be the index of funcItem where the current function pointer is in // this case is 15.. so the initial value of funcItem[15]._cmdID - not the updated internal one ! _nppTbData.dlgID = idFrmGotToLine; // define the default docking behaviour _nppTbData.uMask = NppTbMsg.DWS_DF_CONT_RIGHT | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR; _nppTbData.hIconTab = (uint)tbIcon.Handle; _nppTbData.pszModuleName = PluginName; IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData)); Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData); // Following message will toogle both menu item state and toolbar button Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_SETMENUITEMCHECK, PluginBase._funcItems.Items[idFrmGotToLine]._cmdID, 1); } else { if (!frmGoToLine.Visible) { Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMSHOW, 0, frmGoToLine.Handle); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_SETMENUITEMCHECK, PluginBase._funcItems.Items[idFrmGotToLine]._cmdID, 1); } else { Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMHIDE, 0, frmGoToLine.Handle); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_SETMENUITEMCHECK, PluginBase._funcItems.Items[idFrmGotToLine]._cmdID, 0); } } frmGoToLine.textBox1.Focus(); }
public static void OpenForm(Form form, string title, int dialogID) { NppTbData _nppTbData = new NppTbData(); _nppTbData.hClient = form.Handle; _nppTbData.pszName = title; // the dlgDlg should be the index of funcItem where the current function pointer is in _nppTbData.dlgID = dialogID; // define the default docking behaviour _nppTbData.uMask = NppTbMsg.DWS_DF_CONT_RIGHT | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR; Icon icon = null; if (ADDSNIP_MENU_LABEL.Equals(title)) { if (addSnipBmp != null) { icon = Icon.FromHandle(addSnipBmp.GetHicon()); } } else if (SEARCHSNIP_MENU_LABEL.Equals(title)) { if (addSnipBmp != null) { icon = Icon.FromHandle(searchSnipBmp.GetHicon()); } } if (icon != null) { _nppTbData.hIconTab = (uint)icon.Handle; } _nppTbData.pszModuleName = PluginName; IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData)); Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false); //try to programmatically change the config.xml of Notepad++ in order to set the initial docking layout: SetInitialSizeOfDockedForm(form.Size.Width); try { Win32.SendMessage(nppData._nppHandle, NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData); } catch (Exception exc) { if (log != null) { log.ErrorFormat("Cannot open form due to {0}", exc.Message); } } }
static void DockableDlg() { // Dockable Dialog Demo // // This demonstration shows you how to do a dockable dialog. // You can create your own non dockable dialog - in this case you don't nedd this demonstration. if (xdcDlg == null) { xdcDlg = new XDCDialog(); using (Bitmap newBmp = new Bitmap(16, 16)) { Graphics g = Graphics.FromImage(newBmp); ColorMap[] colorMap = new ColorMap[1]; colorMap[0] = new ColorMap(); colorMap[0].OldColor = Color.FromArgb(0xFF, 0xEC, 0xE9, 0xD8); // 0xECE9D8 (KnownColor.ButtonFace on Windows XP) colorMap[0].NewColor = Color.FromKnownColor(KnownColor.ButtonFace); ImageAttributes attr = new ImageAttributes(); attr.SetRemapTable(colorMap); g.DrawImage(tbBmp_tbTab, new Rectangle(0, 0, 16, 16), 0, 0, 16, 16, GraphicsUnit.Pixel, attr); //g.DrawImage(tbBmp_tbTab, new Rectangle(0, 0, 16, 16), 0, 0, 16, 16, GraphicsUnit.Pixel); tbIcon = Icon.FromHandle(newBmp.GetHicon()); } NppTbData _nppTbData = new NppTbData(); _nppTbData.hClient = xdcDlg.Handle; _nppTbData.pszName = xdcDlg.Text; // the dlgDlg should be the index of funcItem where the current function pointer is in // this case is 15.. so the initial value of funcItem[15]._cmdID - not the updated internal one ! _nppTbData.dlgID = idXDCDlgItem; // define the default docking behaviour _nppTbData.uMask = NppTbMsg.DWS_DF_CONT_BOTTOM | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR; _nppTbData.hIconTab = (uint)tbIcon.Handle; _nppTbData.pszModuleName = PluginName; IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData)); Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false); xdcDlg.__nppTbData = _nppTbData; Win32.SendMessage(nppData._nppHandle, NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData); } else { if (!xdcDlg.Visible) { Win32.SendMessage(nppData._nppHandle, NppMsg.NPPM_DMMSHOW, 0, xdcDlg.Handle); xdcDlg.Start(); } else { Win32.SendMessage(nppData._nppHandle, NppMsg.NPPM_DMMHIDE, 0, xdcDlg.Handle); xdcDlg.Stop(); } } }
/// <summary> /// Creates structure with dialog parameters and returns pointer on that structure. /// </summary> /// <param name="form">Form to describe</param> /// <param name="shownName">Name to show at form caption</param> /// <param name="dialogId">Plugin command index</param> /// <param name="settings">Bit-mask with window settings</param> private static IntPtr CreateNppToolbarDataPointer(Form form, string shownName, int dialogId, NppTbMsg settings, Icon icon) { NppTbData _nppTbData = new NppTbData { hClient = form.Handle, pszName = shownName, dlgID = dialogId, uMask = settings, hIconTab = (uint)icon.Handle, pszModuleName = PluginName }; return(GetStructPointer(_nppTbData)); }
/* * internal static void myMenuFunction() * { * MessageBox.Show("Hello N++!"); * } * */ internal static void myDockableDialog() { if (frmMyDlg == null) { frmMyDlg = new frmMyDlg(); using (Bitmap newBmp = new Bitmap(16, 16)) { Graphics g = Graphics.FromImage(newBmp); ColorMap[] colorMap = new ColorMap[1]; colorMap[0] = new ColorMap(); colorMap[0].OldColor = Color.Fuchsia; colorMap[0].NewColor = Color.FromKnownColor(KnownColor.ButtonFace); ImageAttributes attr = new ImageAttributes(); attr.SetRemapTable(colorMap); g.DrawImage(tbBmp_tbTab, new Rectangle(0, 0, 16, 16), 0, 0, 16, 16, GraphicsUnit.Pixel, attr); tbIcon = Icon.FromHandle(newBmp.GetHicon()); } NppTbData _nppTbData = new NppTbData(); _nppTbData.hClient = frmMyDlg.Handle; _nppTbData.pszName = "Linq2Lines query"; _nppTbData.dlgID = idMyDlg; _nppTbData.uMask = NppTbMsg.DWS_DF_CONT_BOTTOM | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR; _nppTbData.hIconTab = (uint)tbIcon.Handle; _nppTbData.pszModuleName = PluginName; IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData)); Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false); Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData); // init config if (xmlConfig != null) { try { frmMyDlg.QueryText = xmlConfig.Element("query").Value; frmMyDlg.HelpersText = xmlConfig.Element("helpers").Value; } catch (Exception ex) { MessageBox.Show("Linq2Lines error: " + ex.Message); } } } else { Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DMMSHOW, 0, frmMyDlg.Handle); } }
/// <summary> /// Toggle the docked form on and off, can be called first and will initialize the form /// </summary> public void Toggle() { try { // initialize if not done if (_fakeForm == null) { // register fake form to Npp _fakeForm = new NppDockableDialogFakeForm { Dock = System.Windows.Forms.DockStyle.Fill }; NppTbData nppTbData = new NppTbData { hClient = _fakeForm.Handle, pszName = AssemblyInfo.AssemblyProduct + " - " + _dialogDescription, dlgID = DockableCommandIndex, uMask = _formDefaultPos | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR, hIconTab = (uint)Utils.GetIconFromImage(_iconImage).Handle, pszModuleName = AssemblyInfo.AssemblyProduct }; Npp.RegisterDockableDialog(nppTbData); _fakeForm.OnDockableDialogClose += FormOnOnDockableDialogClose; InitForm(); IsVisible = true; } else { if (IsVisible) { Npp.HideDockableDialog(_fakeForm.Handle); IsVisible = false; } else { Npp.ShowDockableDialog(_fakeForm.Handle); InitForm(); IsVisible = true; } } // Dock the NppDialog at _fakeform Form.TopLevel = false; Form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; Form.Dock = System.Windows.Forms.DockStyle.Fill; _fakeForm.Controls.Add(Form); } catch (Exception e) { ErrorHandler.ShowErrors(e, "Error loading " + _dialogDescription); } }
internal static void myDockableDialog() { try { if (MainDlg == null) { MainDlg = new MainDlg(); using (Bitmap newBmp = new Bitmap(16, 16)) { Graphics g = Graphics.FromImage(newBmp); ColorMap[] colorMap = new ColorMap[1]; colorMap[0] = new ColorMap(); colorMap[0].OldColor = Color.Fuchsia; colorMap[0].NewColor = Color.FromKnownColor(KnownColor.ButtonFace); ImageAttributes attr = new ImageAttributes(); attr.SetRemapTable(colorMap); g.DrawImage(tbBmp_tbTab, new Rectangle(0, 0, 16, 16), 0, 0, 16, 16, GraphicsUnit.Pixel, attr); tbIcon = Icon.FromHandle(newBmp.GetHicon()); } NppTbData _nppTbData = new NppTbData(); _nppTbData.hClient = MainDlg.Handle; _nppTbData.pszName = "Assembly"; _nppTbData.dlgID = idMyDlg; _nppTbData.uMask = NppTbMsg.DWS_DF_CONT_RIGHT | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR; _nppTbData.hIconTab = (uint)tbIcon.Handle; _nppTbData.pszModuleName = PluginName; IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData)); Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false); Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData); } else { Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DMMSHOW, 0, MainDlg.Handle); Thread.Sleep(50); MainDlg.Refresh(); } UpdateSFInfo(false); } catch (Exception e) { Main.NotifyError(e); } }
/// <summary> /// Initialize the form /// </summary> public static void Init() { FakeForm = new EmptyForm(); NppTbData nppTbData = new NppTbData { hClient = FakeForm.Handle, pszName = AssemblyInfo.AssemblyProduct + " - Code explorer", dlgID = DockableCommandIndex, uMask = NppTbMsg.DWS_DF_CONT_RIGHT | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR, hIconTab = (uint)Utils.GetIconFromImage(ImageResources.CodeExplorerLogo).Handle, pszModuleName = AssemblyInfo.AssemblyProduct }; IntPtr ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(nppTbData)); Marshal.StructureToPtr(nppTbData, ptrNppTbData, false); WinApi.SendMessage(Npp.HandleNpp, NppMsg.NPPM_DMMREGASDCKDLG, 0, ptrNppTbData); Form = new CodeExplorerForm(FakeForm); }
internal static void ShowQuickSearchDlg() { if (frmQuickSearch == null) { frmQuickSearch = QuickSearchPanel.Instance.Form; using (Bitmap newBmp = new Bitmap(16, 16)) { Graphics g = Graphics.FromImage(newBmp); ColorMap[] colorMap = new ColorMap[1]; colorMap[0] = new ColorMap(); colorMap[0].OldColor = Color.Fuchsia; colorMap[0].NewColor = Color.FromKnownColor(KnownColor.ButtonFace); ImageAttributes attr = new ImageAttributes(); attr.SetRemapTable(colorMap); g.DrawImage(tbQuickSearchBmp_tbTab, new Rectangle(0, 0, 16, 16), 0, 0, 16, 16, GraphicsUnit.Pixel, attr); tbQuickSearchIcon = Icon.FromHandle(newBmp.GetHicon()); } NppTbData _nppTbData = new NppTbData(); _nppTbData.hClient = frmQuickSearch.Handle; _nppTbData.pszName = Properties.Resources.quick_search_dlg_label; _nppTbData.dlgID = idQuickSearchDlg; _nppTbData.uMask = NppTbMsg.DWS_DF_CONT_RIGHT | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR; _nppTbData.hIconTab = (uint)tbQuickSearchIcon.Handle; _nppTbData.pszModuleName = PluginName; IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData)); Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false); Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData); Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_SETMENUITEMCHECK, PluginBase._funcItems.Items[idQuickSearchDlg]._cmdID, 1); } else { if (frmQuickSearch.Visible) { Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DMMHIDE, 0, frmQuickSearch.Handle); Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_SETMENUITEMCHECK, PluginBase._funcItems.Items[idQuickSearchDlg]._cmdID, 0); } else { Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DMMSHOW, 0, frmQuickSearch.Handle); Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_SETMENUITEMCHECK, PluginBase._funcItems.Items[idQuickSearchDlg]._cmdID, 1); } } }
protected void RegisterPanel(int uiId, Bitmap icon, Form panel, PanelPosition position = PanelPosition.Left) { var tbIcon = GetTransparentIcon(icon, 16, 16); var nppTbData = new NppTbData(); nppTbData.hClient = panel.Handle; nppTbData.pszName = PluginName; nppTbData.dlgID = uiId; // define the default docking behavior nppTbData.uMask = (NppTbMsg)position | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR; nppTbData.hIconTab = (uint)tbIcon.Handle; nppTbData.pszModuleName = PluginName; var ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(nppTbData)); Marshal.StructureToPtr(nppTbData, ptrNppTbData, false); Win32.SendMessage(_nppData._nppHandle, NppMsg.NPPM_DMMREGASDCKDLG, 0, ptrNppTbData); }
internal static void WDMainFormShow() { try { if (WDMainForm == null) { WDMainForm = new WDMainForm(); NppTbData _nppTbData = new NppTbData(); _nppTbData.hClient = WDMainForm.Handle; _nppTbData.pszName = "ERP Helper - Workday"; _nppTbData.dlgID = idWDForm; _nppTbData.uMask = NppTbMsg.DWS_DF_CONT_RIGHT; _nppTbData.pszModuleName = PluginName; IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData)); Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData); // Load Saxon new Thread(() => { try { Thread.CurrentThread.IsBackground = true; SaxonXForm.TransformXml(Properties.Resources.Sample_GetWorkers, Properties.Resources.Sample_Stylesheet); } catch { // ignore exception } }).Start(); } else { Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMSHOW, 0, WDMainForm.Handle); } } catch (Exception ex) { MessageBox.Show("Error initializing the plugin. " + ex.Message, "Main", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
internal static void myDockableDialog() { if (frmMyDlg == null) { frmMyDlg = new frmMyDlg(); using (Bitmap newBmp = new Bitmap(16, 16)) { Graphics g = Graphics.FromImage(newBmp); ColorMap[] colorMap = new ColorMap[1]; colorMap[0] = new ColorMap(); colorMap[0].OldColor = Color.Fuchsia; colorMap[0].NewColor = Color.FromKnownColor(KnownColor.ButtonFace); ImageAttributes attr = new ImageAttributes(); attr.SetRemapTable(colorMap); g.DrawImage(tbBmp_tbTab, new Rectangle(0, 0, 16, 16), 0, 0, 16, 16, GraphicsUnit.Pixel, attr); tbIcon = Icon.FromHandle(newBmp.GetHicon()); } NppTbData _nppTbData = new NppTbData(); _nppTbData.hClient = frmMyDlg.Handle; _nppTbData.pszName = "My dockable dialog"; _nppTbData.dlgID = idMyDlg; _nppTbData.uMask = NppTbMsg.DWS_DF_CONT_RIGHT | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR; _nppTbData.hIconTab = (uint)tbIcon.Handle; _nppTbData.pszModuleName = PluginName; IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData)); Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData); } else { Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMSHOW, 0, frmMyDlg.Handle); Win32.SendMessage(PluginBase.GetCurrentScintilla(), SciMsg.SCI_SETSELFORE, 1, 0xFFFFFF); Win32.SendMessage(PluginBase.GetCurrentScintilla(), SciMsg.SCI_SETSELBACK, 1, 0xFFFFFF); Win32.SendMessage(PluginBase.GetCurrentScintilla(), SciMsg.SCI_SETVIEWWS, 1, SCWS_VISIBLEALWAYS); } }
public void Register(string formName, Form form, string title, int index, NppTbMsg flags) { Validate.IsTrue(!Forms.ContainsKey(formName)); NppTbData data = new NppTbData { hClient = form.Handle, pszName = title, uMask = flags, dlgID = index, pszModuleName = "Sql Easy Studio" }; IntPtr hwnd = Marshal.AllocHGlobal(Marshal.SizeOf(data)); Marshal.StructureToPtr(data, hwnd, false); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMREGASDCKDLG, 0, hwnd); Forms.Add(formName, new PluginForm(form)); }
internal static void MyDockableDialog() { if (_form == null) { _form = new frmMain(); using (var newBmp = new Bitmap(16, 16)) { Graphics g = Graphics.FromImage(newBmp); var colorMap = new ColorMap[1]; colorMap[0] = new ColorMap { OldColor = Color.Fuchsia, NewColor = Color.FromKnownColor(KnownColor.ButtonFace) }; var attr = new ImageAttributes(); attr.SetRemapTable(colorMap); g.DrawImage(TbBmpTbTab, new Rectangle(0, 0, 16, 16), 0, 0, 16, 16, GraphicsUnit.Pixel, attr); _tbIcon = Icon.FromHandle(newBmp.GetHicon()); } var nppTbData = new NppTbData { hClient = _form.Handle, pszName = "Arduino Notepad++", dlgID = _idMyDlg, uMask = NppTbMsg.DWS_DF_CONT_RIGHT | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR, hIconTab = (uint)_tbIcon.Handle, pszModuleName = PluginName }; IntPtr ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(nppTbData)); Marshal.StructureToPtr(nppTbData, ptrNppTbData, false); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMREGASDCKDLG, 0, ptrNppTbData); _form.Init(); } else { Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMSHOW, 0, _form.Handle); _form.Init(); } }
public static void DockPanel(Form panel, int scriptId, string name, Icon tollbarIcon, NppTbMsg tbMsg, bool initiallyVisible = true) { var tbIcon = tollbarIcon ?? Utils.NppBitmapToIcon(Resources.Resources.css_logo_16x16); //tbIcon = Utils.NppBitmapToIcon(Properties.Resources.css_logo_16x16); NppTbData _nppTbData = new NppTbData(); _nppTbData.hClient = panel.Handle; _nppTbData.pszName = name; // the dlgDlg should be the index of funcItem where the current function pointer is, //in this case is 15. so the initial value of funcItem[15]._cmdID - not the updated internal one ! _nppTbData.dlgID = scriptId; // define the default docking behaviour _nppTbData.uMask = tbMsg; _nppTbData.hIconTab = (uint)tbIcon.Handle; _nppTbData.pszModuleName = PluginName; IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData)); Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false); Win32.SendMessage(Npp.NppHandle, NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData); Win32.SendMessage(Npp.NppHandle, NppMsg.NPPM_SETMENUITEMCHECK, Plugin.FuncItems.Items[scriptId]._cmdID, 1); //from this moment the panel is visible if (!initiallyVisible) { SetDockedPanelVisible(panel, scriptId, initiallyVisible); } if (dockedManagedPanels.ContainsKey(scriptId)) { //there is already another panel Win32.SendMessage(Npp.NppHandle, NppMsg.NPPM_DMMHIDE, 0, dockedManagedPanels[scriptId]); dockedManagedPanels[scriptId] = panel.Handle; } else { dockedManagedPanels.Add(scriptId, panel.Handle); } }
internal static void myDockableDialog() { if (frmMyDlg == null) { frmMyDlg = new ClipboardForm(); using (Bitmap newBmp = new Bitmap(16, 16)) { Graphics g = Graphics.FromImage(newBmp); ColorMap[] colorMap = new ColorMap[1]; colorMap[0] = new ColorMap(); colorMap[0].OldColor = Color.Fuchsia; colorMap[0].NewColor = Color.FromKnownColor(KnownColor.ButtonFace); ImageAttributes attr = new ImageAttributes(); attr.SetRemapTable(colorMap); g.DrawImage(tbBmp_tbTab, new Rectangle(0, 0, 16, 16), 0, 0, 16, 16, GraphicsUnit.Pixel, attr); tbIcon = Icon.FromHandle(newBmp.GetHicon()); } NppTbData _nppTbData = new NppTbData(); _nppTbData.hClient = frmMyDlg.Handle; _nppTbData.pszName = "Clipboard Helper"; _nppTbData.dlgID = idMyDlg; _nppTbData.uMask = NppTbMsg.DWS_DF_CONT_RIGHT | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR; _nppTbData.hIconTab = (uint)tbIcon.Handle; _nppTbData.pszModuleName = PluginName; IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData)); Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false); Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData); isDialogVisible = true; } else { Win32.SendMessage(PluginBase.nppData._nppHandle, isDialogVisible ? NppMsg.NPPM_DMMHIDE : NppMsg.NPPM_DMMSHOW, 0, frmMyDlg.Handle); isDialogVisible = !isDialogVisible; } frmMyDlg.SetItems(repository.Get()); }
/// <summary> /// Toggle the docked form on and off, can be called first and will initialize the form /// </summary> public void Toggle() { try { // initialize if not done if (_fakeForm == null) { // register fake form to Npp _fakeForm = new NppDockableDialogFakeForm(); NppTbData nppTbData = new NppTbData { hClient = _fakeForm.Handle, pszName = AssemblyInfo.AssemblyProduct + " - " + _dialogDescription, dlgID = DockableCommandIndex, uMask = _formDefaultPos | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR, hIconTab = (uint)Utils.GetIconFromImage(_iconImage).Handle, pszModuleName = AssemblyInfo.AssemblyProduct }; Npp.RegisterDockableDialog(nppTbData); _fakeForm.OnDockableDialogClose += FormOnOnDockableDialogClose; InitForm(); IsVisible = true; } else { if (IsVisible) { Npp.HideDockableDialog(_fakeForm.Handle); IsVisible = false; } else { Npp.ShowDockableDialog(_fakeForm.Handle); IsVisible = true; } } Form.RefreshPosAndLoc(); } catch (Exception e) { ErrorHandler.ShowErrors(e, "Error loading " + _dialogDescription); } }