// Task Factory Method public static ProgramElement CreateElement(string CompleteFilename) { string e = Path.GetExtension(CompleteFilename).ToLower(); if (e.Length == 0) { //Console.Out.WriteLine(CompleteFilename); FileElement R = new FileElement(CompleteFilename); AddParsers(R, e); R.ElementType = ElementType.TextFile; return(R); } if (isText(e)) { FileElement R = new FileElement(CompleteFilename); AddParsers(R, e); R.ElementType = ElementType.TextFile; return(R); } if (isBin(e)) { BinElement R = new BinElement(CompleteFilename); R.ElementType = ElementType.BinaryFile; return(R); } Console.Out.Write("Unknown Type file : " + CompleteFilename); ExtraTypes.Add(e); return(new RumpElement(CompleteFilename)); }
private void NavigateToFile(string Filename, bool isForward) { if (Filename == null) { return; } txtAddressBar.Text = Filename; Filename = Filename.Trim(); if (!M.Elements.ContainsKey(Filename)) { MessageBox.Show("not found : " + Filename); return; } ProgramElement E = M.Elements[Filename]; lstDepends.Items.Clear(); lstSupports.Items.Clear(); foreach (ElementRelationship Dp in E.Depends.Values) { if (Dp.Supporter != null) { lstDepends.Items.Add(Dp.Supporter.name); } } //FillWithDescendents(lstSupports, E,1); foreach (ElementRelationship Sp in E.Supports.Values) { lstSupports.Items.Add(Sp.Dependent.name); } lstFiles.SelectedItem = Filename; if (isForward) { History.Push(Filename); } try { FileElement F = E as FileElement; cmdFindTextinFiles.Text = F.contents; if (this.Width < 1280) { this.Width = 1280; } } catch (Exception xe) { if (this.Width < 800) { this.Width = 800; } } }
private void lst_DoubleClick(object sender, EventArgs e) { ListBox LB = sender as ListBox; ProgramElement E = M.Elements[LB.SelectedItem as string]; try { FileElement F = E as FileElement; cmdFindTextinFiles.Text = F.contents; this.Width = 1280; } catch (Exception xe) { } }
private void cmdFindText_Click(object sender, EventArgs e) { int i = 0; if (txtSearchText.Text.Length > 0) { lstFiles.Items.Clear(); ProgramElement E; string S; foreach (KeyValuePair <string, ProgramElement> KVP in M.Elements) { S = KVP.Key; E = KVP.Value; if (E.ElementType == ElementType.TextFile) { FileElement F = E as FileElement; if (F.contents.Length > 0) { if (F.contents.ToUpper().Contains(txtSearchText.Text.ToUpper())) { lstFiles.Items.Add(S); i++; } } } } if (i == 0) { MessageBox.Show("No Files were found with text string (" + txtSearchText.Text + ")"); } else { MessageBox.Show(String.Format("{0:d} were found with text string ('{1}')", i, txtSearchText.Text)); } } }