Esempio n. 1
0
 private void BtDeleteOnButtonPressed(object sender, EventArgs eventArgs)
 {
     if (FileCustomInfo.DeleteFileTags(_filename, _locFileTagObject.CorrectionNumber))
     {
         UpdateInfo();
     }
 }
Esempio n. 2
0
 private void BtOkOnButtonPressed(object sender, EventArgs buttonPressedEventArgs)
 {
     Save(_filename);
     Save(FileCustomInfo.LastTag);
     UpdateInfo();
     FileCustomInfo.Export();
     Appli.ToggleView();
 }
Esempio n. 3
0
        /// <summary>
        /// Call this method to update the content of the form according to the current document
        /// </summary>
        public void UpdateInfo()
        {
            _filename = Npp.CurrentFileInfo.FileName;

            // populate combobox
            var list = new List <ItemCombo> {
                new ItemCombo {
                    DisplayText = "Last info", Nb = FileCustomInfo.LastTag
                },
                new ItemCombo {
                    DisplayText = "Default info", Nb = FileCustomInfo.DefaultTag
                }
            };

            cb_info.DisplayMember = "DisplayText";
            cb_info.ValueMember   = "Nb";

            if (FileCustomInfo.Contains(_filename))
            {
                var currentList = FileCustomInfo.GetFileTagsList(_filename);
                _locFileTagObject = currentList.Last();

                var i           = 2;
                var lastItemPos = 0;
                foreach (var fileTag in currentList.OrderByDescending(o => o.CorrectionNumber).ToList())
                {
                    list.Add(new ItemCombo {
                        DisplayText = _filename + " # " + fileTag.CorrectionNumber, Nb = fileTag.CorrectionNumber
                    });
                    if (fileTag.CorrectionNumber.Equals(_locFileTagObject.CorrectionNumber))
                    {
                        lastItemPos = i;
                    }
                    i++;
                }

                cb_info.DataSource    = list;
                cb_info.SelectedIndex = lastItemPos;
            }
            else
            {
                _locFileTagObject = FileCustomInfo.GetFileTags(Config.Instance.UseDefaultValuesInsteadOfLastValuesInEditTags ? FileCustomInfo.DefaultTag : FileCustomInfo.LastTag, "");

                cb_info.DataSource    = list;
                cb_info.SelectedIndex = Config.Instance.UseDefaultValuesInsteadOfLastValuesInEditTags ? 1 : 0;
            }

            UpdateView();
            ActiveControl = cb_info;
        }
Esempio n. 4
0
        /// <summary>
        /// called when the user changes the value of the combo box
        /// </summary>
        private void SelectedIndexChanged(YamuiComboBox sender)
        {
            var val = cb_info.SelectedValue.ToString();

            if (val.Equals(FileCustomInfo.LastTag) || val.Equals(FileCustomInfo.DefaultTag))
            {
                _locFileTagObject = FileCustomInfo.GetFileTags(val, "");
            }
            else
            {
                _locFileTagObject = FileCustomInfo.GetFileTags(_filename, val);
                FileCustomInfo.SetFileTags(_filename, _locFileTagObject.CorrectionNumber, _locFileTagObject.CorrectionDate, _locFileTagObject.CorrectionDecription, _locFileTagObject.ApplicationName, _locFileTagObject.ApplicationVersion, _locFileTagObject.WorkPackage, _locFileTagObject.BugId);
            }
            UpdateView();
        }
Esempio n. 5
0
        /// <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 -= OpenedFilesInfo.ProExecutionHandleCompilationOnEachCompilationOk;

                // export modified conf
                FileCustomInfo.Export();

                // Npp stopped correctly
                Config.Instance.NppStoppedCorrectly = true;

                // 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");
            }
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
 /// <summary>
 /// Save the info
 /// </summary>
 /// <param name="filename"></param>
 private void Save(string filename)
 {
     UpdateModel();
     FileCustomInfo.SetFileTags(filename, _locFileTagObject.CorrectionNumber, _locFileTagObject.CorrectionDate, _locFileTagObject.CorrectionDecription, _locFileTagObject.ApplicationName, _locFileTagObject.ApplicationVersion, _locFileTagObject.WorkPackage, _locFileTagObject.BugId);
 }
