Пример #1
0
        /// <summary>
        /// Edit the selected text editor.
        /// </summary>
        /// <param name="sender">system parameter</param>
        /// <param name="e">system parameter</param>

        private void btnEdit_Click(object sender, System.EventArgs e)
        {
            if (tbcOptions.SelectedTab == tabTextEditors)
            {
                if (TextEditorsList.SelectedItems.Count > 0)
                {
                    ListViewItem         item = TextEditorsList.SelectedItems[0];
                    frmAddEditTextEditor dlg  = new frmAddEditTextEditor();

                    // set values
                    dlg.IsAdd             = false;
                    dlg.IsAllTypesDefined = IsAllTypesDefined();
                    dlg.Editor            = item.Tag as TextEditor;
                    dlg.ExistingFileTypes = GetExistingFileTypes();

                    if (dlg.ShowDialog(this) == DialogResult.OK)
                    {
                        // get values
                        TextEditorsList.SelectedItems[0].Tag              = dlg.Editor;
                        TextEditorsList.SelectedItems[0].Text             = dlg.Editor.FileType;
                        TextEditorsList.SelectedItems[0].SubItems[1].Text = dlg.Editor.Editor;
                        TextEditorsList.SelectedItems[0].SubItems[2].Text = dlg.Editor.Arguments;
                        TextEditorsList.SelectedItems[0].SubItems[3].Text = dlg.Editor.TabSize.ToString();
                    }

                    SetTextEditorsButtonState();
                }
            }

            this.DialogResult = DialogResult.None;
        }
Пример #2
0
        /// <summary>
        /// Add a new text editor.
        /// </summary>
        /// <param name="sender">system parameter</param>
        /// <param name="e">system parameter</param>

        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            if (tbcOptions.SelectedTab == tabTextEditors)
            {
                frmAddEditTextEditor dlg = new frmAddEditTextEditor();
                dlg.IsAdd             = true;
                dlg.IsAllTypesDefined = IsAllTypesDefined();
                dlg.ExistingFileTypes = GetExistingFileTypes();

                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    // create new entry
                    ListViewItem item = new ListViewItem();
                    item.Tag  = dlg.Editor;
                    item.Text = dlg.Editor.FileType;
                    item.SubItems.Add(dlg.Editor.Editor);
                    item.SubItems.Add(dlg.Editor.Arguments);
                    item.SubItems.Add(dlg.Editor.TabSize.ToString());
                    TextEditorsList.Items.Add(item);

                    SetTextEditorsButtonState();
                }
            }

            this.DialogResult = DialogResult.None;
        }