コード例 #1
0
        static void beNotified(IntPtr notifyCode)
        {
            try
            {
                SCNotification nc = (SCNotification)Marshal.PtrToStructure(notifyCode, typeof(SCNotification));
                if (nc.nmhdr.code == (uint)NppMsg.NPPN_TBMODIFICATION)
                {
                    Plugin.FuncItems.RefreshItems();
                    Plugin.RefreshToolbarImages();
                }
                else if (nc.nmhdr.code == (uint)SciMsg.SCN_CHARADDED)
                {
                }
                else if (nc.nmhdr.code == (uint)NppMsg.NPPN_READY)
                {
                    CSScriptIntegration.Initialize();
                    Plugin.InitView();
                }
                else if (nc.nmhdr.code == (uint)NppMsg.NPPN_SHUTDOWN)
                {
                    Marshal.FreeHGlobal(_ptrPluginName);
                    Plugin.CleanUp();
                }

                Plugin.OnNotification(nc);
            }
            catch { }//this is indeed the last line of defense as all CS-S calls have the error handling inside
        }
コード例 #2
0
 static public void ClearBuildError()
 {
     if (BuildOutputWriteLine != null)
     {
         CSScriptIntegration.BuildOutputWriteLine("");
     }
 }
コード例 #3
0
ファイル: UnmanagedExports.cs プロジェクト: chcg/scripts.npp
        public void beNotified(IntPtr notifyCode)
        {
            lock (typeof(UnmanagedExports))
            {
                try
                {
                    ScNotification nc          = (ScNotification)Marshal.PtrToStructure(notifyCode, typeof(ScNotification));
                    string         contentFile = Npp.Editor.GetTabFile(nc.Header.IdFrom);

                    if (nc.Header.Code == (uint)NppMsg.NPPN_TBMODIFICATION)
                    {
                        PluginBase._funcItems.RefreshItems();
                        Plugin.RefreshToolbarImages();
                    }
                    else if (nc.Header.Code == (uint)SciMsg.SCN_CHARADDED)
                    {
                    }
                    else if (nc.Header.Code == (uint)NppMsg.NPPN_READY)
                    {
                        CSScriptIntegration.Initialize();
                        Plugin.InitView();
                    }
                    else if (nc.Header.Code == (uint)NppMsg.NPPN_SHUTDOWN)
                    {
                        Marshal.FreeHGlobal(_ptrPluginName);
                        Plugin.CleanUp();
                    }

                    Plugin.OnNotification(nc);
                }
                catch { }//this is indeed the last line of defense as all CS-S calls have the error handling inside
            }
        }
コード例 #4
0
 static public void ShowBuildError(string error)
 {
     if (BuildOutputWriteLine != null)
     {
         CSScriptIntegration.BuildOutputWriteLine(error);
     }
     else
     {
         MessageBox.Show(error, "Notepad++ Automation");
     }
 }
コード例 #5
0
ファイル: Plugin.cs プロジェクト: jeason0813/scripts.npp
 static public object GetOutputPanel()
 {
     try
     {
         return(CSScriptIntegration.GetOutputPanel());
     }
     catch
     {
         MessageBox.Show("CS-Script Output Panel cannot be found.\nPlease ensure you have CS-Script Plugin installed.", "Notepad++ Automation");
     }
     return(null);
 }
コード例 #6
0
ファイル: Plugin.cs プロジェクト: jeason0813/scripts.npp
        static NppScript LoadScript(string file, int id)
        {
            try
            {
                CSScriptIntegration.ClearBuildError();

                CSScript.CacheEnabled = true;
                bool debugScript = true;

                string asmFile      = CSScript.CompileFile(file, null, debugScript, Assembly.GetExecutingAssembly().Location);
                string debugSymbols = Path.ChangeExtension(asmFile, ".pdb");

                Assembly asm;
                if (File.Exists(debugSymbols) && debugScript)
                {
                    asm = Assembly.Load(File.ReadAllBytes(asmFile), File.ReadAllBytes(debugSymbols));
                }
                else
                {
                    asm = Assembly.Load(File.ReadAllBytes(asmFile));
                }

                object script = CreateObject(asm, "Script");

                var retval = (NppScript)script;
                retval.ScriptFile = file;
                retval.ScriptId   = id;
                retval.OnLoaded();

                return(retval);
            }
            catch (UnauthorizedAccessException)
            {
                if (DialogResult.Yes == MessageBox.Show("The Script is locked. Restarting Notepad++ will release it.\nDo you want to restart it now?", "Notepad++ Automation", MessageBoxButtons.YesNo))
                {
                    var proc = System.Diagnostics.Process.GetProcessById(55);
                    ScriptManager.RestartNpp();
                }
            }
            catch (Exception e)
            {
                //MessageBox.Show("Script '" + file + "' is invalid.\n" + e.Message, "Notepad++ Automation");
                CSScriptIntegration.ShowBuildError("Script '" + file + "' is invalid.\n" + e.Message);
            }

            return(new NppScriptStub
            {
                ScriptFile = file,
                ScriptId = id
            });
        }