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

                // clean up timers
                ReccurentAction.CleanAll();
                DelayedAction.CleanAll();

                // export modified conf
                FileTag.Export();

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

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

                // close every form
                AutoComplete.ForceClose();
                InfoToolTip.ForceClose();
                Appli.ForceClose();
                FileExplorer.ForceClose();
                CodeExplorer.ForceClose();
                UserCommunication.ForceClose();
                AppliMenu.ForceCloseMenu();
            } catch (Exception e) {
                ErrorHandler.ShowErrors(e, "Stop");
            }
        }
Exemplo n.º 2
0
Arquivo: Plug.cs Projeto: devjerome/3P
        /// <summary>
        /// called when the user changes its selection in npp (the carret moves)
        /// </summary>
        public static void OnUpdateSelection()
        {
            Npp.UpdateScintilla();

            // close popup windows
            ClosePopups();
            Snippets.FinalizeCurrent();

            // update scope of code explorer (the selection img)
            CodeExplorer.RedrawCodeExplorerList();
        }
Exemplo n.º 3
0
        /// <summary>
        /// force everything to redraw to apply a new theme
        /// </summary>
        public static void RefreshApplicationWithTheme(Theme theme)
        {
            Current = theme;
            Config.Instance.AccentColor = theme.AccentColor;

            // force the autocomplete to redraw
            AutoComplete.ForceClose();
            CodeExplorer.ApplyColorSettings();
            FileExplorer.ApplyColorSettings();
            Application.DoEvents();
            Appli.Refresh();
        }
Exemplo n.º 4
0
Arquivo: Plug.cs Projeto: devjerome/3P
        public static void DoNppDocumentSwitched(bool initiating = false)
        {
            // update current file info
            IsPreviousFileProgress = IsCurrentFileProgress;
            IsCurrentFileProgress  = Abl.IsCurrentProgressFile;
            CurrentFilePath        = Npp.GetCurrentFilePath();
            CurrentFileObject      = FilesInfo.GetFileInfo(CurrentFilePath);

            // accept advanced notifications only if the current file is a progress file
            CurrentFileAllowed = IsCurrentFileProgress;

            // update current scintilla
            Npp.UpdateScintilla();

            // Apply options to npp and scintilla depending if we are on a progress file or not
            ApplyOptionsForScintilla();

            // close popups..
            ClosePopups();

            // Update info on the current file
            FilesInfo.UpdateErrorsInScintilla();

            // refresh file explorer currently opened file
            FileExplorer.RedrawFileExplorerList();

            if (!initiating)
            {
                if (Config.Instance.CodeExplorerAutoHideOnNonProgressFile)
                {
                    CodeExplorer.Toggle(IsCurrentFileProgress);
                }
                if (Config.Instance.FileExplorerAutoHideOnNonProgressFile)
                {
                    FileExplorer.Toggle(IsCurrentFileProgress);
                }
            }
            else
            {
                // make sure to use the ProEnvironment and colorize the error counter
                FilesInfo.UpdateFileStatus();
                ProEnvironment.Current.ReComputeProPath();
            }

            if (IsCurrentFileProgress)
            {
                // Need to compute the propath again, because we take into account relative path
                ProEnvironment.Current.ReComputeProPath();

                // rebuild lines info (MANDATORY)
                Npp.RebuildLinesInfo();
            }

            // Parse the document
            ParserHandler.ParseCurrentDocument(true);

            // publish the event
            if (OnDocumentChangedEnd != null)
            {
                OnDocumentChangedEnd();
            }
        }
Exemplo n.º 5
0
Arquivo: Plug.cs Projeto: devjerome/3P
        /// <summary>
        /// Called on npp ready
        /// </summary>
        internal static bool DoNppReady()
        {
            try {
                // need to set some values in the yamuiThemeManager
                ThemeManager.OnStartUp();

                // init an empty form, this gives us a Form to hook onto if we want to do stuff on the UI thread
                // from a back groundthread with BeginInvoke()
                // once this method is done, we are able to publish notifications
                UserCommunication.Init();

                // if the UDL is not installed
                if (!Style.InstallUdl(true))
                {
                    Style.InstallUdl();
                }
                else
                {
                    // first use message?
                    if (Config.Instance.UserFirstUse)
                    {
                        UserCommunication.NotifyUnique("welcome", "<div>Dear user,<br><br>Thank you for installing 3P, you are awesome!<br><br>If this is your first look at 3P I invite you to read the <b>Getting started</b> section of the home page by clicking <a href='go'>on this link right here</a>.<br><br></div><div align='right'>Enjoy!</div>", MessageImg.MsgInfo, "Information", "Hello and welcome aboard!", args => {
                            Appli.ToggleView();
                            UserCommunication.CloseUniqueNotif("welcome");
                            args.Handled = true;
                        });
                        Config.Instance.UserFirstUse = false;
                    }
                }

                // check Npp version, 3P requires version 6.8 or higher
                if (!String.IsNullOrEmpty(Npp.GetNppVersion) && !Npp.GetNppVersion.IsHigherVersionThan("6.7"))
                {
                    UserCommunication.Notify("Dear user,<br><br>Your version of notepad++ (" + Npp.GetNppVersion + ") is outdated.<br>3P <b>requires</b> the version <b>6.8</b> or above, <b>there are known issues with inferior versions</b>. Please upgrade to an up-to-date version of Notepad++ or use 3P at your own risks.<br><br><a href='https://notepad-plus-plus.org/download/'>Download the lastest version of Notepad++ here</a>", MessageImg.MsgError, "Outdated version", "3P requirements are not met");
                }

                // Check if an update has been done and start checking for new updates
                UpdateHandler.CheckForUpdateDone();
                UpdateHandler.StartCheckingForUpdate(); // async

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

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

                // code explorer
                if (Config.Instance.CodeExplorerAutoHideOnNonProgressFile)
                {
                    CodeExplorer.Toggle(Abl.IsCurrentProgressFile);
                }
                else if (Config.Instance.CodeExplorerVisible)
                {
                    CodeExplorer.Toggle();
                }

                // File explorer
                if (Config.Instance.FileExplorerAutoHideOnNonProgressFile)
                {
                    FileExplorer.Toggle(Abl.IsCurrentProgressFile);
                }
                else if (Config.Instance.FileExplorerVisible)
                {
                    FileExplorer.Toggle();
                }

                return(true);
            } catch (Exception e) {
                ErrorHandler.ShowErrors(e, "Plugin startup");
            }
            return(false);
        }