/// <summary> /// Save all files automatically. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AutoSave(object sender, EventArgs e) { foreach (TabPage tab in tabControl.TabPages) { EditorTab editorTab = tab as EditorTab; if (editorTab != null) { editorTab.AutoSave(); } } }
/// <summary> /// Save current file. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Save(object sender, EventArgs e) { if (tabControl.SelectedTab != null) { EditorTab tab = tabControl.SelectedTab as EditorTab; if (tab != null) { tab.SaveFile(); } } }
/// <summary> /// Choose font for current tab. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Format(object sender, EventArgs e) { if (tabControl.SelectedTab != null) { EditorTab tab = tabControl.SelectedTab as EditorTab; if (tab != null) { FontDialog dialog = new FontDialog(); dialog.Font = tab.editor.EditorTextBox.SelectionFont; dialog.ShowDialog(); tab.editor.EditorTextBox.SelectionFont = dialog.Font; } } }
/// <summary> /// Apply changes in ui colors. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NotepadForm_Activated(object sender, EventArgs e) { this.BackColor = settings.color3; this.ForeColor = settings.color2; foreach (Control item in this.Controls) { item.BackColor = settings.color3; item.ForeColor = settings.color2; } foreach (TabPage tab in tabControl.TabPages) { foreach (Control item in tab.Controls) { item.BackColor = settings.color1; item.ForeColor = settings.color2; } EditorTab editorTab = tab as EditorTab; if (editorTab != null) { editorTab.editor.EditorTextBox.BackColor = settings.color1; editorTab.editor.EditorTextBox.ForeColor = settings.color2; } } }
/// <summary> /// Create new tab. /// </summary> private void NewTab(object sender, EventArgs e) { EditorTab newTab = new EditorTab("Новый файл", settings); tabControl.TabPages.Add(newTab); }