Exemplo n.º 1
0
        /// <summary>
        /// Gets preview text for specified setting value.
        /// </summary>
        public static string GetPreviewText(string settingName, string settingValue)
        {
            if (String.IsNullOrEmpty(settingValue))
            {
                return(Resources.DoNotCheck);
            }

            if (IsCommon(settingName))
            {
                return(NamingMacro.BuildExample(settingValue));
            }

            switch (settingName)
            {
            case BlockAt:
                return(new BlockAt().GetPreviewText(settingValue));

            case EnglishOnly:
                return(new EnglishOnly().GetPreviewText(settingValue));

            case CheckLength:
                return(new CheckLength().GetPreviewText(settingValue));

            default:
                return(settingValue);
            }
        }
        /// <summary>
        /// Initializes common settings.
        /// </summary>
        private void InitializeCommon(SourceAnalyzer analyzer, CodeDocument document)
        {
            m_names    = new Dictionary <string, string>();
            m_examples = new Dictionary <string, string>();
            m_regulars = new Dictionary <string, Regex>();

            string words = SettingsManager.GetValue <string>(
                analyzer,
                document.Settings,
                NamingSettings.Words);

            foreach (string setting in NamingSettings.GetCommon())
            {
                string name = SettingsManager.GetFriendlyName(analyzer, setting);
                m_names.Add(setting, name);

                string value = SettingsManager.GetValue <string>(analyzer, document.Settings, setting);
                if (String.IsNullOrEmpty(value))
                {
                    m_examples.Add(setting, null);
                    m_regulars.Add(setting, null);
                }
                else
                {
                    string example = NamingMacro.BuildExample(value);
                    m_examples.Add(setting, example);

                    Regex regex = NamingMacro.BuildRegex(value, words);
                    m_regulars.Add(setting, regex);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Does action "Insert".
        /// </summary>
        private void Action_Insert_Do()
        {
            if (!Action_Insert_IsAvailable())
            {
                return;
            }

            ListViewItem lvi  = listMacro.SelectedItems[0];
            string       key  = lvi.Text;
            string       text = NamingMacro.GetMarkup(key);

            textEditor.RichTextBox.SelectedText = text;
        }
Exemplo n.º 4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!NamingMacro.CheckRule(textEditor.RichTextBox.Text))
            {
                Messages.ShowWarningOk(this, Resources.NamingRuleEditorWarning);
                textEditor.Focus();
                return;
            }

            TargetRule = checkDisable.Checked ?
                         String.Empty :
                         NamingMacro.ParseRuleFromText(textEditor.RichTextBox.Text);

            DialogResult = DialogResult.OK;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Rebuilds macro list.
        /// </summary>
        private void RebuildMacroList()
        {
            listMacro.BeginUpdate();
            listMacro.Items.Clear();

            foreach (string key in NamingMacro.GetKeys(true))
            {
                string descripion = NamingMacro.GetDescription(key);

                ListViewItem lvi = new ListViewItem();
                lvi.UseItemStyleForSubItems = false;
                lvi.Text = key;

                ListViewItem.ListViewSubItem sub = new ListViewItem.ListViewSubItem(lvi, descripion);
                sub.ForeColor = SystemColors.GrayText;
                lvi.SubItems.Add(sub);

                listMacro.Items.Add(lvi);
            }

            listMacro.EndUpdate();
        }
Exemplo n.º 6
0
        private void NamingRuleEditor_Load(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(ObjectName))
            {
                throw new InvalidOperationException("ObjectName is not set.");
            }

            Text = String.Format(Resources.NamingRuleEditorCaption, ObjectName);

            labelHelp.Text = Resources.NamingRuleEditorHelp;

            if (String.IsNullOrEmpty(TargetRule))
            {
                checkDisable.Checked = true;
            }
            else
            {
                textEditor.RichTextBox.Text = NamingMacro.ConvertRuleToText(TargetRule);
            }

            RebuildMacroList();
            UpdateControls();
        }
Exemplo n.º 7
0
 private void textEditor_Highlight(object sender, ControlEventArgs e)
 {
     NamingMacro.HighlightRule((RichTextBox)e.Control);
 }
 /// <summary>
 /// Highlights rich text box with definition string.
 /// </summary>
 public void Highlight(RichTextBox rich)
 {
     NamingMacro.HighlightSimpleSetting(rich, this, this);
 }
 /// <summary>
 /// Checks if specified text is valid.
 /// </summary>
 public bool IsValidText(string text)
 {
     return(NamingMacro.CheckSimpleSetting(text, this));
 }
 /// <summary>
 /// Creates text from definition string.
 /// </summary>
 public string ConvertTo(string ruleDefinition)
 {
     return(NamingMacro.ConvertWhitespacedSettingToText(ruleDefinition));
 }
 /// <summary>
 /// Creates definition string from specified text.
 /// </summary>
 public string ParseFrom(string text)
 {
     return(NamingMacro.ParseWhitespacedSettingFromText(text));
 }