Exemplo n.º 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;
        }
Exemplo n.º 2
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(FileTag.LastTag) || val.Equals(FileTag.DefaultTag))
            {
                _locFileTagObject = FileTag.GetFileTags(val, "");
            }
            else
            {
                _locFileTagObject = FileTag.GetFileTags(_filename, val);
                FileTag.SetFileTags(_filename, _locFileTagObject.CorrectionNumber, _locFileTagObject.CorrectionDate, _locFileTagObject.CorrectionDecription, _locFileTagObject.ApplicationName, _locFileTagObject.ApplicationVersion, _locFileTagObject.WorkPackage, _locFileTagObject.BugId);
            }
            UpdateView();
        }