private void LoadSettings()
        {
            _NO_TRANSLATE_numericMaxFirstLineLength.Value = Settings.CommitValidationMaxCntCharsFirstLine;
            _NO_TRANSLATE_numericMaxLineLength.Value = Settings.CommitValidationMaxCntCharsPerLine;
            checkBoxSecondLineEmpty.Checked = Settings.CommitValidationSecondLineMustBeEmpty;
            _NO_TRANSLATE_textBoxCommitValidationRegex.Text = Settings.CommitValidationRegEx;

            _commitTemplates = CommitTemplateItem.DeserializeCommitTemplates(Settings.CommitTemplates);

            if (null == _commitTemplates)
            {
                _commitTemplates = new CommitTemplateItem[_maxCommitTemplates];
                for (int i = 0; i < _commitTemplates.Length; i++)
                    _commitTemplates[i] = new CommitTemplateItem();
            }

            _NO_TRANSLATE_comboBoxCommitTemplates.Items.Clear();

            for (int i = 0; i < _commitTemplates.Length; i++)
            {
                _NO_TRANSLATE_comboBoxCommitTemplates.Items.Add(String.Empty);
                RefreshLineInListBox(i);
            }

            _NO_TRANSLATE_comboBoxCommitTemplates.SelectedIndex = 0;
        }
        private void LoadSettings()
        {
            _NO_TRANSLATE_numericMaxFirstLineLength.Value = Settings.CommitValidationMaxCntCharsFirstLine;
            _NO_TRANSLATE_numericMaxLineLength.Value      = Settings.CommitValidationMaxCntCharsPerLine;
            checkBoxSecondLineEmpty.Checked = Settings.CommitValidationSecondLineMustBeEmpty;
            _NO_TRANSLATE_textBoxCommitValidationRegex.Text = Settings.CommitValidationRegEx;

            _commitTemplates = CommitTemplateItem.DeserializeCommitTemplates(Settings.CommitTemplates);

            if (null == _commitTemplates)
            {
                _commitTemplates = new CommitTemplateItem[_maxCommitTemplates];
                for (int i = 0; i < _commitTemplates.Length; i++)
                {
                    _commitTemplates[i] = new CommitTemplateItem();
                }
            }

            _NO_TRANSLATE_comboBoxCommitTemplates.Items.Clear();

            for (int i = 0; i < _commitTemplates.Length; i++)
            {
                _NO_TRANSLATE_comboBoxCommitTemplates.Items.Add(String.Empty);
                RefreshLineInListBox(i);
            }

            _NO_TRANSLATE_comboBoxCommitTemplates.SelectedIndex = 0;
        }
        private void SaveSettings()
        {
            Settings.CommitValidationMaxCntCharsFirstLine  = Convert.ToInt32(_NO_TRANSLATE_numericMaxFirstLineLength.Value);
            Settings.CommitValidationMaxCntCharsPerLine    = Convert.ToInt32(_NO_TRANSLATE_numericMaxLineLength.Value);
            Settings.CommitValidationSecondLineMustBeEmpty = checkBoxSecondLineEmpty.Checked;
            Settings.CommitValidationRegEx = _NO_TRANSLATE_textBoxCommitValidationRegex.Text;

            string serializedCommitTemplates = CommitTemplateItem.SerializeCommitTemplates(_commitTemplates);

            if (null == serializedCommitTemplates)
            {
                Settings.CommitTemplates = "";
            }
            else
            {
                Settings.CommitTemplates = serializedCommitTemplates;
            }
        }
Ejemplo n.º 4
0
        private void AddTemplateCommitMessageToMenu(CommitTemplateItem item, string name)
        {
            if (string.IsNullOrEmpty(name))
                return;

            var toolStripItem =
                new ToolStripMenuItem
                {
                    Tag = item,
                    Text = name
                };

            toolStripItem.Click += commitTemplatesToolStripMenuItem_Clicked;
            commitTemplatesToolStripMenuItem.DropDownItems.Add(toolStripItem);
        }
Ejemplo n.º 5
0
 public static string SerializeCommitTemplates(CommitTemplateItem[] items)
 {
     try
     {
         if (_useBinaryFormatter)
         {
             // Serialize to a base 64 string
             byte[] bytes;
             MemoryStream ws = new MemoryStream();
             BinaryFormatter sf = new BinaryFormatter();
             sf.Serialize(ws, items);
             bytes = ws.GetBuffer();
             return bytes.Length.ToString() + ":" + Convert.ToBase64String(bytes, 0, bytes.Length, Base64FormattingOptions.None);
         }
         else
         {
             var sw = new StringWriter();
             var serializer = new XmlSerializer(typeof(CommitTemplateItem[]));
             serializer.Serialize(sw, items);
             return sw.ToString();
         }
     }
     catch
     {
         return null;
     }
 }