private void toolStripComboBoxDB_TextChanged(object sender, EventArgs e) { DbAccess.ChangeDBinConnectionString(toolStripComboBoxDB.Text); UserControlEditor ucE = tabControlMain.SelectedTab.Controls["UserControlEditor"] as UserControlEditor; ucE.CurrentDBName = toolStripComboBoxDB.Text; }
private void tabControlMain_MouseDown(object sender, MouseEventArgs e) { for (var i = 0; i < this.tabControlMain.TabPages.Count; i++) { var tabRect = this.tabControlMain.GetTabRect(i); tabRect.Inflate(-2, -2); var closeImage = new Bitmap(Properties.Resources.CloseBtn); var imageRect = new Rectangle( (tabRect.Right - closeImage.Width), tabRect.Top + (tabRect.Height - closeImage.Height) / 2, closeImage.Width, closeImage.Height); TabPage tp = tabControlMain.TabPages[i]; UserControlEditor ucE = tp.Controls["UserControlEditor"] as UserControlEditor; if (imageRect.Contains(e.Location)) { if (tp.Text[tp.Text.Trim().Length - 1] == '*') { switch (MessageBox.Show( String.Format("Sollen die Änderungen am folgenden Element: {0} gespeichert werden!", tp.Text.Remove(tp.Text.Trim().Length - 1)), "Schließung", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)) { case DialogResult.Yes: if (!SaveFile(tp)) { break; } listEditor.Remove(ucE); toolStripButtonAusfuhren.Enabled = listEditor.Count != 0; tabControlMain.TabPages.RemoveAt(i); break; case DialogResult.No: listEditor.Remove(ucE); tabControlMain.TabPages.RemoveAt(i); toolStripButtonAusfuhren.Enabled = listEditor.Count != 0; break; default: break; } } else { listEditor.Remove(ucE); toolStripButtonAusfuhren.Enabled = listEditor.Count != 0; tabControlMain.TabPages.RemoveAt(i); } } } }
private void NewQueryWindow(string fileName) { UserControlEditor ucEditor = new UserControlEditor(fileName); listEditor.Add(ucEditor); TabPage tp = new TabPage(Path.GetFileName(fileName) + " "); tp.Controls.Add(ucEditor); ucEditor.Dock = DockStyle.Fill; tabControlMain.TabPages.Add(tp); tabControlMain.SelectedTab = tp; toolStripComboBoxDB.Text = ucTree.CurrentDBName; ucEditor.CurrentDBName = toolStripComboBoxDB.Text; toolStripButtonAusfuhren.Enabled = true; ucEditor.Focus(); }
private bool SaveFile(TabPage tp) { UserControlEditor ucE = tp.Controls["UserControlEditor"] as UserControlEditor; string fileName = ucE.FileName; if (tp.Text[tp.Text.Trim().Length - 1] == '*') { if (!File.Exists(fileName)) { saveFileDialog.FileName = tp.Text.Remove(tp.Text.Trim().Length - 1); if (saveFileDialog.ShowDialog(this) == DialogResult.Cancel) { return(false); } fileName = saveFileDialog.FileName; } return(ucE.SaveFile(fileName)); } return(false); }
private void toolStripButtonAusfuhren_Click(object sender, EventArgs e) { UserControlEditor ucE = tabControlMain.SelectedTab.Controls["UserControlEditor"] as UserControlEditor; ucE.ExecSQL(); }