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); } }
internal static void myMenuFunction() { try { /* Not sure why this works when running as a local admin user but something * fails when running as a user without local admin. Will investigate later, * for now just accept that previous values may not be retrieved. */ StringBuilder sbIniFilePath = new StringBuilder(Win32.MAX_PATH); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, sbIniFilePath); iniFilePath = sbIniFilePath.ToString(); if (!Directory.Exists(iniFilePath)) { Directory.CreateDirectory(iniFilePath); } iniFilePath = Path.Combine(iniFilePath, PluginName + ".ini"); StringBuilder savedPathname = new StringBuilder("", 255); int i = Win32.GetPrivateProfileString("Dependencies", "7ZipExeDirectory", "", savedPathname, 255, iniFilePath); config7ZipPath = savedPathname.ToString(); } catch (Exception) { } PathTo7Zip = Find7zPath(); INotepadPPGateway notepad = new NotepadPPGateway(); string currentFile = notepad.GetCurrentFilePath(); if (string.IsNullOrEmpty(currentFile) || !File.Exists(currentFile)) { MessageBox.Show("Please save the file list first"); return; } if (frmMyDlg == null) { frmMyDlg = new frmMyDlg(); } frmMyDlg.SourceFilePath = currentFile; if (frmMyDlg.ShowDialog() == DialogResult.OK) { CreateArchive(currentFile, frmMyDlg.ArchiveFilename, frmMyDlg.StartDirectory); } }
internal static void saveAsDrawIO() { try { frmMyDlg frmMyDlg = new frmMyDlg(); var filename = frmMyDlg.filename; IntPtr currentScint = PluginBase.GetCurrentScintilla(); ScintillaGateway scintillaGateway = new ScintillaGateway(currentScint); // Get selected text. string selectedText = scintillaGateway.GetSelText(); var lines = selectedText.Split('\n'); for (var i = 0; i < lines.Length; i++) { var line = lines[i]; lines[i] = line.Trim(new char[] { ' ', '\r' }); } DrawIOBuilder builder = new DrawIOBuilder(); DrawIOComponent[] drawIOComponent = builder.FlowchartBuilder(lines); builder.SaveToFile(filename, drawIOComponent); } catch (Exception ex) { MessageBox.Show(ex.Message); } }