Esempio n. 8
0
        protected override bool SetExecutionInfo()
        {
            if (!base.SetExecutionInfo())
            {
                return(false);
            }

            if (!Config.Instance.GlobalDontCheckProlintUpdates && (!Updater <ProlintUpdaterWrapper> .Instance.LocalVersion.IsHigherVersionThan("v0") || !Updater <ProparseUpdaterWrapper> .Instance.LocalVersion.IsHigherVersionThan("v0")))
            {
                UserCommunication.NotifyUnique("NeedProlint",
                                               "The Prolint installation folder could not be found in 3P.<br>This is normal if it is the first time that you are using this feature.<br><br>" + "download".ToHtmlLink("Please click here to download the latest release of Prolint automatically") + "<br><br><i>You will be informed when it is installed and you will be able to use this feature immediately after.<br><br>If you do not wish to download it and see this message again :<br> toggle off automatic updates for Prolint in the " + "options".ToHtmlLink("update options page") + ".<br>Please note that in that case, you will need to configure Prolint yourself</i>",
                                               MessageImg.MsgQuestion, "Prolint execution", "Prolint installation not found", args => {
                    if (args.Link.Equals("options"))
                    {
                        args.Handled = true;
                        Appli.Appli.GoToPage(PageNames.OptionsUpdate);
                    }
                    else if (args.Link.Equals("download"))
                    {
                        args.Handled = true;
                        Updater <ProlintUpdaterWrapper> .Instance.CheckForUpdate();
                        Updater <ProparseUpdaterWrapper> .Instance.CheckForUpdate();
                    }
                    if (args.Handled)
                    {
                        UserCommunication.CloseUniqueNotif("NeedProlint");
                    }
                });
                return(false);
            }

            // prolint, we need to copy the StartProlint program
            var fileToExecute = "prolint_" + DateTime.Now.ToString("yyMMdd_HHmmssfff") + ".p";

            _prolintOutputPath = Path.Combine(_localTempDir, "prolint.log");

            StringBuilder prolintProgram = new StringBuilder();

            prolintProgram.AppendLine("&SCOPED-DEFINE PathFileToProlint " + Files.First().CompiledSourcePath.PreProcQuoter());
            prolintProgram.AppendLine("&SCOPED-DEFINE PathProlintOutputFile " + _prolintOutputPath.PreProcQuoter());
            prolintProgram.AppendLine("&SCOPED-DEFINE PathToStartProlintProgram " + Config.ProlintStartProcedure.PreProcQuoter());
            prolintProgram.AppendLine("&SCOPED-DEFINE UserName " + Config.Instance.UserName.PreProcQuoter());
            prolintProgram.AppendLine("&SCOPED-DEFINE PathActualFilePath " + Files.First().SourcePath.PreProcQuoter());
            var filename = Npp.CurrentFileInfo.FileName;

            if (FileCustomInfo.Contains(filename))
            {
                var fileInfo = FileCustomInfo.GetLastFileTag(filename);
                prolintProgram.AppendLine("&SCOPED-DEFINE FileApplicationName " + fileInfo.ApplicationName.PreProcQuoter());
                prolintProgram.AppendLine("&SCOPED-DEFINE FileApplicationVersion " + fileInfo.ApplicationVersion.PreProcQuoter());
                prolintProgram.AppendLine("&SCOPED-DEFINE FileWorkPackage " + fileInfo.WorkPackage.PreProcQuoter());
                prolintProgram.AppendLine("&SCOPED-DEFINE FileBugID " + fileInfo.BugId.PreProcQuoter());
                prolintProgram.AppendLine("&SCOPED-DEFINE FileCorrectionNumber " + fileInfo.CorrectionNumber.PreProcQuoter());
                prolintProgram.AppendLine("&SCOPED-DEFINE FileDate " + fileInfo.CorrectionDate.PreProcQuoter());

                prolintProgram.AppendLine("&SCOPED-DEFINE ModificationTagOpening " + ModificationTag.ReplaceTokens(fileInfo, ModificationTagTemplate.Instance.TagOpener).PreProcQuoter());
                prolintProgram.AppendLine("&SCOPED-DEFINE ModificationTagEnding " + ModificationTag.ReplaceTokens(fileInfo, ModificationTagTemplate.Instance.TagCloser).PreProcQuoter());
            }
            prolintProgram.AppendLine("&SCOPED-DEFINE PathDirectoryToProlint " + Updater <ProlintUpdaterWrapper> .Instance.ApplicationFolder.PreProcQuoter());
            prolintProgram.AppendLine("&SCOPED-DEFINE PathDirectoryToProparseAssemblies " + Updater <ProparseUpdaterWrapper> .Instance.ApplicationFolder.PreProcQuoter());
            var encoding = TextEncodingDetect.GetFileEncoding(Config.ProlintStartProcedure);

            Utils.FileWriteAllText(Path.Combine(_localTempDir, fileToExecute), Utils.ReadAllText(Config.ProlintStartProcedure, encoding).Replace(@"/*<inserted_3P_values>*/", prolintProgram.ToString()), encoding);

            SetPreprocessedVar("CurrentFilePath", fileToExecute.PreProcQuoter());

            return(true);
        }