Exemplo n.º 1
0
Arquivo: Plug.cs Projeto: massreuy/3P
        /// <summary>
        /// Called on Npp shutdown
        /// </summary>
        internal static void DoNppShutDown()
        {
            try {
                if (OnShutDown != null)
                {
                    OnShutDown();
                }

                // clean up timers
                RecurentAction.CleanAll();
                DelayedAction.CleanAll();
                AsapButDelayableAction.CleanAll();

                // Triggered when the resolution of an assembly fails, gives us the opportunity to feed the required assembly
                AppDomain.CurrentDomain.AssemblyResolve -= LibLoader.AssemblyResolver;

                // catch unhandled errors to log them
                AppDomain.CurrentDomain.UnhandledException -= ErrorHandler.UnhandledErrorHandler;
                Application.ThreadException           -= ErrorHandler.ThreadErrorHandler;
                TaskScheduler.UnobservedTaskException -= ErrorHandler.UnobservedErrorHandler;

                // unsubscribe to static events
                ProEnvironment.OnEnvironmentChange -= FileExplorer.Instance.RebuildFileList;
                ProEnvironment.OnEnvironmentChange -= DataBase.Instance.UpdateDatabaseInfo;
                ProEnvironment.OnEnvironmentChange -= ParserHandler.ClearStaticData;

                Keywords.Instance.OnImport         -= AutoCompletion.SetStaticItems;
                DataBase.Instance.OnDatabaseUpdate -= AutoCompletion.SetStaticItems;
                AutoCompletion.OnUpdateStaticItems -= ParserHandler.UpdateKnownStaticItems;

                ParserHandler.OnEndSendCompletionItems -= AutoCompletion.SetDynamicItems;
                ParserHandler.OnStart -= CodeExplorer.Instance.OnStart;
                ParserHandler.OnEndSendParserItems       -= CodeExplorer.Instance.OnParseEndParserItems;
                ParserHandler.OnEndSendCodeExplorerItems -= CodeExplorer.Instance.OnParseEndCodeExplorerItems;
                ParserHandler.OnEnd -= CodeExplorer.Instance.OnParseEnd;

                ProExecutionHandleCompilation.OnEachCompilationOk -= FilesInfo.ProExecutionHandleCompilationOnEachCompilationOk;

                // export modified conf
                FileTag.Export();

                // save config (should be done but just in case)
                Config.Save();

                // remember the most used keywords
                Keywords.Instance.SaveRanking();

                // close every form
                FileExplorer.Instance.ForceClose();
                CodeExplorer.Instance.ForceClose();
                AutoCompletion.ForceClose();
                InfoToolTip.ForceClose();
                Appli.ForceClose();
                UserCommunication.ForceClose();
                AppliMenu.ForceClose();
            } catch (Exception e) {
                ErrorHandler.ShowErrors(e, "Stop");
            }
        }
Exemplo n.º 2
0
Arquivo: Plug.cs Projeto: massreuy/3P
        internal static void DoPlugStart()
        {
            if (OnPlugReady != null)
            {
                OnPlugReady();
            }

            // subscribe to static events
            ProEnvironment.OnEnvironmentChange += FileExplorer.Instance.RebuildFileList;
            ProEnvironment.OnEnvironmentChange += DataBase.Instance.UpdateDatabaseInfo;
            ProEnvironment.OnEnvironmentChange += ParserHandler.ClearStaticData;

            Keywords.Instance.OnImport         += AutoCompletion.SetStaticItems;
            DataBase.Instance.OnDatabaseUpdate += AutoCompletion.SetStaticItems;
            AutoCompletion.OnUpdateStaticItems += ParserHandler.UpdateKnownStaticItems;

            ParserHandler.OnEndSendCompletionItems += AutoCompletion.SetDynamicItems;
            ParserHandler.OnStart += CodeExplorer.Instance.OnStart;
            ParserHandler.OnEndSendParserItems       += CodeExplorer.Instance.OnParseEndParserItems;
            ParserHandler.OnEndSendCodeExplorerItems += CodeExplorer.Instance.OnParseEndCodeExplorerItems;
            ParserHandler.OnEnd += CodeExplorer.Instance.OnParseEnd;

            ProExecutionHandleCompilation.OnEachCompilationOk += FilesInfo.ProExecutionHandleCompilationOnEachCompilationOk;

            // Clear the %temp% directory if we didn't do it properly last time
            Utils.DeleteDirectory(Config.FolderTemp, true);

            //Snippets.Init();
            FileTag.Import();

            // ask to disable the default autocompletion
            DelayedAction.StartNew(100, () => {
                if (!Npp.ConfXml.AskToDisableAutocompletionAndRestart())
                {
                    // check if an update was done
                    UpdateHandler.CheckForUpdateDone();
                }
            });

            // start checking for new updates
            UpdateHandler.StartCheckingForUpdate(); // async

            // Try to update the configuration from the distant shared folder
            ShareExportConf.StartCheckingForUpdates();

            // ReSharper disable once ObjectCreationAsStatement
            RecurentAction.StartNew(User.Ping, 1000 * 60 * 120);

            // Make sure to give the focus to scintilla on startup
            Sci.GrabFocus();
        }
