Esempio n. 1
0
 private void CreateEditor()
 {
     EventHandler handler = null;
     EventHandler handler2 = null;
     EventHandler handler3 = null;
     this._editor = new QueryEditor();
     this._editor.UriLayer = this._docMan.UriLayer;
     this._editor.WarningsLayer = this._docMan.WarningsLayer;
     this._editor.MainErrorLayer = this._docMan.MainErrorLayer;
     this._editor.StackTraceLayer = this._docMan.StackTraceLayer;
     this._editor.set_Document(this._docMan.Document);
     if (Program.PresentationMode)
     {
         if (handler == null)
         {
             handler = (sender, e) => this.NextQueryRequest(this, EventArgs.Empty);
         }
         this._editor.NextQueryRequest += handler;
         if (handler2 == null)
         {
             handler2 = (sender, e) => this.PreviousQueryRequest(this, EventArgs.Empty);
         }
         this._editor.PreviousQueryRequest += handler2;
         if (handler3 == null)
         {
             handler3 = delegate (object sender, EventArgs e) {
                 if (!(this.AreResultsDetached() || this.AreResultsCollapsed()))
                 {
                     this.ToggleResultsCollapse();
                 }
             };
         }
         this._editor.EscapeRequest += handler3;
     }
     this._editor.KeyPress += delegate (object sender, KeyPressEventArgs e) {
         if (this._docMan != null)
         {
             this._docMan.CheckForRepositoryChange();
         }
     };
     this.panEditor.Controls.Add(this._editor);
     this._editor.BringToFront();
 }
