Ejemplo n.º 1
0
        protected override void OnDragDrop(DragEventArgs e)
        {
            bool flag  = false;
            bool flag2 = e.Effect == DragDropEffects.Copy;

            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] source = e.Data.GetData(DataFormats.FileDrop) as string[];
                if ((source != null) && (MainForm.Instance != null))
                {
                    Func <string, bool> predicate = s => ".dll .exe .xml .pdb .winmd".Split(new char[0]).Contains <string>(Path.GetExtension(s).ToLowerInvariant());
                    if (source.All <string>(predicate))
                    {
                        RunnableQuery currentQuery = MainForm.Instance.CurrentQuery;
                        if (currentQuery != null)
                        {
                            foreach (string str in source)
                            {
                                if (".dll .exe .winmd".Split(new char[0]).Contains <string>(Path.GetExtension(str).ToLowerInvariant()))
                                {
                                    currentQuery.AddRefIfNotPresent(true, new string[] { str });
                                }
                            }
                            currentQuery.SortReferences();
                            flag = true;
                        }
                    }
                    else
                    {
                        foreach (string str in source)
                        {
                            if (".linq .sql .txt".Split(new char[0]).Contains <string>(Path.GetExtension(str).ToLowerInvariant()) || (new FileInfo(str).Length < 0xc350L))
                            {
                                MainForm.Instance.OpenQuery(str, true);
                            }
                        }
                    }
                }
                MainForm.Instance.Activate();
            }
            else if (e.Data.GetDataPresent(typeof(RepositoryDragData)))
            {
                RepositoryDragData  data = (RepositoryDragData)e.Data.GetData(typeof(RepositoryDragData));
                RepositoryEventArgs args = new RepositoryEventArgs {
                    Repository = data.Repository,
                    Copy       = flag2
                };
                this.RepositoryDropped(this, args);
            }
            base.OnDragDrop(e);
            base.Focus();
            if (flag)
            {
                MainForm.Instance.BeginInvoke(new Action(MainForm.Instance.AdvancedQueryProps));
            }
        }
Ejemplo n.º 2
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            this.btnSubmit.Enabled   = false;
            this.txtFeedback.Enabled = false;
            this.Text = "Submitting....";
            string queryData = null;

            if (this.chkSubmitQuery.Checked)
            {
                try
                {
                    MemoryStream  stream = new MemoryStream();
                    StreamWriter  sr     = new StreamWriter(stream);
                    RunnableQuery query  = MainForm.Instance.CurrentQueryControl.Query;
                    query.WriteTo(sr, query.FilePath, true);
                    sr.Flush();
                    queryData = Convert.ToBase64String(stream.ToArray());
                }
                catch
                {
                }
            }
            new Thread(delegate {
                try
                {
                    Program.SubmitFeedback("LINQPad Feedback", this.txtEmail.Text.Trim(), this.txtFeedback.Text.Trim(), queryData);
                    if (!this.IsDisposed)
                    {
                        this.Invoke(new MethodInvoker(this.Success));
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show("Could not submit: " + exception.Message);
                    if (!this.IsDisposed)
                    {
                        try
                        {
                            this.Invoke(new MethodInvoker(this.Failure));
                        }
                        catch
                        {
                        }
                    }
                }
            })
            {
                Name = "Feedback submission", IsBackground = true
            }.Start();
        }