public SettingsForm(SettingsFormInput settings)
 {
     InitializeComponent();
     this.settingsControl1.Configure(settings);
 }
        void Create(SettingsFormInput formsInput, List <CustomFileExtentionHighlightsMapping> previouslySavedMappings)
        {
            var allHightLights = HighlightingManager.Instance.HighlightingDefinitions;

            DataTable highligtsTable = new DataTable("HighlightingDefinitionsTable");

            highligtsTable.Columns.Add("column1", typeof(string));
            foreach (var item in allHightLights)
            {
                highligtsTable.Rows.Add(item.ToString());
            }

            DataGridViewCheckBoxColumn checkBoxColumn = new DataGridViewCheckBoxColumn();

            checkBoxColumn.HeaderText = "Default";
            dataGridView1.Columns.Add(checkBoxColumn);

            DataGridViewTextBoxColumn fileExtentionNameColumn = new DataGridViewTextBoxColumn();

            fileExtentionNameColumn.HeaderText = "File Extention";
            dataGridView1.Columns.Add(fileExtentionNameColumn);

            DataGridViewComboBoxColumn highlightsComboBoxColumn = new DataGridViewComboBoxColumn();

            highlightsComboBoxColumn.DataSource    = new BindingSource(highligtsTable, null);
            highlightsComboBoxColumn.DisplayMember = "column1";
            highlightsComboBoxColumn.ValueMember   = "column1";
            dataGridView1.Columns.Add(highlightsComboBoxColumn);

            /*DataGridViewButtonColumn btn = new DataGridViewButtonColumn();
             * btn.HeaderText = "Click Data";
             * btn.Text = "Click Here";
             * btn.Name = "btn";
             * btn.HeaderText = "Delete";
             * btn.UseColumnTextForButtonValue = true;
             * dataGridView1.Columns.Add(btn);*/

            var privSavedExts           = previouslySavedMappings.Select(x => x.Extention);
            var filteredInputExtentions = formsInput.FileExtentions.Where(x => privSavedExts.Contains(x) == false);


            var defaultList = filteredInputExtentions
                              .Where(x => HighlightingManager.Instance.GetDefinitionByExtension(x) != null)
                              .OrderBy(x => x)
                              .ToList();

            var unknownList = filteredInputExtentions
                              .Where(x => HighlightingManager.Instance.GetDefinitionByExtension(x) == null)
                              .OrderBy(x => x)
                              .ToList();

            for (int i = 0; i < previouslySavedMappings.Count; i++)
            {
                CreateRow(false, previouslySavedMappings[i].Extention, previouslySavedMappings[i].HighlightMapping);
            }

            for (int i = 0; i < defaultList.Count; i++)
            {
                CreateRow(true, defaultList[i], HighlightingManager.Instance.GetDefinitionByExtension(defaultList[i]).ToString());
            }

            for (int i = 0; i < unknownList.Count; i++)
            {
                CreateRow(false, unknownList[i]);
            }

            dataGridView1.CellEnter += datagridview_CellEnter;
            dataGridView1.CurrentCellDirtyStateChanged += datagridview_CurrentCellDirtyStateChanged;
        }
Exemplo n.º 3
0
 public void Configure(SettingsFormInput input)
 {
     _settingsInput = input;
 }
 public FileExtentionSyntaxMappingForm(SettingsFormInput formsInput, List <CustomFileExtentionHighlightsMapping> previouslySavedMappings)
 {
     InitializeComponent();
     Create(formsInput, previouslySavedMappings);
 }