private void editTabMenuItem_Click(object sender, RoutedEventArgs e) { var tab = (Tab)(e.OriginalSource as MenuItem).DataContext; if (tab == null) { return; } NewTabDialog dialog = new NewTabDialog(); dialog.Title = "Edit Tab"; dialog.TabName = tab.Name; dialog.Rows = tab.Rows; dialog.Columns = tab.Columns; dialog.Owner = this; dialog.ShowDialog(); if (dialog.DialogResult == true) { tab.Name = dialog.TabName; if ((dialog.Rows != tab.Rows || dialog.Columns != tab.Columns) && MessageBox.Show(string.Format("Are you sure you want to resize \"{0}\"?\nYou will lose any unsaved changes.", tab.Name), "Edit Tab", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { tab.Rows = dialog.Rows; tab.Columns = dialog.Columns; tab.Destroy(); tab.Initialize(); } } }
private void newTabMenuItem_Click(object sender, RoutedEventArgs e) { NewTabDialog dialog = new NewTabDialog(); dialog.Owner = this; dialog.ShowDialog(); if (dialog.DialogResult == true) { string name = dialog.TabName; int rows = dialog.Rows; int cols = dialog.Columns; Tab tab = new Tab(name, rows, cols); Tabs.Add(tab); tabControl.SelectedItem = tab; } }