Exemplo n.º 3
0
        internal static void DoPlugStart()
        {
            if (OnPlugReady != null)
            {
                OnPlugReady();
            }

            ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

            // subscribe to static events
            ProEnvironment.OnEnvironmentChange += FileExplorer.Instance.RebuildFileList;
            ProEnvironment.OnEnvironmentChange += DataBase.Instance.UpdateDatabaseInfo;
            ProEnvironment.OnEnvironmentChange += ParserHandler.ClearStaticData;

            Keywords.Instance.OnImport         += AutoCompletion.SetStaticItems;
            DataBase.Instance.OnDatabaseUpdate += AutoCompletion.SetStaticItems;
            AutoCompletion.OnUpdateStaticItems += ParserHandler.UpdateKnownStaticItems;

            ParserHandler.OnStart += CodeExplorer.Instance.OnStart;
            ParserHandler.OnEndSendCompletionItems   += AutoCompletion.SetDynamicItems;
            ParserHandler.OnEndSendParserItems       += CodeExplorer.Instance.OnParseEndParserItems;
            ParserHandler.OnEndSendParserItems       += SyntaxFolding.OnParseEndParserItems;
            ParserHandler.OnEndSendCodeExplorerItems += CodeExplorer.Instance.OnParseEndCodeExplorerItems;
            ParserHandler.OnEnd += CodeExplorer.Instance.OnParseEnd;

            ProExecutionHandleCompilation.OnEachCompilationOk += OpenedFilesInfo.ProExecutionHandleCompilationOnEachCompilationOk;

            // Clear the %temp% directory if we didn't do it properly last time
            Utils.DeleteDirectory(Config.FolderTemp, true);

            //Snippets.Init();
            FileCustomInfo.Import();

            DelayedAction.StartNew(100, () => {
                if (Config.Instance.InstallStep == 0)
                {
                    Config.Instance.InstallStep++;

                    // we are at the first notepad++ start
                    Npp.ConfXml.FinishPluginInstall(); // will apply npp options and restart npp
                    return;
                }
                if (Config.Instance.InstallStep == 1)
                {
                    Config.Instance.InstallStep++;

                    // global options applied, we are at the second startup
                    UserCommunication.NotifyUnique("welcome", "Thank you for installing 3P, you are awesome!<br><br>If this is your first look at 3P you should probably read the <b>getting started</b> section of the home page by clicking " + "go".ToHtmlLink("on this link right here") + ".<br><br><div align='right'>And as always... Enjoy!</div>", MessageImg.MsgInfo, "Fresh install", "Hello and welcome aboard!", args => {
                        Appli.ToggleView();
                        UserCommunication.CloseUniqueNotif("welcome");
                        args.Handled = true;
                    });
                }
                else if (!Config.Instance.NppStoppedCorrectly)
                {
                    // Npp didn't stop correctly, if the backup mode is activated, inform the user
                    if (Npp.ConfXml.BackupMode > 0)
                    {
                        UserCommunication.Notify("It seems that notepad++ didn't stop correctly.<br>If you lost some modifications, don't forget that you have a backup folder here :<br><br><div>" + Npp.ConfXml.BackupDirectory.ToHtmlLink() + "</div>" + (Npp.ConfXml.BackupUseCustomDir ? "<div>" + Npp.ConfXml.CustomBackupDirectory.ToHtmlLink() + "</div>" : ""), MessageImg.MsgInfo, "Notepad++ crashed", "Backup folder location");
                    }
                }

                Config.Instance.NppStoppedCorrectly = false;

                // check if an update was done and start checking for new updates
                Updater <MainUpdaterWrapper> .Instance.CheckForUpdateDoneAndStartCheckingForUpdates();

                if (Updater <ProlintUpdaterWrapper> .Instance.LocalVersion.IsHigherVersionThan("v0"))
                {
                    Updater <ProlintUpdaterWrapper> .Instance.StartCheckingForUpdate();
                }
                if (Updater <ProparseUpdaterWrapper> .Instance.LocalVersion.IsHigherVersionThan("v0"))
                {
                    Updater <ProparseUpdaterWrapper> .Instance.StartCheckingForUpdate();
                }

                // Try to update the configuration from the distant shared folder
                ShareExportConf.StartCheckingForUpdates();
            });

            // check if npp version is meeting current recommended version
            if (!string.IsNullOrEmpty(Npp.SoftwareStringVersion) && !Npp.SoftwareStringVersion.IsHigherOrEqualVersionThan(Config.RequiredNppVersion))
            {
                if (!Config.Instance.NppOutdatedVersion)
                {
                    UserCommunication.Notify("This version of 3P has been developed for Notepad++ " + Config.RequiredNppVersion + ", your version (" + Npp.SoftwareStringVersion + ") is outdated.<br><br>Using an outdated version, you might encounter bugs that would not occur otherwise.<br>Try to update your version of Notepad++ as soon as possible, or use 3P at your own risks.<br><br><a href='https://notepad-plus-plus.org/download/'>Download the latest version of Notepad++ here</a>", MessageImg.MsgHighImportance, "Outdated version", "3P requirements are not met");
                    Config.Instance.NppOutdatedVersion = true;
                }
            }
            else
            {
                Config.Instance.NppOutdatedVersion = false;
            }

            // ReSharper disable once ObjectCreationAsStatement
            RecurentAction.StartNew(User.Ping, 1000 * 60 * 120);

            // Make sure to give the focus to scintilla on startup
            Sci.GrabFocus();

            DelayedAction.StartNew(1000, Config.Save);
        }
Exemplo n.º 4
0
 /// <summary>
 /// ASYNC - Call this method to start checking for updates every xx min, also check once immediatly
 /// </summary>
 public static void StartCheckingForUpdates()
 {
     // check for updates every now and then (15min)
     // ReSharper disable once ObjectCreationAsStatement
     RecurentAction.StartNew(() => { UpdateList(Config.Instance.SharedConfFolder); }, 1000 * 60 * 15);
 }