예제 #1
0
        public FormEditor(string[] files = null)
        {
            InitializeComponent();

            tabControl.ControlAdded += TabControl_ControlAddedOrRemoved;
            tabControl.ControlRemoved += TabControl_ControlAddedOrRemoved;
            tabControl.SelectedIndexChanged += (sender, arg) => f5Title();

            quitToolStripMenuItem.Click += (sender, arg) => Close();

            f5Buttons();

            if (files == null)
            {
                tabControl.Controls.Add(new Editor(this));
            }
            else
            {
                foreach (var file in files)
                {
                    var editor = new Editor(this);
                    if (editor.openFile(file))
                        tabControl.Controls.Add(editor);
                }
            }
        }
예제 #2
0
 private void openToolStripMenuItem_Click(object sender, EventArgs e)
 {
     var ofd = new OpenFileDialog();
     ofd.Filter = "文本文档|*.txt|所有文件|*.*";
     if (ofd.ShowDialog() == DialogResult.OK)
     {
         var editor = new Editor(this);
         editor.openFile(ofd.FileName);
         tabControl.Controls.Add(editor);
         tabControl.SelectedTab = editor;
     }
 }
예제 #3
0
 private void newToolStripMenuItem_Click(object sender, EventArgs e)
 {
     var tp = new Editor(this);
     tabControl.Controls.Add(tp);
     tabControl.SelectedTab = tp;
 }