Ejemplo n.º 1
0
        internal static List<FilePathViewIndex> GetOpenedFiles(int view = 0)
        {
            var result = new List<FilePathViewIndex>();

            int filesCount;
            ClikeStringArray cStrArray;
            int ind;

            if (view == 0 || view == 1)
            {
                filesCount = (int)Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETNBOPENFILES, 0, 1);
                using (cStrArray = new ClikeStringArray(filesCount, Win32.MAX_PATH))
                {
                    ind = 0;
                    if (Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETOPENFILENAMESPRIMARY, cStrArray.NativePointer, filesCount) != IntPtr.Zero)
                        if (cStrArray.ManagedStringsUnicode.Count > 1 || !Utils.IsFileNew(cStrArray.ManagedStringsUnicode[0]))
                            result.AddRange(cStrArray.ManagedStringsUnicode.Select(str => new FilePathViewIndex(str, 0, ind++)));
                }
            }

            if (view == 0 || view == 2)
            {
                filesCount = (int)Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETNBOPENFILES, 0, 2);
                using (cStrArray = new ClikeStringArray(filesCount, Win32.MAX_PATH))
                {
                    ind = 0;
                    if (Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETOPENFILENAMESSECOND, cStrArray.NativePointer, filesCount) != IntPtr.Zero)
                        if (cStrArray.ManagedStringsUnicode.Count > 1 || !Utils.IsFileNew(cStrArray.ManagedStringsUnicode[0]))
                            result.AddRange(cStrArray.ManagedStringsUnicode.Select(str => new FilePathViewIndex(str, 1, ind++)));
                }
            }

            return result;
        }
Ejemplo n.º 2
0
        static void getSessionFileNamesDemo()
        {
            int nbFile = (int)Win32.SendMessage(nppData._nppHandle, NppMsg.NPPM_GETNBSESSIONFILES, 0, sessionFilePath);

            if (nbFile < 1)
            {
                MessageBox.Show("Please modify \"sessionFilePath\" in \"Demo.cs\" in order to point to a valid session file", "Error");
                return;
            }
            MessageBox.Show(nbFile.ToString(), "Number of session files:");

            using (ClikeStringArray cStrArray = new ClikeStringArray(nbFile, Win32.MAX_PATH))
            {
                if (Win32.SendMessage(nppData._nppHandle, NppMsg.NPPM_GETSESSIONFILES, cStrArray.NativePointer, sessionFilePath) != IntPtr.Zero)
                    foreach (string file in cStrArray.ManagedStringsUnicode) MessageBox.Show(file);
            }
        }
Ejemplo n.º 3
0
        static void getFileNamesDemo()
        {
            int nbFile = (int)Win32.SendMessage(nppData._nppHandle, NppMsg.NPPM_GETNBOPENFILES, 0, 0);
            MessageBox.Show(nbFile.ToString(), "Number of opened files:");

            using (ClikeStringArray cStrArray = new ClikeStringArray(nbFile, Win32.MAX_PATH))
            {
                if (Win32.SendMessage(nppData._nppHandle, NppMsg.NPPM_GETOPENFILENAMES, cStrArray.NativePointer, nbFile) != IntPtr.Zero)
                    foreach (string file in cStrArray.ManagedStringsUnicode) MessageBox.Show(file);
            }
        }