private void Application_Idle(object sender, EventArgs e) { if (_startup) { _startup = false; string[] cmdLine = Environment.GetCommandLineArgs(); bool edit = false; foreach (string s in cmdLine) { if (s == "\\Edit") { edit = true; } } if (cmdLine.Length > 1) { OpenFile(cmdLine[1], !edit); } } ToolStripCommandHelper.SetEnabledProperties(_menuStrip); ToolStripCommandHelper.SetEnabledProperties(_toolbarStrip); _cancelToolStripMenuItem.Enabled = _resultsControl.IsQueryExecuting; if (_resultsControl.IsQueryFinished && _resultsControl.LastQueryError != null) { Exception exception = _resultsControl.LastQueryError; _resultsControl.LastQueryError = null; MessageBox.Show(this, exception.Message, _originalCaption); } }
public ClickAndQueryForm() { InitializeComponent(); new SelfRegisteringWatch(new ControlPreferences.FormWatch(this)); new SelfRegisteringWatch(new ControlPreferences.SplitContainerWatch(_splitContainer)); _recentFiles = new RecentFiles(_fileToolStripMenuItem, _recentFilesSeparator, RecentFileClickedHandler); // // Bind our commands to their menus new DelegateCommand(delegate { NewDocument(); }).Bind(_newToolStripMenuItem); new DelegateCommand(delegate { OpenFile(); }).Bind(_openToolStripMenuItem); new DelegateCommand(delegate { Save(); }).Bind(_saveToolStripMenuItem); new DelegateCommand(delegate { SaveAs(); }).Bind(_saveAsToolStripMenuItem); new DelegateCommand(delegate { Close(); }).Bind(_exitToolStripMenuItem); new DelegateCommand(delegate { CopyToClipboard(); }).Bind(_copyToolStripMenuItem); new DelegateCommand(delegate { ShowOptionsForm(); }).Bind(_optionsToolStripMenuItem); new DelegateCommand(delegate { ShowAboutForm(); }).Bind(_aboutToolStripMenuItem); new DelegateCommand(delegate { _resultsControl.CancelQuery(); }, delegate { return(_resultsControl.IsQueryExecuting); }).Bind(_cancelToolStripMenuItem); new DelegateCommand(delegate { _resultsControl.SizeColumnsToFit(); }).Bind(_sizeColumnsToFitToolStripMenuItem); new DelegateCommand(delegate { ExecuteQuery(); }, delegate { return(_document != null && _document.Query.Length > 0); }).Bind(_executeToolStripMenuItem); new DelegateCommand(delegate { ShowConnectionDetailsForm(); }).Bind(_connectionDetailsToolStripMenuItem); ToolStripCommandHelper.BindToolStripItems(_menuStrip, _toolbarStrip); UpdateCaption(); }