public void SetActiveDocument(Document document) { foreach (LayoutDocument entry in this.editors.Children) { if (entry.GetType() == typeof(AvalonDocument)) { AvalonDocument doc = (AvalonDocument)entry; if (doc.GetDocument().Equals(document)) { doc.IsActive = true; lastactivedocument = doc; return; } doc.IsActive = false; } } var newdoc = new AvalonDocument(document); newdoc.IsActive = true; lastactivedocument = newdoc; editors.Children.Add(newdoc); }
public void SaveAllDocument() { foreach (LayoutDocument child in editors.Children) { if (child.GetType() == typeof(AvalonDocument)) { AvalonDocument avalondoc = (AvalonDocument)child; avalondoc.GetDocument().SaveDocument(); } } }
private void button9_Click(object sender, EventArgs e) { if (Results == null) { return; } if (ef == null) { return; } if (ef.scr == null) { return; } int bb = comboBox2.SelectedIndex; if (bb == 2) { ScriptControl.ScriptControl scr = ef.scr; ArrayList L = ToLinesProject(Results); AvalonDocument doc = ef.scr.GetActiveDocument(); string filename = doc.FileName; VSSolution vs = ef.GetVSSolution(); VSProject vp = vs.GetProjectbyFileName(filename); scr.BookmarkAll(filename, vp, L); } else if (bb == 3) { ScriptControl.ScriptControl scr = ef.scr; ArrayList L = ToLinesProject(Results); AvalonDocument doc = ef.scr.GetActiveDocument(); string filename = doc.FileName; VSSolution vs = ef.GetVSSolution(); VSProject vp = vs.MainVSProject; scr.BookmarkAll(vp, L); } }
internal void OnChanged(Document document, Document.State state) { Logger.Info("[IDE] Changed document: " + document.GetName() + " >> " + state); switch (state) { case Document.State.CREATED: AvalonDocument d = new AvalonDocument(document); this.editors.Children.Add(d); this.SetActiveDocument(document); break; case Document.State.CHANGED: foreach (LayoutDocument entry in this.editors.Children) { if (entry.GetType() == typeof(AvalonDocument)) { AvalonDocument doc = (AvalonDocument)entry; if (doc.GetDocument() == document) { doc.Title = document.GetName() + "*"; } } } break; case Document.State.REMOVED: foreach (LayoutDocument entry in this.editors.Children) { if (entry.GetType() == typeof(AvalonDocument)) { AvalonDocument doc = (AvalonDocument)entry; if (doc.GetDocument() == document) { //Boot.Core.Workspace.RemoveDocument( ? doc.GetDocument() : null); this.editors.Children.Remove(doc); this.GetMenu().Update(); //state = Document.State.CREATED; break; } } } break; } this.GetMenu().Update(); }
public ArrayList FindAll() { ArrayList results = new ArrayList(); SearchEngine se = new SearchEngine(); bool mc = true; if (checkBox2.Checked == false) { mc = false; } string s = comboBox1.Text; //MessageBox.Show("Find " + s); VSSolution vs = ef.GetVSSolution(); if (vs == null) { return(results); } int bb = comboBox2.SelectedIndex; if (bb == 1) { MessageBox.Show("Find for All Open Documents"); ScriptControl.ScriptControl scr = ef.scr; VSProject vp = vs.MainVSProject; ArrayList L = new ArrayList();//.GetOpenFiles(); if (BB != bb || patterns != s) { Results = null; } BB = bb; patterns = s; if (Results == null) { { { Finder finders = new Finder(); Results = new ArrayList(); foreach (string f in L) { string text = File.ReadAllText(f); if (mc == false) { text = text.ToLower(); s = s.ToLower(); } char[] texts = text.ToCharArray(); char[] pattern = s.ToCharArray(); ArrayList found = null; if (checkBox4.Checked == true) { found = RegexMatch(text, s, true); } else { found = finders.TW(pattern, pattern.Length, texts, texts.Length); } if (found.Count == 0) { continue; } string[] lines = text.Split("\n".ToCharArray()); int fp = 0; int pos = (int)found[fp]; int r = 0; int n = 0; int i = 0; while (i < lines.Length) { string line = lines[i]; n = r + line.Length + 1; if (pos >= r && pos <= n) { do { if (checkBox3.Checked == true) { if (Char.IsLetterOrDigit(texts[pos + patterns.Length]) == false) { if (pos > 0) { if (Char.IsLetterOrDigit(texts[pos - 1]) == false) { Results.Add(f + "\t\t" + (pos - r) + " \t" + i); } } } } else { Results.Add(f + "\t\t" + (pos - r) + " \t" + i); } fp++; if (fp < found.Count) { pos = (int)found[fp]; } else { break; } }while (pos <= n); } r = n; i++; } } act = 0; return(Results); } } } if (Results == null) { return(null); } if (act >= Results.Count) { return(null); } string dd = Results[act] as string; string[] cc = dd.Split("\t".ToCharArray()); string file = cc[0]; int l2 = Convert.ToInt32(cc[2]); int c2 = Convert.ToInt32(cc[1]); scr = ef.scr; string filename = file; //VSProject vp = vs.GetProjectbyFileName(filename); DomRegion dr = new DomRegion(l2, c2, l2, c2 + patterns.Length); scr.OpenDocuments2(filename, vp, dr, true); return(null); } else if (bb == 0) { MessageBox.Show("Find for Current Block"); ScriptControl.ScriptControl scr = ef.scr; AvalonDocument doc = ef.scr.GetActiveDocument(); string filename = doc.FileName; //Dom.IMember m = scr.GetCurrentBlock(); //if (m == null) //{ // Results = null; // return null; //} //string text = "";// scr.GetCurrentBlockText(m.BodyRegion); //TextPoint p = new TextPoint(0, m.Region.BeginLine); ////if (BB != bb || patterns != s || filename != filenamedoc) //if (m != mb) // Results = null; //mb = m; filenamedoc = filename; BB = bb; patterns = s; if (Results == null) { { { Finder finders = new Finder(); Results = new ArrayList(); if (mc == false) { //text = text.ToLower(); s = s.ToLower(); } char[] texts = "text".ToCharArray(); char[] pattern = s.ToCharArray(); ArrayList found = null; if (checkBox4.Checked == true) { //found = RegexMatch(text, s, true); } else { found = finders.TW(pattern, pattern.Length, texts, texts.Length); } string[] lines = "text".Split("\n".ToCharArray()); int fp = 0; int pos = (int)found[fp]; int r = 0; int n = 0; int i = 0; while (i < lines.Length) { string line = lines[i]; n = r + line.Length + 1; if (pos >= r && pos <= n) { Results.Add(filename + "\t\t" + (pos - r) + " \t" + (0 /*p.Y*/ + i)); fp++; if (fp < found.Count) { pos = (int)found[fp]; } else { break; } } r = n; i++; } } act = 0; return(Results); } } if (Results == null) { return(null); } if (act >= Results.Count) { return(null); } string dd = Results[act] as string; string[] cc = dd.Split("\t".ToCharArray()); int l2 = Convert.ToInt32(cc[2]); int c2 = Convert.ToInt32(cc[1]); scr = ef.scr; filename = doc.FileName; VSProject vp = vs.GetProjectbyFileName(filename); DomRegion dr = new DomRegion(l2, c2, l2, c2 + patterns.Length); scr.OpenDocuments2(filename, vp, dr, true); return(null); } if (bb == 7) { MessageBox.Show("Find for Current Selection"); ScriptControl.ScriptControl scr = ef.scr; AvalonDocument doc = ef.scr.GetActiveDocument(); string filename = doc.FileName; string text = scr.GetCurrentSelection(); //TextPoint p = new TextPoint(0, 0); // scr.GetCurrentSelectionStart(); if (BB != bb || patterns != s || filename != filenamedoc) { Results = null; } filenamedoc = filename; BB = bb; patterns = s; if (Results == null) { { { Finder finders = new Finder(); Results = new ArrayList(); if (mc == false) { text = text.ToLower(); s = s.ToLower(); } char[] texts = text.ToCharArray(); char[] pattern = s.ToCharArray(); ArrayList found = null; if (checkBox4.Checked == true) { found = RegexMatch(text, s, true); } else { found = finders.TW(pattern, pattern.Length, texts, texts.Length); } string[] lines = text.Split("\n".ToCharArray()); int fp = 0; int pos = (int)found[fp]; int r = 0; int n = 0; int i = 0; while (i < lines.Length) { string line = lines[i]; n = r + line.Length + 1; if (pos >= r && pos <= n) { // Results.Add(filename + "\t\t" + (pos - r) + " \t" + (p.Y + i)); fp++; if (fp < found.Count) { pos = (int)found[fp]; } else { break; } } r = n; i++; } } act = 0; return(Results); } } if (Results == null) { return(null); } if (act >= Results.Count) { return(null); } string dd = Results[act] as string; string[] cc = dd.Split("\t".ToCharArray()); int l2 = Convert.ToInt32(cc[2]); int c2 = Convert.ToInt32(cc[1]); scr = ef.scr; filename = doc.FileName; VSProject vp = vs.GetProjectbyFileName(filename); DomRegion dr = new DomRegion(l2, c2, l2, c2 + patterns.Length); scr.OpenDocuments2(filename, vp, dr, true); return(null); } if (bb == 3) { //MessageBox.Show("Find for Project"); ScriptControl.ScriptControl scr = ef.scr; //string filename = doc.FileName; VSProject vp = vs.MainVSProject; if (vp == null) { MessageBox.Show("No project has been selected"); Results = new ArrayList(); return(Results); } ArrayList L = vp.GetCompileItems(); if (BB != bb || patterns != s) { Results = null; } BB = bb; patterns = s; if (Results == null) { { { Finder finders = new Finder(); Results = new ArrayList(); foreach (string f in L) { string text = File.ReadAllText(f); if (mc == false) { text = text.ToLower(); s = s.ToLower(); } char[] texts = text.ToCharArray(); char[] pattern = s.ToCharArray(); ArrayList found = null; if (checkBox4.Checked == true) { found = RegexMatch(text, s, true); } else { found = finders.TW(pattern, pattern.Length, texts, texts.Length); } if (found.Count == 0) { continue; } string[] lines = text.Split("\n".ToCharArray()); int fp = 0; int pos = (int)found[fp]; int r = 0; int n = 0; int i = 0; while (i < lines.Length) { string line = lines[i]; n = r + line.Length + 1; if (pos >= r && pos <= n) { Results.Add(f + "\t" + (pos - r) + " \t" + i); fp++; if (fp < found.Count) { pos = (int)found[fp]; } else { break; } } r = n; i++; } } act = 0; return(Results); } } } if (Results == null) { return(null); } if (act >= Results.Count) { return(null); } string dd = Results[act] as string; string[] cc = dd.Split("\t".ToCharArray()); string file = cc[0]; int l2 = Convert.ToInt32(cc[2]); int c2 = Convert.ToInt32(cc[1]); scr = ef.scr; string filename = file; //VSProject vp = vs.GetProjectbyFileName(filename); DomRegion dr = new DomRegion(l2, c2, l2, c2 + patterns.Length); scr.OpenDocuments2(filename, vp, dr, true); return(null); } else if (bb == 2) { //MessageBox.Show("Find for Current Document"); AvalonDocument doc = ef.scr.GetActiveDocument(); string filename = doc.FileName; string text = "doc.syntaxDocument1.Text"; if (BB != bb || patterns != s || filename != filenamedoc) { Results = null; } filenamedoc = filename; BB = bb; patterns = s; if (Results == null) { { { Finder finders = new Finder(); Results = new ArrayList(); //text = File.ReadAllText(f); if (mc == false) { text = text.ToLower(); s = s.ToLower(); } char[] texts = text.ToCharArray(); char[] pattern = s.ToCharArray(); ArrayList found = null; if (checkBox4.Checked == true) { found = RegexMatch(text, s, true); } else { found = finders.TW(pattern, pattern.Length, texts, texts.Length); } if (found.Count > 0) { string[] lines = text.Split("\n".ToCharArray()); int fp = 0; int pos = (int)found[fp]; int r = 0; int n = 0; int i = 0; while (i < lines.Length) { string line = lines[i]; n = r + line.Length + 1; if (pos >= r && pos <= n) { do { Results.Add(filename + "\t" + (pos - r) + " \t" + i); fp++; if (fp < found.Count) { pos = (int)found[fp]; } else { break; } }while (pos <= n); } r = n; i++; } } } act = 0; return(Results); } } if (Results == null) { return(null); } if (act >= Results.Count) { return(null); } string dd = Results[act] as string; string[] cc = dd.Split("\t".ToCharArray()); int l2 = Convert.ToInt32(cc[2]); int c2 = Convert.ToInt32(cc[1]); ScriptControl.ScriptControl scr = ef.scr; filename = doc.FileName; VSProject vp = vs.GetProjectbyFileName(filename); DomRegion dr = new DomRegion(l2, c2, l2, c2 + patterns.Length); scr.OpenDocuments2(filename, vp, dr, true); return(null); } Finder finder = new Finder(); foreach (VSProject p in vs.Projects) { ArrayList L = p.GetCompileItems(); foreach (string f in L) { string text = File.ReadAllText(f); if (mc == false) { text = text.ToLower(); s = s.ToLower(); } char[] texts = text.ToCharArray(); char[] pattern = s.ToCharArray(); ArrayList found = null; if (checkBox4.Checked == true) { found = RegexMatch(text, s, true); } else { found = finder.TW(pattern, pattern.Length, texts, texts.Length); } if (found.Count == 0) { continue; } string[] lines = text.Split("\n".ToCharArray()); int fp = 0; int pos = (int)found[fp]; int r = 0; int n = 0; int i = 0; while (i < lines.Length) { string line = lines[i]; n = r + line.Length + 1; if (pos >= r && pos <= n) { results.Add(f + "\t" + (pos - r) + " \t" + i); fp++; if (fp < found.Count) { pos = (int)found[fp]; } else { break; } } r = n; i++; } } } if (checkBox3.Checked == true) { string pp = comboBox1.Text; char[] separators = { '\t', ' ', '\n', '.', '-', '(' }; ArrayList R = new ArrayList(); foreach (string sw in results) { string[] d = sw.Split(separators); foreach (string b in d) { if (b.Trim().ToLower() == pp.Trim().ToLower()) { R.Add(sw); } } } results = R; } if (checkBox10.Checked == true) { ArrayList R = new ArrayList(); foreach (string sw in results) { string[] d = sw.Split(" ".ToCharArray()); R.Add(d[0] + "\n"); } results = R; } return(results); }
private void button8_Click(object sender, EventArgs e) { int bc = comboBox2.SelectedIndex; string s = comboBox1.Text; if (BB != bc || patterns != s) { results = FindAll(); } else if (bc == 2) { AvalonDocument doc = ef.scr.GetActiveDocument(); string filename = doc.FileName; if (filename != filenamedoc) { results = FindAll(); } else { results = Results; } } else { results = Results; } if (results == null) { return; } Results = results; FindResultsForm rf = ef.rfs; if (radioButton2.Checked == true) { rf = ef.rfs2; } if (rf == null) { return; } if (rf.results == null) { rf.results = new ArrayList(); } if (checkBox9.Checked == false) { rf.ClearLog(); } //string bb = ""; rf.AddOrUpdateOutputs(s); foreach (string b in results) { rf.LogLine(b); } if (checkBox9.Checked == true) { rf.results.AddRange(results); } else { rf.results = results; } rf.text = comboBox1.Text; UpdateButtons(); }
public static ArrayList FindInActiveDocument(string s) { // else if (bb == 2) //{ //MessageBox.Show("Find for Current Document"); ArrayList Results = new ArrayList(); ExplorerForms ef = ExplorerForms.ef; AvalonDocument doc = ef.scr.GetActiveDocument(); string filename = doc.FileName; string text = "doc.syntaxDocument1.Text"; string filenamedoc = filename; string patterns = s; //if (Results == null) { { { Finder finders = new Finder(); Results = new ArrayList(); //text = File.ReadAllText(f); //if (mc == false) { // text = text.ToLower(); // s = s.ToLower(); } char[] texts = text.ToCharArray(); char[] pattern = s.ToCharArray(); ArrayList found = null; //if (checkBox4.Checked == true) //{ // found = RegexMatch(text, s, true); //} //else { found = finders.TW(pattern, pattern.Length, texts, texts.Length); } if (found.Count > 0) { string[] lines = text.Split("\n".ToCharArray()); int fp = 0; int pos = (int)found[fp]; int r = 0; int n = 0; int i = 0; while (i < lines.Length) { string line = lines[i]; n = r + line.Length + 1; if (pos >= r && pos <= n) { do { Results.Add(filename + "\t" + (pos - r) + " \t" + i); fp++; if (fp < found.Count) { pos = (int)found[fp]; } else { break; } }while (pos <= n); } r = n; i++; } } } int act = 0; return(Results); } } //} return(Results); }
public void LoadIntellisenseResults(List <Diagnostic> hc) { lock (s_obs) { if (ef == null) { return; } ScriptControl.ScriptControl scr = null; VSSolution vs = null; string filename = ""; if (ef != null) { if (ef.scr != null) { scr = ef.scr; } } ToolStripComboBox b = toolStripComboBox1; int i = b.SelectedIndex; vs = ef.GetVSSolution(); VSProject vp = null; //if (vs != null) // vp = vs.MainVSProject; //dg.SuspendLayout(); //LI = new ArrayList(); //if (vp != null) // if (i == 2) // { // foreach (IntErrors e in DD) // { // if (vp != null) // if (e.vp != vp) // continue; // int rowId = dg.Rows.Add(); // DataGridViewRow row = dg.Rows[rowId]; // row.Cells[0].Value = ""; // row.Cells[1].Value = ve_resource.Breakall_6323; // row.Cells[2].Value = "e.Code"; // row.Cells[3].Value = e.e.Message; // row.Cells[4].Value = Path.GetFileNameWithoutExtension(e.vp.FileName); // row.Cells[5].Value = Path.GetFileName(e.file); // row.Cells[6].Value = e.e.Region.BeginLine.ToString(); // row.Cells[7].Value = "project"; // string message = e.e.Message; // //if (message.StartsWith("UnknownIdentifier") == true) // // MessageBox.Show("Unknown identifier"); // //v.Checked = true; // row.Tag = e; // //lv.Items.Add(v); // } // dg.ResumeLayout(); // return; // } //if (i == 3 || i == 0) { if (hc != null) { } //filename = d.FileName; foreach (/*IntErrors e in DD*/ Diagnostic hs in hc) { //if (filename != "") // if (e.file != filename) // continue; Diagnostic dc = hs;// hc[hs]; filename = dc.Location.SourceTree.FilePath; AvalonDocument d = scr.FileOpened(filename, false); int hash = dc.GetMessage().GetHashCode(); if (hcd.ContainsKey(hash)) { continue; } int line = 0; string file = ""; if (dc.Location != Microsoft.CodeAnalysis.Location.None) { if (dc.Location.SourceTree != null) { file = dc.Location.SourceTree.FilePath;// syntaxTree.FilePath; FileLinePositionSpan c = dc.Location.GetLineSpan(); line = c.StartLinePosition.Line; } } int rowId = dg.Rows.Add(); DataGridViewRow row = dg.Rows[rowId]; row.InheritedStyle.BackColor = Color.FromKnownColor(KnownColor.Control); //dg.Rows.Remove(row); //dg.Rows.Insert(0, row); row.Cells[0].Value = dc.Descriptor.Category; if (dc.Severity.ToString() == "Error") { row.Cells[1].Value = new Bitmap(ve_resource.Breakall_6323, 15, 15); Ep.Add(row); } else if (dc.Severity.ToString() == "Warning") { row.Cells[1].Value = new Bitmap(ve_resource.StatusWarning_16x, 15, 15); Wp.Add(row); } else { row.Cells[1].Value = new Bitmap(ve_resource.StatusHelp_256x, 15, 15); Mp.Add(row); } row.Cells[2].Value = dc.Descriptor.Id; row.Cells[3].Value = dc.GetMessage(); if (dc.Location != Microsoft.CodeAnalysis.Location.None) { if (vp != null) { row.Cells[4].Value = Path.GetFileNameWithoutExtension(vp.FileName); } else if (dc.Location != Microsoft.CodeAnalysis.Location.None) { if (dc.Location.SourceTree != null) { row.Cells[4].Value = Path.GetFileNameWithoutExtension(dc.Location.SourceTree.FilePath); } } } row.Cells[5].Value = Path.GetFileName(file); if (line > 0) { row.Cells[6].Value = d.GetLineExtended(line) + 1; } row.Cells[7].Value = "project"; //row.Cells[0].Value = ""; //row.Cells[1].Value = ve_resource.Errors; //row.Cells[2].Value = "e.Code"; //row.Cells[3].Value = e.e.Message; //row.Cells[4].Value = Path.GetFileNameWithoutExtension(e.vp.FileName); //row.Cells[5].Value = Path.GetFileName(e.file); //row.Cells[6].Value = e.e.Region.BeginLine.ToString(); //row.Cells[7].Value = "project"; //ListViewItem v = new ListViewItem(); //v.Text = ""; //v.SubItems.Add(""); //v.SubItems.Add("e.Code"); //v.SubItems.Add(e.e.Message); //v.SubItems.Add(Path.GetFileNameWithoutExtension(e.vp.FileName)); //v.SubItems.Add(Path.GetFileName(e.c.FileName)); //v.SubItems.Add(e.e.Region.BeginLine.ToString()); //v.SubItems.Add("project"); //v.Checked = true; row.Tag = dc; dg.Rows.Remove(row); dg.Rows.Insert(0, row); hcd.Add(hash, row); //lv.Items.Add(v); } dg.ResumeLayout(); //ef.scr.FocusActiveDocument(); return; } //ArrayList F = ef.scr.GetOpenFiles(); /* * foreach (IntErrors e in DD) * { * //ListViewItem v = new ListViewItem(); * //v.Text = ""; * //v.SubItems.Add(""); * //v.SubItems.Add("e.Code"); * //v.SubItems.Add(e.e.Message); * //v.SubItems.Add(Path.GetFileNameWithoutExtension(e.c.FileName)); * //v.SubItems.Add(Path.GetFileName(e.c.FileName)); * //v.SubItems.Add(e.e.Region.BeginLine.ToString()); * //v.SubItems.Add("project"); * * //v.Checked = true; * * int rowId = dg.Rows.Add(); * DataGridViewRow row = dg.Rows[rowId]; * row.InheritedStyle.BackColor = Color.FromKnownColor(KnownColor.Control); * * row.Cells[0].Value = ""; * row.Cells[1].Value = ve_resource.Errors; * row.Cells[2].Value = "e.Code"; * row.Cells[3].Value = e.e.Message; * row.Cells[4].Value = Path.GetFileNameWithoutExtension(e.vp.FileName); * row.Cells[5].Value = Path.GetFileName(e.file); * row.Cells[6].Value = e.e.Region.BeginLine.ToString(); * row.Cells[7].Value = "project"; * * //string message = e.e.Message; * * //if (message.StartsWith("UnknownIdentifier") == true) * //{ * // // MessageBox.Show("Unknown identifier"); * * // string[] cc = e.e.Message.Split(" ".ToCharArray()); * * // Document d = ef.scr.FileOpened(e.c.FileName); * * // //foreach (Row r in d.Editor.Document) * // // foreach (Word w in r) * // // w.HasError = false; * * // if (d != null) * // { * // // MessageBox.Show("File has been found"); * * // if (e.e.Region.BeginLine < 0) * // continue; * * // d.SuspendLayout(); * * // Row r = d.Editor.Document[e.e.Region.BeginLine]; * * // foreach (Word w in r) * // { * // string[] bb = w.Text.Split(";".ToCharArray()); * * // foreach (string dd in bb) * * // if (dd == cc[1]) * // { * // // MessageBox.Show("Identifier found"); * * // w.HasError = true; * * // //d.Refresh(); * // } * // } * * // d.ResumeLayout(); * // } * * //} * * row.Tag = e; * } * * ef.scr.LoadErrors(DD); * * dg.ResumeLayout(); */ } }