Esempio n. 2
0
 private void _editor_RepositoryDropped(object sender, QueryEditor.RepositoryEventArgs e)
 {
     Func<LinkedDatabase, bool> predicate = null;
     if (!this._query.IsMyExtensions)
     {
         this.CheckToFromProgramLanguage(this._query.QueryKind, this._query.QueryKind, this._query.Repository != null, e.Repository != null);
         if (!((this._query.Repository != null) && e.Copy))
         {
             this._query.Repository = e.Repository;
         }
         else
         {
             if ((!e.Repository.IsSqlServer || !this._query.Repository.IsSqlServer) || (e.Repository.Server.ToLowerInvariant() != this._query.Repository.Server.ToLowerInvariant()))
             {
                 MessageBox.Show("Multi-database queries are supported only for SQL Server databases on the same server (or linked servers).", "LINQPad", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                 return;
             }
             if (this._query.Repository.IsAzure || e.Repository.IsAzure)
             {
                 MessageBox.Show("SQL Azure does not permit cross-database queries.", "LINQPad", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                 return;
             }
             if (this._query.Repository.Database == e.Repository.Database)
             {
                 return;
             }
             if (predicate == null)
             {
                 predicate = d => string.IsNullOrEmpty(d.Server) && (d.Database == e.Repository.Database);
             }
             if (this._query.Repository.LinkedDatabases.Any<LinkedDatabase>(predicate))
             {
                 return;
             }
             if (this._query.Repository.Parent != null)
             {
                 Repository r = this._query.Repository.Clone();
                 r.ID = Guid.NewGuid();
                 r.ShowServer = false;
                 r.Persist = false;
                 r.LinkedDatabases = r.LinkedDatabases.Concat<LinkedDatabase>(new LinkedDatabase[] { new LinkedDatabase(e.Repository.Database) });
                 this._schemaTree.AddCx(r, false, false);
                 this._query.Repository = r;
             }
             else
             {
                 this._query.Repository.LinkedDatabases = this._query.Repository.LinkedDatabases.Concat<LinkedDatabase>(new LinkedDatabase[] { new LinkedDatabase(e.Repository.Database) });
                 this._schemaTree.UpdateRepository(this._query.Repository);
             }
         }
         this._editor.Focus();
     }
 }
Esempio n. 3
0
        private bool HandleCommonKeys(Keys keyData)
        {
            Keys keys = keyData;

            if (keys <= (Keys.Control | Keys.OemMinus))
            {
                switch (keys)
                {
                case Keys.F5:
                    goto Label_05AF;

                case Keys.F7:
                    this.CurrentQueryControl.FocusQueryExplicit();
                    return(true);

                case Keys.F1:
                    this.CurrentQueryControl.ActivateHelp();
                    return(true);

                case (Keys.Shift | Keys.F1):
                    this.CurrentQueryControl.ActivateReflector();
                    return(true);

                case (Keys.Shift | Keys.F4):
                    this.CurrentQueryControl.CloseCurrentVisualizer();
                    return(true);

                case (Keys.Shift | Keys.F5):
                    this.CurrentQueryControl.Cancel(false);
                    return(true);

                case (Keys.Control | Keys.Tab):
                case (Keys.Control | Keys.PageDown):
                    MainForm.Instance.NextQuery();
                    return(true);

                case (Keys.Control | Keys.PageUp):
                    goto Label_030F;

                case (Keys.Control | Keys.D0):
                    this.CurrentQueryControl.SetLanguage(9);
                    return(true);

                case (Keys.Control | Keys.D1):
                    this.CurrentQueryControl.SetLanguage(0);
                    return(true);

                case (Keys.Control | Keys.D2):
                    this.CurrentQueryControl.SetLanguage(1);
                    return(true);

                case (Keys.Control | Keys.D3):
                    this.CurrentQueryControl.SetLanguage(2);
                    return(true);

                case (Keys.Control | Keys.D4):
                    this.CurrentQueryControl.SetLanguage(3);
                    return(true);

                case (Keys.Control | Keys.D5):
                    this.CurrentQueryControl.SetLanguage(4);
                    return(true);

                case (Keys.Control | Keys.D6):
                    this.CurrentQueryControl.SetLanguage(5);
                    return(true);

                case (Keys.Control | Keys.D7):
                    this.CurrentQueryControl.SetLanguage(6);
                    return(true);

                case (Keys.Control | Keys.D8):
                    this.CurrentQueryControl.SetLanguage(7);
                    return(true);

                case (Keys.Control | Keys.D9):
                    this.CurrentQueryControl.SetLanguage(8);
                    return(true);

                case (Keys.Control | Keys.D):
                    this.CurrentQueryControl.UseCurrentDb(true);
                    return(true);

                case (Keys.Control | Keys.R):
                    this.CurrentQueryControl.ToggleResultsCollapse();
                    return(true);

                case (Keys.Control | Keys.Add):
                case (Keys.Control | Keys.Oemplus):
                    QueryEditor.Zoom(1);
                    return(true);

                case (Keys.Control | Keys.Subtract):
                case (Keys.Control | Keys.OemMinus):
                    QueryEditor.Zoom(-1);
                    return(true);

                case (Keys.Control | Keys.F3):
                    this.CurrentQueryControl.FindNextSelected();
                    return(true);

                case (Keys.Control | Keys.F4):
                    this.CurrentQueryControl.TryClose();
                    return(true);
                }
            }
            else if (keys > (Keys.Control | Keys.Shift | Keys.F5))
            {
                switch (keys)
                {
                case (Keys.Alt | Keys.PageUp):
                    this.CurrentQueryControl.ScrollResults(VerticalScrollAmount.Page, false);
                    return(true);

                case (Keys.Alt | Keys.PageDown):
                    this.CurrentQueryControl.ScrollResults(VerticalScrollAmount.Page, true);
                    return(true);

                case (Keys.Alt | Keys.End):
                    this.CurrentQueryControl.ScrollResults(VerticalScrollAmount.Document, true);
                    return(true);

                case (Keys.Alt | Keys.Home):
                    this.CurrentQueryControl.ScrollResults(VerticalScrollAmount.Document, false);
                    return(true);

                case (Keys.Alt | Keys.Left):
                    this.CurrentQueryControl.NavigateResultPanel(false);
                    return(true);

                case (Keys.Alt | Keys.Up):
                    this.CurrentQueryControl.ScrollResults(VerticalScrollAmount.Line, false);
                    return(true);

                case (Keys.Alt | Keys.Right):
                    this.CurrentQueryControl.NavigateResultPanel(true);
                    return(true);

                case (Keys.Alt | Keys.Down):
                    this.CurrentQueryControl.ScrollResults(VerticalScrollAmount.Line, true);
                    return(true);

                case (Keys.Alt | Keys.D0):
                    this.CurrentQueryControl.CollapseResultsTo(null);
                    return(true);

                case (Keys.Alt | Keys.D1):
                    this.CurrentQueryControl.CollapseResultsTo(1);
                    return(true);

                case (Keys.Alt | Keys.D2):
                    this.CurrentQueryControl.CollapseResultsTo(2);
                    return(true);

                case (Keys.Alt | Keys.D3):
                    this.CurrentQueryControl.CollapseResultsTo(3);
                    return(true);

                case (Keys.Alt | Keys.D4):
                    this.CurrentQueryControl.CollapseResultsTo(4);
                    return(true);

                case (Keys.Alt | Keys.D5):
                    this.CurrentQueryControl.CollapseResultsTo(5);
                    return(true);

                case (Keys.Alt | Keys.A):
                    this.CurrentQueryControl.SelectLambdaPanel(true);
                    return(true);

                case (Keys.Alt | Keys.O):
                    if (this.CurrentQueryControl.IsInDataGridMode())
                    {
                        this.CurrentQueryControl.SelectResultsPanel(true);
                        return(true);
                    }
                    return(false);

                case (Keys.Alt | Keys.R):
                    this.CurrentQueryControl.SelectResultsPanel(true);
                    return(true);

                case (Keys.Alt | Keys.S):
                    this.CurrentQueryControl.SelectSqlPanel(true);
                    return(true);

                case (Keys.Alt | Keys.X):
                    goto Label_05AF;

                case (Keys.Alt | Keys.I):
                    this.CurrentQueryControl.SelectILPanel(true);
                    return(true);
                }
            }
            else if (keys > (Keys.Control | Keys.Shift | Keys.G))
            {
                switch (keys)
                {
                case (Keys.Control | Keys.Shift | Keys.R):
                    this.CurrentQueryControl.ReflectIL();
                    return(true);

                case (Keys.Control | Keys.Shift | Keys.T):
                    this.CurrentQueryControl.Query.ToDataGrids = false;
                    return(true);

                case (Keys.Control | Keys.Shift | Keys.J):
                    this.CurrentQueryControl.JumpToExecutingLine();
                    return(true);

                case (Keys.Control | Keys.Shift | Keys.F3):
                    this.CurrentQueryControl.FindPreviousSelected();
                    return(true);

                case (Keys.Control | Keys.Shift | Keys.F5):
                    this.CurrentQueryControl.Cancel(true);
                    return(true);
                }
            }
            else
            {
                switch (keys)
                {
                case (Keys.Control | Keys.Shift | Keys.Tab):
                    goto Label_030F;

                case (Keys.Control | Keys.Shift | Keys.G):
                    this.CurrentQueryControl.Query.ToDataGrids = true;
                    return(true);
                }
            }
            return(false);

Label_030F:
            MainForm.Instance.PreviousQuery();
            return(true);

Label_05AF:
            this.CurrentQueryControl.Run();
            return(true);
        }