コード例 #1
0
 protected override void OnClosed(EventArgs e)
 {
     base.OnClosed(e);
     if ((base.DialogResult == DialogResult.OK) && (this.lstResults.SelectedItems.Count > 0))
     {
         foreach (QueryMatch match in this.lstResults.SelectedItems)
         {
             match.Query.Open();
         }
         QueryControl qc = MainForm.Instance.CurrentQueryControl;
         if (qc != null)
         {
             Program.RunOnWinFormsTimer(delegate {
                 if (!qc.IsDisposed)
                 {
                     qc.FocusQuery();
                 }
             });
         }
     }
 }
コード例 #2
0
        private void FindAll()
        {
            StringBuilder builder = new StringBuilder("var search = new Regex (");

            if (this.chkWholeWord.Checked)
            {
                builder.Append("@\"\\b\" + ");
            }
            string str = this.cboText.Text.Trim().Replace("\"", "\"\"");

            if (!this.chkRegEx.Checked)
            {
                str = Regex.Escape(str);
            }
            builder.Append("@\"" + str + "\"");
            if (this.chkWholeWord.Checked)
            {
                builder.Append(" + @\"\\b\"");
            }
            if (!this.chkMatchCase.Checked)
            {
                builder.Append(", RegexOptions.IgnoreCase");
            }
            builder.AppendLine(");");
            builder.Append("\r\nvar queries =\r\n\tfrom query in ");
            if (!(!this.chkMyQueries.Checked || this.chkSamples.Checked))
            {
                builder.Append("Util.GetMyQueries()");
            }
            else if (!(this.chkMyQueries.Checked || !this.chkSamples.Checked))
            {
                builder.Append("Util.GetSamples()");
            }
            else
            {
                builder.Append("Util.GetMyQueries().Concat (Util.GetSamples())");
            }
            builder.AppendLine((Environment.Version.Major >= 4) ? ".AsParallel().AsOrdered()" : "");
            if ((!this.chkCSharp.Checked || !this.chkVB.Checked) || !this.chkSQL.Checked)
            {
                List <string> list = new List <string>();
                if (this.chkCSharp.Checked)
                {
                    list.Add("query.IsCSharp");
                }
                if (this.chkVB.Checked)
                {
                    list.Add("query.IsVB");
                }
                if (this.chkSQL.Checked)
                {
                    list.Add("query.IsSQL");
                }
                builder.AppendLine("\twhere " + string.Join(" || ", list.ToArray()));
            }
            builder.AppendLine("\tlet matches = search.Matches (query.Text)\r\n\twhere matches.Count > 0 || search.IsMatch (query.Name)\r\n\tgroup new { Query = query.OpenLink, Matches = query.FormatMatches (matches) } by query.Location;\r\n\r\nforeach (var item in queries)\r\n\titem.ToArray().Dump (item.Key);");
            string name = "Find: " + this.cboText.Text.Trim();

            if (name.Length > 30)
            {
                name = name.Substring(0, 0x19) + "...";
            }
            QueryControl qc = MainForm.Instance.AddQueryPage(false, false, builder.ToString(), 1, name, false, false, false);

            qc.Query.Repository  = null;
            qc.Query.ToDataGrids = false;
            qc.Query.IsModified  = false;
            qc.Query.OnQueryChanged();
            qc.SetSplitterHeight(0.2f);
            qc.Run();
            Program.RunOnWinFormsTimer(delegate {
                if (!qc.IsDisposed)
                {
                    qc.FocusQuery();
                }
            });
        }