예제 #1
0
        private void LoadSettings()
        {
            _NO_TRANSLATE_numericMaxFirstLineLength.Value = AppSettings.CommitValidationMaxCntCharsFirstLine;
            _NO_TRANSLATE_numericMaxLineLength.Value      = AppSettings.CommitValidationMaxCntCharsPerLine;
            checkBoxSecondLineEmpty.Checked = AppSettings.CommitValidationSecondLineMustBeEmpty;
            checkBoxUseIndent.Checked       = AppSettings.CommitValidationIndentAfterFirstLine;
            _NO_TRANSLATE_textBoxCommitValidationRegex.Text = AppSettings.CommitValidationRegEx;

            _commitTemplates = CommitTemplateItem.LoadFromSettings();

            if (_commitTemplates == null)
            {
                _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;
            checkBoxAutoWrap.Checked = AppSettings.CommitValidationAutoWrap;
        }
        private void LoadSettings()
        {
            _NO_TRANSLATE_numericMaxFirstLineLength.Value = Settings.CommitValidationMaxCntCharsFirstLine;
            _NO_TRANSLATE_numericMaxLineLength.Value = Settings.CommitValidationMaxCntCharsPerLine;
            checkBoxSecondLineEmpty.Checked = Settings.CommitValidationSecondLineMustBeEmpty;
            checkBoxUseIndent.Checked = Settings.CommitValidationIndentAfterFirstLine;
            _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;
            checkBoxAutoWrap.Checked = Settings.CommitValidationAutoWrap;
        }
예제 #3
0
        private void SaveSettings()
        {
            AppSettings.CommitValidationMaxCntCharsFirstLine  = Convert.ToInt32(_NO_TRANSLATE_numericMaxFirstLineLength.Value);
            AppSettings.CommitValidationMaxCntCharsPerLine    = Convert.ToInt32(_NO_TRANSLATE_numericMaxLineLength.Value);
            AppSettings.CommitValidationSecondLineMustBeEmpty = checkBoxSecondLineEmpty.Checked;
            AppSettings.CommitValidationIndentAfterFirstLine  = checkBoxUseIndent.Checked;
            AppSettings.CommitValidationRegEx = _NO_TRANSLATE_textBoxCommitValidationRegex.Text;

            CommitTemplateItem.SaveToSettings(_commitTemplates);
            AppSettings.CommitValidationAutoWrap = checkBoxAutoWrap.Checked;
        }
        private void SaveSettings()
        {
            Settings.CommitValidationMaxCntCharsFirstLine  = Convert.ToInt32(_NO_TRANSLATE_numericMaxFirstLineLength.Value);
            Settings.CommitValidationMaxCntCharsPerLine    = Convert.ToInt32(_NO_TRANSLATE_numericMaxLineLength.Value);
            Settings.CommitValidationSecondLineMustBeEmpty = checkBoxSecondLineEmpty.Checked;
            Settings.CommitValidationIndentAfterFirstLine  = checkBoxUseIndent.Checked;
            Settings.CommitValidationRegEx = _NO_TRANSLATE_textBoxCommitValidationRegex.Text;

            string serializedCommitTemplates = CommitTemplateItem.SerializeCommitTemplates(_commitTemplates);

            if (null == serializedCommitTemplates)
            {
                Settings.CommitTemplates = "";
            }
            else
            {
                Settings.CommitTemplates = serializedCommitTemplates;
            }
            Settings.CommitValidationAutoWrap = checkBoxAutoWrap.Checked;
        }
예제 #5
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);
        }
예제 #6
0
 private static string SerializeCommitTemplates(CommitTemplateItem[] items)
 {
     return JsonSerializer.Serialize(items);
 }
예제 #7
0
 public static void SaveToSettings(CommitTemplateItem[] items)
 {
     string strVal = SerializeCommitTemplates(items);
     GitCommands.AppSettings.CommitTemplates = strVal ?? string.Empty;
 }
예제 #8
0
 public static string SerializeCommitTemplates(CommitTemplateItem[] items)
 {
     try
     {
         if (UseBinaryFormatter)
         {
             // Serialize to a base 64 string
             byte[] bytes;
             using (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
         {
             using (var sw = new StringWriter())
             {
                 var serializer = new XmlSerializer(typeof(CommitTemplateItem[]));
                 serializer.Serialize(sw, items);
                 return sw.ToString();
             }
         }
     }
     catch
     {
         return null;
     }
 }