using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace NotepadEnhanced.Refactexing
{
    class RegexOptionsCheckedListBox : CheckedListBox
    {
        protected override void OnCreateControl()
        {
            Items.Clear();
            Items.Add(RegexOptions.IgnorePatternWhitespace);
            Items.Add(RegexOptions.ExplicitCapture);
            Items.Add(RegexOptions.CultureInvariant);
            Items.Add(RegexOptions.IgnoreCase);
            Items.Add(RegexOptions.RightToLeft);
            Items.Add(RegexOptions.Multiline);
            Items.Add(RegexOptions.Singleline);
        }

        /// <summary>
        /// Uncheck all checkboxes
        /// </summary>
        public void UncheckAll()
        {
            for (int i = 0; i < this.Items.Count; i++)
                this.SetItemChecked(i, false);
        }

        /// <summary>
        /// Gets the checked regex options
        /// </summary>
        public RegexOptions GetCheckedOptions()
        {
            var options = RegexOptions.None;

            foreach (var item in Items)
                options |= (RegexOptions)item;

            return options;
        }
    }
}
