public PluginWindowManager(QueryControl qc)
 {
     Timer timer = new Timer {
         Interval = 100
     };
     this._tmr = timer;
     this._queryControl = qc;
     this._tmr.Tick += new EventHandler(this._tmr_Tick);
 }
 internal void CheckQuery(QueryControl qc)
 {
     if ((this._resultsTorn && (qc != null)) && (this.FindQueryControlPanel(qc) == null))
     {
         Control control = qc.DetachResultsControl();
         control.Tag = qc;
         base.Controls.Add(control);
         control.BringToFront();
     }
 }
 private Control FindQueryControlPanel(QueryControl qc)
 {
     return base.Controls.Cast<Control>().FirstOrDefault<Control>(c => (c.Tag == qc));
 }
 internal void QueryClosed(QueryControl qc)
 {
     if (this._resultsTorn && (qc != null))
     {
         Control control = this.FindQueryControlPanel(qc);
         if (control != null)
         {
             control.Dispose();
         }
     }
 }
 internal void QueryActivated(QueryControl qc)
 {
     if (this._resultsTorn && (qc != null))
     {
         Control control = this.FindQueryControlPanel(qc);
         if (control != null)
         {
             control.Show();
             control.BringToFront();
         }
     }
 }
Esempio n. 6
0
        internal bool CloseAll(QueryControl butThis, bool promptOnly)
        {
            Func<QueryControl, bool> predicate = null;
            IEnumerable<QueryControl> source = from qc in this.GetQueryControls()
                where (qc.Query.IsModified && (qc.Query.Source.Trim().Length > 0)) && (qc != butThis)
                select qc;
            if (source.Any<QueryControl>())
            {
                using (SaveChanges changes = new SaveChanges(from qc in source select qc.Query.Name))
                {
                    switch (changes.ShowDialog(this))
                    {
                        case DialogResult.Cancel:
                            return false;

                        case DialogResult.Yes:
                            foreach (QueryControl control in source)
                            {
                                this.tcQueries.SelectedTab = (TabPage) control.Parent;
                                if (!control.Save())
                                {
                                    return false;
                                }
                                this.UpdateQueryUI(control.Query);
                            }
                            break;
                    }
                }
            }
            if (!promptOnly)
            {
                if (predicate == null)
                {
                    predicate = qc => qc != butThis;
                }
                foreach (QueryControl control in this.GetQueryControls().Where<QueryControl>(predicate))
                {
                    control.Close();
                }
                if (butThis == null)
                {
                    this._untitledCount = 1;
                    this.AddQueryPage();
                }
            }
            return true;
        }
Esempio n. 7
0
 internal SuppressPullData(QueryControl qc)
 {
     this._qc = qc;
     this._qc._suppressPullCount++;
 }
Esempio n. 8
0
 private QueryControl AddQueryPage(RunnableQuery q, bool focusEllipses, bool afterCurrent)
 {
     QueryControl control;
     if ((this.NextCacheQueryControl == null) || (this.NextCacheQueryControl.Query != q))
     {
         control = new QueryControl(q, this.schemaTree);
     }
     else
     {
         control = this._cacheQueryControls.Dequeue();
     }
     if (this.VerticalResultsLayout)
     {
         control.SetVerticalLayout();
     }
     control.Dock = DockStyle.Fill;
     control.QueryClosed += new EventHandler(this.qc_QueryClosed);
     q.QueryChanged += new EventHandler<QueryChangedEventArgs>(this.q_QueryChanged);
     if (Program.PresentationMode)
     {
         control.NextQueryRequest += new EventHandler(this.qc_NextQueryRequest);
         control.PreviousQueryRequest += new EventHandler(this.qc_PreviousQueryRequest);
     }
     control.UpdateEditorZoom();
     if (this.ResultsDockForm.AreResultsTorn)
     {
         this.ResultsDockForm.CheckQuery(control);
     }
     TabPage tabPage = new TabPage(q.Name);
     int left = Control.DefaultFont.Height / 5;
     tabPage.Padding = new Padding(left, 1, left, 0);
     tabPage.UseVisualStyleBackColor = true;
     tabPage.Controls.Add(control);
     this._queryPages[q] = tabPage;
     this.tcQueries.SuspendLayout();
     try
     {
         if (afterCurrent && (this.tcQueries.TabPages.Count > 0))
         {
             this.tcQueries.TabPages.Insert(this.tcQueries.SelectedIndex + 1, tabPage);
         }
         else
         {
             this.tcQueries.TabPages.Add(tabPage);
         }
         this.tcQueries.SelectedTab = tabPage;
     }
     finally
     {
         this.tcQueries.ResumeLayout();
     }
     control.FocusQuery(focusEllipses);
     control.FixEditorScrollBars();
     this.UpdateMessagePosition();
     this.schemaTree.UpdateSqlMode((this.CurrentQueryControl == null) ? null : this.CurrentQueryControl.Query);
     return control;
 }
