PageRenderTime 82ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/Tools/LinqPad/LINQPad/UI/QueryControl.cs

https://github.com/vishalsh-spec/TestProject
C# | 5227 lines | 4971 code | 255 blank | 1 comment | 1166 complexity | f9b8f29f0fabf30d488ecc21c7e86f1b MD5 | raw file
Possible License(s): CC-BY-SA-3.0, LGPL-2.0, Apache-2.0
  1. namespace LINQPad.UI
  2. {
  3. using ActiproBridge;
  4. using ActiproSoftware.Drawing;
  5. using ActiproSoftware.SyntaxEditor;
  6. using ActiproSoftware.SyntaxEditor.Addons.CSharp;
  7. using ActiproSoftware.SyntaxEditor.Addons.DotNet.Ast;
  8. using LINQPad;
  9. using LINQPad.ExecutionModel;
  10. using LINQPad.Properties;
  11. using Microsoft.Win32;
  12. using mscorlib;
  13. using System;
  14. using System.CodeDom.Compiler;
  15. using System.Collections.Generic;
  16. using System.ComponentModel;
  17. using System.Diagnostics;
  18. using System.Drawing;
  19. using System.IO;
  20. using System.Linq;
  21. using System.Reflection;
  22. using System.Runtime.CompilerServices;
  23. using System.Runtime.InteropServices;
  24. using System.Text;
  25. using System.Text.RegularExpressions;
  26. using System.Threading;
  27. using System.Windows.Forms;
  28. using System.Xml.Linq;
  29. [ComVisible(true)]
  30. public class QueryControl : UserControl
  31. {
  32. private Timer _autoSaveTimer;
  33. private volatile bool _autoSaving;
  34. private bool? _autoScrollResultsFromQuery;
  35. private bool _browserHidden;
  36. private Timer _clockTimer;
  37. private bool _compileOnly;
  38. private List<BitmapBookmarkLineIndicator> _currentExecutionStack;
  39. private DataResultsWebBrowser _dataBrowser;
  40. private BrowserBorder _dataPanel;
  41. private DocumentManager _docMan;
  42. private QueryEditor _editor;
  43. private bool _enableUseCurrentDb;
  44. private Color? _errorSquigglyColor;
  45. private QueryLanguage _executingQueryLanguage;
  46. private bool _executingQueryOptimized;
  47. private Timer _executionTrackingTimer;
  48. private bool _firstExecutionTrack;
  49. private bool _firstResultsShow;
  50. private bool _gotPluginsReadyMessage;
  51. private volatile bool _gotQueryCompletionMessage;
  52. private Timer _ieComExceptionTimer;
  53. private ResultsWebBrowser _ilBrowser;
  54. private MemoryStream _ilData;
  55. private bool _ilDirty;
  56. private BrowserBorder _ilPanel;
  57. private ResultsWebBrowser _lambdaBrowser;
  58. private MemoryStream _lambdaData;
  59. private BrowserBorder _lambdaPanel;
  60. private bool? _lastAutoScrollResultsFromQuery;
  61. private QueryCompilationEventArgs _lastCompilation;
  62. private static string _lastDefaultQueryFolder;
  63. private int _lastExecutionLine;
  64. private int _lastExecutionLineCount;
  65. private ExecutionProgress? _lastExecutionProgress;
  66. private int _lastExecutionTrackCost1;
  67. private int _lastExecutionTrackCost2;
  68. private QueryLanguage _lastQueryKind;
  69. private string _lastRanSourceSelection;
  70. private static string _lastSaveFolder;
  71. private DateTime _lastServerAction;
  72. private ExecutionTrackInfo _lastTrackInfo;
  73. private long _memoryAtStart;
  74. private bool _modifiedWhenRunning;
  75. private MemoryStream _msData;
  76. private double _oldHorizontalSplitFraction;
  77. private double _oldVerticalSplitFraction;
  78. private bool _optimizeTipShown;
  79. private string _outputInfoMessage;
  80. private bool _pendingReflection;
  81. private bool _pendingResultsShow;
  82. private string _pendingSqlTranslation;
  83. private ContextMenuStrip _pluginWinButtonMenu;
  84. private List<ToolStripButton> _pluginWinButtons;
  85. private PluginWindowManager _pluginWinManager;
  86. private volatile bool _processingProvisionalData;
  87. private RunnableQuery _query;
  88. private int _queryCount;
  89. private int _querySelectionStartCol;
  90. private int _querySelectionStartRow;
  91. private Random _random;
  92. private ReadLinePanel _readLinePanel;
  93. private bool _readLinePanelVisible;
  94. private int _refreshTicksOnResults;
  95. private Timer _refreshTimer;
  96. private byte[] _resultsContent;
  97. private SchemaTree _schemaTree;
  98. private bool _splitterMovingViaToolStrip;
  99. private int _suppressPullCount;
  100. private bool _uberCancelMessage;
  101. private static bool _warnedAboutOptimizationTracking;
  102. private Color? _warningSquigglyColor;
  103. private ToolStripMenuItem btn1NestingLevel;
  104. private ToolStripMenuItem btn2NestingLevels;
  105. private ToolStripMenuItem btn3NestingLevels;
  106. private ToolStripButton btnActivateAutocompletion;
  107. private ToolStripMenuItem btnAllNestingLevels;
  108. private ToolStripDropDownButton btnAnalyze;
  109. private ToolStripDropDownButton btnArrange;
  110. private ImageButton btnCancel;
  111. private ClearButton btnClose;
  112. private ImageButton btnExecute;
  113. private ToolStripDropDownButton btnExport;
  114. private ToolStripMenuItem btnExportExcel;
  115. private ToolStripMenuItem btnExportExcelNoFormat;
  116. private ToolStripMenuItem btnExportHtml;
  117. private ToolStripMenuItem btnExportWord;
  118. private ToolStripMenuItem btnExportWordNoFormat;
  119. private ToolStripDropDownButton btnFormat;
  120. private ClearButton btnGrids;
  121. private ToolStripButton btnIL;
  122. private ToolStripButton btnLambda;
  123. private ClearButton btnPin;
  124. private ToolStripMenuItem btnResultFormattingPreferences;
  125. private ToolStripButton btnResults;
  126. private ToolStripButton btnSql;
  127. private ClearButton btnText;
  128. private ComboBox cboDb;
  129. private ComboBox cboLanguage;
  130. private IContainer components;
  131. private Label lblDb;
  132. private ToolStripStatusLabel lblElapsed;
  133. private ToolStripStatusLabel lblExecTime;
  134. private ToolStripStatusLabel lblFill;
  135. private ToolStripStatusLabel lblMiscStatus;
  136. private ToolStripStatusLabel lblOptimize;
  137. private ToolStripStatusLabel lblStatus;
  138. private Label lblSyncDb;
  139. private Label lblType;
  140. private ToolStripStatusLabel lblUberCancel;
  141. private FixedLinkLabel llDbUseCurrent;
  142. private ToolStripMenuItem miArrangeVertical;
  143. private ToolStripMenuItem miAutoScroll;
  144. private ToolStripMenuItem miHideResults;
  145. private ToolStripMenuItem miKeyboardShortcuts;
  146. private ToolStripMenuItem miOpenInSSMS;
  147. private ToolStripMenuItem miOpenSQLQueryNewTab;
  148. private ToolStripMenuItem miScrollEnd;
  149. private ToolStripMenuItem miScrollStart;
  150. private ToolStripMenuItem miUndock;
  151. private Panel panBottom;
  152. private Panel panCloseButton;
  153. private Panel panEditor;
  154. private Panel panError;
  155. private Panel panMain;
  156. private PanelEx panOutput;
  157. private Panel panTop;
  158. private TableLayoutPanel panTopControls;
  159. private ToolStripProgressBar queryProgressBar;
  160. private SplitContainer splitContainer;
  161. private StatusStrip statusStrip;
  162. private ToolStripSeparator toolStripMenuItem1;
  163. private ToolStripSeparator toolStripMenuItem2;
  164. private ToolStripSeparator toolStripMenuItem3;
  165. private ToolStripSeparator toolStripMenuItem4;
  166. private ToolStripSeparator toolStripSeparator1;
  167. private ToolTip toolTip;
  168. private ToolStripEx tsOutput;
  169. private TextBox txtError;
  170. private ActiproSoftware.SyntaxEditor.SyntaxEditor txtSQL;
  171. internal event EventHandler NextQueryRequest;
  172. internal event EventHandler PreviousQueryRequest;
  173. internal event EventHandler QueryClosed;
  174. internal QueryControl(RunnableQuery q, SchemaTree schemaTree)
  175. {
  176. EventHandler onClick = null;
  177. EventHandler handler2 = null;
  178. EventHandler handler3 = null;
  179. EventHandler handler4 = null;
  180. SplitterCancelEventHandler handler5 = null;
  181. this._browserHidden = true;
  182. Timer timer = new Timer {
  183. Interval = 0x2710,
  184. Enabled = true
  185. };
  186. this._autoSaveTimer = timer;
  187. this._executionTrackingTimer = new Timer();
  188. this._pluginWinButtons = new List<ToolStripButton>();
  189. this._query = new RunnableQuery();
  190. this.NextQueryRequest = delegate (object sender, EventArgs e) {
  191. };
  192. this.PreviousQueryRequest = delegate (object sender, EventArgs e) {
  193. };
  194. this._lambdaData = new MemoryStream();
  195. this._ilDirty = true;
  196. this._ilData = new MemoryStream();
  197. this._queryCount = 0;
  198. Timer timer2 = new Timer {
  199. Interval = 200
  200. };
  201. this._refreshTimer = timer2;
  202. Timer timer3 = new Timer {
  203. Interval = 200
  204. };
  205. this._clockTimer = timer3;
  206. this._firstResultsShow = true;
  207. this._lastQueryKind = QueryLanguage.SQL;
  208. this._suppressPullCount = 0;
  209. this._random = new Random();
  210. this.components = null;
  211. this._query = q;
  212. this._schemaTree = schemaTree;
  213. try
  214. {
  215. this.Font = FontManager.GetDefaultFont();
  216. }
  217. catch
  218. {
  219. }
  220. this.InitializeComponent();
  221. this.CheckIsMyExtensions();
  222. this._pluginWinManager = new PluginWindowManager(this);
  223. this._pluginWinButtonMenu = new ContextMenuStrip(this.components);
  224. if (onClick == null)
  225. {
  226. onClick = (sender, e) => this.CloseCurrentVisualizer();
  227. }
  228. this._pluginWinButtonMenu.Items.Add("Close visualizer (Shift+F4 or Middle-Click or Ctrl+Click)", Resources.Delete, onClick);
  229. if (this.btnExecute.Height > 0x20)
  230. {
  231. this.btnExecute.Height -= 3;
  232. this.cboLanguage.Margin = new Padding(this.cboLanguage.Margin.Left, 2, this.cboLanguage.Margin.Right, 4);
  233. this.cboDb.Margin = new Padding(this.cboDb.Margin.Left, 2, this.cboDb.Margin.Right, 4);
  234. }
  235. else if (this.btnExecute.Height > 0x1d)
  236. {
  237. this.btnExecute.Height -= 2;
  238. }
  239. else if (this.btnExecute.Height > 0x18)
  240. {
  241. this.btnExecute.Height--;
  242. }
  243. this.btnCancel.Height = this.btnExecute.Height;
  244. this.btnText.Height = this.btnGrids.Height = this.btnExecute.Height - 1;
  245. if ((IntPtr.Size == 4) && (this.btnExecute.Height > 0x1b))
  246. {
  247. Padding margin = this.cboLanguage.Margin;
  248. this.cboLanguage.Margin = new Padding(margin.Left, margin.Top, margin.Right, margin.Bottom - 1);
  249. margin = this.cboDb.Margin;
  250. this.cboDb.Margin = new Padding(margin.Left, margin.Top, margin.Right, margin.Bottom - 1);
  251. }
  252. if (this.btnExecute.Height > 40)
  253. {
  254. this.btnExecute.Image = ControlUtil.ResizeImage(this.btnExecute.Image, this.btnExecute.Width, this.btnExecute.Height, true);
  255. this.btnCancel.Image = ControlUtil.ResizeImage(this.btnCancel.Image, this.btnCancel.Width, this.btnCancel.Height, true);
  256. this.btnGrids.Image = ControlUtil.ResizeImage(this.btnGrids.Image, (this.btnGrids.Width * 3) / 4, (this.btnGrids.Height * 3) / 4, true);
  257. this.btnText.Image = ControlUtil.ResizeImage(this.btnText.Image, (this.btnText.Width * 3) / 4, (this.btnText.Height * 3) / 4, true);
  258. }
  259. this.UpdateAutocompletionMsg();
  260. try
  261. {
  262. this.txtError.Font = new Font("Verdana", 8.25f);
  263. this.txtSQL.Font = new Font("Verdana", 9.5f);
  264. this.btnActivateAutocompletion.Font = new Font("Verdana", 8f, FontStyle.Bold);
  265. this.lblOptimize.Font = new Font("Verdana", 7f, FontStyle.Bold);
  266. }
  267. catch
  268. {
  269. }
  270. this.txtSQL.get_Document().set_Language(DocumentManager.GetDynamicLanguage("SQL", SystemColors.Window.GetBrightness()));
  271. this.txtSQL.get_Document().get_Outlining().set_Mode(2);
  272. this.txtSQL.set_BracketHighlightingVisible(true);
  273. this.txtSQL.get_Document().set_ReadOnly(true);
  274. VisualStudio2005SyntaxEditorRenderer renderer = new VisualStudio2005SyntaxEditorRenderer();
  275. SimpleBorder border = new SimpleBorder();
  276. border.set_Style(0);
  277. renderer.set_Border(border);
  278. VisualStudio2005SyntaxEditorRenderer renderer2 = renderer;
  279. this.txtSQL.set_Renderer(renderer2);
  280. this._docMan = new DocumentManager(this._query, this);
  281. this.CreateEditor();
  282. this.PropagateOptions();
  283. this.UpdateEditorZoom();
  284. this.CreateBrowser();
  285. this._browserHidden = true;
  286. this.panBottom.BorderStyle = BorderStyle.None;
  287. this.tsOutput.BackColor = Color.Transparent;
  288. this.tsOutput.Renderer = new OutputToolsRenderer();
  289. this.statusStrip.BackColor = Color.Transparent;
  290. this.statusStrip.Padding = new Padding(this.statusStrip.Padding.Left, this.statusStrip.Padding.Top, this.statusStrip.Padding.Left, this.statusStrip.Padding.Bottom);
  291. this.PullData(QueryChangedEventArgs.Refresh);
  292. this.ToggleResultsCollapse();
  293. this._query.QueryCompiled += new EventHandler<QueryCompilationEventArgs>(this._query_QueryCompiled);
  294. this._query.PluginsReady += new EventHandler(this._query_PluginsReady);
  295. this._query.CustomClickCompleted += new EventHandler(this._query_CustomClickCompleted);
  296. this._query.QueryCompleted += new EventHandler<QueryStatusEventArgs>(this._query_QueryCompleted);
  297. this._query.QueryChanged += new EventHandler<QueryChangedEventArgs>(this._query_QueryChanged);
  298. this._query.ReadLineRequested += new EventHandler<ReadLineEventArgs>(this._query_ReadLineRequested);
  299. this._editor.TextChanged += new EventHandler(this._editor_TextChanged);
  300. this._editor.add_SelectionChanged(new SelectionEventHandler(this, (IntPtr) this._editor_SelectionChanged));
  301. this._editor.RepositoryDropped += new EventHandler<QueryEditor.RepositoryEventArgs>(this._editor_RepositoryDropped);
  302. this._schemaTree.AfterSelect += new TreeViewEventHandler(this._schemaTree_AfterSelect);
  303. this._docMan.CheckForRepositoryChange();
  304. this._refreshTimer.Tick += new EventHandler(this.RefreshTimer_Tick);
  305. this._clockTimer.Tick += new EventHandler(this.ClockTimer_Tick);
  306. this._autoSaveTimer.Tick += new EventHandler(this.AutoSaveTimer_Tick);
  307. if (handler2 == null)
  308. {
  309. handler2 = (sender, e) => this.ReportMainThreadPosition();
  310. }
  311. this._executionTrackingTimer.Tick += handler2;
  312. if (SystemColors.Window.GetBrightness() < 0.5f)
  313. {
  314. this.llDbUseCurrent.ForeColor = SystemColors.HotTrack;
  315. }
  316. this.ExtendOutputSplitter();
  317. if (handler3 == null)
  318. {
  319. handler3 = (sender, e) => this.UpdateErrorHeight();
  320. }
  321. this.panError.SizeChanged += handler3;
  322. this.statusStrip.Parent = null;
  323. base.Controls.Add(this.statusStrip);
  324. this.statusStrip.SendToBack();
  325. if (handler4 == null)
  326. {
  327. handler4 = (sender, e) => this.RequestWinManagerRelocation();
  328. }
  329. EventHandler handler6 = handler4;
  330. this.panOutput.Resize += handler6;
  331. for (Control control = this.panOutput; control != null; control = control.Parent)
  332. {
  333. control.Move += handler6;
  334. }
  335. this._query.PluginWindowManager = this._pluginWinManager;
  336. this.queryProgressBar.Margin = new Padding(3, 3, 0, 1);
  337. this.tsOutput.Padding = new Padding(0, 0, 0, 2);
  338. this.splitContainer.SplitterWidth--;
  339. if (handler5 == null)
  340. {
  341. handler5 = delegate (object sender, SplitterCancelEventArgs e) {
  342. if (Control.MouseButtons == MouseButtons.Left)
  343. {
  344. MainForm.Instance.IsSplitting = true;
  345. }
  346. if ((this.panOutput.BackColor == MainForm.Instance.TransparencyKey) && (this.panOutput.BackColor != Program.LightTransparencyKey))
  347. {
  348. this.panOutput.BackColor = MainForm.Instance.TransparencyKey = Program.LightTransparencyKey;
  349. }
  350. };
  351. }
  352. this.splitContainer.SplitterMoving += handler5;
  353. this.panOutput.BorderStyle = BorderStyle.None;
  354. this.panOutput.BorderColor = Color.FromArgb(160, 160, 160);
  355. this.lblSyncDb.Cursor = Cursors.Hand;
  356. this.toolTip.ShowAlways = true;
  357. this.EnableControls();
  358. this.panBottom.Layout += new LayoutEventHandler(this.panBottom_Layout);
  359. }
  360. private void _browser_LinqClicked(object sender, LinqClickEventArgs e)
  361. {
  362. WebHelper.LaunchBrowser(e.Uri.ToString());
  363. }
  364. private void _browser_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
  365. {
  366. if (e.KeyData == Keys.F5)
  367. {
  368. e.IsInputKey = true;
  369. this.Run();
  370. }
  371. else if (e.KeyData == (Keys.Control | Keys.Shift | Keys.E))
  372. {
  373. MainForm.Instance.ToggleAutoScrollResults(true);
  374. }
  375. }
  376. private void _editor_RepositoryDropped(object sender, QueryEditor.RepositoryEventArgs e)
  377. {
  378. Func<LinkedDatabase, bool> predicate = null;
  379. if (!this._query.IsMyExtensions)
  380. {
  381. this.CheckToFromProgramLanguage(this._query.QueryKind, this._query.QueryKind, this._query.Repository != null, e.Repository != null);
  382. if (!((this._query.Repository != null) && e.Copy))
  383. {
  384. this._query.Repository = e.Repository;
  385. }
  386. else
  387. {
  388. if ((!e.Repository.IsSqlServer || !this._query.Repository.IsSqlServer) || (e.Repository.Server.ToLowerInvariant() != this._query.Repository.Server.ToLowerInvariant()))
  389. {
  390. MessageBox.Show("Multi-database queries are supported only for SQL Server databases on the same server (or linked servers).", "LINQPad", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  391. return;
  392. }
  393. if (this._query.Repository.IsAzure || e.Repository.IsAzure)
  394. {
  395. MessageBox.Show("SQL Azure does not permit cross-database queries.", "LINQPad", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  396. return;
  397. }
  398. if (this._query.Repository.Database == e.Repository.Database)
  399. {
  400. return;
  401. }
  402. if (predicate == null)
  403. {
  404. predicate = d => string.IsNullOrEmpty(d.Server) && (d.Database == e.Repository.Database);
  405. }
  406. if (this._query.Repository.LinkedDatabases.Any<LinkedDatabase>(predicate))
  407. {
  408. return;
  409. }
  410. if (this._query.Repository.Parent != null)
  411. {
  412. Repository r = this._query.Repository.Clone();
  413. r.ID = Guid.NewGuid();
  414. r.ShowServer = false;
  415. r.Persist = false;
  416. r.LinkedDatabases = r.LinkedDatabases.Concat<LinkedDatabase>(new LinkedDatabase[] { new LinkedDatabase(e.Repository.Database) });
  417. this._schemaTree.AddCx(r, false, false);
  418. this._query.Repository = r;
  419. }
  420. else
  421. {
  422. this._query.Repository.LinkedDatabases = this._query.Repository.LinkedDatabases.Concat<LinkedDatabase>(new LinkedDatabase[] { new LinkedDatabase(e.Repository.Database) });
  423. this._schemaTree.UpdateRepository(this._query.Repository);
  424. }
  425. }
  426. this._editor.Focus();
  427. }
  428. }
  429. private void _editor_SelectionChanged(object sender, EventArgs e)
  430. {
  431. this.ClearQueryHighlight();
  432. if (this._docMan.ExecutedSelectionLayer.get_Count() > 0)
  433. {
  434. this._docMan.ExecutedSelectionLayer.Clear();
  435. }
  436. }
  437. private void _editor_TextChanged(object sender, EventArgs e)
  438. {
  439. this._modifiedWhenRunning = true;
  440. using (this.SuppressPull())
  441. {
  442. this._query.Source = this._editor.Text;
  443. }
  444. this.btnPin.Checked = this._query.Pinned;
  445. this.ClearQueryHighlight();
  446. if (this._docMan.StackTraceLayer.get_Count() > 0)
  447. {
  448. this._docMan.StackTraceLayer.Clear();
  449. }
  450. this.ClearExecutionTrackingIndicators();
  451. }
  452. private void _query_CustomClickCompleted(object sender, EventArgs e)
  453. {
  454. this._outputInfoMessage = null;
  455. }
  456. private void _query_PluginsReady(object sender, EventArgs e)
  457. {
  458. this.BeginInvoke(delegate {
  459. this._gotPluginsReadyMessage = true;
  460. foreach (PluginControl control in this._pluginWinManager.GetControls())
  461. {
  462. this.CreatePluginWinButton(control, false, false);
  463. }
  464. if (this._pluginWinButtons.Any<ToolStripButton>())
  465. {
  466. bool flag = MainForm.Instance.CurrentQueryControl == this;
  467. if (this.btnResults.Checked && !this.panError.Visible)
  468. {
  469. if (flag)
  470. {
  471. base.FindForm().Activate();
  472. }
  473. this.SelectOutputPanel(this._pluginWinButtons[0], false);
  474. }
  475. else
  476. {
  477. this.UpdateOutputToolStripLayout();
  478. }
  479. if (flag)
  480. {
  481. base.FindForm().Activate();
  482. }
  483. else
  484. {
  485. this._pluginWinManager.Hide();
  486. }
  487. }
  488. });
  489. }
  490. private void _query_QueryChanged(object sender, QueryChangedEventArgs e)
  491. {
  492. this.KillIEComExceptionTimer();
  493. this.PullData(e);
  494. }
  495. private void _query_QueryCompiled(object sender, QueryCompilationEventArgs e)
  496. {
  497. this.BeginInvoke(delegate {
  498. try
  499. {
  500. this.QueryCompiled(e);
  501. }
  502. catch (Exception exception)
  503. {
  504. Program.ProcessException(exception);
  505. }
  506. });
  507. }
  508. private void _query_QueryCompleted(object sender, QueryStatusEventArgs e)
  509. {
  510. if (e.ExecutionComplete)
  511. {
  512. this._clockTimer.Stop();
  513. }
  514. this.BeginInvoke(() => this.QueryCompleted(e));
  515. }
  516. private void _query_ReadLineRequested(object sender, ReadLineEventArgs e)
  517. {
  518. int num = this._queryCount;
  519. while (this._readLinePanelVisible)
  520. {
  521. Thread.Sleep(100);
  522. if (this._queryCount != num)
  523. {
  524. return;
  525. }
  526. }
  527. base.BeginInvoke(() => this.ShowReadLinePanel(e.Client, e.Prompt, e.DefaultValue, e.Options));
  528. }
  529. private void _schemaTree_AfterSelect(object sender, TreeViewEventArgs e)
  530. {
  531. this.UpdateFocusedRepository();
  532. }
  533. internal void ActivateAndKillDomain()
  534. {
  535. base.FindForm().Activate();
  536. Program.RunOnWinFormsTimer(() => this.Cancel(true), 0x7d0);
  537. }
  538. internal void ActivateHelp()
  539. {
  540. if (!(MainForm.Instance.ShowLicensee || !(this._editor.get_SelectedView().get_SelectedText() == "")))
  541. {
  542. MessageBox.Show("This feature requires an Autocompletion license.", "LINQPad", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  543. }
  544. else
  545. {
  546. MemberHelpInfo memberHelpInfo = this.GetMemberHelpInfo();
  547. string str = ((memberHelpInfo == null) || !memberHelpInfo.HasStrongName) ? null : memberHelpInfo.get_HelpSearchString();
  548. if (string.IsNullOrEmpty(str))
  549. {
  550. str = (this._editor.get_SelectedView().get_SelectedText() ?? "").Trim();
  551. if (str.Length == 0)
  552. {
  553. return;
  554. }
  555. if (this._query.QueryKind <= QueryLanguage.Program)
  556. {
  557. str = "C# " + str;
  558. }
  559. else if (this._query.QueryKind.ToString().StartsWith("VB"))
  560. {
  561. str = "VB " + str;
  562. }
  563. else if (this._query.QueryKind.ToString().StartsWith("FSharp"))
  564. {
  565. str = "F# " + str;
  566. }
  567. else if (this._query.QueryKind == QueryLanguage.SQL)
  568. {
  569. str = "\"SQL Server\" " + str;
  570. }
  571. else
  572. {
  573. str = this._query.QueryKind + " " + str;
  574. }
  575. }
  576. WebHelper.LaunchBrowser("http://www.google.com/search?hl=en&q=" + Uri.EscapeDataString(str));
  577. }
  578. }
  579. public void ActivateReflector()
  580. {
  581. if (!MainForm.Instance.ShowLicensee)
  582. {
  583. MessageBox.Show("This feature requires an Autocompletion license.", "LINQPad", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  584. }
  585. else
  586. {
  587. MemberHelpInfo memberHelpInfo = this.GetMemberHelpInfo();
  588. if ((memberHelpInfo != null) && !string.IsNullOrEmpty(memberHelpInfo.get_ReflectorCodeUri()))
  589. {
  590. ReflectorAgent.ActivateReflector(memberHelpInfo);
  591. }
  592. }
  593. }
  594. internal void AncestorMoved()
  595. {
  596. this.RequestWinManagerRelocation();
  597. }
  598. internal bool AreResultsCollapsed()
  599. {
  600. return (this.panEditor.Parent == this.panMain);
  601. }
  602. internal bool AreResultsDetached()
  603. {
  604. return (this.panBottom.Parent != this.splitContainer.Panel2);
  605. }
  606. internal bool AreResultsVisible()
  607. {
  608. return (!this.AreResultsCollapsed() || this.AreResultsDetached());
  609. }
  610. internal void AttachResultsControl(Control c)
  611. {
  612. c.Parent = this.splitContainer.Panel2;
  613. if (this.AreResultsCollapsed())
  614. {
  615. this.ToggleResultsCollapse();
  616. }
  617. this.UpdateOutputVisibility();
  618. }
  619. private void AutoSaveTimer_Tick(object sender, EventArgs e)
  620. {
  621. if (!base.IsDisposed && !(!this._query.IsModified || this._autoSaving))
  622. {
  623. ThreadPool.QueueUserWorkItem(delegate (object param0) {
  624. if (!this._autoSaving)
  625. {
  626. this._autoSaving = true;
  627. try
  628. {
  629. this._query.AutoSave(false);
  630. }
  631. catch
  632. {
  633. }
  634. finally
  635. {
  636. this._autoSaving = false;
  637. }
  638. }
  639. });
  640. }
  641. }
  642. private void BeginInvoke(Action a)
  643. {
  644. base.BeginInvoke(a);
  645. }
  646. private void btn1NestingLevel_Click(object sender, EventArgs e)
  647. {
  648. this.CollapseResultsTo(1);
  649. }
  650. private void btn2NestingLevels_Click(object sender, EventArgs e)
  651. {
  652. this.CollapseResultsTo(2);
  653. }
  654. private void btn3NestingLevels_Click(object sender, EventArgs e)
  655. {
  656. this.CollapseResultsTo(3);
  657. }
  658. private void btnActivateAutocompletion_Click(object sender, EventArgs e)
  659. {
  660. MainForm.Instance.ActivateAutocompletion();
  661. }
  662. private void btnAllNestingLevels_Click(object sender, EventArgs e)
  663. {
  664. this.CollapseResultsTo(null);
  665. }
  666. private void btnArrange_DropDownOpening(object sender, EventArgs e)
  667. {
  668. this.miUndock.Checked = MainForm.Instance.ResultsDockForm.AreResultsTorn;
  669. this.miArrangeVertical.Checked = MainForm.Instance.VerticalResultsLayout;
  670. this.miUndock.Enabled = MainForm.Instance.ResultsDockForm.AreResultsTorn || (Screen.AllScreens.Length > 1);
  671. this.miAutoScroll.Checked = MainForm.Instance.AutoScrollResults;
  672. }
  673. private void btnCancel_Click(object sender, EventArgs e)
  674. {
  675. this.Cancel(false);
  676. this._editor.Focus();
  677. }
  678. private void btnClose_Click(object sender, EventArgs e)
  679. {
  680. this.TryClose();
  681. }
  682. private void btnExecute_Click(object sender, EventArgs e)
  683. {
  684. this.Run();
  685. }
  686. private void btnExpandTypes_CheckedChanged(object sender, EventArgs e)
  687. {
  688. }
  689. private void btnExportExcel_Click(object sender, EventArgs e)
  690. {
  691. if ((this._msData != null) && (this._msData.Length > 0L))
  692. {
  693. this.OpenExcel(this.ExportResults(false));
  694. }
  695. }
  696. private void btnExportExcelNoFormat_Click(object sender, EventArgs e)
  697. {
  698. if ((this._msData != null) && (this._msData.Length > 0L))
  699. {
  700. this.OpenExcel(this.ExportResults(true));
  701. }
  702. }
  703. private void btnExportHtml_Click(object sender, EventArgs e)
  704. {
  705. if ((this._msData != null) && (this._msData.Length != 0L))
  706. {
  707. using (SaveFileDialog dialog = new SaveFileDialog())
  708. {
  709. dialog.Title = "Save Results";
  710. dialog.DefaultExt = "html";
  711. dialog.Filter = "HTML files (*.html)|*.html";
  712. if ((dialog.ShowDialog() == DialogResult.OK) && !string.IsNullOrEmpty(dialog.FileName))
  713. {
  714. try
  715. {
  716. using (FileStream stream = File.Create(dialog.FileName))
  717. {
  718. this._msData.WriteTo(stream);
  719. }
  720. }
  721. catch (Exception exception)
  722. {
  723. MessageBox.Show("Cannot write file: " + exception.Message);
  724. }
  725. }
  726. }
  727. }
  728. }
  729. private void btnExportWord_Click(object sender, EventArgs e)
  730. {
  731. if ((this._msData != null) && (this._msData.Length > 0L))
  732. {
  733. this.OpenWord(this.ExportResults(false));
  734. }
  735. }
  736. private void btnExportWordNoFormat_Click(object sender, EventArgs e)
  737. {
  738. if ((this._msData != null) && (this._msData.Length > 0L))
  739. {
  740. this.OpenWord(this.ExportResults(true));
  741. }
  742. }
  743. private void btnGrids_Click(object sender, EventArgs e)
  744. {
  745. this._query.ToDataGrids = true;
  746. }
  747. private void btnIL_Click(object sender, EventArgs e)
  748. {
  749. this.SelectILPanel(true);
  750. }
  751. private void btnLambda_Click(object sender, EventArgs e)
  752. {
  753. this.SelectLambdaPanel(true);
  754. }
  755. private void btnPin_Click(object sender, EventArgs e)
  756. {
  757. this._query.Pinned = !this._query.Pinned;
  758. }
  759. private void btnResultFormattingPreferences_Click(object sender, EventArgs e)
  760. {
  761. using (OptionsForm form = new OptionsForm(2))
  762. {
  763. if (form.ShowDialog(MainForm.Instance) == DialogResult.OK)
  764. {
  765. this.PropagateOptions();
  766. }
  767. }
  768. }
  769. private void btnResults_Click(object sender, EventArgs e)
  770. {
  771. this.SelectResultsPanel(true);
  772. }
  773. private void btnSql_Click(object sender, EventArgs e)
  774. {
  775. this.SelectSqlPanel(true);
  776. }
  777. private void btnText_Click(object sender, EventArgs e)
  778. {
  779. this._query.ToDataGrids = false;
  780. }
  781. internal void Cancel(bool uberMode)
  782. {
  783. if (!base.IsDisposed)
  784. {
  785. this._outputInfoMessage = null;
  786. this._executionTrackingTimer.Stop();
  787. this.ClearExecutionTrackingIndicators();
  788. if (this._editor.get_Document().get_LineIndicators().get_Count() == 0)
  789. {
  790. this._editor.set_IndicatorMarginVisible(false);
  791. }
  792. if ((((this._query.QueryKind != QueryLanguage.SQL) && (this._query.QueryKind != QueryLanguage.ESQL)) || this.btnCancel.Enabled) || uberMode)
  793. {
  794. this.HideReadLinePanel();
  795. this._pendingReflection = false;
  796. if (!((uberMode || Program.PreserveAppDomains) || this._query.IsRunning))
  797. {
  798. uberMode = true;
  799. }
  800. if (uberMode)
  801. {
  802. this.ResetPluginManager(true);
  803. this._query.Cancel(false, true);
  804. }
  805. else
  806. {
  807. this._query.Cancel(true, false);
  808. }
  809. if (this.btnCancel.Enabled || uberMode)
  810. {
  811. this.EnableControls();
  812. this.lblElapsed.Visible = false;
  813. this.lblStatus.Text = uberMode ? "Application Domain Unloaded" : "Query canceled";
  814. this.lblUberCancel.Visible = false;
  815. }
  816. }
  817. }
  818. }
  819. private void cboDb_DropDown(object sender, EventArgs e)
  820. {
  821. int num;
  822. this.UpdateRepositoryItems(true);
  823. Func<object, float> selector = null;
  824. using (Graphics g = this.cboDb.CreateGraphics())
  825. {
  826. if (selector == null)
  827. {
  828. selector = item => g.MeasureString(item.ToString(), this.cboDb.Font).Width;
  829. }
  830. num = (((int) this.cboDb.Items.Cast<object>().Max<object>(selector)) + SystemInformation.VerticalScrollBarWidth) + 2;
  831. }
  832. Rectangle workingArea = Screen.FromControl(this.cboDb).WorkingArea;
  833. this.cboDb.DropDownWidth = Math.Max(this.cboDb.Width, Math.Min((workingArea.Right - this.cboDb.PointToScreen(Point.Empty).X) - 3, num));
  834. }
  835. private void cboDb_DropDownClosed(object sender, EventArgs e)
  836. {
  837. this._editor.Focus();
  838. }
  839. private void cboDb_Enter(object sender, EventArgs e)
  840. {
  841. if (Control.ModifierKeys == Keys.Alt)
  842. {
  843. this.cboDb.DroppedDown = true;
  844. }
  845. }
  846. private void cboDb_SelectedIndexChanged(object sender, EventArgs e)
  847. {
  848. if (this.cboDb.SelectedItem != null)
  849. {
  850. using (this.SuppressPull())
  851. {
  852. this.CheckToFromProgramLanguage();
  853. if (this.cboDb.SelectedItem is string)
  854. {
  855. if ((((string) this.cboDb.SelectedItem) == "<None>") && (this._query.Repository != null))
  856. {
  857. this._query.Repository = null;
  858. }
  859. else
  860. {
  861. this.cboDb.SelectedIndex = 0;
  862. }
  863. }
  864. Repository selectedItem = this.cboDb.SelectedItem as Repository;
  865. if (selectedItem != null)
  866. {
  867. this._query.Repository = selectedItem;
  868. }
  869. this.lblSyncDb.Visible = this._query.Repository != null;
  870. }
  871. this.btnPin.Checked = this._query.Pinned;
  872. this.UpdateFocusedRepository();
  873. this._docMan.CheckForRepositoryChange();
  874. this._schemaTree.UpdateSqlMode(this._query);
  875. }
  876. }
  877. private void cboLanguage_SelectionChangeCommitted(object sender, EventArgs e)
  878. {
  879. this.CheckToFromProgramLanguage();
  880. this._schemaTree.UpdateSqlMode(this._query);
  881. }
  882. private void cboType_DropDownClosed(object sender, EventArgs e)
  883. {
  884. this._editor.Focus();
  885. }
  886. private void cboType_Enter(object sender, EventArgs e)
  887. {
  888. if (Control.ModifierKeys == Keys.Alt)
  889. {
  890. this.cboLanguage.DroppedDown = true;
  891. }
  892. }
  893. private void cboType_SelectedIndexChanged(object sender, EventArgs e)
  894. {
  895. if (this._editor.get_IntelliPrompt().get_MemberList().get_Visible())
  896. {
  897. this._editor.get_IntelliPrompt().get_MemberList().Abort();
  898. }
  899. QueryLanguage language = this.IndexToQueryLanguage(this.cboLanguage.SelectedIndex);
  900. if (language != this._query.QueryKind)
  901. {
  902. this._query.QueryKind = language;
  903. }
  904. }
  905. private bool CheckAndPromptQueryDriver()
  906. {
  907. if ((this._query.Repository == null) || this._query.Repository.DriverLoader.IsValid)
  908. {
  909. return true;
  910. }
  911. if (MessageBox.Show("The database for this query relies on the following custom driver which has not been installed:\r\n\r\n " + this._query.Repository.DriverLoader.SimpleAssemblyName + " (" + this._query.Repository.DriverLoader.PublicKeyToken + ")\r\n\r\nWould you like to view the publicly available drivers?", "LINQPad", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  912. {
  913. using (BrowseDriversForm form = new BrowseDriversForm(true))
  914. {
  915. form.ShowDialog(MainForm.Instance);
  916. if (form.DoRestart)
  917. {
  918. MainForm.Instance.Restart();
  919. }
  920. }
  921. }
  922. return false;
  923. }
  924. internal void CheckAutocompletionCache()
  925. {
  926. this._docMan.ConfigureResolver();
  927. }
  928. private void CheckIsMyExtensions()
  929. {
  930. if (this._query.IsMyExtensions)
  931. {
  932. if (this.cboLanguage.Items.Count > 1)
  933. {
  934. this.cboLanguage.Items.Clear();
  935. this.cboLanguage.Items.Add("C# Program");
  936. }
  937. this.cboDb.Enabled = false;
  938. }
  939. }
  940. private void CheckQueryRepositoryWithSchemaTree()
  941. {
  942. if ((this._query.Repository != null) && (this._query.Repository != this._schemaTree.GetCurrentRepository(true)))
  943. {
  944. bool isModified = this._query.IsModified;
  945. this._schemaTree.RegisterRepository(this._query, false, false);
  946. if (!(isModified || !this._query.IsModified))
  947. {
  948. this._query.IsModified = false;
  949. }
  950. }
  951. }
  952. internal void CheckToFromProgramLanguage()
  953. {
  954. this.CheckToFromProgramLanguage(this._query.QueryKind, this.IndexToQueryLanguage(this.cboLanguage.SelectedIndex), this._query.Repository != null, this.cboDb.SelectedIndex > 0);
  955. }
  956. internal void CheckToFromProgramLanguage(QueryLanguage oldLanguage, QueryLanguage newLanguage, bool oldDC, bool newDC)
  957. {
  958. string str2;
  959. bool flag = (oldLanguage == QueryLanguage.FSharpProgram) && oldDC;
  960. bool flag2 = (newLanguage == QueryLanguage.FSharpProgram) && newDC;
  961. string str = UserOptions.Instance.ConvertTabsToSpaces ? "".PadRight(UserOptions.Instance.TabSizeActual) : "\t";
  962. if ((oldLanguage == QueryLanguage.Program) && (newLanguage != QueryLanguage.Program))
  963. {
  964. if (this._editor.Text.StartsWith("void Main", StringComparison.Ordinal) && this._editor.Text.TrimEnd(new char[0]).EndsWith("// Define other methods and classes here", StringComparison.Ordinal))
  965. {
  966. str2 = Regex.Replace(Regex.Replace(this._editor.Text, @"^void Main\s*\(\s*\)\s*{\s*", ""), @"\s*}\s*// Define other methods and classes here\s*$", "").Replace("\n" + str, "\n");
  967. this._editor.Text = str2;
  968. }
  969. }
  970. else if ((oldLanguage == QueryLanguage.VBProgram) && (newLanguage != QueryLanguage.VBProgram))
  971. {
  972. if (this._editor.Text.StartsWith("Sub Main", StringComparison.OrdinalIgnoreCase) && this._editor.Text.TrimEnd(new char[0]).EndsWith("' Define other methods and classes here", StringComparison.OrdinalIgnoreCase))
  973. {
  974. str2 = Regex.Replace(Regex.Replace(this._editor.Text, @"^Sub Main\s*", "", RegexOptions.IgnoreCase), @"\s*End Sub\s*' Define other methods and classes here\s*$", "", RegexOptions.IgnoreCase).Replace("\n" + str, "\n");
  975. this._editor.Text = str2;
  976. }
  977. }
  978. else if (!(!flag || flag2) && this._editor.Text.StartsWith("let dc = new TypedDataContext()", StringComparison.Ordinal))
  979. {
  980. this._editor.Text = this._editor.Text.Substring("let dc = new TypedDataContext()".Length).TrimStart(new char[0]);
  981. }
  982. if ((oldLanguage != QueryLanguage.Program) && (newLanguage == QueryLanguage.Program))
  983. {
  984. if (!((this._editor.Text.Contains("void Main") || this._editor.Text.ToUpperInvariant().Contains("SUB MAIN")) || this._editor.Text.Contains("Task Main")))
  985. {
  986. this._editor.Text = "void Main()\n{\n" + str + this._query.Source.Replace("\n", "\n" + str) + "\n}\n\n// Define other methods and classes here\n";
  987. this._editor.get_SelectedView().get_Selection().set_TextRange(new TextRange(14 + str.Length));
  988. }
  989. }
  990. else if ((oldLanguage != QueryLanguage.VBProgram) && (newLanguage == QueryLanguage.VBProgram))
  991. {
  992. if (!(this._editor.Text.ToUpperInvariant().Contains("SUB MAIN") || this._editor.Text.Contains("void Main")))
  993. {
  994. this._editor.Text = "Sub Main\n" + str + this._query.Source.Replace("\n", "\n" + str) + "\nEnd Sub\n\n' Define other methods and classes here\n";
  995. this._editor.get_SelectedView().get_Selection().set_TextRange(new TextRange(9 + str.Length));
  996. }
  997. }
  998. else if (!(flag || !flag2) && !this._editor.Text.Contains("let dc = new TypedDataContext()"))
  999. {
  1000. this._editor.Text = "let dc = new TypedDataContext()\r\n\r\n" + this._query.Source;
  1001. this._editor.get_SelectedView().get_Selection().set_TextRange(new TextRange("let dc = new TypedDataContext()".Length + 2));
  1002. }
  1003. }
  1004. private void ClearExecutionTrackingIndicators()
  1005. {
  1006. if (this._currentExecutionStack != null)
  1007. {
  1008. foreach (BitmapBookmarkLineIndicator indicator in this._currentExecutionStack)
  1009. {
  1010. this._editor.get_Document().get_LineIndicators().Remove(indicator);
  1011. }
  1012. this._currentExecutionStack = null;
  1013. }
  1014. }
  1015. private void ClearQueryHighlight()
  1016. {
  1017. if (this._editor.get_CurrentLineHighlightingVisible())
  1018. {
  1019. this._editor.set_CurrentLineHighlightingVisible(false);
  1020. }
  1021. }
  1022. private void ClearRegion()
  1023. {
  1024. }
  1025. private void ClockTimer_Tick(object sender, EventArgs e)
  1026. {
  1027. this.UpdateElapsed();
  1028. }
  1029. internal void Close()
  1030. {
  1031. this._query.ClearAutoSave();
  1032. this.KillIEComExceptionTimer();
  1033. if (this.QueryClosed != null)
  1034. {
  1035. this.QueryClosed(this, EventArgs.Empty);
  1036. }
  1037. }
  1038. internal void CloseCurrentVisualizer()
  1039. {
  1040. this.CloseVisualizer(this.GetSelectedPluginControl());
  1041. }
  1042. internal void CloseVisualizer(PluginControl c)
  1043. {
  1044. if (c != null)
  1045. {
  1046. ToolStripButton button = (this.GetSelectedPluginControl() == c) ? this._pluginWinButtons.FirstOrDefault<ToolStripButton>(b => (b.Tag == c)) : null;
  1047. int num = (button == null) ? -1 : this.tsOutput.Items.IndexOf(button);
  1048. ToolStripButton selectedButton = (num < 1) ? null : (this.tsOutput.Items[num - 1] as ToolStripButton);
  1049. try
  1050. {
  1051. this._pluginWinManager.DisposeControl(c);
  1052. if (selectedButton != null)
  1053. {
  1054. this.SelectOutputPanel(selectedButton, false);
  1055. }
  1056. }
  1057. catch
  1058. {
  1059. }
  1060. }
  1061. }
  1062. internal void CollapseResultsTo(int? depth)
  1063. {
  1064. this._dataBrowser.CollapseTo(depth);
  1065. }
  1066. internal void CompleteParam()
  1067. {
  1068. if (this._editor.get_Document().get_Language() is CSharpSyntaxLanguage)
  1069. {
  1070. this._editor.get_Document().get_Language().ShowIntelliPromptParameterInfo(this._editor);
  1071. }
  1072. }
  1073. internal void CompleteWord()
  1074. {
  1075. if (this._editor.get_Document().get_Language() is CSharpSyntaxLanguage)
  1076. {
  1077. this._editor.get_Document().get_Language().IntelliPromptCompleteWord(this._editor);
  1078. }
  1079. }
  1080. internal void CopyPlain()
  1081. {
  1082. this._editor.CopyPlain();
  1083. }
  1084. private void CreateBrowser()
  1085. {
  1086. this._dataBrowser = new DataResultsWebBrowser();
  1087. this._lambdaBrowser = new ResultsWebBrowser();
  1088. this._ilBrowser = new ResultsWebBrowser();
  1089. this._dataBrowser.PreviewKeyDown += new PreviewKeyDownEventHandler(this._browser_PreviewKeyDown);
  1090. this._dataBrowser.LinqClicked += new EventHandler<LinqClickEventArgs>(this._browser_LinqClicked);
  1091. this._lambdaBrowser.PreviewKeyDown += new PreviewKeyDownEventHandler(this._browser_PreviewKeyDown);
  1092. this._ilBrowser.PreviewKeyDown += new PreviewKeyDownEventHandler(this._browser_PreviewKeyDown);
  1093. this._dataPanel = new BrowserBorder();
  1094. BrowserBorder border = new BrowserBorder {
  1095. BackColor = Control.DefaultBackColor
  1096. };
  1097. this._lambdaPanel = border;
  1098. BrowserBorder border2 = new BrowserBorder {
  1099. BackColor = Control.DefaultBackColor
  1100. };
  1101. this._ilPanel = border2;
  1102. this._dataPanel.Controls.Add(this._dataBrowser);
  1103. this._dataPanel.Dock = DockStyle.Fill;
  1104. this._dataPanel.Hide();
  1105. this._lambdaPanel.Controls.Add(this._lambdaBrowser);
  1106. this._lambdaPanel.Dock = DockStyle.Fill;
  1107. this._lambdaPanel.Hide();
  1108. this._ilPanel.Controls.Add(this._ilBrowser);
  1109. this._ilPanel.Dock = DockStyle.Fill;
  1110. this._ilPanel.Hide();
  1111. this.panOutput.Controls.Add(this._dataPanel);
  1112. this.panOutput.Controls.Add(this._lambdaPanel);
  1113. this.panOutput.Controls.Add(this._ilPanel);
  1114. this._dataBrowser.ObjectForScripting = this;
  1115. }
  1116. private void CreateEditor()
  1117. {
  1118. EventHandler handler = null;
  1119. EventHandler handler2 = null;
  1120. EventHandler handler3 = null;
  1121. this._editor = new QueryEditor();
  1122. this._editor.UriLayer = this._docMan.UriLayer;
  1123. this._editor.WarningsLayer = this._docMan.WarningsLayer;
  1124. this._editor.MainErrorLayer = this._docMan.MainErrorLayer;
  1125. this._editor.StackTraceLayer = this._docMan.StackTraceLayer;
  1126. this._editor.set_Document(this._docMan.Document);
  1127. if (Program.PresentationMode)
  1128. {
  1129. if (handler == null)
  1130. {
  1131. handler = (sender, e) => this.NextQueryRequest(this, EventArgs.Empty);
  1132. }
  1133. this._editor.NextQueryRequest += handler;
  1134. if (handler2 == null)
  1135. {
  1136. handler2 = (sender, e) => this.PreviousQueryRequest(this, EventArgs.Empty);
  1137. }
  1138. this._editor.PreviousQueryRequest += handler2;
  1139. if (handler3 == null)
  1140. {
  1141. handler3 = delegate (object sender, EventArgs e) {
  1142. if (!(this.AreResultsDetached() || this.AreResultsCollapsed()))
  1143. {
  1144. this.ToggleResultsCollapse();
  1145. }
  1146. };
  1147. }
  1148. this._editor.EscapeRequest += handler3;
  1149. }
  1150. this._editor.KeyPress += delegate (object sender, KeyPressEventArgs e) {
  1151. if (this._docMan != null)
  1152. {
  1153. this._docMan.CheckForRepositoryChange();
  1154. }
  1155. };
  1156. this.panEditor.Controls.Add(this._editor);
  1157. this._editor.BringToFront();
  1158. }
  1159. private void CreatePluginWinButton(PluginControl c, bool activate, bool afterCurrent)
  1160. {
  1161. Action a = delegate {
  1162. if (!this._pluginWinButtons.Any<ToolStripButton>(b => (b.Tag == c)))
  1163. {
  1164. bool flag = !MainForm.Instance.IsActive && !MainForm.Instance.ResultsDockForm.IsActive;
  1165. ToolStripButton button = new ToolStripButton(c.Heading) {
  1166. DisplayStyle = ToolStripItemDisplayStyle.Text,
  1167. Margin = new Padding(0, 0, 0, 1),
  1168. Tag = c,
  1169. ToolTipText = c.ToolTipText
  1170. };
  1171. button.Click += delegate (object sender, EventArgs e) {
  1172. if (Control.ModifierKeys == Keys.Control)
  1173. {
  1174. this.CloseVisualizer(c);
  1175. }
  1176. else
  1177. {
  1178. this.SelectOutputPanel(button, true);
  1179. }
  1180. };
  1181. button.MouseEnter += delegate (object sender, EventArgs e) {
  1182. this.tsOutput.Cursor = Cursors.Default;
  1183. try
  1184. {
  1185. button.ToolTipText = c.ToolTipText;
  1186. bool isActive = MainForm.Instance.IsActive;
  1187. if (!(string.IsNullOrEmpty(button.ToolTipText) || isActive))
  1188. {
  1189. this._pluginWinManager.ShowToolTip(button.ToolTipText);
  1190. }
  1191. }
  1192. catch
  1193. {
  1194. }
  1195. };
  1196. button.MouseLeave += delegate (object sender, EventArgs e) {
  1197. if (!(string.IsNullOrEmpty(c.ToolTipText) || MainForm.Instance.IsActive))
  1198. {
  1199. this._pluginWinManager.ShowToolTip(null);
  1200. }
  1201. };
  1202. button.MouseDown += delegate (object sender, MouseEventArgs e) {
  1203. if (e.Button == MouseButtons.Middle)
  1204. {
  1205. this.CloseVisualizer(c);
  1206. }
  1207. else if (e.Button == MouseButtons.Right)
  1208. {
  1209. this.SelectOutputPanel(button, false);
  1210. Point p = this.tsOutput.PointToScreen(e.Location);
  1211. p.Offset(button.Bounds.Location);
  1212. Program.RunOnWinFormsTimer(delegate {
  1213. this.FocusQueryExplicit();
  1214. this._pluginWinButtonMenu.Show(p);
  1215. }, 50);
  1216. }
  1217. };
  1218. if ((afterCurrent && this.IsPluginSelected()) && flag)
  1219. {
  1220. int index = this._pluginWinButtons.IndexOf(this.GetSelectedPanelButton());
  1221. this._pluginWinButtons.Insert(index + 1, button);
  1222. this.tsOutput.Items.Insert(index + 3, button);
  1223. }
  1224. else
  1225. {
  1226. this._pluginWinButtons.Add(button);
  1227. this.tsOutput.Items.Insert(this.tsOutput.Items.IndexOf(this.btnLambda), button);
  1228. }
  1229. if (activate)
  1230. {
  1231. this.SelectOutputPanel(button, false);
  1232. }
  1233. }
  1234. };
  1235. if (base.InvokeRequired)
  1236. {
  1237. this.BeginInvoke(a);
  1238. }
  1239. else
  1240. {
  1241. a();
  1242. }
  1243. }
  1244. public bool CustomClick(string idString, bool graphTruncated)
  1245. {
  1246. int id;
  1247. if (int.TryParse(idString, out id))
  1248. {
  1249. ContextMenuStrip strip = new ContextMenuStrip();
  1250. strip.Items.Add(new ToolStripMenuItem("Explore " + (graphTruncated ? "all rows " : "") + "in grid", null, delegate (object sender, EventArgs e) {
  1251. if (!this._query.HasDomain)
  1252. {
  1253. MessageBox.Show("The query's application domain has been unloaded. Re-run the query to enable the object explorer.", "LINQPad", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  1254. }
  1255. else if (this._query.MessageLoopEnded)
  1256. {
  1257. MessageBox.Show("The query was faulted. Re-run to enable the object explorer.", "LINQPad", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  1258. }
  1259. else
  1260. {
  1261. this.lblMiscStatus.Text = this._outputInfoMessage = "Querying...";
  1262. try
  1263. {
  1264. this.lblMiscStatus.Font = new Font(this.Font.FontFamily, 9f, FontStyle.Bold);
  1265. }
  1266. catch
  1267. {
  1268. }
  1269. this.lblMiscStatus.BackColor = Color.FromArgb(250, 250, 140);
  1270. this._query.CallCustomClick(id);
  1271. }
  1272. }));
  1273. strip.Show(Control.MousePosition);
  1274. }
  1275. return false;
  1276. }
  1277. private void DestroyBrowsers(bool recreate)
  1278. {
  1279. BrowserBorder border = this._lambdaPanel;
  1280. BrowserBorder border2 = this._dataPanel;
  1281. BrowserBorder border3 = this._ilPanel;
  1282. ResultsWebBrowser browser = this._lambdaBrowser;
  1283. DataResultsWebBrowser browser2 = this._dataBrowser;
  1284. ResultsWebBrowser browser3 = this._ilBrowser;
  1285. if (recreate)
  1286. {
  1287. this.CreateBrowser();
  1288. }
  1289. browser2.Dispose();
  1290. browser.Dispose();
  1291. browser3.Dispose();
  1292. this.panOutput.Controls.Remove(border2);
  1293. this.panOutput.Controls.Remove(border);
  1294. this.panOutput.Controls.Remove(border3);
  1295. border.Dispose();
  1296. border2.Dispose();
  1297. border3.Dispose();
  1298. }
  1299. internal Control DetachResultsControl()
  1300. {
  1301. if (!this.AreResultsCollapsed())
  1302. {
  1303. this.ToggleResultsCollapse();
  1304. }
  1305. this.panBottom.Parent = null;
  1306. this.UpdateOutputVisibility();
  1307. return this.panBottom;
  1308. }
  1309. private void DisplayError(string msg)
  1310. {
  1311. if ((msg == "InvalidOperationException: The calling thread must be STA, because many UI components require this.") || msg.StartsWith("ThreadStateException: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made."))
  1312. {
  1313. if (UserOptions.Instance.MTAThreadingMode)
  1314. {
  1315. msg = msg + "\r\n\r\n(You've got this error because you've requested MTA threads in LINQPad - go to Edit | Preferences | Advanced to switch this off.)";
  1316. }
  1317. else if (this._query.AllFileReferences.Any<string>(r => r.EndsWith(".winmd", StringComparison.InvariantCultureIgnoreCase)))
  1318. {
  1319. msg = msg + "\r\n\r\n(You've got this error because you've referenced a Windows Runtime assembly which requires MTA mode.)";
  1320. }
  1321. }
  1322. this.panError.Visible = true;
  1323. this.txtError.Text = msg;
  1324. this.UpdateErrorHeight();
  1325. }
  1326. private void DisplayUberCancel(bool highlight)
  1327. {
  1328. this._uberCancelMessage = true;
  1329. this.lblExecTime.Visible = false;
  1330. this.lblUberCancel.Visible = true;
  1331. this.lblUberCancel.ForeColor = Color.DarkRed;
  1332. if (highlight)
  1333. {
  1334. this.lblUberCancel.BackColor = Color.FromArgb(250, 250, 140);
  1335. Timer tmr = new Timer {
  1336. Enabled = true,
  1337. Interval = 0x7d0
  1338. };
  1339. tmr.Tick += delegate (object sender, EventArgs e) {
  1340. tmr.Dispose();
  1341. if (!this.IsDisposed)
  1342. {
  1343. this.lblUberCancel.BackColor = Color.Transparent;
  1344. }
  1345. };
  1346. }
  1347. else
  1348. {
  1349. this.lblUberCancel.BackColor = Color.Transparent;
  1350. }
  1351. }
  1352. protected override void Dispose(bool disposing)
  1353. {
  1354. if (disposing && (this.components != null))
  1355. {
  1356. this.components.Dispose();
  1357. this.KillIEComExceptionTimer();
  1358. if (this._dataBrowser != null)
  1359. {
  1360. this._dataBrowser.ObjectForScripting = null;
  1361. }
  1362. this._pluginWinManager.Reset(false);
  1363. this._query.Dispose();
  1364. this._query = null;
  1365. this._schemaTree.AfterSelect -= new TreeViewEventHandler(this._schemaTree_AfterSelect);
  1366. if (this._docMan != null)
  1367. {
  1368. this._docMan.Dispose();
  1369. }
  1370. this._docMan = null;
  1371. if (this._readLinePanel != null)
  1372. {
  1373. this._readLinePanel.Dispose();
  1374. this._readLinePanel = null;
  1375. }
  1376. this._dataBrowser.Dispose();
  1377. this._lambdaBrowser.Dispose();
  1378. this._ilBrowser.Dispose();
  1379. this._dataPanel.Dispose();
  1380. this._lambdaPanel.Dispose();
  1381. this._ilPanel.Dispose();
  1382. this._refreshTimer.Dispose();
  1383. this._clockTimer.Dispose();
  1384. this._autoSaveTimer.Dispose();
  1385. this._executionTrackingTimer.Dispose();
  1386. this._pluginWinManager.Dispose();
  1387. }
  1388. base.Dispose(disposing);
  1389. }
  1390. public bool DoesBrowserHaveFocus()
  1391. {
  1392. return ((((this._dataBrowser == null) || !this._dataBrowser.Focused) && ((this._lambdaBrowser == null) || !this._lambdaBrowser.Focused)) ? ((this._ilBrowser != null) && this._ilBrowser.Focused) : true);
  1393. }
  1394. internal void EditorBackColorChanged()
  1395. {
  1396. this._docMan.ConfigureLanguage();
  1397. this._docMan.ConfigureResolver();
  1398. this._editor.UpdateColors(true);
  1399. }
  1400. private void EnableControls()
  1401. {
  1402. bool queryRunning = this.QueryRunning;
  1403. this.btnCancel.Enabled = queryRunning;
  1404. this.btnExecute.Enabled = this.cboLanguage.Enabled = !queryRunning;
  1405. this.cboDb.Enabled = !this._query.IsMyExtensions && !queryRunning;
  1406. this.queryProgressBar.Visible = queryRunning && (this._query.ExecutionProgress != ExecutionProgress.Async);
  1407. }
  1408. public bool ExecuteQuery(string query, int queryKind)
  1409. {
  1410. this.KillIEComExceptionTimer();
  1411. query = Encoding.UTF8.GetString(Convert.FromBase64String(query));
  1412. QueryControl control = MainForm.Instance.NewQuerySameProps(query, true);
  1413. if ((queryKind >= 0) && (queryKind <= 9))
  1414. {
  1415. control.Query.QueryKind = (QueryLanguage) queryKind;
  1416. }
  1417. control.Query.IsModified = false;
  1418. control.Run();
  1419. MainForm.Instance.UpdateQueryUI(control.Query);
  1420. return false;
  1421. }
  1422. private string ExportResults(bool stripFormatting)
  1423. {
  1424. this._msData.Position = 0L;
  1425. XDocument document = XDocument.Load(new StreamReader(this._msData));
  1426. this._msData.Position = 0L;
  1427. XNamespace namespace2 = "http://www.w3.org/1999/xhtml";
  1428. document.Descendants((XName) (namespace2 + "script")).Remove<XElement>();
  1429. (from el in document.Descendants((XName) (namespace2 + "span"))
  1430. where ((string) el.Attribute("class")) == "typeglyph"
  1431. select el).Remove<XElement>();
  1432. (from a in document.Descendants().Attributes("style")
  1433. where ((string) a) == "display:none"
  1434. select a).Remove();
  1435. if (stripFormatting)
  1436. {
  1437. document.Descendants((XName) (namespace2 + "style")).Remove<XElement>();
  1438. (from tr in document.Descendants((XName) (namespace2 + "tr"))
  1439. where tr.Elements().Any<XElement>(td => ((string) td.Attribute("class")) == "typeheader")
  1440. select tr).Remove<XElement>();
  1441. (from e in document.Descendants((XName) (namespace2 + "i"))
  1442. where e.Value == "null"
  1443. select e).Remove<XElement>();
  1444. }
  1445. foreach (XElement element in document.Descendants((XName) (namespace2 + "a")).ToArray<XElement>())
  1446. {
  1447. element.ReplaceWith(element.Nodes());
  1448. }
  1449. foreach (XElement element2 in (from e in document.Descendants((XName) (namespace2 + "table"))
  1450. where ((string) e.Attribute("class")) == "headingpresenter"
  1451. where e.Elements().Count<XElement>() == 2
  1452. select e).ToArray<XElement>())
  1453. {
  1454. IEnumerable<XElement> enumerable = element2.Elements().First<XElement>().Elements();
  1455. IEnumerable<XElement> content = element2.Elements().Skip<XElement>(1).First<XElement>().Elements();
  1456. if (stripFormatting)
  1457. {
  1458. element2.ReplaceWith(new object[] { enumerable, new XElement((XName) (namespace2 + "p"), content) });
  1459. }
  1460. else
  1461. {
  1462. element2.ReplaceWith(new object[] { new XElement((XName) (namespace2 + "br")), new XElement((XName) (namespace2 + "span"), new object[] { new XAttribute("style", "color: green; font-weight:bold; font-size: 110%;"), enumerable }), content });
  1463. }
  1464. }
  1465. foreach (XElement element3 in document.Descendants((XName) (namespace2 + "th")))
  1466. {
  1467. element3.Name = (XName) (namespace2 + "td");
  1468. if (!(stripFormatting || (element3.Attribute("style") != null)))
  1469. {
  1470. element3.Add(new XAttribute("style", "font-weight: bold; background-color: #ddd;"));
  1471. }
  1472. }
  1473. string path = Path.ChangeExtension(Path.GetTempFileName(), ".html");
  1474. File.WriteAllText(path, document.ToString().Replace("Ξ", "").Replace("▪", ""));
  1475. return path;
  1476. }
  1477. private void ExtendOutputSplitter()
  1478. {
  1479. EventHandler handler = null;
  1480. this.tsOutput.MouseDown += delegate (object sender, MouseEventArgs e) {
  1481. if (((e.Button == MouseButtons.Left) && (this.tsOutput.GetItemAt(e.Location) == null)) && (this.splitContainer.Orientation != Orientation.Vertical))
  1482. {
  1483. this._splitterMovingViaToolStrip = true;
  1484. MouseEventArgs args = new MouseEventArgs(e.Button, e.Clicks, e.X, this.splitContainer.SplitterRectangle.Bottom - 1, e.Delta);
  1485. MethodInfo method = this.splitContainer.GetType().GetMethod("OnMouseDown", BindingFlags.NonPublic | BindingFlags.Instance);
  1486. if (method != null)
  1487. {
  1488. method.Invoke(this.splitContainer, new MouseEventArgs[] { args });
  1489. }
  1490. }
  1491. };
  1492. this.tsOutput.MouseUp += delegate (object sender, MouseEventArgs e) {
  1493. if (this._splitterMovingViaToolStrip)
  1494. {
  1495. this._splitterMovingViaToolStrip = false;
  1496. MethodInfo method = this.splitContainer.GetType().GetMethod("OnMouseUp", BindingFlags.NonPublic | BindingFlags.Instance);
  1497. if (method != null)
  1498. {
  1499. method.Invoke(this.splitContainer, new MouseEventArgs[] { e });
  1500. }
  1501. }
  1502. };
  1503. this.tsOutput.MouseMove += delegate (object sender, MouseEventArgs e) {
  1504. if (this.splitContainer.Orientation != Orientation.Vertical)
  1505. {
  1506. this.tsOutput.Cursor = (this.tsOutput.GetItemAt(e.Location) != null) ? Cursors.Default : Cursors.HSplit;
  1507. if (this._splitterMovingViaToolStrip && (e.Button == MouseButtons.Left))
  1508. {
  1509. MethodInfo method = this.splitContainer.GetType().GetMethod("OnMouseMove", BindingFlags.NonPublic | BindingFlags.Instance);
  1510. if (method != null)
  1511. {
  1512. method.Invoke(this.splitContainer, new MouseEventArgs[] { e });
  1513. }
  1514. }
  1515. }
  1516. };
  1517. this.tsOutput.MouseLeave += (sender, e) => (this.tsOutput.Cursor = Cursors.Default);
  1518. foreach (ToolStripItem item in this.tsOutput.Items)
  1519. {
  1520. if (handler == null)
  1521. {
  1522. handler = (sender, e) => this.tsOutput.Cursor = Cursors.Default;
  1523. }
  1524. item.MouseEnter += handler;
  1525. }
  1526. }
  1527. internal void FindNext()
  1528. {
  1529. if (QueryEditor.Options.get_FindText().Length == 0)
  1530. {
  1531. this.FindReplace();
  1532. }
  1533. else
  1534. {
  1535. bool flag = QueryEditor.Options.get_SearchUp();
  1536. QueryEditor.Options.set_SearchUp(false);
  1537. this._editor.get_SelectedView().get_FindReplace().Find(QueryEditor.Options);
  1538. QueryEditor.Options.set_SearchUp(flag);
  1539. this._editor.Focus();
  1540. }
  1541. }
  1542. internal void FindNextSelected()
  1543. {
  1544. string str = (this._editor.get_SelectedView().get_SelectedText().Length > 0) ? this._editor.get_SelectedView().get_SelectedText() : this._editor.get_SelectedView().GetCurrentWordText();
  1545. if (!string.IsNullOrEmpty(str))
  1546. {
  1547. QueryEditor.Options.set_FindText(str);
  1548. this.FindNext();
  1549. }
  1550. }
  1551. internal void FindPrevious()
  1552. {
  1553. if (QueryEditor.Options.get_FindText().Length == 0)
  1554. {
  1555. QueryEditor.Options.set_SearchUp(true);
  1556. this.FindReplace();
  1557. }
  1558. else
  1559. {
  1560. bool flag = QueryEditor.Options.get_SearchUp();
  1561. QueryEditor.Options.set_SearchUp(true);
  1562. this._editor.get_SelectedView().get_FindReplace().Find(QueryEditor.Options);
  1563. QueryEditor.Options.set_SearchUp(flag);
  1564. this._editor.Focus();
  1565. }
  1566. }
  1567. internal void FindPreviousSelected()
  1568. {
  1569. string str = (this._editor.get_SelectedView().get_SelectedText().Length > 0) ? this._editor.get_SelectedView().get_SelectedText() : this._editor.get_SelectedView().GetCurrentWordText();
  1570. if (!string.IsNullOrEmpty(str))
  1571. {
  1572. QueryEditor.Options.set_FindText(str);
  1573. this.FindPrevious();
  1574. }
  1575. }
  1576. internal void FindReplace()
  1577. {
  1578. this._editor.Focus();
  1579. if (string.IsNullOrEmpty(QueryEditor.Options.get_FindText()) || (this._editor.get_SelectedView().get_SelectedText().Length > 0))
  1580. {
  1581. string str = (this._editor.get_SelectedView().get_SelectedText().Length > 0) ? this._editor.get_SelectedView().get_SelectedText() : this._editor.get_SelectedView().GetCurrentWordText();
  1582. if (!string.IsNullOrEmpty(str))
  1583. {
  1584. QueryEditor.Options.set_FindText(str);
  1585. }
  1586. }
  1587. using (LINQPadFindReplaceForm form = new LINQPadFindReplaceForm(this._editor, QueryEditor.Options))
  1588. {
  1589. form.ShowInTaskbar = false;
  1590. try
  1591. {
  1592. form.Font = FontManager.GetDefaultFont();
  1593. }
  1594. catch
  1595. {
  1596. }
  1597. Button button = form.Controls.OfType<Button>().FirstOrDefault<Button>(b => b.Text.Contains("Mark"));
  1598. if (button != null)
  1599. {
  1600. button.Hide();
  1601. }
  1602. CheckBox box = form.Controls.OfType<CheckBox>().FirstOrDefault<CheckBox>(b => b.Text.Contains("hidden"));
  1603. if (box != null)
  1604. {
  1605. box.Hide();
  1606. }
  1607. CheckBox box2 = form.Controls.OfType<CheckBox>().FirstOrDefault<CheckBox>(b => b.Text.Contains("selection"));
  1608. if ((box2 != null) && (box != null))
  1609. {
  1610. box2.Location = box.Location;
  1611. }
  1612. form.ShowDialog(MainForm.Instance);
  1613. }
  1614. }
  1615. internal void FixEditorScrollBars()
  1616. {
  1617. this._editor.set_ScrollBarType(6);
  1618. this._editor.set_ScrollBarType(0);
  1619. }
  1620. internal void FixOutliningStartupBug()
  1621. {
  1622. this._editor.IsOutliningEnabled = (this._query.QueryKind == QueryLanguage.Program) || (this._query.QueryKind == QueryLanguage.VBProgram);
  1623. }
  1624. internal void FocusQuery()
  1625. {
  1626. this.FocusQuery(false);
  1627. }
  1628. internal void FocusQuery(bool focusEllipses)
  1629. {
  1630. if (((!base.IsDisposed && (this._editor != null)) && (this._editor.get_Document() != null)) && (this._docMan != null))
  1631. {
  1632. if ((!focusEllipses && this._readLinePanelVisible) && (this._readLinePanel != null))
  1633. {
  1634. this._readLinePanel.FocusTextBox();
  1635. }
  1636. else
  1637. {
  1638. this._editor.Focus();
  1639. if (focusEllipses)
  1640. {
  1641. string text = this._editor.get_Document().GetText(0);
  1642. int index = text.IndexOf('…');
  1643. if (index >= 0)
  1644. {
  1645. this._editor.get_Document().set_Text(text.Substring(0, index) + text.Substring(index + 1));
  1646. this._editor.get_Caret().set_Offset(index);
  1647. }
  1648. else
  1649. {
  1650. index = text.IndexOf("...");
  1651. if (index >= 0)
  1652. {
  1653. this._editor.get_SelectedView().get_Selection().set_StartOffset(index);
  1654. this._editor.get_SelectedView().get_Selection().set_EndOffset(index + 3);
  1655. }
  1656. }
  1657. }
  1658. }
  1659. this._docMan.CheckForRepositoryChange();
  1660. }
  1661. }
  1662. internal void FocusQueryExplicit()
  1663. {
  1664. if (!((!this._readLinePanelVisible || (this._readLinePanel == null)) || this._readLinePanel.ContainsFocus))
  1665. {
  1666. this._readLinePanel.FocusTextBox();
  1667. }
  1668. else
  1669. {
  1670. this._editor.Focus();
  1671. }
  1672. }
  1673. internal void FocusSelectedPlugin()
  1674. {
  1675. if (this._pluginWinManager != null)
  1676. {
  1677. PluginControl selectedPluginControl = this.GetSelectedPluginControl();
  1678. if (selectedPluginControl != null)
  1679. {
  1680. this.LastPluginFocus = DateTime.UtcNow;
  1681. this._pluginWinManager.Show(selectedPluginControl, true);
  1682. }
  1683. }
  1684. }
  1685. private static Control GetActiveControl()
  1686. {
  1687. Form activeForm = Form.ActiveForm;
  1688. if (activeForm != null)
  1689. {
  1690. Control activeControl = activeForm.ActiveControl;
  1691. if (activeControl != null)
  1692. {
  1693. while (activeControl is ContainerControl)
  1694. {
  1695. Control control3 = ((ContainerControl) activeControl).ActiveControl;
  1696. if (control3 == null)
  1697. {
  1698. return activeControl;
  1699. }
  1700. activeControl = control3;
  1701. }
  1702. return activeControl;
  1703. }
  1704. }
  1705. return null;
  1706. }
  1707. private Color GetErrorSquigglyColor()
  1708. {
  1709. if (!this._errorSquigglyColor.HasValue)
  1710. {
  1711. this._errorSquigglyColor = new Color?((UserOptions.Instance.ActualEditorBackColor.GetBrightness() < 0.4f) ? Color.FromArgb(140, 180, 0xff) : Color.Blue);
  1712. }
  1713. return this._errorSquigglyColor.Value;
  1714. }
  1715. private string GetErrorText(CompilerError error)
  1716. {
  1717. if (((this._query.AdditionalNamespaces.Length > 0) && (error.Line <= 0)) && ((error.ErrorNumber == "CS0246") || (error.ErrorNumber == "CS0234")))
  1718. {
  1719. return (Regex.Replace(error.ErrorText, @"\(.+\)", "") + " (Press F4 to check imported namespaces)");
  1720. }
  1721. return error.ErrorText;
  1722. }
  1723. private MemberHelpInfo GetMemberHelpInfo()
  1724. {
  1725. if (MainForm.Instance.ShowLicensee)
  1726. {
  1727. if (this._editor.get_IntelliPrompt().get_MemberList().get_Visible())
  1728. {
  1729. CustomIntelliPromptMemberListItem item = this._editor.get_IntelliPrompt().get_MemberList().get_SelectedItem() as CustomIntelliPromptMemberListItem;
  1730. if ((item != null) && (item.MemberHelpInfo != null))
  1731. {
  1732. return item.MemberHelpInfo;
  1733. }
  1734. }
  1735. if (this._editor.get_IntelliPrompt().get_QuickInfo().get_Visible() && (AutocompletionManager.get_QuickInfoHelp() != null))
  1736. {
  1737. return AutocompletionManager.get_QuickInfoHelp();
  1738. }
  1739. if (this._editor.get_IntelliPrompt().get_ParameterInfo().get_Visible())
  1740. {
  1741. return AutocompletionManager.get_ParamInfoHelp();
  1742. }
  1743. CustomCSharpSyntaxLanguage language = this._editor.get_Document().get_Language() as CustomCSharpSyntaxLanguage;
  1744. if (language != null)
  1745. {
  1746. return language.GetMemberHelpInfoAtCaret(this._editor);
  1747. }
  1748. }
  1749. return null;
  1750. }
  1751. private int GetOffsetFromRowCol(int row, int column)
  1752. {
  1753. if (this.Doc.get_Lines().get_Count() == 0)
  1754. {
  1755. return 0;
  1756. }
  1757. if (column == -1)
  1758. {
  1759. column = 0;
  1760. }
  1761. if ((this._querySelectionStartRow > 0) || (this._querySelectionStartCol > 0))
  1762. {
  1763. if (row == 0)
  1764. {
  1765. column += this._querySelectionStartCol;
  1766. }
  1767. row += this._querySelectionStartRow;
  1768. }
  1769. if (row >= this.Doc.get_Lines().get_Count())
  1770. {
  1771. row = this.Doc.get_Lines().get_Count() - 1;
  1772. if (row < 0)
  1773. {
  1774. return -1;
  1775. }
  1776. column = Math.Max(0, this.Doc.get_Lines().get_Item(row).get_Length() - 1);
  1777. }
  1778. if ((row < 0) || (row >= this.Doc.get_Lines().get_Count()))
  1779. {
  1780. return -1;
  1781. }
  1782. DocumentLine line = this.Doc.get_Lines().get_Item(row);
  1783. if (column > line.get_Length())
  1784. {
  1785. return -1;
  1786. }
  1787. return (line.get_StartOffset() + Math.Max(0, column));
  1788. }
  1789. private Control GetOutputControl(ToolStripButton selectedButton)
  1790. {
  1791. if (selectedButton == this.btnResults)
  1792. {
  1793. return this._dataBrowser;
  1794. }
  1795. if (selectedButton == this.btnLambda)
  1796. {
  1797. return this._lambdaBrowser;
  1798. }
  1799. if (selectedButton == this.btnSql)
  1800. {
  1801. return this.txtSQL;
  1802. }
  1803. if (selectedButton == this.btnIL)
  1804. {
  1805. return this._ilBrowser;
  1806. }
  1807. return null;
  1808. }
  1809. private Control GetOutputPanel(ToolStripButton selectedButton)
  1810. {
  1811. if (selectedButton == this.btnResults)
  1812. {
  1813. return this._dataPanel;
  1814. }
  1815. if (selectedButton == this.btnLambda)
  1816. {
  1817. return this._lambdaPanel;
  1818. }
  1819. if (selectedButton == this.btnSql)
  1820. {
  1821. return this.txtSQL;
  1822. }
  1823. if (selectedButton == this.btnIL)
  1824. {
  1825. return this._ilPanel;
  1826. }
  1827. return null;
  1828. }
  1829. private IEnumerable<ToolStripButton> GetPanelSelectorButtons(bool includePlugins)
  1830. {
  1831. ToolStripButton[] first = new ToolStripButton[] { this.btnResults, this.btnLambda, this.btnSql, this.btnIL };
  1832. if (!includePlugins)
  1833. {
  1834. return first;
  1835. }
  1836. return first.Concat<ToolStripButton>(this._pluginWinButtons);
  1837. }
  1838. internal EditManager GetPluginEditManager()
  1839. {
  1840. if (this._pluginWinManager == null)
  1841. {
  1842. return null;
  1843. }
  1844. return this._pluginWinManager.EditManager;
  1845. }
  1846. private ToolStripButton GetSelectedPanelButton()
  1847. {
  1848. return this.GetPanelSelectorButtons(true).FirstOrDefault<ToolStripButton>(b => b.Checked);
  1849. }
  1850. private PluginControl GetSelectedPluginControl()
  1851. {
  1852. ToolStripButton selectedPanelButton = this.GetSelectedPanelButton();
  1853. if (selectedPanelButton == null)
  1854. {
  1855. return null;
  1856. }
  1857. return (selectedPanelButton.Tag as PluginControl);
  1858. }
  1859. private string GetSSMSLocation()
  1860. {
  1861. RegistryKey key = Registry.ClassesRoot.OpenSubKey(".sql");
  1862. if (key == null)
  1863. {
  1864. return null;
  1865. }
  1866. string name = key.GetValue(null) as string;
  1867. if (name == null)
  1868. {
  1869. return null;
  1870. }
  1871. RegistryKey key2 = Registry.ClassesRoot.OpenSubKey(name);
  1872. if (key2 == null)
  1873. {
  1874. return null;
  1875. }
  1876. key2 = key2.OpenSubKey(@"Shell\Open\Command");
  1877. if (key2 == null)
  1878. {
  1879. return null;
  1880. }
  1881. string source = key2.GetValue(null) as string;
  1882. if (!source.StartsWith("\"", StringComparison.Ordinal))
  1883. {
  1884. return null;
  1885. }
  1886. source = source.Substring(1);
  1887. if (!source.Contains<char>('"'))
  1888. {
  1889. return null;
  1890. }
  1891. return source.Substring(0, source.IndexOf('"'));
  1892. }
  1893. private Color GetWarningSquigglyColor()
  1894. {
  1895. if (!this._warningSquigglyColor.HasValue)
  1896. {
  1897. this._warningSquigglyColor = new Color?((UserOptions.Instance.ActualEditorBackColor.GetBrightness() < 0.4f) ? Color.LightGreen : Color.Green);
  1898. }
  1899. return this._warningSquigglyColor.Value;
  1900. }
  1901. internal Rectangle GetWinManagerTargetBounds()
  1902. {
  1903. Rectangle rectangle;
  1904. rectangle = new Rectangle(Point.Empty, this.panOutput.ClientSize) {
  1905. X = rectangle.X + this.panOutput.Padding.Left,
  1906. Y = rectangle.Y + this.panOutput.Padding.Top,
  1907. Width = rectangle.Width - (this.panOutput.Padding.Left + this.panOutput.Padding.Right),
  1908. Height = rectangle.Height - (this.panOutput.Padding.Top + this.panOutput.Padding.Bottom)
  1909. };
  1910. return this.panOutput.RectangleToScreen(rectangle);
  1911. }
  1912. public bool GotoRowColumn(int row, int column)
  1913. {
  1914. Action a = null;
  1915. this.KillIEComExceptionTimer();
  1916. int offsetFromRowCol = this.GetOffsetFromRowCol(row, column);
  1917. if (offsetFromRowCol >= 0)
  1918. {
  1919. this._editor.get_Caret().set_Offset(offsetFromRowCol);
  1920. this._editor.Focus();
  1921. this._editor.set_CurrentLineHighlightingVisible(true);
  1922. if (a == null)
  1923. {
  1924. a = delegate {
  1925. this._editor.set_CurrentLineHighlightingVisible(false);
  1926. };
  1927. }
  1928. Program.RunOnWinFormsTimer(a, 300);
  1929. }
  1930. return false;
  1931. }
  1932. private void HideReadLinePanel()
  1933. {
  1934. if (this.lblStatus.Text == "Awaiting user input")
  1935. {
  1936. this.lblStatus.Text = "";
  1937. }
  1938. if (this._readLinePanelVisible)
  1939. {
  1940. this._readLinePanelVisible = false;
  1941. this._readLinePanel.Parent = null;
  1942. }
  1943. }
  1944. private void HighlightErrorOrWarning(int row, int column, string message, bool warning, bool compileTime, bool isMainError)
  1945. {
  1946. int offsetFromRowCol = this.GetOffsetFromRowCol(row, column);
  1947. if (offsetFromRowCol != -1)
  1948. {
  1949. row += this._querySelectionStartRow;
  1950. if (isMainError)
  1951. {
  1952. if (this._editor.get_SelectedView().get_Selection().get_IsZeroLength())
  1953. {
  1954. this._editor.get_Caret().set_Offset(offsetFromRowCol);
  1955. this._editor.set_CurrentLineHighlightingVisible(true);
  1956. }
  1957. this._editor.CheckSmartTagAtLocation(offsetFromRowCol + 1);
  1958. }
  1959. if (!(!warning || string.IsNullOrEmpty(message)))
  1960. {
  1961. message = "Warning: " + message;
  1962. }
  1963. if (column != -1)
  1964. {
  1965. int num3 = this._editor.get_Document().GetWordTextRange(offsetFromRowCol).get_EndOffset() - offsetFromRowCol;
  1966. if ((num3 == 0) && (offsetFromRowCol > 0))
  1967. {
  1968. offsetFromRowCol--;
  1969. num3++;
  1970. }
  1971. if (num3 > 0)
  1972. {
  1973. Color color = warning ? this.GetWarningSquigglyColor() : this.GetErrorSquigglyColor();
  1974. SpanIndicatorLayer layer = isMainError ? this._docMan.MainErrorLayer : this._docMan.WarningsLayer;
  1975. SpanIndicator indicator = layer.GetIndicatorsForTextRange(new TextRange(offsetFromRowCol, offsetFromRowCol + num3)).FirstOrDefault<SpanIndicator>();
  1976. if (indicator is CompilerErrorSpanIndicator)
  1977. {
  1978. System.Boolean ReflectorVariable0;
  1979. if (message != null)
  1980. {
  1981. ReflectorVariable0 = true;
  1982. }
  1983. else
  1984. {
  1985. ReflectorVariable0 = false;
  1986. }
  1987. if (!(ReflectorVariable0 ? (((indicator.get_Tag() as string) ?? "").Split(new char[] { '\n' }).Length >= 5) : true))
  1988. {
  1989. indicator.set_Tag(((indicator.get_Tag() as string) ?? "") + "\n" + message);
  1990. }
  1991. }
  1992. else if (indicator == null)
  1993. {
  1994. try
  1995. {
  1996. CompilerErrorSpanIndicator indicator2 = new CompilerErrorSpanIndicator();
  1997. indicator2.set_UnderlineColor(color);
  1998. indicator2.set_Tag(message);
  1999. CompilerErrorSpanIndicator indicator3 = indicator2;
  2000. layer.Add(indicator3, offsetFromRowCol, num3);
  2001. }
  2002. catch (ArgumentException)
  2003. {
  2004. }
  2005. }
  2006. }
  2007. }
  2008. if (row >= 0)
  2009. {
  2010. this._editor.set_IndicatorMarginVisible(true);
  2011. LineIndicator indicator4 = this._editor.get_Document().get_LineIndicators().GetIndicatorsForDocumentLine(row).FirstOrDefault<LineIndicator>(i => !(i is BitmapBookmarkLineIndicator));
  2012. if ((indicator4 != null) && (message != null))
  2013. {
  2014. if (string.IsNullOrEmpty(indicator4.get_Tag() as string))
  2015. {
  2016. indicator4.set_Tag(message);
  2017. }
  2018. else
  2019. {
  2020. indicator4.set_Tag(((string) indicator4.get_Tag()) + "\n" + message);
  2021. }
  2022. }
  2023. else
  2024. {
  2025. if (!(compileTime || warning))
  2026. {
  2027. indicator4 = new ExceptionLineIndicator();
  2028. }
  2029. else if (warning)
  2030. {
  2031. indicator4 = new WarningLineIndicator();
  2032. }
  2033. else
  2034. {
  2035. indicator4 = new ErrorLineIndicator();
  2036. }
  2037. indicator4.set_Tag(message);
  2038. this._editor.get_Document().get_LineIndicators().Add(indicator4, row);
  2039. }
  2040. }
  2041. }
  2042. }
  2043. private void HighlightStackTraceError(int row, int column)
  2044. {
  2045. int offsetFromRowCol = this.GetOffsetFromRowCol(row, column);
  2046. if ((offsetFromRowCol != -1) && (column != -1))
  2047. {
  2048. int num3 = this._editor.get_Document().GetWordTextRange(offsetFromRowCol).get_EndOffset() - offsetFromRowCol;
  2049. if ((num3 == 0) && (offsetFromRowCol > 0))
  2050. {
  2051. offsetFromRowCol--;
  2052. num3++;
  2053. }
  2054. if (num3 > 0)
  2055. {
  2056. SpanIndicatorLayer stackTraceLayer = this._docMan.StackTraceLayer;
  2057. if (stackTraceLayer.GetIndicatorsForTextRange(new TextRange(offsetFromRowCol, offsetFromRowCol + num3)).FirstOrDefault<SpanIndicator>() == null)
  2058. {
  2059. try
  2060. {
  2061. stackTraceLayer.Add(new GrayPinkBackgroundSpanIndicator(), offsetFromRowCol, num3);
  2062. }
  2063. catch (ArgumentException)
  2064. {
  2065. }
  2066. }
  2067. }
  2068. }
  2069. }
  2070. private QueryLanguage IndexToQueryLanguage(int index)
  2071. {
  2072. if (this._query.IsMyExtensions)
  2073. {
  2074. return QueryLanguage.Program;
  2075. }
  2076. QueryLanguage language2 = (QueryLanguage) index;
  2077. if (language2 >= QueryLanguage.SQL)
  2078. {
  2079. language2 -= 2;
  2080. }
  2081. else if ((language2 == QueryLanguage.FSharpExpression) || (language2 == QueryLanguage.FSharpProgram))
  2082. {
  2083. language2 += 2;
  2084. }
  2085. return language2;
  2086. }
  2087. private void InitializeComponent()
  2088. {
  2089. this.components = new Container();
  2090. Document document = new Document();
  2091. ComponentResourceManager manager = new ComponentResourceManager(typeof(QueryControl));
  2092. this.splitContainer = new SplitContainer();
  2093. this.panEditor = new Panel();
  2094. this.panError = new Panel();
  2095. this.txtError = new TextBox();
  2096. this.panBottom = new Panel();
  2097. this.panOutput = new PanelEx();
  2098. this.txtSQL = new ActiproSoftware.SyntaxEditor.SyntaxEditor();
  2099. this.statusStrip = new StatusStrip();
  2100. this.lblStatus = new ToolStripStatusLabel();
  2101. this.queryProgressBar = new ToolStripProgressBar();
  2102. this.lblExecTime = new ToolStripStatusLabel();
  2103. this.lblFill = new ToolStripStatusLabel();
  2104. this.lblMiscStatus = new ToolStripStatusLabel();
  2105. this.lblUberCancel = new ToolStripStatusLabel();
  2106. this.lblElapsed = new ToolStripStatusLabel();
  2107. this.lblOptimize = new ToolStripStatusLabel();
  2108. this.tsOutput = new ToolStripEx();
  2109. this.btnArrange = new ToolStripDropDownButton();
  2110. this.miHideResults = new ToolStripMenuItem();
  2111. this.miUndock = new ToolStripMenuItem();
  2112. this.miArrangeVertical = new ToolStripMenuItem();
  2113. this.toolStripMenuItem3 = new ToolStripSeparator();
  2114. this.miScrollStart = new ToolStripMenuItem();
  2115. this.miScrollEnd = new ToolStripMenuItem();
  2116. this.miAutoScroll = new ToolStripMenuItem();
  2117. this.toolStripMenuItem4 = new ToolStripSeparator();
  2118. this.miKeyboardShortcuts = new ToolStripMenuItem();
  2119. this.btnResults = new ToolStripButton();
  2120. this.btnLambda = new ToolStripButton();
  2121. this.btnSql = new ToolStripButton();
  2122. this.btnIL = new ToolStripButton();
  2123. this.btnActivateAutocompletion = new ToolStripButton();
  2124. this.btnAnalyze = new ToolStripDropDownButton();
  2125. this.miOpenSQLQueryNewTab = new ToolStripMenuItem();
  2126. this.miOpenInSSMS = new ToolStripMenuItem();
  2127. this.btnExport = new ToolStripDropDownButton();
  2128. this.btnExportExcelNoFormat = new ToolStripMenuItem();
  2129. this.btnExportExcel = new ToolStripMenuItem();
  2130. this.toolStripSeparator1 = new ToolStripSeparator();
  2131. this.btnExportWordNoFormat = new ToolStripMenuItem();
  2132. this.btnExportWord = new ToolStripMenuItem();
  2133. this.toolStripMenuItem1 = new ToolStripSeparator();
  2134. this.btnExportHtml = new ToolStripMenuItem();
  2135. this.btnFormat = new ToolStripDropDownButton();
  2136. this.btn1NestingLevel = new ToolStripMenuItem();
  2137. this.btn2NestingLevels = new ToolStripMenuItem();
  2138. this.btn3NestingLevels = new ToolStripMenuItem();
  2139. this.btnAllNestingLevels = new ToolStripMenuItem();
  2140. this.toolStripMenuItem2 = new ToolStripSeparator();
  2141. this.btnResultFormattingPreferences = new ToolStripMenuItem();
  2142. this.lblDb = new Label();
  2143. this.cboLanguage = new ComboBox();
  2144. this.cboDb = new ComboBox();
  2145. this.lblType = new Label();
  2146. this.panTopControls = new TableLayoutPanel();
  2147. this.btnExecute = new ImageButton();
  2148. this.btnCancel = new ImageButton();
  2149. this.llDbUseCurrent = new FixedLinkLabel();
  2150. this.lblSyncDb = new Label();
  2151. this.btnText = new ClearButton();
  2152. this.btnGrids = new ClearButton();
  2153. this.panTop = new Panel();
  2154. this.panCloseButton = new Panel();
  2155. this.btnPin = new ClearButton();
  2156. this.btnClose = new ClearButton();
  2157. this.toolTip = new ToolTip(this.components);
  2158. this.panMain = new Panel();
  2159. this.splitContainer.Panel1.SuspendLayout();
  2160. this.splitContainer.Panel2.SuspendLayout();
  2161. this.splitContainer.SuspendLayout();
  2162. this.panEditor.SuspendLayout();
  2163. this.panError.SuspendLayout();
  2164. this.panBottom.SuspendLayout();
  2165. this.panOutput.SuspendLayout();
  2166. this.statusStrip.SuspendLayout();
  2167. this.tsOutput.SuspendLayout();
  2168. this.panTopControls.SuspendLayout();
  2169. this.panTop.SuspendLayout();
  2170. this.panCloseButton.SuspendLayout();
  2171. this.panMain.SuspendLayout();
  2172. base.SuspendLayout();
  2173. this.splitContainer.Dock = DockStyle.Fill;
  2174. this.splitContainer.Location = new Point(0, 0);
  2175. this.splitContainer.Name = "splitContainer";
  2176. this.splitContainer.Orientation = Orientation.Horizontal;
  2177. this.splitContainer.Panel1.Controls.Add(this.panEditor);
  2178. this.splitContainer.Panel2.Controls.Add(this.panBottom);
  2179. this.splitContainer.Size = new Size(0x2cf, 0x192);
  2180. this.splitContainer.SplitterDistance = 0xc5;
  2181. this.splitContainer.SplitterWidth = 5;
  2182. this.splitContainer.TabIndex = 0;
  2183. this.splitContainer.SplitterMoved += new SplitterEventHandler(this.splitContainer_SplitterMoved);
  2184. this.panEditor.Controls.Add(this.panError);
  2185. this.panEditor.Dock = DockStyle.Fill;
  2186. this.panEditor.Location = new Point(0, 0);
  2187. this.panEditor.Name = "panEditor";
  2188. this.panEditor.Size = new Size(0x2cf, 0xc5);
  2189. this.panEditor.TabIndex = 4;
  2190. this.panError.BackColor = SystemColors.Info;
  2191. this.panError.BorderStyle = BorderStyle.Fixed3D;
  2192. this.panError.Controls.Add(this.txtError);
  2193. this.panError.Dock = DockStyle.Top;
  2194. this.panError.Location = new Point(0, 0);
  2195. this.panError.Name = "panError";
  2196. this.panError.Padding = new Padding(3);
  2197. this.panError.Size = new Size(0x2cf, 0x27);
  2198. this.panError.TabIndex = 3;
  2199. this.panError.Visible = false;
  2200. this.panError.Layout += new LayoutEventHandler(this.panError_Layout);
  2201. this.txtError.BackColor = SystemColors.Info;
  2202. this.txtError.BorderStyle = BorderStyle.None;
  2203. this.txtError.Dock = DockStyle.Fill;
  2204. this.txtError.ForeColor = SystemColors.InfoText;
  2205. this.txtError.Location = new Point(3, 3);
  2206. this.txtError.Margin = new Padding(2);
  2207. this.txtError.Multiline = true;
  2208. this.txtError.Name = "txtError";
  2209. this.txtError.ReadOnly = true;
  2210. this.txtError.Size = new Size(0x2c5, 0x1d);
  2211. this.txtError.TabIndex = 0;
  2212. this.panBottom.BorderStyle = BorderStyle.Fixed3D;
  2213. this.panBottom.Controls.Add(this.panOutput);
  2214. this.panBottom.Controls.Add(this.statusStrip);
  2215. this.panBottom.Controls.Add(this.tsOutput);
  2216. this.panBottom.Dock = DockStyle.Fill;
  2217. this.panBottom.Location = new Point(0, 0);
  2218. this.panBottom.Name = "panBottom";
  2219. this.panBottom.Size = new Size(0x2cf, 200);
  2220. this.panBottom.TabIndex = 0;
  2221. this.panOutput.BorderColor = Color.Empty;
  2222. this.panOutput.Controls.Add(this.txtSQL);
  2223. this.panOutput.Dock = DockStyle.Fill;
  2224. this.panOutput.Location = new Point(0, 0x1a);
  2225. this.panOutput.Name = "panOutput";
  2226. this.panOutput.Size = new Size(0x2cb, 0x92);
  2227. this.panOutput.TabIndex = 1;
  2228. this.panOutput.Layout += new LayoutEventHandler(this.panOutput_Layout);
  2229. this.txtSQL.Dock = DockStyle.Fill;
  2230. this.txtSQL.set_Document(document);
  2231. this.txtSQL.set_IndicatorMarginVisible(false);
  2232. this.txtSQL.Location = new Point(0, 0);
  2233. this.txtSQL.Margin = new Padding(2);
  2234. this.txtSQL.Name = "txtSQL";
  2235. this.txtSQL.set_ScrollBarType(0);
  2236. this.txtSQL.Size = new Size(0x2cb, 0x92);
  2237. this.txtSQL.TabIndex = 0;
  2238. this.statusStrip.Items.AddRange(new ToolStripItem[] { this.lblStatus, this.queryProgressBar, this.lblExecTime, this.lblFill, this.lblMiscStatus, this.lblUberCancel, this.lblElapsed, this.lblOptimize });
  2239. this.statusStrip.Location = new Point(0, 0xac);
  2240. this.statusStrip.Name = "statusStrip";
  2241. this.statusStrip.Size = new Size(0x2cb, 0x18);
  2242. this.statusStrip.SizingGrip = false;
  2243. this.statusStrip.TabIndex = 2;
  2244. this.lblStatus.Name = "lblStatus";
  2245. this.lblStatus.Size = new Size(0x2e, 0x13);
  2246. this.lblStatus.Text = "Ready";
  2247. this.queryProgressBar.Name = "queryProgressBar";
  2248. this.queryProgressBar.Size = new Size(100, 0x12);
  2249. this.queryProgressBar.Style = ProgressBarStyle.Marquee;
  2250. this.queryProgressBar.Visible = false;
  2251. this.lblExecTime.Name = "lblExecTime";
  2252. this.lblExecTime.Size = new Size(0x11, 0x13);
  2253. this.lblExecTime.Text = " ";
  2254. this.lblExecTime.Visible = false;
  2255. this.lblFill.DisplayStyle = ToolStripItemDisplayStyle.Text;
  2256. this.lblFill.Name = "lblFill";
  2257. this.lblFill.Size = new Size(0x7a, 0x13);
  2258. this.lblFill.Spring = true;
  2259. this.lblMiscStatus.Alignment = ToolStripItemAlignment.Right;
  2260. this.lblMiscStatus.DisplayStyle = ToolStripItemDisplayStyle.Text;
  2261. this.lblMiscStatus.Name = "lblMiscStatus";
  2262. this.lblMiscStatus.Size = new Size(0x15, 0x13);
  2263. this.lblMiscStatus.Text = " ";
  2264. this.lblMiscStatus.TextAlign = ContentAlignment.MiddleRight;
  2265. this.lblUberCancel.Alignment = ToolStripItemAlignment.Right;
  2266. this.lblUberCancel.DisplayStyle = ToolStripItemDisplayStyle.Text;
  2267. this.lblUberCancel.Name = "lblUberCancel";
  2268. this.lblUberCancel.Size = new Size(0x10a, 0x13);
  2269. this.lblUberCancel.Text = " Press Ctrl+Shift+F5 to cancel all threads ";
  2270. this.lblUberCancel.TextAlign = ContentAlignment.MiddleRight;
  2271. this.lblUberCancel.Visible = false;
  2272. this.lblElapsed.Alignment = ToolStripItemAlignment.Right;
  2273. this.lblElapsed.DisplayStyle = ToolStripItemDisplayStyle.Text;
  2274. this.lblElapsed.Name = "lblElapsed";
  2275. this.lblElapsed.Size = new Size(0x11, 0x13);
  2276. this.lblElapsed.Text = " ";
  2277. this.lblElapsed.TextAlign = ContentAlignment.MiddleRight;
  2278. this.lblOptimize.BorderSides = ToolStripStatusLabelBorderSides.All;
  2279. this.lblOptimize.DisplayStyle = ToolStripItemDisplayStyle.Text;
  2280. this.lblOptimize.ImageScaling = ToolStripItemImageScaling.None;
  2281. this.lblOptimize.ImageTransparentColor = Color.White;
  2282. this.lblOptimize.Margin = new Padding(0, 2, 0, 0);
  2283. this.lblOptimize.Name = "lblOptimize";
  2284. this.lblOptimize.Padding = new Padding(2, 0, 0, 0);
  2285. this.lblOptimize.Size = new Size(0x4e, 0x17);
  2286. this.lblOptimize.Text = "/optimize+";
  2287. this.lblOptimize.MouseHover += new EventHandler(this.lblOptimize_MouseHover);
  2288. this.lblOptimize.Paint += new PaintEventHandler(this.lblOptimize_Paint);
  2289. this.lblOptimize.MouseEnter += new EventHandler(this.lblOptimize_MouseEnter);
  2290. this.lblOptimize.MouseLeave += new EventHandler(this.lblOptimize_MouseLeave);
  2291. this.lblOptimize.MouseDown += new MouseEventHandler(this.lblOptimize_MouseDown);
  2292. this.lblOptimize.Click += new EventHandler(this.lblOptimize_Click);
  2293. this.tsOutput.GripStyle = ToolStripGripStyle.Hidden;
  2294. this.tsOutput.Items.AddRange(new ToolStripItem[] { this.btnArrange, this.btnResults, this.btnLambda, this.btnSql, this.btnIL, this.btnActivateAutocompletion, this.btnAnalyze, this.btnExport, this.btnFormat });
  2295. this.tsOutput.Location = new Point(0, 0);
  2296. this.tsOutput.Name = "tsOutput";
  2297. this.tsOutput.Padding = new Padding(0, 0, 1, 2);
  2298. this.tsOutput.RenderMode = ToolStripRenderMode.System;
  2299. this.tsOutput.Size = new Size(0x2cb, 0x1a);
  2300. this.tsOutput.TabIndex = 0;
  2301. this.tsOutput.Text = "toolStrip1";
  2302. this.tsOutput.MouseEnter += new EventHandler(this.tsOutput_MouseEnter);
  2303. this.btnArrange.DisplayStyle = ToolStripItemDisplayStyle.Image;
  2304. this.btnArrange.DropDownItems.AddRange(new ToolStripItem[] { this.miHideResults, this.miUndock, this.miArrangeVertical, this.toolStripMenuItem3, this.miScrollStart, this.miScrollEnd, this.miAutoScroll, this.toolStripMenuItem4, this.miKeyboardShortcuts });
  2305. this.btnArrange.Image = Resources.DropArrow;
  2306. this.btnArrange.ImageScaling = ToolStripItemImageScaling.None;
  2307. this.btnArrange.Margin = new Padding(0, 1, 3, 2);
  2308. this.btnArrange.Name = "btnArrange";
  2309. this.btnArrange.Padding = new Padding(0, 3, 0, 2);
  2310. this.btnArrange.ShowDropDownArrow = false;
  2311. this.btnArrange.Size = new Size(0x12, 0x15);
  2312. this.btnArrange.DropDownOpening += new EventHandler(this.btnArrange_DropDownOpening);
  2313. this.miHideResults.Name = "miHideResults";
  2314. this.miHideResults.ShortcutKeyDisplayString = "Ctrl+R";
  2315. this.miHideResults.Size = new Size(0x142, 0x18);
  2316. this.miHideResults.Text = "Hide Results Panel";
  2317. this.miHideResults.Click += new EventHandler(this.miHideResults_Click);
  2318. this.miUndock.Name = "miUndock";
  2319. this.miUndock.ShortcutKeyDisplayString = "F8";
  2320. this.miUndock.Size = new Size(0x142, 0x18);
  2321. this.miUndock.Text = "Undock Panel into Second Monitor";
  2322. this.miUndock.Click += new EventHandler(this.miUndock_Click);
  2323. this.miArrangeVertical.Name = "miArrangeVertical";
  2324. this.miArrangeVertical.ShortcutKeyDisplayString = "Ctrl+F8";
  2325. this.miArrangeVertical.Size = new Size(0x142, 0x18);
  2326. this.miArrangeVertical.Text = "Arrange Panel Vertically";
  2327. this.miArrangeVertical.Click += new EventHandler(this.miArrangeVertical_Click);
  2328. this.toolStripMenuItem3.Name = "toolStripMenuItem3";
  2329. this.toolStripMenuItem3.Size = new Size(0x13f, 6);
  2330. this.miScrollStart.Name = "miScrollStart";
  2331. this.miScrollStart.ShortcutKeyDisplayString = "Alt+Home";
  2332. this.miScrollStart.Size = new Size(0x142, 0x18);
  2333. this.miScrollStart.Text = "Scroll to Start";
  2334. this.miScrollStart.Click += new EventHandler(this.miScrollStart_Click);
  2335. this.miScrollEnd.Name = "miScrollEnd";
  2336. this.miScrollEnd.ShortcutKeyDisplayString = "Alt+End";
  2337. this.miScrollEnd.Size = new Size(0x142, 0x18);
  2338. this.miScrollEnd.Text = "Scroll to End";
  2339. this.miScrollEnd.Click += new EventHandler(this.miScrollEnd_Click);
  2340. this.miAutoScroll.Name = "miAutoScroll";
  2341. this.miAutoScroll.ShortcutKeyDisplayString = "Ctrl+Shift+E";
  2342. this.miAutoScroll.Size = new Size(0x142, 0x18);
  2343. this.miAutoScroll.Text = "Auto-Scroll Results to End";
  2344. this.miAutoScroll.Click += new EventHandler(this.miAutoScroll_Click);
  2345. this.toolStripMenuItem4.Name = "toolStripMenuItem4";
  2346. this.toolStripMenuItem4.Size = new Size(0x13f, 6);
  2347. this.miKeyboardShortcuts.Name = "miKeyboardShortcuts";
  2348. this.miKeyboardShortcuts.Size = new Size(0x142, 0x18);
  2349. this.miKeyboardShortcuts.Text = "See more keyboard shortcuts...";
  2350. this.miKeyboardShortcuts.Click += new EventHandler(this.miKeyboardShortcuts_Click);
  2351. this.btnResults.Checked = true;
  2352. this.btnResults.CheckState = CheckState.Checked;
  2353. this.btnResults.DisplayStyle = ToolStripItemDisplayStyle.Text;
  2354. this.btnResults.Image = (Image) manager.GetObject("btnResults.Image");
  2355. this.btnResults.ImageTransparentColor = Color.Magenta;
  2356. this.btnResults.Margin = new Padding(0, 0, 0, 1);
  2357. this.btnResults.Name = "btnResults";
  2358. this.btnResults.Size = new Size(0x38, 0x17);
  2359. this.btnResults.Text = "&Results";
  2360. this.btnResults.Click += new EventHandler(this.btnResults_Click);
  2361. this.btnLambda.DisplayStyle = ToolStripItemDisplayStyle.Text;
  2362. this.btnLambda.Font = new Font("Microsoft Sans Serif", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
  2363. this.btnLambda.Image = (Image) manager.GetObject("btnLambda.Image");
  2364. this.btnLambda.ImageTransparentColor = Color.Magenta;
  2365. this.btnLambda.Margin = new Padding(0, 0, 0, 1);
  2366. this.btnLambda.Name = "btnLambda";
  2367. this.btnLambda.Size = new Size(0x1b, 0x17);
  2368. this.btnLambda.Text = " λ ";
  2369. this.btnLambda.Click += new EventHandler(this.btnLambda_Click);
  2370. this.btnSql.DisplayStyle = ToolStripItemDisplayStyle.Text;
  2371. this.btnSql.Image = (Image) manager.GetObject("btnSql.Image");
  2372. this.btnSql.ImageTransparentColor = Color.Magenta;
  2373. this.btnSql.Margin = new Padding(0, 0, 0, 1);
  2374. this.btnSql.Name = "btnSql";
  2375. this.btnSql.Size = new Size(0x26, 0x17);
  2376. this.btnSql.Text = "&SQL";
  2377. this.btnSql.Click += new EventHandler(this.btnSql_Click);
  2378. this.btnIL.DisplayStyle = ToolStripItemDisplayStyle.Text;
  2379. this.btnIL.Image = (Image) manager.GetObject("btnIL.Image");
  2380. this.btnIL.ImageTransparentColor = Color.Magenta;
  2381. this.btnIL.Margin = new Padding(0, 0, 0, 1);
  2382. this.btnIL.Name = "btnIL";
  2383. this.btnIL.Size = new Size(0x20, 0x17);
  2384. this.btnIL.Text = " &IL ";
  2385. this.btnIL.Click += new EventHandler(this.btnIL_Click);
  2386. this.btnActivateAutocompletion.Alignment = ToolStripItemAlignment.Right;
  2387. this.btnActivateAutocompletion.DisplayStyle = ToolStripItemDisplayStyle.Text;
  2388. this.btnActivateAutocompletion.ForeColor = Color.Blue;
  2389. this.btnActivateAutocompletion.Image = (Image) manager.GetObject("btnActivateAutocompletion.Image");
  2390. this.btnActivateAutocompletion.ImageTransparentColor = Color.Magenta;
  2391. this.btnActivateAutocompletion.Margin = new Padding(5, 0, 0, 0);
  2392. this.btnActivateAutocompletion.Name = "btnActivateAutocompletion";
  2393. this.btnActivateAutocompletion.Size = new Size(0xa4, 0x18);
  2394. this.btnActivateAutocompletion.Text = "Activate Autocompletion";
  2395. this.btnActivateAutocompletion.Click += new EventHandler(this.btnActivateAutocompletion_Click);
  2396. this.btnAnalyze.Alignment = ToolStripItemAlignment.Right;
  2397. this.btnAnalyze.DisplayStyle = ToolStripItemDisplayStyle.Text;
  2398. this.btnAnalyze.DropDownItems.AddRange(new ToolStripItem[] { this.miOpenSQLQueryNewTab, this.miOpenInSSMS });
  2399. this.btnAnalyze.Image = (Image) manager.GetObject("btnAnalyze.Image");
  2400. this.btnAnalyze.ImageTransparentColor = Color.Magenta;
  2401. this.btnAnalyze.Margin = new Padding(2, 0, 0, 0);
  2402. this.btnAnalyze.Name = "btnAnalyze";
  2403. this.btnAnalyze.Size = new Size(0x62, 0x18);
  2404. this.btnAnalyze.Text = "A&nalyze SQL";
  2405. this.miOpenSQLQueryNewTab.Image = Resources.New;
  2406. this.miOpenSQLQueryNewTab.Name = "miOpenSQLQueryNewTab";
  2407. this.miOpenSQLQueryNewTab.Size = new Size(0x11d, 0x18);
  2408. this.miOpenSQLQueryNewTab.Text = "Open as SQL Query in New Tab";
  2409. this.miOpenSQLQueryNewTab.Click += new EventHandler(this.miOpenSQLQueryNewTab_Click);
  2410. this.miOpenInSSMS.Image = Resources.SSMS;
  2411. this.miOpenInSSMS.Name = "miOpenInSSMS";
  2412. this.miOpenInSSMS.Size = new Size(0x11d, 0x18);
  2413. this.miOpenInSSMS.Text = "Open in SQL Management Studio";
  2414. this.miOpenInSSMS.Click += new EventHandler(this.miOpenInSSMS_Click);
  2415. this.btnExport.Alignment = ToolStripItemAlignment.Right;
  2416. this.btnExport.DisplayStyle = ToolStripItemDisplayStyle.Text;
  2417. this.btnExport.DropDownItems.AddRange(new ToolStripItem[] { this.btnExportExcelNoFormat, this.btnExportExcel, this.toolStripSeparator1, this.btnExportWordNoFormat, this.btnExportWord, this.toolStripMenuItem1, this.btnExportHtml });
  2418. this.btnExport.ImageTransparentColor = Color.Magenta;
  2419. this.btnExport.Margin = new Padding(2, 0, 0, 0);
  2420. this.btnExport.Name = "btnExport";
  2421. this.btnExport.Size = new Size(0x3d, 0x18);
  2422. this.btnExport.Text = "Ex&port";
  2423. this.btnExportExcelNoFormat.Image = Resources.Excel;
  2424. this.btnExportExcelNoFormat.Name = "btnExportExcelNoFormat";
  2425. this.btnExportExcelNoFormat.Size = new Size(0x115, 0x18);
  2426. this.btnExportExcelNoFormat.Text = "Export to Excel";
  2427. this.btnExportExcelNoFormat.Click += new EventHandler(this.btnExportExcelNoFormat_Click);
  2428. this.btnExportExcel.Image = Resources.Excel;
  2429. this.btnExportExcel.Name = "btnExportExcel";
  2430. this.btnExportExcel.Size = new Size(0x115, 0x18);
  2431. this.btnExportExcel.Text = "Export to Excel With Formatting";
  2432. this.btnExportExcel.Click += new EventHandler(this.btnExportExcel_Click);
  2433. this.toolStripSeparator1.Name = "toolStripSeparator1";
  2434. this.toolStripSeparator1.Size = new Size(0x112, 6);
  2435. this.btnExportWordNoFormat.Image = Resources.Word;
  2436. this.btnExportWordNoFormat.Name = "btnExportWordNoFormat";
  2437. this.btnExportWordNoFormat.Size = new Size(0x115, 0x18);
  2438. this.btnExportWordNoFormat.Text = "Export to Word";
  2439. this.btnExportWordNoFormat.Click += new EventHandler(this.btnExportWordNoFormat_Click);
  2440. this.btnExportWord.Image = Resources.Word;
  2441. this.btnExportWord.Name = "btnExportWord";
  2442. this.btnExportWord.Size = new Size(0x115, 0x18);
  2443. this.btnExportWord.Text = "Export to Word With Formatting";
  2444. this.btnExportWord.Click += new EventHandler(this.btnExportWord_Click);
  2445. this.toolStripMenuItem1.Name = "toolStripMenuItem1";
  2446. this.toolStripMenuItem1.Size = new Size(0x112, 6);
  2447. this.btnExportHtml.Name = "btnExportHtml";
  2448. this.btnExportHtml.Size = new Size(0x115, 0x18);
  2449. this.btnExportHtml.Text = "Export to HTML";
  2450. this.btnExportHtml.Click += new EventHandler(this.btnExportHtml_Click);
  2451. this.btnFormat.Alignment = ToolStripItemAlignment.Right;
  2452. this.btnFormat.DisplayStyle = ToolStripItemDisplayStyle.Text;
  2453. this.btnFormat.DropDownItems.AddRange(new ToolStripItem[] { this.btn1NestingLevel, this.btn2NestingLevels, this.btn3NestingLevels, this.btnAllNestingLevels, this.toolStripMenuItem2, this.btnResultFormattingPreferences });
  2454. this.btnFormat.ImageTransparentColor = Color.Magenta;
  2455. this.btnFormat.Margin = new Padding(2, 0, 0, 0);
  2456. this.btnFormat.Name = "btnFormat";
  2457. this.btnFormat.Size = new Size(0x42, 0x18);
  2458. this.btnFormat.Text = "Format";
  2459. this.btn1NestingLevel.Name = "btn1NestingLevel";
  2460. this.btn1NestingLevel.ShortcutKeyDisplayString = "Alt+1";
  2461. this.btn1NestingLevel.Size = new Size(0x126, 0x18);
  2462. this.btn1NestingLevel.Text = "Collapse to 1 Nesting Level";
  2463. this.btn1NestingLevel.Click += new EventHandler(this.btn1NestingLevel_Click);
  2464. this.btn2NestingLevels.Name = "btn2NestingLevels";
  2465. this.btn2NestingLevels.ShortcutKeyDisplayString = "Alt+2";
  2466. this.btn2NestingLevels.Size = new Size(0x126, 0x18);
  2467. this.btn2NestingLevels.Text = "Collapse to 2 Nesting Levels";
  2468. this.btn2NestingLevels.Click += new EventHandler(this.btn2NestingLevels_Click);
  2469. this.btn3NestingLevels.Name = "btn3NestingLevels";
  2470. this.btn3NestingLevels.ShortcutKeyDisplayString = "Alt+3";
  2471. this.btn3NestingLevels.Size = new Size(0x126, 0x18);
  2472. this.btn3NestingLevels.Text = "Collapse to 3 Nesting Levels";
  2473. this.btn3NestingLevels.Click += new EventHandler(this.btn3NestingLevels_Click);
  2474. this.btnAllNestingLevels.Name = "btnAllNestingLevels";
  2475. this.btnAllNestingLevels.ShortcutKeyDisplayString = "Alt+0";
  2476. this.btnAllNestingLevels.Size = new Size(0x126, 0x18);
  2477. this.btnAllNestingLevels.Text = "Show All Nesting Levels";
  2478. this.btnAllNestingLevels.Click += new EventHandler(this.btnAllNestingLevels_Click);
  2479. this.toolStripMenuItem2.Name = "toolStripMenuItem2";
  2480. this.toolStripMenuItem2.Size = new Size(0x123, 6);
  2481. this.btnResultFormattingPreferences.Name = "btnResultFormattingPreferences";
  2482. this.btnResultFormattingPreferences.Size = new Size(0x126, 0x18);
  2483. this.btnResultFormattingPreferences.Text = "Result Formatting Preferences...";
  2484. this.btnResultFormattingPreferences.Click += new EventHandler(this.btnResultFormattingPreferences_Click);
  2485. this.lblDb.Anchor = AnchorStyles.Left;
  2486. this.lblDb.AutoSize = true;
  2487. this.lblDb.Location = new Point(0x151, 6);
  2488. this.lblDb.Margin = new Padding(0);
  2489. this.lblDb.Name = "lblDb";
  2490. this.lblDb.Size = new Size(60, 15);
  2491. this.lblDb.TabIndex = 4;
  2492. this.lblDb.Text = "&Database";
  2493. this.lblDb.TextAlign = ContentAlignment.MiddleLeft;
  2494. this.cboLanguage.Anchor = AnchorStyles.Left;
  2495. this.cboLanguage.DropDownStyle = ComboBoxStyle.DropDownList;
  2496. this.cboLanguage.FormattingEnabled = true;
  2497. this.cboLanguage.Items.AddRange(new object[] { "C# Expression", "C# Statement(s)", "C# Program", "VB Expression", "VB Statement(s)", "VB Program", "SQL", "ESQL", "F# Expression", "F# Program" });
  2498. this.cboLanguage.Location = new Point(0xc6, 3);
  2499. this.cboLanguage.Margin = new Padding(2, 2, 12, 2);
  2500. this.cboLanguage.Name = "cboLanguage";
  2501. this.cboLanguage.Size = new Size(0x69, 0x15);
  2502. this.cboLanguage.TabIndex = 3;
  2503. this.cboLanguage.TabStop = false;
  2504. this.cboLanguage.SelectionChangeCommitted += new EventHandler(this.cboLanguage_SelectionChangeCommitted);
  2505. this.cboLanguage.Leave += new EventHandler(this.cboType_SelectedIndexChanged);
  2506. this.cboLanguage.Enter += new EventHandler(this.cboType_Enter);
  2507. this.cboLanguage.DropDownClosed += new EventHandler(this.cboType_DropDownClosed);
  2508. this.cboDb.Anchor = AnchorStyles.Right | AnchorStyles.Left;
  2509. this.cboDb.DropDownStyle = ComboBoxStyle.DropDownList;
  2510. this.cboDb.FormattingEnabled = true;
  2511. this.cboDb.Location = new Point(0x18f, 3);
  2512. this.cboDb.Margin = new Padding(2);
  2513. this.cboDb.Name = "cboDb";
  2514. this.cboDb.Size = new Size(0xbb, 0x15);
  2515. this.cboDb.TabIndex = 5;
  2516. this.cboDb.TabStop = false;
  2517. this.cboDb.Leave += new EventHandler(this.cboDb_SelectedIndexChanged);
  2518. this.cboDb.Enter += new EventHandler(this.cboDb_Enter);
  2519. this.cboDb.DropDownClosed += new EventHandler(this.cboDb_DropDownClosed);
  2520. this.cboDb.DropDown += new EventHandler(this.cboDb_DropDown);
  2521. this.lblType.Anchor = AnchorStyles.Left;
  2522. this.lblType.AutoSize = true;
  2523. this.lblType.Location = new Point(0x7f, 6);
  2524. this.lblType.Margin = new Padding(2, 0, 0, 0);
  2525. this.lblType.Name = "lblType";
  2526. this.lblType.Padding = new Padding(6, 0, 0, 0);
  2527. this.lblType.Size = new Size(0x45, 15);
  2528. this.lblType.TabIndex = 2;
  2529. this.lblType.Text = "&Language";
  2530. this.lblType.TextAlign = ContentAlignment.MiddleLeft;
  2531. this.panTopControls.AutoSize = true;
  2532. this.panTopControls.AutoSizeMode = AutoSizeMode.GrowAndShrink;
  2533. this.panTopControls.ColumnCount = 10;
  2534. this.panTopControls.ColumnStyles.Add(new ColumnStyle());
  2535. this.panTopControls.ColumnStyles.Add(new ColumnStyle());
  2536. this.panTopControls.ColumnStyles.Add(new ColumnStyle());
  2537. this.panTopControls.ColumnStyles.Add(new ColumnStyle());
  2538. this.panTopControls.ColumnStyles.Add(new ColumnStyle());
  2539. this.panTopControls.ColumnStyles.Add(new ColumnStyle());
  2540. this.panTopControls.ColumnStyles.Add(new ColumnStyle());
  2541. this.panTopControls.ColumnStyles.Add(new ColumnStyle());
  2542. this.panTopControls.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100f));
  2543. this.panTopControls.ColumnStyles.Add(new ColumnStyle());
  2544. this.panTopControls.Controls.Add(this.btnExecute, 0, 0);
  2545. this.panTopControls.Controls.Add(this.btnCancel, 1, 0);
  2546. this.panTopControls.Controls.Add(this.lblDb, 7, 0);
  2547. this.panTopControls.Controls.Add(this.lblType, 4, 0);
  2548. this.panTopControls.Controls.Add(this.cboLanguage, 5, 0);
  2549. this.panTopControls.Controls.Add(this.llDbUseCurrent, 9, 0);
  2550. this.panTopControls.Controls.Add(this.cboDb, 8, 0);
  2551. this.panTopControls.Controls.Add(this.lblSyncDb, 6, 0);
  2552. this.panTopControls.Controls.Add(this.btnText, 2, 0);
  2553. this.panTopControls.Controls.Add(this.btnGrids, 3, 0);
  2554. this.panTopControls.Dock = DockStyle.Top;
  2555. this.panTopControls.Location = new Point(0, 0);
  2556. this.panTopControls.Margin = new Padding(2);
  2557. this.panTopControls.Name = "panTopControls";
  2558. this.panTopControls.Padding = new Padding(0, 0, 15, 1);
  2559. this.panTopControls.RowCount = 1;
  2560. this.panTopControls.RowStyles.Add(new RowStyle());
  2561. this.panTopControls.Size = new Size(0x2a3, 0x1d);
  2562. this.panTopControls.TabIndex = 8;
  2563. this.btnExecute.Image = Resources.Execute;
  2564. this.btnExecute.Location = new Point(0, 2);
  2565. this.btnExecute.Margin = new Padding(0, 2, 1, 2);
  2566. this.btnExecute.Name = "btnExecute";
  2567. this.btnExecute.Size = new Size(30, 0x17);
  2568. this.btnExecute.TabIndex = 0;
  2569. this.btnExecute.TabStop = false;
  2570. this.toolTip.SetToolTip(this.btnExecute, "Execute (F5)");
  2571. this.btnExecute.UseVisualStyleBackColor = true;
  2572. this.btnExecute.Click += new EventHandler(this.btnExecute_Click);
  2573. this.btnCancel.Enabled = false;
  2574. this.btnCancel.Image = Resources.Cancel;
  2575. this.btnCancel.Location = new Point(0x21, 2);
  2576. this.btnCancel.Margin = new Padding(2);
  2577. this.btnCancel.Name = "btnCancel";
  2578. this.btnCancel.Size = new Size(30, 0x17);
  2579. this.btnCancel.TabIndex = 1;
  2580. this.btnCancel.TabStop = false;
  2581. this.toolTip.SetToolTip(this.btnCancel, "Cancel (Shift+F5)");
  2582. this.btnCancel.UseVisualStyleBackColor = true;
  2583. this.btnCancel.Click += new EventHandler(this.btnCancel_Click);
  2584. this.llDbUseCurrent.Anchor = AnchorStyles.Left;
  2585. this.llDbUseCurrent.AutoSize = true;
  2586. this.llDbUseCurrent.Cursor = Cursors.Hand;
  2587. this.llDbUseCurrent.ForeColor = Color.Blue;
  2588. this.llDbUseCurrent.Location = new Point(590, 6);
  2589. this.llDbUseCurrent.Margin = new Padding(2, 0, 0, 0);
  2590. this.llDbUseCurrent.Name = "llDbUseCurrent";
  2591. this.llDbUseCurrent.Size = new Size(70, 15);
  2592. this.llDbUseCurrent.TabIndex = 6;
  2593. this.llDbUseCurrent.TabStop = true;
  2594. this.llDbUseCurrent.Text = "Use current";
  2595. this.llDbUseCurrent.TextAlign = ContentAlignment.MiddleLeft;
  2596. this.llDbUseCurrent.LinkClicked += new EventHandler(this.llDbUseCurrent_LinkClicked);
  2597. this.lblSyncDb.Anchor = AnchorStyles.Left;
  2598. this.lblSyncDb.AutoSize = true;
  2599. this.lblSyncDb.Cursor = Cursors.Hand;
  2600. this.lblSyncDb.Font = new Font("Wingdings", 10.2f, FontStyle.Regular, GraphicsUnit.Point, 2);
  2601. this.lblSyncDb.Location = new Point(0x13b, 6);
  2602. this.lblSyncDb.Margin = new Padding(0, 2, 0, 0);
  2603. this.lblSyncDb.Name = "lblSyncDb";
  2604. this.lblSyncDb.Size = new Size(0x16, 0x11);
  2605. this.lblSyncDb.TabIndex = 7;
  2606. this.lblSyncDb.Text = "\x00ef";
  2607. this.lblSyncDb.Click += new EventHandler(this.lblSyncDb_Click);
  2608. this.btnText.Checked = true;
  2609. this.btnText.Image = Resources.TextResults;
  2610. this.btnText.Location = new Point(0x4d, 3);
  2611. this.btnText.Margin = new Padding(12, 3, 0, 2);
  2612. this.btnText.Name = "btnText";
  2613. this.btnText.NoImageScale = false;
  2614. this.btnText.Size = new Size(0x17, 0x17);
  2615. this.btnText.TabIndex = 8;
  2616. this.btnText.TabStop = false;
  2617. this.toolTip.SetToolTip(this.btnText, "Results to Rich Text (Ctrl+Shift+T)");
  2618. this.btnText.ToolTipText = "";
  2619. this.btnText.Click += new EventHandler(this.btnText_Click);
  2620. this.btnGrids.Checked = false;
  2621. this.btnGrids.Image = Resources.GridResults;
  2622. this.btnGrids.Location = new Point(100, 3);
  2623. this.btnGrids.Margin = new Padding(0, 3, 2, 2);
  2624. this.btnGrids.Name = "btnGrids";
  2625. this.btnGrids.NoImageScale = false;
  2626. this.btnGrids.Size = new Size(0x17, 0x17);
  2627. this.btnGrids.TabIndex = 9;
  2628. this.btnGrids.TabStop = false;
  2629. this.toolTip.SetToolTip(this.btnGrids, "Results to Data Grids (Ctrl+Shift+G)");
  2630. this.btnGrids.ToolTipText = "";
  2631. this.btnGrids.Click += new EventHandler(this.btnGrids_Click);
  2632. this.panTop.AutoSize = true;
  2633. this.panTop.Controls.Add(this.panTopControls);
  2634. this.panTop.Controls.Add(this.panCloseButton);
  2635. this.panTop.Dock = DockStyle.Top;
  2636. this.panTop.Location = new Point(0, 0);
  2637. this.panTop.Name = "panTop";
  2638. this.panTop.Size = new Size(0x2cf, 0x1d);
  2639. this.panTop.TabIndex = 4;
  2640. this.panCloseButton.Controls.Add(this.btnPin);
  2641. this.panCloseButton.Controls.Add(this.btnClose);
  2642. this.panCloseButton.Dock = DockStyle.Right;
  2643. this.panCloseButton.Location = new Point(0x2a3, 0);
  2644. this.panCloseButton.Margin = new Padding(2);
  2645. this.panCloseButton.Name = "panCloseButton";
  2646. this.panCloseButton.Padding = new Padding(0, 3, 2, 4);
  2647. this.panCloseButton.Size = new Size(0x2c, 0x1d);
  2648. this.panCloseButton.TabIndex = 9;
  2649. this.btnPin.Checked = false;
  2650. this.btnPin.Dock = DockStyle.Left;
  2651. this.btnPin.Glyph = ButtonGlyph.Pin;
  2652. this.btnPin.Location = new Point(0, 3);
  2653. this.btnPin.Margin = new Padding(2);
  2654. this.btnPin.Name = "btnPin";
  2655. this.btnPin.NoImageScale = false;
  2656. this.btnPin.Size = new Size(20, 0x16);
  2657. this.btnPin.TabIndex = 1;
  2658. this.toolTip.SetToolTip(this.btnPin, "Keep query open");
  2659. this.btnPin.ToolTipText = "";
  2660. this.btnPin.Click += new EventHandler(this.btnPin_Click);
  2661. this.btnClose.Checked = false;
  2662. this.btnClose.Dock = DockStyle.Right;
  2663. this.btnClose.Location = new Point(0x16, 3);
  2664. this.btnClose.Margin = new Padding(2);
  2665. this.btnClose.Name = "btnClose";
  2666. this.btnClose.NoImageScale = false;
  2667. this.btnClose.Size = new Size(20, 0x16);
  2668. this.btnClose.TabIndex = 0;
  2669. this.toolTip.SetToolTip(this.btnClose, "Close query (Ctrl+F4)");
  2670. this.btnClose.ToolTipText = "";
  2671. this.btnClose.Click += new EventHandler(this.btnClose_Click);
  2672. this.panMain.Controls.Add(this.splitContainer);
  2673. this.panMain.Dock = DockStyle.Fill;
  2674. this.panMain.Location = new Point(0, 0x1d);
  2675. this.panMain.Name = "panMain";
  2676. this.panMain.Size = new Size(0x2cf, 0x192);
  2677. this.panMain.TabIndex = 3;
  2678. base.AutoScaleDimensions = new SizeF(6f, 13f);
  2679. base.AutoScaleMode = AutoScaleMode.Font;
  2680. this.BackColor = Color.Transparent;
  2681. base.Controls.Add(this.panMain);
  2682. base.Controls.Add(this.panTop);
  2683. base.Name = "QueryControl";
  2684. base.Size = new Size(0x2cf, 0x1af);
  2685. this.splitContainer.Panel1.ResumeLayout(false);
  2686. this.splitContainer.Panel2.ResumeLayout(false);
  2687. this.splitContainer.ResumeLayout(false);
  2688. this.panEditor.ResumeLayout(false);
  2689. this.panError.ResumeLayout(false);
  2690. this.panError.PerformLayout();
  2691. this.panBottom.ResumeLayout(false);
  2692. this.panBottom.PerformLayout();
  2693. this.panOutput.ResumeLayout(false);
  2694. this.statusStrip.ResumeLayout(false);
  2695. this.statusStrip.PerformLayout();
  2696. this.tsOutput.ResumeLayout(false);
  2697. this.tsOutput.PerformLayout();
  2698. this.panTopControls.ResumeLayout(false);
  2699. this.panTopControls.PerformLayout();
  2700. this.panTop.ResumeLayout(false);
  2701. this.panTop.PerformLayout();
  2702. this.panCloseButton.ResumeLayout(false);
  2703. this.panMain.ResumeLayout(false);
  2704. base.ResumeLayout(false);
  2705. base.PerformLayout();
  2706. }
  2707. internal void InsertSnippet(bool surroundWith)
  2708. {
  2709. if (this._editor.get_Document().get_Language() is CSharpSyntaxLanguage)
  2710. {
  2711. this._editor.InsertSnippet(surroundWith);
  2712. }
  2713. }
  2714. internal void InsertText(string text, int postCaretAdjustment)
  2715. {
  2716. this._editor.get_Document().InsertText(0x1d, this._editor.get_Caret().get_Offset(), text);
  2717. try
  2718. {
  2719. Caret caret1 = this._editor.get_Caret();
  2720. caret1.set_Offset(caret1.get_Offset() + postCaretAdjustment);
  2721. }
  2722. catch
  2723. {
  2724. }
  2725. }
  2726. public bool IsAutoScrollingResultsFromQuery()
  2727. {
  2728. return (this._autoScrollResultsFromQuery == true);
  2729. }
  2730. internal bool IsEditorFocused()
  2731. {
  2732. return this._editor.ContainsFocus;
  2733. }
  2734. internal bool IsInDataGridMode()
  2735. {
  2736. return (this.btnResults.Text == "&Output");
  2737. }
  2738. internal bool IsMouseInPlugIn()
  2739. {
  2740. if (!this.IsPluginSelected())
  2741. {
  2742. return false;
  2743. }
  2744. return this.GetWinManagerTargetBounds().Contains(Control.MousePosition);
  2745. }
  2746. internal bool IsPluginSelected()
  2747. {
  2748. return this._pluginWinButtons.Any<ToolStripButton>(b => b.Checked);
  2749. }
  2750. private bool IsQueryLanguageTrackable(QueryLanguage language)
  2751. {
  2752. return ((((language == QueryLanguage.Statements) || (language == QueryLanguage.Program)) || (language == QueryLanguage.VBStatements)) || (language == QueryLanguage.VBProgram));
  2753. }
  2754. internal void JumpToExecutingLine()
  2755. {
  2756. Action a = null;
  2757. if (this._query.IsRunning)
  2758. {
  2759. if (!this.IsQueryLanguageTrackable(this._executingQueryLanguage))
  2760. {
  2761. MessageBox.Show("Query is not in Statements or Program mode.", "Jump to Execution Point", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  2762. }
  2763. if (this._executingQueryOptimized && !_warnedAboutOptimizationTracking)
  2764. {
  2765. _warnedAboutOptimizationTracking = true;
  2766. MessageBox.Show("Execution tracking is only approximate while compiler optimizations are enabled. Click the button on the status bar and re-run query to disable optimizations.", "Jump to Execution Point", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  2767. }
  2768. this._editor.set_CurrentLineHighlightingVisible(false);
  2769. ExecutionTrackInfo mainThreadPosition = this._query.GetMainThreadPosition(true);
  2770. if (((mainThreadPosition != null) && (mainThreadPosition.MainThreadStack != null)) && (mainThreadPosition.MainThreadStack.Length != 0))
  2771. {
  2772. int row = mainThreadPosition.MainThreadStack[0].Row - 1;
  2773. int column = mainThreadPosition.MainThreadStack[0].Column - 1;
  2774. try
  2775. {
  2776. int num3;
  2777. this._editor.get_SelectedView().get_Selection().set_StartOffset(num3 = this.GetOffsetFromRowCol(row, column));
  2778. this._editor.get_SelectedView().get_Selection().set_EndOffset(num3);
  2779. if (a == null)
  2780. {
  2781. a = () => this._editor.set_CurrentLineHighlightingVisible(true);
  2782. }
  2783. Program.RunOnWinFormsTimer(a, 50);
  2784. }
  2785. catch
  2786. {
  2787. }
  2788. }
  2789. }
  2790. }
  2791. private void KillIEComExceptionTimer()
  2792. {
  2793. if (this._ieComExceptionTimer != null)
  2794. {
  2795. this._ieComExceptionTimer.Dispose();
  2796. this._ieComExceptionTimer = null;
  2797. }
  2798. }
  2799. private void lblOptimize_Click(object sender, EventArgs e)
  2800. {
  2801. MainForm.Instance.OptimizeQueries = !MainForm.Instance.OptimizeQueries;
  2802. if (this._optimizeTipShown)
  2803. {
  2804. this.ShowOptimizeTip();
  2805. }
  2806. }
  2807. private void lblOptimize_MouseDown(object sender, MouseEventArgs e)
  2808. {
  2809. if (e.Button == MouseButtons.Right)
  2810. {
  2811. using (OptionsForm form = new OptionsForm(1))
  2812. {
  2813. form.ShowDialog(MainForm.Instance);
  2814. }
  2815. }
  2816. }
  2817. private void lblOptimize_MouseEnter(object sender, EventArgs e)
  2818. {
  2819. }
  2820. private void lblOptimize_MouseHover(object sender, EventArgs e)
  2821. {
  2822. this.ShowOptimizeTip();
  2823. }
  2824. private void lblOptimize_MouseLeave(object sender, EventArgs e)
  2825. {
  2826. if (this._optimizeTipShown)
  2827. {
  2828. this.toolTip.Hide(this.statusStrip);
  2829. this._optimizeTipShown = false;
  2830. }
  2831. }
  2832. private void lblOptimize_Paint(object sender, PaintEventArgs e)
  2833. {
  2834. }
  2835. private void lblSyncDb_Click(object sender, EventArgs e)
  2836. {
  2837. if (this._query.Repository != null)
  2838. {
  2839. this._schemaTree.RegisterRepository(this._query, true, false);
  2840. }
  2841. }
  2842. internal void ListMembers()
  2843. {
  2844. if (this._editor.get_Document().get_Language() is CSharpSyntaxLanguage)
  2845. {
  2846. ((ICustomSyntaxLanguage) this._editor.get_Document().get_Language()).ShowIntelliPromptMemberList(this._editor, false, false);
  2847. }
  2848. }
  2849. internal void ListMembersWithoutExtensions()
  2850. {
  2851. if (this._editor.get_Document().get_Language() is CSharpSyntaxLanguage)
  2852. {
  2853. ((ICustomSyntaxLanguage) this._editor.get_Document().get_Language()).ShowIntelliPromptMemberList(this._editor, false, false, null, true);
  2854. }
  2855. }
  2856. internal void ListTables()
  2857. {
  2858. if (this._editor.get_Document().get_Language() is CSharpSyntaxLanguage)
  2859. {
  2860. ((ICustomSyntaxLanguage) this._editor.get_Document().get_Language()).ShowIntelliPromptMemberList(this._editor, true, false);
  2861. }
  2862. }
  2863. private void llDbUseCurrent_LinkClicked(object sender, EventArgs e)
  2864. {
  2865. this.UseCurrentDb(false);
  2866. }
  2867. internal void ManageNugetRefs()
  2868. {
  2869. }
  2870. private void miArrangeVertical_Click(object sender, EventArgs e)
  2871. {
  2872. MainForm.Instance.ToggleVerticalResults();
  2873. }
  2874. private void miAutoScroll_Click(object sender, EventArgs e)
  2875. {
  2876. MainForm.Instance.ToggleAutoScrollResults(true);
  2877. }
  2878. private void miHideResults_Click(object sender, EventArgs e)
  2879. {
  2880. this.ToggleResultsCollapse();
  2881. }
  2882. private void miKeyboardShortcuts_Click(object sender, EventArgs e)
  2883. {
  2884. MainForm.Instance.ShowKeyboardShortcuts();
  2885. }
  2886. private void miOpenInSSMS_Click(object sender, EventArgs e)
  2887. {
  2888. if (this._query.Repository != null)
  2889. {
  2890. string str2;
  2891. string sSMSLocation = this.GetSSMSLocation();
  2892. if (sSMSLocation == null)
  2893. {
  2894. str2 = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ssms.exe");
  2895. if (File.Exists(str2))
  2896. {
  2897. sSMSLocation = str2;
  2898. }
  2899. }
  2900. if (sSMSLocation == null)
  2901. {
  2902. str2 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + @" (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ssms.exe";
  2903. if (File.Exists(str2))
  2904. {
  2905. sSMSLocation = str2;
  2906. }
  2907. }
  2908. if (sSMSLocation == null)
  2909. {
  2910. MessageBox.Show("Cannot locate SQL Server Management Studio.");
  2911. }
  2912. else
  2913. {
  2914. string path = Path.Combine(Path.GetTempPath(), "LINQPad");
  2915. if (!Directory.Exists(path))
  2916. {
  2917. Directory.CreateDirectory(path);
  2918. }
  2919. FileInfo[] files = new DirectoryInfo(path).GetFiles();
  2920. int index = 0;
  2921. while (true)
  2922. {
  2923. if (index >= files.Length)
  2924. {
  2925. break;
  2926. }
  2927. FileInfo info = files[index];
  2928. if (info.LastWriteTimeUtc < DateTime.UtcNow.AddDays(-7.0))
  2929. {
  2930. try
  2931. {
  2932. info.Delete();
  2933. }
  2934. catch
  2935. {
  2936. }
  2937. }
  2938. index++;
  2939. }
  2940. string str4 = Path.Combine(path, Path.ChangeExtension(Path.GetRandomFileName(), ".sql"));
  2941. File.WriteAllText(str4, this.txtSQL.Text);
  2942. Repository repository = this._query.Repository;
  2943. string arguments = "-nosplash \"" + str4 + "\"";
  2944. if (!(!repository.IsSqlServer || repository.AttachFile))
  2945. {
  2946. arguments = "-S " + repository.Server + " -d " + repository.Database + (repository.SqlSecurity ? (" -U " + repository.UserName + " -P " + repository.Password) : " -E") + " " + arguments;
  2947. }
  2948. Process.Start(sSMSLocation, arguments);
  2949. }
  2950. }
  2951. }
  2952. private void miOpenSQLQueryNewTab_Click(object sender, EventArgs e)
  2953. {
  2954. MainForm.Instance.AddSqlQueryPage(this.txtSQL.Text);
  2955. }
  2956. private void miScrollEnd_Click(object sender, EventArgs e)
  2957. {
  2958. this.ScrollResults(VerticalScrollAmount.Document, true);
  2959. }
  2960. private void miScrollStart_Click(object sender, EventArgs e)
  2961. {
  2962. this.ScrollResults(VerticalScrollAmount.Document, false);
  2963. }
  2964. private void miUndock_Click(object sender, EventArgs e)
  2965. {
  2966. MainForm.Instance.ToggleDockResults();
  2967. }
  2968. internal void NavigateResultPanel(bool next)
  2969. {
  2970. int index = this.tsOutput.Items.IndexOf(this.btnIL);
  2971. ToolStripButton button = this.tsOutput.Items.OfType<ToolStripButton>().FirstOrDefault<ToolStripButton>(b => b.Checked);
  2972. if (button != null)
  2973. {
  2974. int num2 = this.tsOutput.Items.IndexOf(button);
  2975. if (num2 <= index)
  2976. {
  2977. num2 += next ? 1 : -1;
  2978. if (num2 > index)
  2979. {
  2980. num2 = 1;
  2981. }
  2982. else if (num2 < 1)
  2983. {
  2984. num2 = index;
  2985. }
  2986. this.SelectOutputPanel(this.tsOutput.Items[num2] as ToolStripButton, false);
  2987. }
  2988. }
  2989. }
  2990. internal void NotifyWindowRestoreFromMaximize()
  2991. {
  2992. if (this.panOutput.BackColor == Program.TransparencyKey)
  2993. {
  2994. this.panOutput.BackColor = Color.White;
  2995. this.panOutput.Refresh();
  2996. this.UpdatePluginTransparency();
  2997. }
  2998. }
  2999. internal void NotifyWindowRestoreFromMinimize()
  3000. {
  3001. if (this.IsPluginSelected() && this.AreResultsVisible())
  3002. {
  3003. this.UpdateOutputVisibility();
  3004. }
  3005. }
  3006. internal void OnAllPluginsRemoved()
  3007. {
  3008. this.ResetPluginManager(false);
  3009. }
  3010. internal void OnFormActivated()
  3011. {
  3012. if (this.splitContainer.ContainsFocus)
  3013. {
  3014. Control activeControl = GetActiveControl();
  3015. if ((activeControl is SplitContainer) || ((activeControl is DataResultsWebBrowser) && !this.btnResults.Checked))
  3016. {
  3017. this._editor.Focus();
  3018. }
  3019. }
  3020. }
  3021. internal void OnIdle()
  3022. {
  3023. }
  3024. internal void OnInfoMessageChanged(PluginControl pic, string value)
  3025. {
  3026. if (this.GetSelectedPluginControl() == pic)
  3027. {
  3028. this.lblMiscStatus.Text = value;
  3029. }
  3030. }
  3031. internal void OnNewlySelectedPage()
  3032. {
  3033. if (this.IsPluginSelected() && this.AreResultsVisible())
  3034. {
  3035. this.panOutput.BackColor = Color.White;
  3036. this.panOutput.Update();
  3037. this._pluginWinManager.Show(this.GetSelectedPluginControl(), false);
  3038. }
  3039. this.RequestWinManagerRelocation();
  3040. this.UpdatePluginTransparency();
  3041. this.SetRegion();
  3042. this.FocusQuery();
  3043. }
  3044. internal void OnNoLongerSelectedPage()
  3045. {
  3046. if ((this._editor != null) && (this._editor.get_IntelliPrompt() != null))
  3047. {
  3048. if (this._editor.get_IntelliPrompt().get_MemberList() != null)
  3049. {
  3050. this._editor.get_IntelliPrompt().get_MemberList().Abort();
  3051. }
  3052. if (this._editor.get_IntelliPrompt().get_ParameterInfo() != null)
  3053. {
  3054. this._editor.get_IntelliPrompt().get_ParameterInfo().Hide();
  3055. }
  3056. if (this._editor.get_IntelliPrompt().get_QuickInfo() != null)
  3057. {
  3058. this._editor.get_IntelliPrompt().get_QuickInfo().Hide();
  3059. }
  3060. }
  3061. if (this.IsPluginSelected())
  3062. {
  3063. this.panOutput.BackColor = Color.White;
  3064. this.panOutput.Update();
  3065. }
  3066. this._pluginWinManager.Hide();
  3067. this.ClearRegion();
  3068. }
  3069. protected override void OnParentChanged(EventArgs e)
  3070. {
  3071. this.RefreshOptimizeQuery();
  3072. base.OnParentChanged(e);
  3073. }
  3074. internal void OnPluginAdded(PluginControl c)
  3075. {
  3076. if (this._gotPluginsReadyMessage || this._query.MessageLoopStartedWithoutForm)
  3077. {
  3078. this.CreatePluginWinButton(c, true, true);
  3079. this.UpdateOutputToolStripLayout();
  3080. }
  3081. }
  3082. internal void OnPluginRemoved(PluginControl plugin)
  3083. {
  3084. this.RemovePluginWinButton(plugin);
  3085. }
  3086. protected override void OnResize(EventArgs e)
  3087. {
  3088. base.OnResize(e);
  3089. this.UpdateUseCurrentDbVisibility();
  3090. this.UpdateOutputToolStripLayout();
  3091. }
  3092. private void OpenExcel(string target)
  3093. {
  3094. ExcelHelper.OpenInExcel(target, false);
  3095. }
  3096. public bool OpenFileQuery(string fullPath)
  3097. {
  3098. fullPath = Encoding.UTF8.GetString(Convert.FromBase64String(fullPath));
  3099. MainForm.Instance.ActivateMyQueries();
  3100. MainForm.Instance.OpenQuery(fullPath, false);
  3101. return false;
  3102. }
  3103. public bool OpenSample(string query)
  3104. {
  3105. string id = Encoding.UTF8.GetString(Convert.FromBase64String(query));
  3106. MainForm.Instance.OpenSampleQuery(id);
  3107. return false;
  3108. }
  3109. private void OpenWord(string target)
  3110. {
  3111. Type typeFromProgID;
  3112. try
  3113. {
  3114. try
  3115. {
  3116. typeFromProgID = Type.GetTypeFromProgID("Word.Application", true);
  3117. }
  3118. catch (TargetInvocationException exception)
  3119. {
  3120. throw exception.InnerException;
  3121. }
  3122. }
  3123. catch (COMException exception2)
  3124. {
  3125. Log.Write(exception2, "Export to Word");
  3126. MessageBox.Show("Cannot open Word - is it installed?", "LINQPad", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  3127. return;
  3128. }
  3129. object obj2 = Activator.CreateInstance(typeFromProgID);
  3130. Type type2 = obj2.GetType();
  3131. object obj3 = type2.InvokeMember("Documents", BindingFlags.GetProperty, null, obj2, null);
  3132. obj3.GetType().InvokeMember("Open", BindingFlags.InvokeMethod, null, obj3, new object[] { target });
  3133. type2.InvokeMember("Visible", BindingFlags.SetProperty, null, obj2, new object[] { true });
  3134. }
  3135. internal void OverrideAutoScrollFromQuery(bool p)
  3136. {
  3137. this._autoScrollResultsFromQuery = null;
  3138. }
  3139. private void panBottom_Layout(object sender, LayoutEventArgs e)
  3140. {
  3141. }
  3142. private void panError_Layout(object sender, LayoutEventArgs e)
  3143. {
  3144. this.UpdateErrorHeight();
  3145. }
  3146. private void panOutput_Layout(object sender, LayoutEventArgs e)
  3147. {
  3148. }
  3149. internal void PasteIntoEditor(string text)
  3150. {
  3151. this._editor.get_SelectedView().ReplaceSelectedText(20, text);
  3152. }
  3153. internal void PerformIncrementalSearch(bool up)
  3154. {
  3155. this.Editor.get_SelectedView().get_FindReplace().get_IncrementalSearch().PerformSearch(up);
  3156. }
  3157. internal void PropagateOptions()
  3158. {
  3159. this._editor.PropagateOptions();
  3160. }
  3161. internal void PullData(QueryChangedEventArgs changeInfo)
  3162. {
  3163. this.CheckIsMyExtensions();
  3164. if (this._suppressPullCount <= 0)
  3165. {
  3166. bool flag = false;
  3167. bool flag2 = false;
  3168. using (this.SuppressPull())
  3169. {
  3170. if (changeInfo.SourceChanged && (this._editor.Text != this._query.Source))
  3171. {
  3172. this._editor.Text = this._query.Source;
  3173. this._editor.set_IndicatorMarginVisible(false);
  3174. this._editor.get_Document().get_LineIndicators().Clear();
  3175. }
  3176. this._editor.IsOutliningEnabled = (this._query.QueryKind == QueryLanguage.Program) || (this._query.QueryKind == QueryLanguage.VBProgram);
  3177. this.btnPin.Checked = this._query.Pinned;
  3178. this.cboLanguage.SelectedIndex = this.QueryLanguageToIndex(this._query.QueryKind);
  3179. this.btnGrids.Checked = this._query.ToDataGrids;
  3180. this.btnText.Checked = !this._query.ToDataGrids;
  3181. bool flag3 = false;
  3182. if (changeInfo.ReferencesChanged && this._query.IsMyExtensions)
  3183. {
  3184. MyExtensions.UpdateAdditionalRefs(this._query);
  3185. this._docMan.ResetSharedReferences(MyExtensions.AdditionalRefs);
  3186. }
  3187. if (((this._lastQueryKind != this._query.QueryKind) || changeInfo.ReferencesChanged) || changeInfo.NamespacesChanged)
  3188. {
  3189. flag2 = (this._lastQueryKind != this._query.QueryKind) && (this._lastQueryKind >= QueryLanguage.FSharpExpression);
  3190. this._lastQueryKind = this._query.QueryKind;
  3191. this._docMan.ConfigureLanguage();
  3192. this._docMan.ConfigureResolver();
  3193. flag3 = true;
  3194. }
  3195. this.lblSyncDb.Visible = this._query.Repository != null;
  3196. if (changeInfo.DbChanged)
  3197. {
  3198. this.UpdateRepositoryItems(false);
  3199. this.UpdateFocusedRepository();
  3200. }
  3201. if ((!flag3 && !this._docMan.CheckForRepositoryChange()) && (flag || flag2))
  3202. {
  3203. this._docMan.ConfigureResolver();
  3204. }
  3205. }
  3206. this.UpdateOutputVisibility();
  3207. if (base.Parent != null)
  3208. {
  3209. this._schemaTree.UpdateSqlMode(this._query);
  3210. }
  3211. }
  3212. }
  3213. private void QueryCompiled(QueryCompilationEventArgs e)
  3214. {
  3215. Func<CompilerError, string> selector = null;
  3216. Func<CompilerError, bool> predicate = null;
  3217. CompilerError mainError;
  3218. CompilerError[] mainErrors;
  3219. if (!base.IsDisposed)
  3220. {
  3221. this._lastCompilation = e;
  3222. IEnumerable<CompilerError> source = from er in e.Errors.Cast<CompilerError>()
  3223. where !er.IsWarning
  3224. select er;
  3225. mainError = source.FirstOrDefault<CompilerError>();
  3226. mainErrors = (from er in source.Take<CompilerError>(5)
  3227. where er.Line == mainError.Line
  3228. select er).ToArray<CompilerError>();
  3229. if (mainErrors.Length > 0)
  3230. {
  3231. if (selector == null)
  3232. {
  3233. selector = er => this.GetErrorText(er);
  3234. }
  3235. string msg = string.Join("\r\n\r\n", mainErrors.Select<CompilerError, string>(selector).Distinct<string>().ToArray<string>());
  3236. if (e.PartialSource)
  3237. {
  3238. msg = "Cannot execute text selection: " + msg;
  3239. }
  3240. this.DisplayError(msg);
  3241. }
  3242. if (!this._modifiedWhenRunning)
  3243. {
  3244. foreach (CompilerError error in from ce in e.Errors.Cast<CompilerError>()
  3245. where ce.Line > 0
  3246. orderby ce.IsWarning
  3247. select ce)
  3248. {
  3249. this.HighlightErrorOrWarning(error.Line - 1, error.Column - 1, error.ErrorText, error.IsWarning, true, error == mainError);
  3250. }
  3251. if (predicate == null)
  3252. {
  3253. predicate = ce => (ce.Line == 0) && !mainErrors.Contains<CompilerError>(ce);
  3254. }
  3255. string message = string.Join("\n", (from ce in e.Errors.Cast<CompilerError>().Where<CompilerError>(predicate) select ce.ErrorText).ToArray<string>());
  3256. if (message.Length > 0)
  3257. {
  3258. this.HighlightErrorOrWarning(0, 0, message, true, true, false);
  3259. }
  3260. }
  3261. if (mainError != null)
  3262. {
  3263. this.SetILContent("");
  3264. }
  3265. this._ilDirty = true;
  3266. if (this.btnIL.Checked)
  3267. {
  3268. this.UpdateILContent();
  3269. }
  3270. if (mainError != null)
  3271. {
  3272. this.lblStatus.Text = "Error compiling query";
  3273. }
  3274. else if (this._compileOnly)
  3275. {
  3276. this.lblStatus.Text = "Query compiled " + (e.Errors.HasErrors ? "with warnings" : "successfully");
  3277. }
  3278. else
  3279. {
  3280. this.lblStatus.Text = "Executing";
  3281. }
  3282. if ((mainError != null) || this._compileOnly)
  3283. {
  3284. this.lblElapsed.Visible = false;
  3285. if (!(((mainError == null) || this.AreResultsDetached()) || this.AreResultsCollapsed()))
  3286. {
  3287. this.ToggleResultsCollapse();
  3288. }
  3289. this.EnableControls();
  3290. }
  3291. else
  3292. {
  3293. this.ShowResultsUponQueryStart();
  3294. }
  3295. if ((this._compileOnly && this._pendingReflection) && (mainError == null))
  3296. {
  3297. this.ReflectILNow();
  3298. }
  3299. this._pendingReflection = false;
  3300. if ((mainError == null) && this._query.IsMyExtensions)
  3301. {
  3302. foreach (QueryControl control in MainForm.Instance.GetQueryControls())
  3303. {
  3304. if ((control != this) && (control.Query.QueryKind != QueryLanguage.SQL))
  3305. {
  3306. control.CheckAutocompletionCache();
  3307. }
  3308. }
  3309. }
  3310. }
  3311. }
  3312. private void QueryCompleted(QueryStatusEventArgs e)
  3313. {
  3314. Exception exception;
  3315. if (e.ExecutionComplete)
  3316. {
  3317. this._gotQueryCompletionMessage = true;
  3318. this._executionTrackingTimer.Stop();
  3319. this.ClearExecutionTrackingIndicators();
  3320. if (this._editor.get_Document().get_LineIndicators().get_Count() == 0)
  3321. {
  3322. this._editor.set_IndicatorMarginVisible(false);
  3323. }
  3324. }
  3325. this._refreshTimer.Interval = 1;
  3326. try
  3327. {
  3328. this.ShowResultsUponQueryStart();
  3329. if (!string.IsNullOrEmpty(e.StatusMessage))
  3330. {
  3331. this.lblStatus.Text = e.StatusMessage;
  3332. }
  3333. if (!(string.IsNullOrEmpty(e.ErrorMessage) || this.panError.Visible))
  3334. {
  3335. if (!e.IsInfo)
  3336. {
  3337. this.DisplayError(e.ErrorMessage);
  3338. }
  3339. }
  3340. else if ((e.ExecutionComplete && (e.ExecTime.TotalMilliseconds > 0.0)) && this.lblElapsed.Visible)
  3341. {
  3342. TimeSpan execTime = e.ExecTime;
  3343. string str = execTime.Minutes.ToString("D2") + ":" + execTime.Seconds.ToString("D2") + "." + execTime.Milliseconds.ToString("D3");
  3344. if (execTime.Hours > 0)
  3345. {
  3346. str = ((int) execTime.TotalHours) + ":" + str;
  3347. }
  3348. this.lblExecTime.Text = "(" + str + ")";
  3349. this.lblExecTime.Visible = true;
  3350. }
  3351. if ((e.ErrorLine > 0) && !this._modifiedWhenRunning)
  3352. {
  3353. this.HighlightErrorOrWarning(e.ErrorLine - 1, e.ErrorColumn - 1, e.ErrorMessage, e.IsWarning || e.IsInfo, false, !e.IsInfo);
  3354. if ((e.StackTraceLines != null) && (e.StackTraceColumns != null))
  3355. {
  3356. for (int i = 0; i < e.StackTraceLines.Length; i++)
  3357. {
  3358. this.HighlightStackTraceError(e.StackTraceLines[i] - 1, e.StackTraceColumns[i] - 1);
  3359. }
  3360. }
  3361. }
  3362. }
  3363. catch (Exception exception1)
  3364. {
  3365. exception = exception1;
  3366. Program.ProcessException(exception);
  3367. }
  3368. finally
  3369. {
  3370. try
  3371. {
  3372. if (e.ExecutionComplete)
  3373. {
  3374. this.lblElapsed.Visible = false;
  3375. }
  3376. this.EnableControls();
  3377. if (e.ExecutionComplete && ((GC.GetTotalMemory(false) - this._memoryAtStart) > 0x2faf080L))
  3378. {
  3379. MainForm.Instance.TriggerGC(2);
  3380. }
  3381. }
  3382. catch (Exception exception2)
  3383. {
  3384. exception = exception2;
  3385. Program.ProcessException(exception);
  3386. }
  3387. }
  3388. }
  3389. private int QueryLanguageToIndex(QueryLanguage language)
  3390. {
  3391. if (this._query.IsMyExtensions)
  3392. {
  3393. return 0;
  3394. }
  3395. int num2 = (int) language;
  3396. if (language >= QueryLanguage.SQL)
  3397. {
  3398. num2 -= 2;
  3399. }
  3400. else if ((language == QueryLanguage.FSharpExpression) || (language == QueryLanguage.FSharpProgram))
  3401. {
  3402. num2 += 2;
  3403. }
  3404. return num2;
  3405. }
  3406. internal void QuickInfo()
  3407. {
  3408. if (this._editor.get_Document().get_Language() is CSharpSyntaxLanguage)
  3409. {
  3410. this._editor.get_Document().get_Language().ShowIntelliPromptQuickInfo(this._editor);
  3411. }
  3412. }
  3413. internal void ReflectIL()
  3414. {
  3415. if ((this._query.QueryKind != QueryLanguage.SQL) && (this._query.QueryKind != QueryLanguage.ESQL))
  3416. {
  3417. if (!(((this._query.ExecutionProgress != ExecutionProgress.Executing) && (this._query.ExecutionProgress != ExecutionProgress.Async)) && this._query.RequiresRecompilation))
  3418. {
  3419. this.ReflectILNow();
  3420. }
  3421. else
  3422. {
  3423. this._pendingReflection = true;
  3424. if (!this._query.IsRunning)
  3425. {
  3426. this.Run(true);
  3427. }
  3428. }
  3429. }
  3430. }
  3431. private void ReflectILNow()
  3432. {
  3433. if ((this._lastCompilation != null) && (this._lastCompilation.AssemblyDLL != null))
  3434. {
  3435. string fullPath = this._lastCompilation.AssemblyDLL.FullPath;
  3436. if (File.Exists(fullPath))
  3437. {
  3438. string str2 = this._query.QueryKind.ToString().Contains("Program") ? "Main" : "RunUserAuthoredQuery";
  3439. ReflectorAgent.ActivateReflector(new MemberHelpInfo(null, "code://" + Path.GetFileNameWithoutExtension(fullPath) + "/UserQuery/" + str2 + "()", fullPath, false));
  3440. }
  3441. }
  3442. }
  3443. internal void RefreshOptimizeQuery()
  3444. {
  3445. this.lblOptimize.BorderStyle = MainForm.Instance.OptimizeQueries ? Border3DStyle.SunkenInner : Border3DStyle.RaisedOuter;
  3446. this.lblOptimize.Text = MainForm.Instance.OptimizeQueries ? "/o+" : "/o-";
  3447. this.lblOptimize.ForeColor = MainForm.Instance.OptimizeQueries ? Color.Green : Color.Black;
  3448. this.lblOptimize.BackColor = MainForm.Instance.OptimizeQueries ? Color.FromArgb(0xde, 0xec, 0xff) : Color.Empty;
  3449. }
  3450. private void RefreshTimer_Tick(object sender, EventArgs e)
  3451. {
  3452. bool completionResults;
  3453. int queryCount;
  3454. bool completedBeforeWeStarted;
  3455. if (!this._processingProvisionalData)
  3456. {
  3457. ExecutionProgress? nullable;
  3458. ExecutionProgress executionProgress;
  3459. if (!this.IsPluginSelected() && (this.lblMiscStatus.Text != (this._outputInfoMessage ?? "")))
  3460. {
  3461. this.lblMiscStatus.Text = this._outputInfoMessage ?? "";
  3462. }
  3463. completionResults = this._refreshTimer.Interval == 1;
  3464. if (completionResults)
  3465. {
  3466. this._refreshTimer.Interval = 200;
  3467. }
  3468. if (!completionResults)
  3469. {
  3470. nullable = this._lastExecutionProgress;
  3471. executionProgress = this._query.ExecutionProgress;
  3472. }
  3473. if (((((ExecutionProgress) nullable.GetValueOrDefault()) != executionProgress) || !nullable.HasValue) && !this._readLinePanelVisible)
  3474. {
  3475. this._lastExecutionProgress = new ExecutionProgress?(this._query.ExecutionProgress);
  3476. if (((ExecutionProgress) this._lastExecutionProgress) == ExecutionProgress.AwaitingDataContext)
  3477. {
  3478. this.lblStatus.Text = "Fetching schema...";
  3479. }
  3480. else if (((ExecutionProgress) this._lastExecutionProgress) == ExecutionProgress.Async)
  3481. {
  3482. this.lblStatus.Text = "Query continuing asynchronously...";
  3483. }
  3484. else if (((ExecutionProgress) this._lastExecutionProgress) < ExecutionProgress.Finished)
  3485. {
  3486. this.lblStatus.Text = this._lastExecutionProgress.ToString();
  3487. }
  3488. if ((((((ExecutionProgress) this._lastExecutionProgress) == ExecutionProgress.Executing) && !this._executionTrackingTimer.Enabled) && !this._executingQueryOptimized) && this.IsQueryLanguageTrackable(this._executingQueryLanguage))
  3489. {
  3490. this._executionTrackingTimer.Interval = 500;
  3491. this._executionTrackingTimer.Start();
  3492. }
  3493. }
  3494. if (!((MainForm.Instance.CurrentQueryControl == this) && this.btnResults.Checked))
  3495. {
  3496. this._refreshTicksOnResults = 0;
  3497. }
  3498. else
  3499. {
  3500. this._refreshTicksOnResults++;
  3501. }
  3502. if (completionResults || ((((MainForm.Instance.CurrentQueryControl == this) && (Control.MouseButtons == MouseButtons.None)) && (this.btnResults.Checked || this.btnSql.Checked)) && ((this._pendingResultsShow || (this._query.ExecutionProgress != ExecutionProgress.Finished)) || this.AreResultsVisible())))
  3503. {
  3504. TimeSpan span;
  3505. if ((this._query.ExecutionProgress == ExecutionProgress.Executing) || (this._query.ExecutionProgress == ExecutionProgress.Async))
  3506. {
  3507. this.ShowResultsUponQueryStart();
  3508. }
  3509. if (this._query.ExecutionProgress == ExecutionProgress.Finished)
  3510. {
  3511. span = (TimeSpan) (DateTime.Now - this._lastServerAction);
  3512. }
  3513. if ((span.Milliseconds > 0x1388) && (this._refreshTimer.Interval < 0x3e8))
  3514. {
  3515. this._refreshTimer.Interval = 0x3e8;
  3516. }
  3517. if (!completionResults)
  3518. {
  3519. int? progress = this._query.Progress;
  3520. if (progress.HasValue && ((this.queryProgressBar.Style != ProgressBarStyle.Continuous) || (this.queryProgressBar.Value != progress.Value)))
  3521. {
  3522. this.queryProgressBar.Value = progress.Value;
  3523. this.queryProgressBar.Style = ProgressBarStyle.Continuous;
  3524. }
  3525. else if (!(progress.HasValue || (this.queryProgressBar.Style != ProgressBarStyle.Continuous)))
  3526. {
  3527. this.queryProgressBar.Style = ProgressBarStyle.Marquee;
  3528. }
  3529. }
  3530. if (this._query.HaveResultsChanged())
  3531. {
  3532. this._lastServerAction = DateTime.Now;
  3533. if ((this._query.ExecutionProgress == ExecutionProgress.Finished) && (this._refreshTimer.Interval == 0x3e8))
  3534. {
  3535. this._refreshTimer.Interval = 200;
  3536. }
  3537. queryCount = this._queryCount;
  3538. this._processingProvisionalData = true;
  3539. completedBeforeWeStarted = this._gotQueryCompletionMessage;
  3540. ThreadPool.QueueUserWorkItem(delegate (object param0) {
  3541. try
  3542. {
  3543. if ((this._queryCount != queryCount) || this.IsDisposed)
  3544. {
  3545. this._processingProvisionalData = false;
  3546. }
  3547. else
  3548. {
  3549. ResultData resultData = this._query.GetResultData();
  3550. if (((resultData == null) || (this._queryCount != queryCount)) || this.IsDisposed)
  3551. {
  3552. this._processingProvisionalData = false;
  3553. }
  3554. else
  3555. {
  3556. this.BeginInvoke(delegate {
  3557. try
  3558. {
  3559. if ((this._queryCount == queryCount) && !this.IsDisposed)
  3560. {
  3561. if (resultData.AutoScrollResults != this._lastAutoScrollResultsFromQuery)
  3562. {
  3563. this._lastAutoScrollResultsFromQuery = this._autoScrollResultsFromQuery = resultData.AutoScrollResults;
  3564. }
  3565. bool flag = this._autoScrollResultsFromQuery.HasValue ? this._autoScrollResultsFromQuery.Value : ((MainForm.Instance != null) && MainForm.Instance.AutoScrollResults);
  3566. bool flag2 = false;
  3567. Stopwatch stopwatch = Stopwatch.StartNew();
  3568. if (!string.IsNullOrEmpty(resultData.Output))
  3569. {
  3570. using (new SaveBrowserScrollPos(this._dataBrowser, (!flag || (Control.ModifierKeys == Keys.Alt)) ? this._readLinePanelVisible : true))
  3571. {
  3572. if (this.SetDataContent(resultData.Output) && ((((!completionResults && completedBeforeWeStarted) && (this._gotQueryCompletionMessage && !this.IsPluginSelected())) && ((!this._uberCancelMessage && !resultData.MessageLoopFailed) && (this._refreshTicksOnResults > 1))) && this.btnResults.Checked))
  3573. {
  3574. this.DisplayUberCancel(true);
  3575. }
  3576. }
  3577. if (resultData.Output.Length > 0x186a0)
  3578. {
  3579. flag2 = true;
  3580. }
  3581. }
  3582. if (!string.IsNullOrEmpty(resultData.Lambda))
  3583. {
  3584. this.SetLambdaContent(resultData.Lambda);
  3585. }
  3586. if (!string.IsNullOrEmpty(resultData.SQL))
  3587. {
  3588. if (((resultData.SQL.Length < 0x1388) || this.btnSql.Checked) || completionResults)
  3589. {
  3590. this._pendingSqlTranslation = null;
  3591. this.SetSqlContent(resultData.SQL);
  3592. if (resultData.SQL.Length > 0x4e20)
  3593. {
  3594. flag2 = true;
  3595. }
  3596. }
  3597. else
  3598. {
  3599. this._pendingSqlTranslation = resultData.SQL;
  3600. }
  3601. }
  3602. long elapsedMilliseconds = stopwatch.ElapsedMilliseconds;
  3603. if (elapsedMilliseconds > 200L)
  3604. {
  3605. flag2 = true;
  3606. }
  3607. if (flag2)
  3608. {
  3609. this._refreshTimer.Interval = (elapsedMilliseconds > 600L) ? 0x1388 : 0x3e8;
  3610. }
  3611. }
  3612. }
  3613. catch (Exception exception)
  3614. {
  3615. Program.ProcessException(exception);
  3616. }
  3617. finally
  3618. {
  3619. this._processingProvisionalData = false;
  3620. }
  3621. });
  3622. }
  3623. }
  3624. }
  3625. catch (Exception exception)
  3626. {
  3627. Program.ProcessException(exception);
  3628. }
  3629. });
  3630. }
  3631. }
  3632. }
  3633. }
  3634. private void RemovePluginWinButton(PluginControl pluginControl)
  3635. {
  3636. Action a = delegate {
  3637. ToolStripButton button = this._pluginWinButtons.FirstOrDefault<ToolStripButton>(b => b.Tag == pluginControl);
  3638. if (button != null)
  3639. {
  3640. bool flag = button.Checked;
  3641. this.tsOutput.Items.Remove(button);
  3642. this._pluginWinButtons.Remove(button);
  3643. if (flag)
  3644. {
  3645. this.SelectResultsPanel(false);
  3646. }
  3647. }
  3648. };
  3649. if (base.InvokeRequired)
  3650. {
  3651. this.BeginInvoke(a);
  3652. }
  3653. else
  3654. {
  3655. a();
  3656. }
  3657. }
  3658. internal void ReportMainThreadPosition()
  3659. {
  3660. bool flag = this._firstExecutionTrack;
  3661. this._firstExecutionTrack = false;
  3662. if ((MainForm.Instance.CurrentQueryControl == this) && (MainForm.Instance.WindowState != FormWindowState.Minimized))
  3663. {
  3664. if (UserOptionsLive.Instance.ExecutionTrackingDisabled)
  3665. {
  3666. this.ClearExecutionTrackingIndicators();
  3667. if ((this._editor.get_Document().get_LineIndicators().get_Count() == 0) && this._editor.get_IndicatorMarginVisible())
  3668. {
  3669. this._editor.set_IndicatorMarginVisible(false);
  3670. }
  3671. }
  3672. else if (!(!this._modifiedWhenRunning && this._query.IsRunning))
  3673. {
  3674. this._executionTrackingTimer.Stop();
  3675. this.ClearExecutionTrackingIndicators();
  3676. }
  3677. else
  3678. {
  3679. ExecutionTrackInfo mainThreadPosition = this._query.GetMainThreadPosition(false);
  3680. int num = this._lastExecutionTrackCost1 + this._lastExecutionTrackCost2;
  3681. if (((mainThreadPosition != null) && flag) && (mainThreadPosition.Cost > 200))
  3682. {
  3683. mainThreadPosition.Cost = 200;
  3684. }
  3685. if ((mainThreadPosition != null) && ((mainThreadPosition.Cost > 200) || (((mainThreadPosition.Cost > 40) && (this._lastExecutionTrackCost1 > 40)) && (this._lastExecutionTrackCost2 > 40))))
  3686. {
  3687. this._executionTrackingTimer.Stop();
  3688. this.ClearExecutionTrackingIndicators();
  3689. Log.Write(string.Concat(new object[] { "Execution tracking timed out [", mainThreadPosition.Cost, ",", this._lastExecutionTrackCost1, ",", this._lastExecutionTrackCost2, "]" }));
  3690. this.lblMiscStatus.Text = this._outputInfoMessage = "Auto execution tracking timed out";
  3691. }
  3692. else if ((mainThreadPosition == null) && (this._lastTrackInfo != null))
  3693. {
  3694. this._lastTrackInfo = null;
  3695. }
  3696. else
  3697. {
  3698. this._lastTrackInfo = mainThreadPosition;
  3699. if (mainThreadPosition != null)
  3700. {
  3701. num += mainThreadPosition.Cost;
  3702. this._lastExecutionTrackCost2 = this._lastExecutionTrackCost1;
  3703. this._lastExecutionTrackCost1 = mainThreadPosition.Cost;
  3704. }
  3705. RowColumn[] source = (mainThreadPosition == null) ? null : mainThreadPosition.MainThreadStack;
  3706. if (this._currentExecutionStack != null)
  3707. {
  3708. foreach (BitmapBookmarkLineIndicator indicator in this._currentExecutionStack)
  3709. {
  3710. this._editor.get_Document().get_LineIndicators().Remove(indicator);
  3711. }
  3712. }
  3713. List<BitmapBookmarkLineIndicator> list = new List<BitmapBookmarkLineIndicator>();
  3714. if ((source != null) && (source.Length > 0))
  3715. {
  3716. Func<BitmapBookmarkLineIndicator, bool> predicate = null;
  3717. int line = (source[0].Row - 1) + this._querySelectionStartRow;
  3718. if (line == this._lastExecutionLine)
  3719. {
  3720. this._lastExecutionLineCount++;
  3721. }
  3722. else
  3723. {
  3724. this._lastExecutionLine = line;
  3725. this._lastExecutionLineCount = 0;
  3726. }
  3727. if (!list.Any<BitmapBookmarkLineIndicator>(i => (((int) i.get_Tag()) == line)))
  3728. {
  3729. ExecutionPointLineIndicator item = new ExecutionPointLineIndicator();
  3730. item.set_Tag(line);
  3731. list.Add(item);
  3732. }
  3733. foreach (RowColumn column in source.Skip<RowColumn>(1))
  3734. {
  3735. line = (column.Row - 1) + this._querySelectionStartRow;
  3736. if (predicate == null)
  3737. {
  3738. predicate = i => ((int) i.get_Tag()) == line;
  3739. }
  3740. if (!list.Any<BitmapBookmarkLineIndicator>(predicate))
  3741. {
  3742. ExecutionPointLineStackIndicator indicator3 = new ExecutionPointLineStackIndicator();
  3743. indicator3.set_Tag(line);
  3744. list.Add(indicator3);
  3745. }
  3746. }
  3747. }
  3748. if (this._currentExecutionStack == null)
  3749. {
  3750. this._currentExecutionStack = new List<BitmapBookmarkLineIndicator>();
  3751. }
  3752. else
  3753. {
  3754. using (List<BitmapBookmarkLineIndicator>.Enumerator enumerator = this._currentExecutionStack.ToList<BitmapBookmarkLineIndicator>().GetEnumerator())
  3755. {
  3756. Func<BitmapBookmarkLineIndicator, bool> func2 = null;
  3757. BitmapBookmarkLineIndicator existingIndicator;
  3758. while (enumerator.MoveNext())
  3759. {
  3760. existingIndicator = enumerator.Current;
  3761. if (func2 == null)
  3762. {
  3763. func2 = i => ((int) i.get_Tag()) == ((int) existingIndicator.get_Tag());
  3764. }
  3765. if (list.FirstOrDefault<BitmapBookmarkLineIndicator>(func2) == null)
  3766. {
  3767. existingIndicator.Opacity *= 0.55f;
  3768. if (existingIndicator.Opacity > 0.3f)
  3769. {
  3770. this._editor.get_Document().get_LineIndicators().Add(existingIndicator, (int) existingIndicator.get_Tag());
  3771. }
  3772. else
  3773. {
  3774. this._currentExecutionStack.Remove(existingIndicator);
  3775. }
  3776. }
  3777. else
  3778. {
  3779. this._currentExecutionStack.Remove(existingIndicator);
  3780. }
  3781. }
  3782. }
  3783. }
  3784. foreach (BitmapBookmarkLineIndicator indicator5 in list)
  3785. {
  3786. this._editor.get_Document().get_LineIndicators().Add(indicator5, (int) indicator5.get_Tag());
  3787. this._currentExecutionStack.Add(indicator5);
  3788. }
  3789. if (this._currentExecutionStack.Count > 0)
  3790. {
  3791. this._editor.set_IndicatorMarginVisible(true);
  3792. }
  3793. this._executionTrackingTimer.Interval = ((170 + this._random.Next(50)) + (num * 5)) + ((this._lastExecutionLineCount > 100) ? 0x3e8 : ((this._lastExecutionLineCount > 20) ? 500 : 0));
  3794. }
  3795. }
  3796. }
  3797. }
  3798. internal void RequestPlugInShow(PluginControl c)
  3799. {
  3800. Action a = delegate {
  3801. if ((!this.IsDisposed && (MainForm.Instance != null)) && (MainForm.Instance.CurrentQueryControl == this))
  3802. {
  3803. ToolStripButton selectedButton = this._pluginWinButtons.FirstOrDefault<ToolStripButton>(b => b.Tag == c);
  3804. if (selectedButton != null)
  3805. {
  3806. this.SelectOutputPanel(selectedButton, false);
  3807. }
  3808. }
  3809. };
  3810. if (base.InvokeRequired)
  3811. {
  3812. this.BeginInvoke(a);
  3813. }
  3814. else
  3815. {
  3816. a();
  3817. }
  3818. }
  3819. internal void RequestWinManagerRelocation()
  3820. {
  3821. Action a = delegate {
  3822. if ((!base.IsDisposed && (MainForm.Instance != null)) && (MainForm.Instance.CurrentQueryControl == this))
  3823. {
  3824. this.SetRegion();
  3825. this._pluginWinManager.Relocate(this.GetWinManagerTargetBounds());
  3826. }
  3827. };
  3828. if (base.InvokeRequired)
  3829. {
  3830. this.BeginInvoke(a);
  3831. }
  3832. else
  3833. {
  3834. a();
  3835. }
  3836. }
  3837. private void ResetPluginManager(bool delayReset)
  3838. {
  3839. this._outputInfoMessage = null;
  3840. this._pluginWinManager.Reset(delayReset);
  3841. bool flag = this.IsPluginSelected();
  3842. foreach (ToolStripButton button in this._pluginWinButtons)
  3843. {
  3844. button.Dispose();
  3845. }
  3846. this._pluginWinButtons.Clear();
  3847. if (flag)
  3848. {
  3849. this.SelectResultsPanel(false);
  3850. }
  3851. else
  3852. {
  3853. this.UpdateOutputToolStripLayout();
  3854. }
  3855. }
  3856. internal void Run()
  3857. {
  3858. this.Run(false);
  3859. }
  3860. internal void Run(bool compileOnly)
  3861. {
  3862. if (!base.IsDisposed && !this.QueryRunning)
  3863. {
  3864. this._gotQueryCompletionMessage = false;
  3865. this._compileOnly = compileOnly;
  3866. this._memoryAtStart = GC.GetTotalMemory(false);
  3867. this._lastExecutionProgress = 5;
  3868. bool? nullable = null;
  3869. this._lastAutoScrollResultsFromQuery = nullable;
  3870. this._autoScrollResultsFromQuery = this._lastAutoScrollResultsFromQuery = nullable;
  3871. this._pendingResultsShow = true;
  3872. this._modifiedWhenRunning = false;
  3873. this._uberCancelMessage = false;
  3874. this._pendingSqlTranslation = null;
  3875. this.lblMiscStatus.Text = "";
  3876. this._queryCount++;
  3877. this._outputInfoMessage = null;
  3878. this.ClearExecutionTrackingIndicators();
  3879. this._executionTrackingTimer.Stop();
  3880. this.ClearExecutionTrackingIndicators();
  3881. this._firstExecutionTrack = true;
  3882. this._lastExecutionTrackCost2 = 0;
  3883. this._lastExecutionTrackCost1 = 0;
  3884. this._lastExecutionLine = -1;
  3885. this._lastTrackInfo = null;
  3886. this._executingQueryOptimized = UserOptionsLive.Instance.OptimizeQueries;
  3887. this._executingQueryLanguage = this._query.QueryKind;
  3888. this._gotPluginsReadyMessage = false;
  3889. this.KillIEComExceptionTimer();
  3890. this.ClearQueryHighlight();
  3891. this.panOutput.BackColor = Color.White;
  3892. this.panOutput.Update();
  3893. this._docMan.MainErrorLayer.Clear();
  3894. this._docMan.WarningsLayer.Clear();
  3895. this._docMan.StackTraceLayer.Clear();
  3896. this._docMan.ExecutedSelectionLayer.Clear();
  3897. this._editor.set_IndicatorMarginVisible(false);
  3898. this._editor.get_Document().get_LineIndicators().Clear();
  3899. string str = this._editor.get_SelectedView().get_SelectedText();
  3900. if (this.CheckAndPromptQueryDriver())
  3901. {
  3902. if (this._query != null)
  3903. {
  3904. this._query.SuppressErrorsOnExistingClient();
  3905. }
  3906. this.ResetPluginManager(false);
  3907. string querySelection = ((str.Trim().Length <= 1) || compileOnly) ? null : this._editor.get_SelectedView().get_SelectedText();
  3908. QueryCompilationEventArgs lastCompiler = (this._query.RequiresRecompilation || (this._lastRanSourceSelection != querySelection)) ? null : this._lastCompilation;
  3909. this._lastRanSourceSelection = querySelection;
  3910. if (querySelection != null)
  3911. {
  3912. this._docMan.ExecutedSelectionLayer.Add(new GrayCodeSpanIndicator(), new TextRange(0, this._editor.get_SelectedView().get_Selection().get_FirstOffset()), false);
  3913. this._docMan.ExecutedSelectionLayer.Add(new GrayCodeSpanIndicator(), new TextRange(this._editor.get_SelectedView().get_Selection().get_LastOffset(), this._editor.get_Document().get_Length()), false);
  3914. this._querySelectionStartRow = this._editor.get_SelectedView().get_Selection().get_FirstDocumentPosition().get_Line();
  3915. this._querySelectionStartCol = this._editor.get_SelectedView().get_Selection().get_FirstDocumentPosition().get_Character();
  3916. this._query.Run(querySelection, compileOnly, lastCompiler, this._pluginWinManager);
  3917. }
  3918. else
  3919. {
  3920. this._querySelectionStartCol = 0;
  3921. this._querySelectionStartRow = 0;
  3922. this._query.Run(null, compileOnly, lastCompiler, this._pluginWinManager);
  3923. }
  3924. this.queryProgressBar.Style = ProgressBarStyle.Marquee;
  3925. this.lblUberCancel.Visible = false;
  3926. this.panError.Hide();
  3927. this.btnResults.Text = this._query.ToDataGrids ? "&Output" : "&Results";
  3928. this.btnSql.Text = ((this._query.Repository == null) || (!(this._query.Repository.DriverLoader.InternalID == "AstoriaAuto") && !(this._query.Repository.DriverLoader.InternalID == "DallasAuto"))) ? "&SQL" : "Reque&st Log";
  3929. if (!compileOnly)
  3930. {
  3931. this.SetDataContent("");
  3932. this.SetLambdaContent("");
  3933. this.SetSqlContent("");
  3934. this._browserHidden = true;
  3935. }
  3936. this.EnableControls();
  3937. this.lblExecTime.Visible = false;
  3938. this.lblElapsed.Text = "";
  3939. this.lblElapsed.Visible = true;
  3940. this._clockTimer.Start();
  3941. this._refreshTimer.Interval = 200;
  3942. this._refreshTimer.Start();
  3943. this.UpdateAutocompletionMsg();
  3944. this._editor.Focus();
  3945. }
  3946. }
  3947. }
  3948. internal bool Save()
  3949. {
  3950. if (((this._query.FilePath.Length > 0) && !this._query.IsReadOnly) && ".linq .sql".Split(new char[0]).Contains<string>(Path.GetExtension(this._query.FilePath).ToLowerInvariant()))
  3951. {
  3952. this._query.Save();
  3953. }
  3954. else if (!this.SaveAs())
  3955. {
  3956. return false;
  3957. }
  3958. return true;
  3959. }
  3960. internal bool SaveAs()
  3961. {
  3962. this._query.LastMoved = DateTime.MinValue;
  3963. using (SaveFileDialog dialog = new SaveFileDialog())
  3964. {
  3965. string defaultQueryFolder = Options.GetDefaultQueryFolder(true);
  3966. if (_lastDefaultQueryFolder != defaultQueryFolder)
  3967. {
  3968. _lastDefaultQueryFolder = defaultQueryFolder;
  3969. _lastSaveFolder = null;
  3970. }
  3971. if (_lastSaveFolder == null)
  3972. {
  3973. _lastSaveFolder = defaultQueryFolder;
  3974. }
  3975. if (_lastSaveFolder != null)
  3976. {
  3977. try
  3978. {
  3979. dialog.InitialDirectory = _lastSaveFolder;
  3980. }
  3981. catch
  3982. {
  3983. }
  3984. }
  3985. dialog.Title = "Save Query As";
  3986. dialog.DefaultExt = "linq";
  3987. dialog.Filter = "LINQ query files (*.linq)|*.linq";
  3988. string str2 = (this._query.FilePath.Length > 0) ? Path.GetExtension(this._query.FilePath).ToLowerInvariant() : "";
  3989. if (this._query.QueryKind == QueryLanguage.SQL)
  3990. {
  3991. string str3 = "SSMS file (*.sql)|*.sql";
  3992. if (str2 == ".sql")
  3993. {
  3994. dialog.Filter = str3 + "|" + dialog.Filter;
  3995. dialog.DefaultExt = "sql";
  3996. }
  3997. else
  3998. {
  3999. dialog.Filter = dialog.Filter + "|" + str3;
  4000. }
  4001. }
  4002. if (this._query.FilePath.Length > 0)
  4003. {
  4004. dialog.FileName = this._query.FilePath;
  4005. if (!".linq .sql".Split(new char[0]).Contains<string>(str2))
  4006. {
  4007. dialog.FileName = Path.ChangeExtension(dialog.FileName, ".linq");
  4008. }
  4009. }
  4010. else if ((((this._query.Name != null) && !this._query.Name.ToLowerInvariant().StartsWith("query ")) && (this._query.Name.Length > 0)) && !char.IsSymbol(this._query.Name, 1))
  4011. {
  4012. dialog.FileName = this._query.Name;
  4013. if (!(!dialog.FileName.Contains<char>('.') || dialog.FileName.ToLowerInvariant().EndsWith(".linq")))
  4014. {
  4015. dialog.FileName = dialog.FileName + ".linq";
  4016. }
  4017. }
  4018. try
  4019. {
  4020. if (!(string.IsNullOrEmpty(dialog.FileName) || !(Path.GetDirectoryName(dialog.FileName) == dialog.InitialDirectory)))
  4021. {
  4022. dialog.FileName = Path.GetFileName(dialog.FileName);
  4023. }
  4024. }
  4025. catch
  4026. {
  4027. }
  4028. if (dialog.ShowDialog() == DialogResult.OK)
  4029. {
  4030. QueryControl control = MainForm.Instance.FindOpenQueryControl(dialog.FileName);
  4031. if ((control != null) && (control != this))
  4032. {
  4033. control.Close();
  4034. MainForm.Instance.CurrentQueryControl = this;
  4035. }
  4036. this._query.SaveAs(dialog.FileName);
  4037. try
  4038. {
  4039. _lastSaveFolder = Path.GetDirectoryName(dialog.FileName);
  4040. }
  4041. catch
  4042. {
  4043. }
  4044. return true;
  4045. }
  4046. return false;
  4047. }
  4048. }
  4049. private void ScrollActiProEditor(ActiproSoftware.SyntaxEditor.SyntaxEditor editor, VerticalScrollAmount amount, bool down)
  4050. {
  4051. if ((amount == VerticalScrollAmount.Line) && down)
  4052. {
  4053. editor.get_SelectedView().ScrollDown();
  4054. }
  4055. else if (amount == VerticalScrollAmount.Line)
  4056. {
  4057. editor.get_SelectedView().ScrollUp();
  4058. }
  4059. else if ((amount == VerticalScrollAmount.Page) && down)
  4060. {
  4061. editor.get_SelectedView().ScrollPageDown();
  4062. }
  4063. else if (amount == VerticalScrollAmount.Page)
  4064. {
  4065. editor.get_SelectedView().ScrollPageUp();
  4066. }
  4067. else if ((amount == VerticalScrollAmount.Document) && down)
  4068. {
  4069. editor.get_SelectedView().ScrollToDocumentEnd();
  4070. }
  4071. else if (amount == VerticalScrollAmount.Document)
  4072. {
  4073. editor.get_SelectedView().ScrollToDocumentStart();
  4074. }
  4075. }
  4076. private void ScrollBrowser(WebBrowser browser, VerticalScrollAmount amount, bool down)
  4077. {
  4078. int height;
  4079. Rectangle scrollRectangle = browser.Document.Body.ScrollRectangle;
  4080. object domDocument = browser.Document.DomDocument;
  4081. object target = domDocument.GetType().InvokeMember("documentElement", BindingFlags.GetProperty, null, domDocument, null);
  4082. if ((amount == VerticalScrollAmount.Document) && down)
  4083. {
  4084. height = scrollRectangle.Height;
  4085. }
  4086. else if (!((amount != VerticalScrollAmount.Document) || down))
  4087. {
  4088. height = 0;
  4089. }
  4090. else
  4091. {
  4092. int num2 = this.Font.Height;
  4093. height = (int) target.GetType().InvokeMember("scrollTop", BindingFlags.GetProperty, null, target, null);
  4094. if ((amount == VerticalScrollAmount.Page) && down)
  4095. {
  4096. height += browser.Height - num2;
  4097. }
  4098. else if (!((amount != VerticalScrollAmount.Page) || down))
  4099. {
  4100. height -= browser.Height - num2;
  4101. }
  4102. else if (down)
  4103. {
  4104. height += num2;
  4105. }
  4106. else
  4107. {
  4108. height -= num2;
  4109. }
  4110. if (height < 0)
  4111. {
  4112. height = 0;
  4113. }
  4114. else if (height > scrollRectangle.Height)
  4115. {
  4116. height = scrollRectangle.Height;
  4117. }
  4118. }
  4119. target.GetType().InvokeMember("scrollTop", BindingFlags.SetProperty, null, target, new object[] { height });
  4120. }
  4121. internal void ScrollResults(VerticalScrollAmount amount, bool down)
  4122. {
  4123. this.ScrollResults(amount, down, false, false);
  4124. }
  4125. internal void ScrollResults(VerticalScrollAmount amount, bool down, bool applyToFirstResultsPanel, bool selectFirstResultsPanel)
  4126. {
  4127. if (this.AreResultsVisible())
  4128. {
  4129. bool flag = this._editor.Focused || this._editor.ContainsFocus;
  4130. if (!(!selectFirstResultsPanel || this.btnResults.Checked))
  4131. {
  4132. this.SelectResultsPanel(false);
  4133. }
  4134. try
  4135. {
  4136. if (this.btnResults.Checked || applyToFirstResultsPanel)
  4137. {
  4138. this.ScrollBrowser(this._dataBrowser, amount, down);
  4139. }
  4140. else if (this.btnSql.Checked)
  4141. {
  4142. this.ScrollActiProEditor(this.txtSQL, amount, down);
  4143. }
  4144. else if (this.btnLambda.Checked)
  4145. {
  4146. this.ScrollBrowser(this._lambdaBrowser, amount, down);
  4147. }
  4148. else if (this.btnIL.Checked)
  4149. {
  4150. this.ScrollBrowser(this._ilBrowser, amount, down);
  4151. }
  4152. else if (this.IsPluginSelected())
  4153. {
  4154. this._pluginWinManager.InvokeScroll(amount, down);
  4155. }
  4156. }
  4157. catch
  4158. {
  4159. if (applyToFirstResultsPanel && selectFirstResultsPanel)
  4160. {
  4161. this._dataBrowser.Focus();
  4162. SendKeys.Flush();
  4163. SendKeys.SendWait("^{END}");
  4164. this._dataBrowser.Focus();
  4165. SendKeys.SendWait("^{END}");
  4166. if (flag)
  4167. {
  4168. this._editor.Focus();
  4169. }
  4170. }
  4171. }
  4172. }
  4173. }
  4174. internal void SelectILPanel(bool focusIfAlreadySelected)
  4175. {
  4176. this.SelectOutputPanel(this.btnIL, focusIfAlreadySelected);
  4177. }
  4178. internal void SelectLambdaPanel(bool focusIfAlreadySelected)
  4179. {
  4180. this.SelectOutputPanel(this.btnLambda, focusIfAlreadySelected);
  4181. }
  4182. private void SelectOutputPanel(ToolStripButton selectedButton, bool focusIfAlreadySelected)
  4183. {
  4184. if (selectedButton != null)
  4185. {
  4186. bool flag2;
  4187. ToolStripButton selectedPanelButton = this.GetSelectedPanelButton();
  4188. if (selectedButton == this.btnResults)
  4189. {
  4190. this._refreshTicksOnResults = 0;
  4191. }
  4192. foreach (ToolStripButton button2 in this.GetPanelSelectorButtons(true))
  4193. {
  4194. button2.Checked = button2 == selectedButton;
  4195. }
  4196. bool focused = this._editor.Focused;
  4197. bool flag3 = (flag2 = this._readLinePanelVisible && (this._readLinePanel != null)) && this._readLinePanel.ContainsFocus;
  4198. this.UpdateOutputVisibility();
  4199. if ((selectedButton == this.btnSql) && (this._pendingSqlTranslation != null))
  4200. {
  4201. this.SetSqlContent(this._pendingSqlTranslation);
  4202. this._pendingSqlTranslation = null;
  4203. }
  4204. if (MainForm.Instance.CurrentQueryControl == this)
  4205. {
  4206. if (flag2 && ((flag3 || !focused) || focusIfAlreadySelected))
  4207. {
  4208. this._readLinePanel.FocusTextBox();
  4209. }
  4210. else if (!focused || (focusIfAlreadySelected && selectedPanelButton.Checked))
  4211. {
  4212. Control outputControl = this.GetOutputControl(selectedButton);
  4213. if (outputControl != null)
  4214. {
  4215. outputControl.Focus();
  4216. }
  4217. else if ((selectedButton.Tag is PluginControl) && this.AreResultsVisible())
  4218. {
  4219. this.LastPluginFocus = DateTime.UtcNow;
  4220. this._pluginWinManager.Show(this.GetSelectedPluginControl(), true);
  4221. }
  4222. }
  4223. }
  4224. }
  4225. }
  4226. internal void SelectResultsPanel(bool focusIfAlreadySelected)
  4227. {
  4228. this.SelectOutputPanel(this.btnResults, focusIfAlreadySelected);
  4229. }
  4230. internal void SelectSqlPanel(bool focusIfAlreadySelected)
  4231. {
  4232. this.SelectOutputPanel(this.btnSql, focusIfAlreadySelected);
  4233. }
  4234. private bool SetDataContent(string content)
  4235. {
  4236. try
  4237. {
  4238. bool flag;
  4239. byte[] bytes = Encoding.UTF8.GetBytes(content);
  4240. if (!(flag = (this._resultsContent != null) && this._resultsContent.SequenceEqual<byte>(bytes)))
  4241. {
  4242. this._dataBrowser.DocumentStream = this._msData = new MemoryStream(this._resultsContent = bytes);
  4243. }
  4244. if (content.Length > 0)
  4245. {
  4246. this._browserHidden = false;
  4247. }
  4248. this.UpdateOutputVisibility();
  4249. return !flag;
  4250. }
  4251. catch (COMException)
  4252. {
  4253. if (!this._query.IsRunning)
  4254. {
  4255. throw;
  4256. }
  4257. return true;
  4258. }
  4259. }
  4260. internal void SetHorizontalLayout()
  4261. {
  4262. if (this.splitContainer.Orientation != Orientation.Horizontal)
  4263. {
  4264. this.splitContainer.SplitterWidth--;
  4265. this._oldVerticalSplitFraction = (this.splitContainer.SplitterDistance * 1.0) / ((double) this.splitContainer.ClientSize.Width);
  4266. this.splitContainer.Orientation = Orientation.Horizontal;
  4267. if ((this._oldHorizontalSplitFraction <= 0.0) || (this._oldHorizontalSplitFraction >= 0.95))
  4268. {
  4269. this._oldHorizontalSplitFraction = 0.5;
  4270. }
  4271. this.splitContainer.SplitterDistance = Convert.ToInt32((double) (this._oldHorizontalSplitFraction * this.splitContainer.ClientSize.Height));
  4272. }
  4273. }
  4274. private void SetILContent(string content)
  4275. {
  4276. this._ilBrowser.DocumentStream = this._ilData = new MemoryStream(Encoding.UTF8.GetBytes(content));
  4277. this._ilBrowser.Visible = !string.IsNullOrEmpty(content);
  4278. this.UpdateOutputVisibility();
  4279. }
  4280. private void SetLambdaContent(string content)
  4281. {
  4282. try
  4283. {
  4284. this._lambdaBrowser.DocumentStream = this._lambdaData = new MemoryStream(Encoding.UTF8.GetBytes(content));
  4285. this._lambdaBrowser.Visible = !string.IsNullOrEmpty(content);
  4286. this.UpdateOutputVisibility();
  4287. }
  4288. catch (COMException)
  4289. {
  4290. }
  4291. }
  4292. internal void SetLanguage(int index)
  4293. {
  4294. if (this.cboLanguage.Enabled)
  4295. {
  4296. if (this._query.IsMyExtensions)
  4297. {
  4298. if (index != 2)
  4299. {
  4300. return;
  4301. }
  4302. index = 0;
  4303. }
  4304. this.cboLanguage.SelectedIndex = index;
  4305. this.CheckToFromProgramLanguage();
  4306. this.cboType_SelectedIndexChanged(this, EventArgs.Empty);
  4307. }
  4308. }
  4309. private void SetRegion()
  4310. {
  4311. }
  4312. internal void SetSplitterHeight(float fraction)
  4313. {
  4314. if (this.splitContainer.Orientation != Orientation.Vertical)
  4315. {
  4316. this.splitContainer.SplitterDistance = Convert.ToInt32((float) (this.splitContainer.ClientSize.Height * fraction));
  4317. }
  4318. }
  4319. private void SetSqlContent(string content)
  4320. {
  4321. this.txtSQL.Text = content ?? "";
  4322. this.txtSQL.Enabled = !string.IsNullOrEmpty(content);
  4323. this.txtSQL.set_ScrollBarType(6);
  4324. this.txtSQL.set_ScrollBarType(0);
  4325. }
  4326. internal void SetVerticalLayout()
  4327. {
  4328. if (this.splitContainer.Orientation != Orientation.Vertical)
  4329. {
  4330. this.splitContainer.SplitterWidth++;
  4331. if (this.Dock == DockStyle.Fill)
  4332. {
  4333. this._oldHorizontalSplitFraction = (this.splitContainer.SplitterDistance * 1.0) / ((double) this.splitContainer.ClientSize.Height);
  4334. }
  4335. this.splitContainer.Orientation = Orientation.Vertical;
  4336. if ((this._oldVerticalSplitFraction <= 0.0) || (this._oldVerticalSplitFraction >= 0.95))
  4337. {
  4338. this._oldVerticalSplitFraction = 0.5;
  4339. }
  4340. this.splitContainer.SplitterDistance = Convert.ToInt32((double) (this._oldVerticalSplitFraction * this.splitContainer.ClientSize.Width));
  4341. }
  4342. }
  4343. private void ShowOptimizeTip()
  4344. {
  4345. string text = MainForm.Instance.OptimizeQueries ? "Compiler optimizations ON: click to toggle (Shift+Alt+O) or right-click for more info" : "Compiler optimizations off: click to toggle (Shift+Alt+O) or right-click for more info";
  4346. int width = TextRenderer.MeasureText(text, this.Font).Width;
  4347. this.toolTip.Show(text, this.statusStrip, new Point((base.Width - width) - 10, -this.Font.Height - 5), 0xbb8);
  4348. this._optimizeTipShown = true;
  4349. }
  4350. private void ShowReadLinePanel(Client client, string prompt, string defaultValue, string[] options)
  4351. {
  4352. this._readLinePanelVisible = true;
  4353. if (this._readLinePanel == null)
  4354. {
  4355. ReadLinePanel panel = new ReadLinePanel {
  4356. Dock = DockStyle.Bottom
  4357. };
  4358. this._readLinePanel = panel;
  4359. }
  4360. this._readLinePanel.EntryMade = delegate (string text) {
  4361. if (this.QueryRunning)
  4362. {
  4363. this.lblStatus.Text = "Executing";
  4364. }
  4365. this.HideReadLinePanel();
  4366. this._query.ReadLineCompleted(client, text);
  4367. };
  4368. if (this._readLinePanel.Parent != this)
  4369. {
  4370. base.SuspendLayout();
  4371. base.Controls.Add(this._readLinePanel);
  4372. this._readLinePanel.SendToBack();
  4373. this.statusStrip.SendToBack();
  4374. base.ResumeLayout();
  4375. }
  4376. this.lblStatus.Text = "Awaiting user input";
  4377. this._readLinePanel.Go(prompt, defaultValue, options);
  4378. this.ScrollResults(VerticalScrollAmount.Document, true, true, false);
  4379. }
  4380. private void ShowResultsUponQueryStart()
  4381. {
  4382. if (!(!this._pendingResultsShow || this.AreResultsVisible()))
  4383. {
  4384. this.ToggleResultsCollapse();
  4385. this._pendingResultsShow = false;
  4386. }
  4387. }
  4388. private void splitContainer_SplitterMoved(object sender, SplitterEventArgs e)
  4389. {
  4390. if (this._editor != null)
  4391. {
  4392. this.FocusQuery();
  4393. }
  4394. MainForm.Instance.IsSplitting = false;
  4395. if (((this.panOutput.BackColor == Program.LightTransparencyKey) && (MainForm.Instance.TransparencyKey == Program.LightTransparencyKey)) && (Program.TransparencyKey != MainForm.Instance.TransparencyKey))
  4396. {
  4397. this.panOutput.BackColor = MainForm.Instance.TransparencyKey = Program.TransparencyKey;
  4398. }
  4399. }
  4400. private SuppressPullData SuppressPull()
  4401. {
  4402. return new SuppressPullData(this);
  4403. }
  4404. internal void ToggleAllOutlining()
  4405. {
  4406. bool flag = true;
  4407. if (this._editor.get_Document().get_Outlining().get_RootNode().get_Count() > 0)
  4408. {
  4409. flag = this._editor.get_Document().get_Outlining().get_RootNode().get_Item(0).get_Expanded();
  4410. }
  4411. OutliningNode node = this._editor.get_Document().get_Outlining().get_RootNode().FindNodeRecursive(this._editor.get_Caret().get_Offset());
  4412. if (node != null)
  4413. {
  4414. flag = node.get_Expanded();
  4415. }
  4416. else if (this._editor.get_Caret().get_Offset() > 0)
  4417. {
  4418. node = this._editor.get_Document().get_Outlining().get_RootNode().FindNodeRecursive(this._editor.get_Caret().get_Offset() - 1);
  4419. if (node != null)
  4420. {
  4421. flag = node.get_Expanded();
  4422. }
  4423. }
  4424. if (flag)
  4425. {
  4426. this._editor.get_Document().get_Outlining().get_RootNode().CollapseDescendants();
  4427. }
  4428. else
  4429. {
  4430. this._editor.get_Document().get_Outlining().get_RootNode().ExpandDescendants();
  4431. }
  4432. }
  4433. public bool ToggleGraphColumn(string tableID, int colIndex)
  4434. {
  4435. this._dataBrowser.ToggleGraphColumn(tableID, colIndex);
  4436. return false;
  4437. }
  4438. internal bool ToggleOutliningExpansion()
  4439. {
  4440. // This item is obfuscated and can not be translated.
  4441. bool flag2;
  4442. bool flag3;
  4443. CompilationUnit unit;
  4444. OutliningNode node3;
  4445. if ((this._query.QueryKind != QueryLanguage.Program) && (this._query.QueryKind != QueryLanguage.VBProgram))
  4446. {
  4447. return false;
  4448. }
  4449. int num = this._editor.get_Caret().get_Offset();
  4450. int num2 = num;
  4451. if (!(flag2 = num == 0))
  4452. {
  4453. while (true)
  4454. {
  4455. if ((num2 > 0) && !char.IsWhiteSpace(this._editor.get_Document().get_Characters(num2)))
  4456. {
  4457. }
  4458. if (0 == 0)
  4459. {
  4460. break;
  4461. }
  4462. num2--;
  4463. }
  4464. }
  4465. if (!flag2)
  4466. {
  4467. flag2 = (num2 == 0) || (this._editor.get_Document().get_Characters(num2) == '\n');
  4468. }
  4469. num2 = num;
  4470. if (!(flag3 = (num2 >= this._editor.get_Document().get_Length()) || (this._editor.get_Document().get_Characters(num2) == '\n')))
  4471. {
  4472. while (true)
  4473. {
  4474. if ((num2 < this._editor.get_Document().get_Length()) && !char.IsWhiteSpace(this._editor.get_Document().get_Characters(num2)))
  4475. {
  4476. }
  4477. if (0 == 0)
  4478. {
  4479. break;
  4480. }
  4481. num2++;
  4482. }
  4483. }
  4484. if (!flag3)
  4485. {
  4486. flag3 = (num2 == this._editor.get_Document().get_Length()) || (this._editor.get_Document().get_Characters(num2) == '\n');
  4487. }
  4488. this._editor.get_Document().get_Characters(num);
  4489. if (flag2 && !flag3)
  4490. {
  4491. while (char.IsWhiteSpace(this._editor.get_Document().get_Characters(num)))
  4492. {
  4493. num++;
  4494. }
  4495. }
  4496. else if (flag3 && !flag2)
  4497. {
  4498. while (this._editor.get_Document().get_Characters(num) == '\0')
  4499. {
  4500. Label_01A3:
  4501. if (1 == 0)
  4502. {
  4503. goto Label_01D8;
  4504. }
  4505. num--;
  4506. }
  4507. goto Label_01A3;
  4508. }
  4509. Label_01D8:
  4510. unit = this._editor.get_Document().get_SemanticParseData() as CompilationUnit;
  4511. if (unit != null)
  4512. {
  4513. for (IAstNode node = unit.FindNodeRecursive(num); node == null; node = node.get_ParentNode())
  4514. {
  4515. Label_0203:
  4516. if (0 == 0)
  4517. {
  4518. IBlockAstNode node2 = node as IBlockAstNode;
  4519. if (((node2 != null) && (node2.get_BlockStartOffset() > 0)) && ((node2 is TypeDeclaration) || (node2 is TypeMemberDeclaration)))
  4520. {
  4521. num = node2.get_BlockStartOffset();
  4522. }
  4523. goto Label_0262;
  4524. }
  4525. }
  4526. goto Label_0203;
  4527. }
  4528. Label_0262:
  4529. node3 = this._editor.get_Document().get_Outlining().get_RootNode().FindNodeRecursive(num);
  4530. if (node3 != null)
  4531. {
  4532. node3.ToggleExpansion();
  4533. return true;
  4534. }
  4535. if (num > 0)
  4536. {
  4537. node3 = this._editor.get_Document().get_Outlining().get_RootNode().FindNodeRecursive(num - 1);
  4538. if (node3 != null)
  4539. {
  4540. node3.ToggleExpansion();
  4541. return true;
  4542. }
  4543. }
  4544. return false;
  4545. }
  4546. internal void ToggleResultsCollapse()
  4547. {
  4548. Func<EditorView, int> selector = null;
  4549. base.SuspendLayout();
  4550. this.panMain.SuspendLayout();
  4551. try
  4552. {
  4553. if (this.panEditor.Parent == this.panMain)
  4554. {
  4555. if (this.AreResultsDetached())
  4556. {
  4557. return;
  4558. }
  4559. this.panEditor.Parent = this.splitContainer.Panel1;
  4560. this.splitContainer.Show();
  4561. if (this.GetSelectedPanelButton().Tag is PluginControl)
  4562. {
  4563. this._pluginWinManager.Show(this.GetSelectedPluginControl(), false);
  4564. }
  4565. }
  4566. else
  4567. {
  4568. this.splitContainer.Hide();
  4569. this.panEditor.Parent = this.panMain;
  4570. this._pluginWinManager.Hide();
  4571. }
  4572. }
  4573. finally
  4574. {
  4575. base.ResumeLayout();
  4576. this.panMain.ResumeLayout();
  4577. }
  4578. if ((this.panEditor.Parent == this.splitContainer.Panel1) && this._firstResultsShow)
  4579. {
  4580. this._firstResultsShow = false;
  4581. if (!MainForm.Instance.VerticalResultsLayout && (this._editor.get_Document().get_Length() > 0))
  4582. {
  4583. try
  4584. {
  4585. if (selector == null)
  4586. {
  4587. selector = v => v.GetCharacterBounds(this._editor.get_Document().get_Length() - 1).Bottom;
  4588. }
  4589. int num = this._editor.get_Views().OfType<EditorView>().Max<EditorView>(selector) + (this.Font.Height * 5);
  4590. num = Math.Min(Math.Max(num, Convert.ToInt32((float) (this.splitContainer.ClientSize.Height * 0.15f))), Convert.ToInt32((float) (this.splitContainer.ClientSize.Height * 0.5f)));
  4591. this.splitContainer.SplitterDistance = num;
  4592. }
  4593. catch
  4594. {
  4595. }
  4596. }
  4597. }
  4598. this.FocusQuery();
  4599. }
  4600. public override string ToString()
  4601. {
  4602. return this._query.Name;
  4603. }
  4604. internal bool TryClose()
  4605. {
  4606. if (this._query.IsModified && (this._query.Source.Trim().Length > 0))
  4607. {
  4608. DialogResult result = MessageBox.Show("Save " + this._query.Name + "?", "LINQPad", MessageBoxButtons.YesNoCancel);
  4609. if (result == DialogResult.Cancel)
  4610. {
  4611. return false;
  4612. }
  4613. if (!((result != DialogResult.Yes) || this.Save()))
  4614. {
  4615. return false;
  4616. }
  4617. }
  4618. this.Close();
  4619. return true;
  4620. }
  4621. private void tsOutput_MouseEnter(object sender, EventArgs e)
  4622. {
  4623. if (this.AreResultsDetached())
  4624. {
  4625. Form form = this.tsOutput.FindForm();
  4626. if (form != null)
  4627. {
  4628. form.Activate();
  4629. }
  4630. }
  4631. }
  4632. internal void UpdateAutocompletionMsg()
  4633. {
  4634. if (base.InvokeRequired)
  4635. {
  4636. this.BeginInvoke(new Action(this.UpdateAutocompletionMsgCore));
  4637. }
  4638. else
  4639. {
  4640. this.UpdateAutocompletionMsgCore();
  4641. }
  4642. }
  4643. private void UpdateAutocompletionMsgCore()
  4644. {
  4645. try
  4646. {
  4647. this.btnActivateAutocompletion.Visible = (MainForm.Instance != null) && !MainForm.Instance.ShowLicensee;
  4648. }
  4649. catch
  4650. {
  4651. }
  4652. }
  4653. internal void UpdateAutocompletionService()
  4654. {
  4655. this._docMan.ConfigureLanguage();
  4656. this._docMan.ConfigureResolver();
  4657. }
  4658. internal void UpdateEditorZoom()
  4659. {
  4660. this._editor.UpdateZoom();
  4661. }
  4662. private void UpdateElapsed()
  4663. {
  4664. TimeSpan totalRunningTime = this._query.TotalRunningTime;
  4665. string str = totalRunningTime.Hours.ToString("D2") + ":" + totalRunningTime.Minutes.ToString("D2") + ":" + totalRunningTime.Seconds.ToString("D2");
  4666. if (str != this.lblElapsed.Text)
  4667. {
  4668. this.lblElapsed.Text = str;
  4669. }
  4670. }
  4671. private void UpdateErrorHeight()
  4672. {
  4673. int lineCount = Native.GetLineCount(this.txtError);
  4674. if (lineCount > 8)
  4675. {
  4676. lineCount = 8;
  4677. this.txtError.ScrollBars = ScrollBars.Vertical;
  4678. }
  4679. else
  4680. {
  4681. this.txtError.ScrollBars = ScrollBars.None;
  4682. }
  4683. this.panError.Height = ((((lineCount * this.txtError.Font.Height) + this.panError.Padding.Top) + this.panError.Padding.Bottom) + this.panError.Height) - this.panError.ClientSize.Height;
  4684. }
  4685. private void UpdateFocusedRepository()
  4686. {
  4687. Repository currentRepository = this._schemaTree.GetCurrentRepository(true);
  4688. this._enableUseCurrentDb = currentRepository != null;
  4689. this.llDbUseCurrent.Enabled = currentRepository != this._query.Repository;
  4690. if (currentRepository != null)
  4691. {
  4692. string friendlyName = currentRepository.GetFriendlyName(Repository.FriendlyNameMode.Short);
  4693. if (friendlyName.Length > 0x17)
  4694. {
  4695. friendlyName = friendlyName.Substring(0, 20) + "...";
  4696. }
  4697. this.llDbUseCurrent.Text = "Use " + friendlyName;
  4698. }
  4699. this.UpdateUseCurrentDbVisibility();
  4700. }
  4701. private void UpdateILContent()
  4702. {
  4703. if (this._ilDirty)
  4704. {
  4705. this._ilDirty = false;
  4706. if ((this._lastCompilation != null) && (this._lastCompilation.AssemblyDLL != null))
  4707. {
  4708. if (((this._query.Repository != null) && this._query.Repository.DriverLoader.IsValid) && this._query.Repository.DriverLoader.Driver.DisallowQueryDisassembly)
  4709. {
  4710. this.SetILContent("");
  4711. }
  4712. else
  4713. {
  4714. string[] additionalReferences = QueryCompiler.Create(this._query, true).References.ToArray<string>();
  4715. this.SetILContent(Disassembler.DisassembleQuery(this._lastCompilation.AssemblyDLL.FullPath, additionalReferences));
  4716. }
  4717. }
  4718. }
  4719. }
  4720. private void UpdateOutputToolStripLayout()
  4721. {
  4722. if ((this._pluginWinButtons.Count != 0) && (CS$<>9__CachedAnonymousMethodDelegate32 == null))
  4723. {
  4724. CS$<>9__CachedAnonymousMethodDelegate32 = i => i.Visible || i.IsOnOverflow;
  4725. }
  4726. int num = (CS$<>9__CachedAnonymousMethodDelegate33 != null) ? 0 : this.tsOutput.Items.Cast<ToolStripItem>().Where<ToolStripItem>(CS$<>9__CachedAnonymousMethodDelegate32).Sum<ToolStripItem>(CS$<>9__CachedAnonymousMethodDelegate33);
  4727. ToolStripLayoutStyle style = ((num > 50) && (num > (this.tsOutput.ClientSize.Width - 20))) ? ToolStripLayoutStyle.Flow : ToolStripLayoutStyle.HorizontalStackWithOverflow;
  4728. if (this.tsOutput.LayoutStyle != style)
  4729. {
  4730. this.tsOutput.LayoutStyle = style;
  4731. }
  4732. }
  4733. private void UpdateOutputVisibility()
  4734. {
  4735. ToolStripButton selectedPanelButton = this.GetSelectedPanelButton();
  4736. string infoMessage = (selectedPanelButton == this.btnResults) ? this._outputInfoMessage : null;
  4737. foreach (ToolStripButton button2 in this.GetPanelSelectorButtons(false))
  4738. {
  4739. if (button2 != selectedPanelButton)
  4740. {
  4741. this.GetOutputPanel(button2).Hide();
  4742. }
  4743. }
  4744. if (this.IsPluginSelected())
  4745. {
  4746. if (this.AreResultsVisible())
  4747. {
  4748. PluginControl selectedPluginControl = this.GetSelectedPluginControl();
  4749. infoMessage = selectedPluginControl.InfoMessage;
  4750. if (!string.IsNullOrEmpty(infoMessage))
  4751. {
  4752. this.lblMiscStatus.Font = this.Font;
  4753. this.lblMiscStatus.BackColor = Color.Transparent;
  4754. }
  4755. if (MainForm.Instance.CurrentQueryControl == this)
  4756. {
  4757. this._pluginWinManager.Show(selectedPluginControl, false);
  4758. this.RequestWinManagerRelocation();
  4759. }
  4760. }
  4761. this.UpdatePluginTransparency();
  4762. }
  4763. else
  4764. {
  4765. this.UpdatePluginTransparency();
  4766. this._pluginWinManager.Hide();
  4767. if (this.btnSql.Checked)
  4768. {
  4769. this.txtSQL.Show();
  4770. }
  4771. else if (this.btnLambda.Checked)
  4772. {
  4773. this._lambdaPanel.Visible = true;
  4774. }
  4775. else if (this.btnIL.Checked)
  4776. {
  4777. if (this._ilDirty)
  4778. {
  4779. this.UpdateILContent();
  4780. }
  4781. this._ilPanel.Visible = true;
  4782. }
  4783. else
  4784. {
  4785. this._dataPanel.Visible = this._dataBrowser.Visible = !this._browserHidden;
  4786. }
  4787. }
  4788. this.lblMiscStatus.Text = infoMessage ?? "";
  4789. this.SetRegion();
  4790. this.btnAnalyze.Visible = this.btnSql.Checked;
  4791. this.btnExport.Visible = this.btnFormat.Visible = this.btnResults.Checked;
  4792. this.UpdateOutputToolStripLayout();
  4793. }
  4794. private void UpdatePluginTransparency()
  4795. {
  4796. Action a = null;
  4797. if (this.IsPluginSelected())
  4798. {
  4799. MainForm.Instance.RequestTransparency();
  4800. if (a == null)
  4801. {
  4802. a = delegate {
  4803. if (!(base.IsDisposed || !this.IsPluginSelected()))
  4804. {
  4805. this.panOutput.BackColor = Program.TransparencyKey;
  4806. }
  4807. };
  4808. }
  4809. Program.RunOnWinFormsTimer(a, 100);
  4810. }
  4811. else if (this.panOutput.BackColor != Color.White)
  4812. {
  4813. this.panOutput.BackColor = Color.White;
  4814. this.panOutput.Refresh();
  4815. }
  4816. }
  4817. private void UpdateRepositoryItems(bool populate)
  4818. {
  4819. this.CheckQueryRepositoryWithSchemaTree();
  4820. this.cboDb.Items.Clear();
  4821. this.cboDb.Items.Add("<None>");
  4822. if (this._query.Repository != null)
  4823. {
  4824. this.cboDb.Items.Add(this._query.Repository);
  4825. }
  4826. IEnumerable<Repository> allRepositories = this._schemaTree.GetAllRepositories(true);
  4827. if (populate)
  4828. {
  4829. this.cboDb.Items.AddRange((from r in allRepositories
  4830. where r != this._query.Repository
  4831. select r).ToArray<Repository>());
  4832. }
  4833. this.cboDb.SelectedIndex = (this._query.Repository == null) ? 0 : 1;
  4834. }
  4835. private void UpdateUseCurrentDbVisibility()
  4836. {
  4837. this.llDbUseCurrent.Visible = this._enableUseCurrentDb && (base.ClientSize.Width > (this.Font.Height * 0x2d));
  4838. }
  4839. internal void UseCurrentDb(bool toggle)
  4840. {
  4841. if (!this._query.IsMyExtensions)
  4842. {
  4843. Repository currentRepository = this._schemaTree.GetCurrentRepository(true);
  4844. Repository repository = this._query.Repository;
  4845. if (currentRepository == null)
  4846. {
  4847. if (toggle)
  4848. {
  4849. this._schemaTree.ReselectRepository();
  4850. repository = this._schemaTree.GetCurrentRepository(true);
  4851. }
  4852. }
  4853. else if (this._query.Repository == currentRepository)
  4854. {
  4855. if (toggle)
  4856. {
  4857. repository = null;
  4858. this._schemaTree.UnselectRepository();
  4859. }
  4860. }
  4861. else
  4862. {
  4863. repository = currentRepository;
  4864. }
  4865. if (repository != this._query.Repository)
  4866. {
  4867. this.CheckToFromProgramLanguage(this._query.QueryKind, this._query.QueryKind, this._query.Repository != null, repository != null);
  4868. this._query.Repository = repository;
  4869. }
  4870. this._editor.Focus();
  4871. }
  4872. }
  4873. internal int CaretOffset
  4874. {
  4875. get
  4876. {
  4877. return this._editor.get_Caret().get_Offset();
  4878. }
  4879. set
  4880. {
  4881. this._editor.get_Caret().set_Offset(value);
  4882. }
  4883. }
  4884. private Document Doc
  4885. {
  4886. get
  4887. {
  4888. return this._docMan.Document;
  4889. }
  4890. }
  4891. internal QueryEditor Editor
  4892. {
  4893. get
  4894. {
  4895. return this._editor;
  4896. }
  4897. }
  4898. internal bool HasPluginControls
  4899. {
  4900. get
  4901. {
  4902. return ((this._pluginWinManager != null) && this._pluginWinManager.HasControls);
  4903. }
  4904. }
  4905. internal DateTime LastPluginFocus { get; private set; }
  4906. internal RunnableQuery Query
  4907. {
  4908. get
  4909. {
  4910. return this._query;
  4911. }
  4912. }
  4913. private bool QueryRunning
  4914. {
  4915. get
  4916. {
  4917. return this._query.IsRunning;
  4918. }
  4919. }
  4920. internal string SelectedQueryText
  4921. {
  4922. get
  4923. {
  4924. return this._editor.get_SelectedView().get_SelectedText();
  4925. }
  4926. }
  4927. internal bool WasPluginRecentlyFocused
  4928. {
  4929. get
  4930. {
  4931. return (((this._pluginWinManager != null) && this.IsPluginSelected()) && (this._pluginWinManager.ActiveFormPulse > DateTime.UtcNow.AddMilliseconds(-250.0)));
  4932. }
  4933. }
  4934. private class BrowserBorder : Panel
  4935. {
  4936. protected override void OnLayout(LayoutEventArgs levent)
  4937. {
  4938. if (base.Controls.Count != 0)
  4939. {
  4940. Rectangle clientRectangle = base.ClientRectangle;
  4941. clientRectangle.Inflate(2, 2);
  4942. if (base.Controls[0].Bounds != clientRectangle)
  4943. {
  4944. base.Controls[0].Bounds = clientRectangle;
  4945. }
  4946. }
  4947. }
  4948. }
  4949. private class LINQPadFindReplaceForm : FindReplaceForm
  4950. {
  4951. public LINQPadFindReplaceForm(ActiproSoftware.SyntaxEditor.SyntaxEditor editor, FindReplaceOptions options) : base(editor, options)
  4952. {
  4953. }
  4954. protected override void OnClosing(CancelEventArgs e)
  4955. {
  4956. }
  4957. }
  4958. private class SuppressPullData : IDisposable
  4959. {
  4960. private QueryControl _qc;
  4961. internal SuppressPullData(QueryControl qc)
  4962. {
  4963. this._qc = qc;
  4964. this._qc._suppressPullCount++;
  4965. }
  4966. public void Dispose()
  4967. {
  4968. this._qc._suppressPullCount--;
  4969. }
  4970. }
  4971. }
  4972. }