public Client(QueryCore query, string querySelection, bool compileOnly, QueryCompilationEventArgs lastCompilation, Func<Client, Server> serverGenerator, PluginWindowManager pluginWinManager) { this._query = query; this._partialSource = !string.IsNullOrEmpty(querySelection); this._source = this._partialSource ? querySelection : this._query.Source; this._compileOnly = compileOnly; this._lastCompilation = lastCompilation; this._serverGenerator = serverGenerator; this._pluginWinManager = pluginWinManager; }
public static PluginControl[] GetExistingControls() { Server currentServer = Server.CurrentServer; if (currentServer == null) { return(new PluginControl[0]); } PluginWindowManager pluginWindowManager = currentServer.PluginWindowManager; if ((pluginWindowManager == null) || (pluginWindowManager.Form == null)) { return(new PluginControl[0]); } return(pluginWindowManager.GetControls()); }
internal PluginForm(PluginWindowManager manager) { ToolTip tip = new ToolTip { ShowAlways = true }; this._toolTip = tip; this.Ready = new ManualResetEvent(false); this._manager = manager; base.ControlBox = false; base.FormBorderStyle = FormBorderStyle.None; base.ShowInTaskbar = false; base.KeyPreview = true; base.StartPosition = FormStartPosition.Manual; this.DoubleBuffered = true; this.EditManager = new LINQPad.UI.EditManager(this); }
public static void DisposeWpfElement(UIElement e) { Server currentServer = Server.CurrentServer; if (currentServer != null) { PluginWindowManager pluginWindowManager = currentServer.PluginWindowManager; if ((pluginWindowManager != null) && (pluginWindowManager.Form != null)) { ElementHost host = pluginWindowManager.Form.Controls.OfType <ElementHost>().FirstOrDefault <ElementHost>(h => h.Child == e); if (host != null) { host.Dispose(); } } } }
public static PluginControl AddControl(Control c, string heading) { Server currentServer = Server.CurrentServer; if (currentServer == null) { return(null); } PluginWindowManager pluginWindowManager = currentServer.PluginWindowManager; if (pluginWindowManager == null) { return(null); } bool flag = false; if (pluginWindowManager.Form == null) { flag = true; pluginWindowManager.Form = new PluginForm(pluginWindowManager); } if (string.IsNullOrEmpty(heading)) { heading = "Custom" + ((CustomCount == 1) ? "" : (" " + CustomCount)); if (CustomCount == 1) { heading = "&" + heading; } CustomCount++; } PluginControl plugin = pluginWindowManager.Form.AddControl(c, heading); if (flag) { currentServer.NotifyPluginFormCreated(pluginWindowManager.Form); } pluginWindowManager.PluginJustAdded(plugin); return(plugin); }
public void Run(string querySelection, bool compileOnly, QueryCompilationEventArgs lastCompiler, LINQPad.UI.PluginWindowManager winManager) { lock (this._executionLock) { FileWithVersionInfo[] infoArray; FileWithVersionInfo[] infoArray2; if (this.IsRunning) { return; } this.GetAssemblyReferenceMap(out infoArray, out infoArray2); bool flag2 = this.NeedsRefresh(this._lastVolatileRefs, infoArray); bool flag3 = this.NeedsRefresh(this._lastNonvolatileRefs, infoArray2); bool flag4 = (!flag2 && (this._lastVolatileRefs != null)) && (this._lastVolatileRefs.Length > infoArray.Length); this._lastVolatileRefs = infoArray; this._lastNonvolatileRefs = infoArray2; if (flag2 || flag3) { this.PolluteCachedDomain(true); } if (this._client != null) { if ((this._cachedDomainPolluted || Program.FreshAppDomains) || ((!Program.PreserveAppDomains && !this.IsUserCachePresent()) && (((this._loadedAssemblyCount > 40) || (this._cumulativeFootprint > 0x1312d00L)) || this._client.LastWorkerThreadAborted()))) { this._client.Cancel(false, true); this._cachedDomain = null; } this._client.Dispose(); } this._queryStarting = true; this._querySnapshot = this.GetSnapshotForExecution(); if ((querySelection != null) && (this._querySnapshot.QueryKind == QueryLanguage.Program)) { if (querySelection.TrimEnd(new char[0]).EndsWith(";")) { this._querySnapshot.QueryKind = QueryLanguage.Statements; } else if (!(querySelection.Trim().Contains("\n") && querySelection.Contains <char>('{'))) { this._querySnapshot.QueryKind = QueryLanguage.Expression; } } else if (((querySelection != null) && (this._querySnapshot.QueryKind == QueryLanguage.Statements)) && !querySelection.Contains <char>(';')) { this._querySnapshot.QueryKind = QueryLanguage.Expression; } this._client = new Client(this._querySnapshot, querySelection, compileOnly, lastCompiler, new Func <Client, Server>(this.CreateServer), winManager); this._client.QueryCompiled += new EventHandler <QueryCompilationEventArgs>(this._client_QueryCompiled); this._client.QueryCompleted += new EventHandler <QueryStatusEventArgs>(this._client_QueryCompleted); this._client.ReadLineRequested += new EventHandler <ReadLineEventArgs>(this._client_ReadLineRequested); this._client.PluginsReady += new EventHandler(this._client_PluginsReady); this._client.CustomClickComplete += new EventHandler(this._client_CustomClickComplete); if (this.AllowShadow()) { Stopwatch stopwatch = Stopwatch.StartNew(); if (flag2) { this.CreateShadow(); } else if (flag4) { this.UpdateShadow(); } stopwatch.Stop(); } } ThreadPool.QueueUserWorkItem(delegate(object _) { try { base.AutoSave(true); } catch { } }); new Thread(new ThreadStart(this._client.Start)) { IsBackground = true, Name = "Query Starter" }.Start(); this._queryWatch.Reset(); this._queryWatch.Start(); }
public void ExecuteSqlQuery(QueryLanguage language, LINQPad.Repository repository, string query, string[] refs, Client client, LINQPad.UI.PluginWindowManager pluginWinManager) { QueryRunner runner; this.IsClrQuery = false; Util.Progress = null; this._repository = repository; this._sqlQuery = query; this._client = client; this._additionalRefs = refs; CurrentQueryAdditionalRefs = this._additionalRefs; this.PluginWindowManager = pluginWinManager; if (language == QueryLanguage.ESQL) { runner = new ESqlQueryRunner(this, query); } else { runner = new SqlQueryRunner(this, query); } Thread thread = new Thread(() => this.StartQuery(runner)) { Name = ((language == QueryLanguage.ESQL) ? "E" : "") + "SQL Query Runner", IsBackground = true }; this._worker = thread; this._worker.SetApartmentState(ApartmentState.STA); this._worker.Start(); }
public void ExecuteClrQuery(Client client, LINQPad.Repository r, string assemblyPath, int lineOffset, string[] additionalRefs, bool mta, bool compilationHadWarnings, string queryPath, string queryName, LINQPad.UI.PluginWindowManager pluginWinManager, bool executionTrackingEnabled) { this.IsClrQuery = true; this._client = client; _currentServer = null; this._repository = r; this._assemblyPath = assemblyPath; this._lineOffset = lineOffset; this._additionalRefs = additionalRefs; this._compilationHadWarnings = compilationHadWarnings; this._lastLambdaLength = 0; this._lastSqlLogLength = 0; this._lastResultsLength = 0; this._cacheVersionAtStart = UserCache.CacheVersion; this.PluginWindowManager = pluginWinManager; CurrentQueryAdditionalRefs = this._additionalRefs; Util.Progress = null; Util.CurrentQueryPath = (queryPath == "") ? null : queryPath; Util.CurrentQueryName = queryName; PluginServer.CustomCount = 1; UserCache.ClearSession(); Thread thread = new Thread(() => this.StartQuery(new ClrQueryRunner(this, executionTrackingEnabled))) { IsBackground = true, Name = System.AppDomain.CurrentDomain.FriendlyName }; this._worker = thread; if (!mta) { this._worker.SetApartmentState(ApartmentState.STA); } this._worker.Start(); }
public void Dispose() { this._disposed = true; this.EndMessageLoop(); this._client = null; this.PluginWindowManager = null; if (this._executionTrackSignal != null) { try { this._executionTrackSignal.Set(); } catch { } } try { RemotingServices.Disconnect(this); } catch { } }
internal QueryControl(RunnableQuery q, SchemaTree schemaTree) { EventHandler onClick = null; EventHandler handler2 = null; EventHandler handler3 = null; EventHandler handler4 = null; SplitterCancelEventHandler handler5 = null; this._browserHidden = true; Timer timer = new Timer { Interval = 0x2710, Enabled = true }; this._autoSaveTimer = timer; this._executionTrackingTimer = new Timer(); this._pluginWinButtons = new List<ToolStripButton>(); this._query = new RunnableQuery(); this.NextQueryRequest = delegate (object sender, EventArgs e) { }; this.PreviousQueryRequest = delegate (object sender, EventArgs e) { }; this._lambdaData = new MemoryStream(); this._ilDirty = true; this._ilData = new MemoryStream(); this._queryCount = 0; Timer timer2 = new Timer { Interval = 200 }; this._refreshTimer = timer2; Timer timer3 = new Timer { Interval = 200 }; this._clockTimer = timer3; this._firstResultsShow = true; this._lastQueryKind = QueryLanguage.SQL; this._suppressPullCount = 0; this._random = new Random(); this.components = null; this._query = q; this._schemaTree = schemaTree; try { this.Font = FontManager.GetDefaultFont(); } catch { } this.InitializeComponent(); this.CheckIsMyExtensions(); this._pluginWinManager = new PluginWindowManager(this); this._pluginWinButtonMenu = new ContextMenuStrip(this.components); if (onClick == null) { onClick = (sender, e) => this.CloseCurrentVisualizer(); } this._pluginWinButtonMenu.Items.Add("Close visualizer (Shift+F4 or Middle-Click or Ctrl+Click)", Resources.Delete, onClick); if (this.btnExecute.Height > 0x20) { this.btnExecute.Height -= 3; this.cboLanguage.Margin = new Padding(this.cboLanguage.Margin.Left, 2, this.cboLanguage.Margin.Right, 4); this.cboDb.Margin = new Padding(this.cboDb.Margin.Left, 2, this.cboDb.Margin.Right, 4); } else if (this.btnExecute.Height > 0x1d) { this.btnExecute.Height -= 2; } else if (this.btnExecute.Height > 0x18) { this.btnExecute.Height--; } this.btnCancel.Height = this.btnExecute.Height; this.btnText.Height = this.btnGrids.Height = this.btnExecute.Height - 1; if ((IntPtr.Size == 4) && (this.btnExecute.Height > 0x1b)) { Padding margin = this.cboLanguage.Margin; this.cboLanguage.Margin = new Padding(margin.Left, margin.Top, margin.Right, margin.Bottom - 1); margin = this.cboDb.Margin; this.cboDb.Margin = new Padding(margin.Left, margin.Top, margin.Right, margin.Bottom - 1); } if (this.btnExecute.Height > 40) { this.btnExecute.Image = ControlUtil.ResizeImage(this.btnExecute.Image, this.btnExecute.Width, this.btnExecute.Height, true); this.btnCancel.Image = ControlUtil.ResizeImage(this.btnCancel.Image, this.btnCancel.Width, this.btnCancel.Height, true); this.btnGrids.Image = ControlUtil.ResizeImage(this.btnGrids.Image, (this.btnGrids.Width * 3) / 4, (this.btnGrids.Height * 3) / 4, true); this.btnText.Image = ControlUtil.ResizeImage(this.btnText.Image, (this.btnText.Width * 3) / 4, (this.btnText.Height * 3) / 4, true); } this.UpdateAutocompletionMsg(); try { this.txtError.Font = new Font("Verdana", 8.25f); this.txtSQL.Font = new Font("Verdana", 9.5f); this.btnActivateAutocompletion.Font = new Font("Verdana", 8f, FontStyle.Bold); this.lblOptimize.Font = new Font("Verdana", 7f, FontStyle.Bold); } catch { } this.txtSQL.get_Document().set_Language(DocumentManager.GetDynamicLanguage("SQL", SystemColors.Window.GetBrightness())); this.txtSQL.get_Document().get_Outlining().set_Mode(2); this.txtSQL.set_BracketHighlightingVisible(true); this.txtSQL.get_Document().set_ReadOnly(true); VisualStudio2005SyntaxEditorRenderer renderer = new VisualStudio2005SyntaxEditorRenderer(); SimpleBorder border = new SimpleBorder(); border.set_Style(0); renderer.set_Border(border); VisualStudio2005SyntaxEditorRenderer renderer2 = renderer; this.txtSQL.set_Renderer(renderer2); this._docMan = new DocumentManager(this._query, this); this.CreateEditor(); this.PropagateOptions(); this.UpdateEditorZoom(); this.CreateBrowser(); this._browserHidden = true; this.panBottom.BorderStyle = BorderStyle.None; this.tsOutput.BackColor = Color.Transparent; this.tsOutput.Renderer = new OutputToolsRenderer(); this.statusStrip.BackColor = Color.Transparent; this.statusStrip.Padding = new Padding(this.statusStrip.Padding.Left, this.statusStrip.Padding.Top, this.statusStrip.Padding.Left, this.statusStrip.Padding.Bottom); this.PullData(QueryChangedEventArgs.Refresh); this.ToggleResultsCollapse(); this._query.QueryCompiled += new EventHandler<QueryCompilationEventArgs>(this._query_QueryCompiled); this._query.PluginsReady += new EventHandler(this._query_PluginsReady); this._query.CustomClickCompleted += new EventHandler(this._query_CustomClickCompleted); this._query.QueryCompleted += new EventHandler<QueryStatusEventArgs>(this._query_QueryCompleted); this._query.QueryChanged += new EventHandler<QueryChangedEventArgs>(this._query_QueryChanged); this._query.ReadLineRequested += new EventHandler<ReadLineEventArgs>(this._query_ReadLineRequested); this._editor.TextChanged += new EventHandler(this._editor_TextChanged); this._editor.add_SelectionChanged(new SelectionEventHandler(this, (IntPtr) this._editor_SelectionChanged)); this._editor.RepositoryDropped += new EventHandler<QueryEditor.RepositoryEventArgs>(this._editor_RepositoryDropped); this._schemaTree.AfterSelect += new TreeViewEventHandler(this._schemaTree_AfterSelect); this._docMan.CheckForRepositoryChange(); this._refreshTimer.Tick += new EventHandler(this.RefreshTimer_Tick); this._clockTimer.Tick += new EventHandler(this.ClockTimer_Tick); this._autoSaveTimer.Tick += new EventHandler(this.AutoSaveTimer_Tick); if (handler2 == null) { handler2 = (sender, e) => this.ReportMainThreadPosition(); } this._executionTrackingTimer.Tick += handler2; if (SystemColors.Window.GetBrightness() < 0.5f) { this.llDbUseCurrent.ForeColor = SystemColors.HotTrack; } this.ExtendOutputSplitter(); if (handler3 == null) { handler3 = (sender, e) => this.UpdateErrorHeight(); } this.panError.SizeChanged += handler3; this.statusStrip.Parent = null; base.Controls.Add(this.statusStrip); this.statusStrip.SendToBack(); if (handler4 == null) { handler4 = (sender, e) => this.RequestWinManagerRelocation(); } EventHandler handler6 = handler4; this.panOutput.Resize += handler6; for (Control control = this.panOutput; control != null; control = control.Parent) { control.Move += handler6; } this._query.PluginWindowManager = this._pluginWinManager; this.queryProgressBar.Margin = new Padding(3, 3, 0, 1); this.tsOutput.Padding = new Padding(0, 0, 0, 2); this.splitContainer.SplitterWidth--; if (handler5 == null) { handler5 = delegate (object sender, SplitterCancelEventArgs e) { if (Control.MouseButtons == MouseButtons.Left) { MainForm.Instance.IsSplitting = true; } if ((this.panOutput.BackColor == MainForm.Instance.TransparencyKey) && (this.panOutput.BackColor != Program.LightTransparencyKey)) { this.panOutput.BackColor = MainForm.Instance.TransparencyKey = Program.LightTransparencyKey; } }; } this.splitContainer.SplitterMoving += handler5; this.panOutput.BorderStyle = BorderStyle.None; this.panOutput.BorderColor = Color.FromArgb(160, 160, 160); this.lblSyncDb.Cursor = Cursors.Hand; this.toolTip.ShowAlways = true; this.EnableControls(); this.panBottom.Layout += new LayoutEventHandler(this.panBottom_Layout); }