Esempio n. 9
0
 private void tcQueries_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this._lastQueryControl != null)
     {
         this._lastQueryControl.OnNoLongerSelectedPage();
     }
     this._lastQueryControl = this.CurrentQueryControl;
     this._lastQuery = (this._lastQueryControl == null) ? null : this._lastQueryControl.Query;
     this.UpdateTreeSelections();
     if (this.CurrentQueryControl != null)
     {
         this.CurrentQueryControl.OnNewlySelectedPage();
         if (this.CurrentQueryControl.Query.Repository != null)
         {
             this.schemaTree.RegisterRepository(this.CurrentQueryControl.Query, false, true);
         }
     }
     this.UpdateMessagePosition();
     this._resultsDockForm.QueryActivated(this.CurrentQueryControl);
     this.schemaTree.UpdateSqlMode((this.CurrentQueryControl == null) ? null : this.CurrentQueryControl.Query);
 }
Esempio n. 10
0
 public MainForm(string queryToLoad, bool runQuery)
 {
     Func<Screen, bool> predicate = null;
     Action a = null;
     SplitterCancelEventHandler handler = null;
     Action action2 = null;
     Action action3 = null;
     EventHandler handler2 = null;
     EventHandler handler3 = null;
     EventHandler handler4 = null;
     EventHandler handler5 = null;
     EventHandler handler6 = null;
     EventHandler handler7 = null;
     this._untitledCount = 1;
     this._firstOpen = true;
     this._queryPages = new Dictionary<RunnableQuery, TabPage>();
     this._cacheQueryControls = new Queue<QueryControl>();
     this._transparencyEnabled = false;
     int? maxQueryRows = UserOptions.Instance.MaxQueryRows;
     this._lastMaxQueryRows = maxQueryRows.HasValue ? maxQueryRows.GetValueOrDefault() : 0x3e8;
     this._lastFormState = FormWindowState.Normal;
     this.components = null;
     this.InitializeComponent();
     base.Icon = Resources.LINQPad;
     LINQPad.UI.ResultsDockForm form = new LINQPad.UI.ResultsDockForm(this) {
         Owner = this
     };
     this._resultsDockForm = form;
     try
     {
         this.llOrganize.UseCompatibleTextRendering = true;
         this.llSetFolder.UseCompatibleTextRendering = true;
     }
     catch
     {
     }
     if (!this.RestoreWindow())
     {
         base.Location = new Point(20, 20);
     }
     this.mainMenu.RenderMode = ToolStripRenderMode.System;
     this.miUnload.Text = "Cancel All Threads and Reset";
     this.miUnload.ShortcutKeys = Keys.Control | Keys.Shift | Keys.F5;
     this.UpdateHotkeys();
     Rectangle testBounds = base.Bounds;
     testBounds.Inflate(-10, -10);
     if (!Screen.AllScreens.Any<Screen>(s => s.Bounds.Contains(testBounds)))
     {
         base.ClientSize = new Size((base.ClientSize.Width * 3) / 4, (base.ClientSize.Height * 3) / 4);
         if (predicate == null)
         {
             predicate = s => s.Bounds.Contains(base.Bounds);
         }
         if (!Screen.AllScreens.Any<Screen>(predicate))
         {
             this._lastWindowState = FormWindowState.Maximized;
             base.WindowState = FormWindowState.Maximized;
         }
     }
     this.schemaTree.NewQuery += new EventHandler<NewQueryArgs>(this.schemaTree_NewQuery);
     this.schemaTree.CxEdited += new EventHandler(this.schemaTree_CxEdited);
     this.schemaTree.RepositoryDeleted += new EventHandler<RepositoryArgs>(this.schemaTree_RepositoryDeleted);
     this.schemaTree.StaticSchemaRepositoryChanged += new EventHandler<RepositoryArgs>(this.schemaTree_StaticSchemaRepositoryChanged);
     Instance = this;
     if (!(!string.IsNullOrEmpty(queryToLoad) && File.Exists(queryToLoad)))
     {
         this.AddQueryPage();
     }
     if (a == null)
     {
         a = delegate {
             if (this.CurrentQueryControl != null)
             {
                 this.CurrentQueryControl.FocusQuery();
             }
         };
     }
     Program.RunOnWinFormsTimer(a);
     this.DisplayMessageCore("Activate premium features", true, true, true);
     this.RepopulateSchemaTree();
     bool flag = false;
     if (!string.IsNullOrEmpty(queryToLoad))
     {
         flag = this.OpenQuery(queryToLoad, true) != null;
     }
     this.verticalSplit.Layout += new LayoutEventHandler(this.verticalSplit_Layout);
     this.verticalSplit.SplitterMoved += new SplitterEventHandler(this.verticalSplit_SplitterMoved);
     if (handler == null)
     {
         handler = delegate (object sender, SplitterCancelEventArgs e) {
             if (Control.MouseButtons == MouseButtons.Left)
             {
                 this.IsSplitting = true;
             }
         };
     }
     this.verticalSplit.SplitterMoving += handler;
     this.tvMyQueries.MouseDown += new MouseEventHandler(this.tvMyQueries_MouseDown);
     this.sampleQueries.MouseDown += new MouseEventHandler(this.sampleQueries_MouseDown);
     if (Program.PresentationMode)
     {
         this.tvMyQueries.KeyDown += new KeyEventHandler(this.tv_KeyDown);
         this.sampleQueries.KeyDown += new KeyEventHandler(this.tv_KeyDown);
         this.schemaTree.KeyDown += new KeyEventHandler(this.tv_KeyDown);
     }
     this._lastQueryControl = this.CurrentQueryControl;
     LicenseManager.GetLicensee();
     if (action2 == null)
     {
         action2 = () => base.Invoke(new Action(this.RestoreActivationMessage));
     }
     WSAgent.MessageChanged = action2;
     base.KeyPreview = true;
     this.Text = this.Text + " 4";
     if ((flag && runQuery) && (this.CurrentQueryControl != null))
     {
         this.CurrentQueryControl.Run();
     }
     if (flag && (this.CurrentQueryControl != null))
     {
         if (action3 == null)
         {
             action3 = delegate {
                 if (this.CurrentQueryControl != null)
                 {
                     this.CurrentQueryControl.FixOutliningStartupBug();
                 }
             };
         }
         Program.RunOnWinFormsTimer(action3);
     }
     if (handler2 == null)
     {
         handler2 = delegate (object sender, EventArgs e) {
             if (this.CurrentQueryControl != null)
             {
                 this.CurrentQueryControl.AncestorMoved();
             }
         };
     }
     EventHandler handler8 = handler2;
     for (Control control = this.tcQueries; control != null; control = control.Parent)
     {
         control.Move += handler8;
     }
     Timer timer = new Timer {
         Interval = 0xbb8
     };
     this._collectTimer = timer;
     if (handler3 == null)
     {
         handler3 = delegate (object sender, EventArgs e) {
             if (this._pendingGC > 0)
             {
                 GC.Collect();
                 if (--this._pendingGC == 0)
                 {
                     this._collectTimer.Stop();
                 }
             }
         };
     }
     this._collectTimer.Tick += handler3;
     Timer timer2 = new Timer {
         Interval = 300
     };
     this._assemblyUnlockTimer = timer2;
     this._assemblyUnlockTimer.Tick += new EventHandler(this._assemblyUnlockTimer_Tick);
     Timer timer3 = new Timer {
         Interval = 0x1388
     };
     this._newQueryCacheTimer = timer3;
     this._newQueryCacheTimer.Tick += new EventHandler(this._newQueryCacheTimer_Tick);
     this._newQueryCacheTimer.Start();
     Timer timer4 = new Timer {
         Interval = 300
     };
     this._fakeActiveFormTimer = timer4;
     if (handler4 == null)
     {
         handler4 = (sender, e) => this.InactivateTitleBarNecessary();
     }
     this._fakeActiveFormTimer.Tick += handler4;
     if (Application.RenderWithVisualStyles)
     {
         this.tvMyQueries.Dock = DockStyle.None;
         this.tvMyQueries.BorderStyle = BorderStyle.None;
         this.pagMyQueries.Layout += new LayoutEventHandler(this.pagMyQueries_Layout);
         this.sampleQueries.BorderStyle = BorderStyle.None;
         this.pagSamples.Padding = new Padding(0, 3, 0, 0);
     }
     this.tvMyQueries.QueryRenamed += new RenamedEventHandler(this.tvMyQueries_QueryRenamed);
     this.tvMyQueries.QueryPotentiallyMoved += new Action<string, string>(this.tvMyQueries_QueryPotentiallyMoved);
     this.miAutoScroll.Checked = UserOptionsLive.Instance.AutoScrollResults;
     if (handler5 == null)
     {
         handler5 = (sender, e) => this.ApplyEditToPlugin = (this.CurrentQueryControl != null) && this.CurrentQueryControl.WasPluginRecentlyFocused;
     }
     this.mainMenu.MenuActivate += handler5;
     if (handler6 == null)
     {
         handler6 = delegate (object sender, EventArgs e) {
             if (this.ApplyEditToPlugin)
             {
                 QueryControl qc = this.CurrentQueryControl;
                 Program.RunOnWinFormsTimer(delegate {
                     this.ApplyEditToPlugin = false;
                     if ((this.CurrentQueryControl == qc) && qc.IsPluginSelected())
                     {
                         this.CurrentQueryControl.FocusSelectedPlugin();
                     }
                 }, 50);
             }
         };
     }
     this.mainMenu.MenuDeactivate += handler6;
     if (handler7 == null)
     {
         handler7 = delegate (object sender, EventArgs e) {
             if (!base.IsDisposed)
             {
                 foreach (QueryControl control in this.GetQueryControls())
                 {
                     control.RefreshOptimizeQuery();
                     control.Query.RequiresRecompilation = true;
                 }
             }
         };
     }
     UserOptionsLive.Instance.OptimizeQueriesChanged += handler7;
 }
Esempio n. 11
0
 public static bool HandleKey(MainForm form, QueryControl qc, Keys keyData)
 {
     HotKeyManager manager = new HotKeyManager(form, qc);
     if (manager.HandleCommonQuerylessKeys(keyData))
     {
         return true;
     }
     if (manager.CurrentQueryControl == null)
     {
         return false;
     }
     if (manager.HandleCommonKeys(keyData))
     {
         return true;
     }
     if (UseStudioKeys)
     {
         return manager.HandleStudioKey(keyData);
     }
     return manager.HandleSSMSKey(keyData);
 }
Esempio n. 12
0
 private HotKeyManager(MainForm f, QueryControl qc)
 {
     this._mainForm = f;
     this._queryControl = qc;
 }