Beispiel #1
0
        /// <summary>
        /// Call this method to update the content of the form according to the current document
        /// </summary>
        public void UpdateInfo()
        {
            _filename = Npp.CurrentFile.FileName;

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

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

            if (FileTag.Contains(_filename))
            {
                var currentList = FileTag.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 = FileTag.GetFileTags(Config.Instance.UseDefaultValuesInsteadOfLastValuesInEditTags ? FileTag.DefaultTag : FileTag.LastTag, "");

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

            UpdateView();
            ActiveControl = cb_info;
        }
Beispiel #2
0
        protected override bool SetExecutionInfo()
        {
            if (!base.SetExecutionInfo())
            {
                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.ProQuoter());
            prolintProgram.AppendLine("&SCOPED-DEFINE PathProlintOutputFile " + _prolintOutputPath.ProQuoter());
            prolintProgram.AppendLine("&SCOPED-DEFINE PathToStartProlintProgram " + Config.FileStartProlint.ProQuoter());
            prolintProgram.AppendLine("&SCOPED-DEFINE UserName " + Config.Instance.UserName.ProQuoter());
            prolintProgram.AppendLine("&SCOPED-DEFINE PathActualFilePath " + Files.First().SourcePath.ProQuoter());
            var filename = Npp.CurrentFile.FileName;

            if (FileTag.Contains(filename))
            {
                var fileInfo = FileTag.GetLastFileTag(filename);
                prolintProgram.AppendLine("&SCOPED-DEFINE FileApplicationName " + fileInfo.ApplicationName.ProQuoter());
                prolintProgram.AppendLine("&SCOPED-DEFINE FileApplicationVersion " + fileInfo.ApplicationVersion.ProQuoter());
                prolintProgram.AppendLine("&SCOPED-DEFINE FileWorkPackage " + fileInfo.WorkPackage.ProQuoter());
                prolintProgram.AppendLine("&SCOPED-DEFINE FileBugID " + fileInfo.BugId.ProQuoter());
                prolintProgram.AppendLine("&SCOPED-DEFINE FileCorrectionNumber " + fileInfo.CorrectionNumber.ProQuoter());
                prolintProgram.AppendLine("&SCOPED-DEFINE FileDate " + fileInfo.CorrectionDate.ProQuoter());
            }
            var encoding = TextEncodingDetect.GetFileEncoding(Config.FileStartProlint);

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

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

            return(true);
        }