private ContainerListViewItem AddItem(ContainerListViewItemCollection parent, FunctionInfo function) { ContainerListViewItem item = parent.Add(currentRun.signatures[function.ID].Signature); item.SubItems[1].Text = ((((double)function.Samples) / (double)currentRun.maxSamples) * 100.0).ToString("0.00;-0.00;0.0"); item.Tag = function; return(item); }
public void AddFunctionItem(ContainerListViewItemCollection parent, FunctionInfo function) { ContainerListViewItem item = AddItem(parent, function); foreach (FunctionInfo callee in function.Children.Values) { AddItem(item.Items, callee); } }
public void AddRun(Run run) { ContainerListViewItem item = new ContainerListViewItem(DateTime.Now.ToString(CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern)); item.Tag = run; runs.Items.Add(item); runs.SelectedItems.Clear(); runs.SelectedItems.Add(item); ShowRun(run); }
void MakeSureComputed(ContainerListViewItem item, bool parentExpanded) { if (item.Items.Count == 0) { foreach (FunctionInfo function in SortFunctions(((FunctionInfo)item.Tag).Children.Values)) { AddFunctionItem(item.Items, function); } } if (item.Expanded || parentExpanded) { foreach (ContainerListViewItem subItem in item.Items) { MakeSureComputed(subItem, item.Expanded); } } }
private void GetDsnList() { //get system|user dsn list OdbcDsn[] sDsns = radioButton1.Checked ? OdbcManager.GetSystemDsnList() : OdbcManager.GetUserDsnList(); if (sDsns != null) { ContainerListViewItem[] clvis = new ContainerListViewItem[sDsns.Length]; ContainerListViewItem clvi = null; int i = 0; foreach (OdbcDsn dsn in sDsns) { clvi = new ContainerListViewItem(dsn.DsnName); clvi.SubItems.AddRange(new string[]{ dsn.DsnDriverName, dsn.DsnServerName, dsn.DsnDescription, dsn.DsnDriverPath, dsn.DsnDatabase}); clvi.Tag = dsn; clvi.ImageIndex = clvi.SubItems[1].Text.ToLower().StartsWith("microsoft access") ? 0 : 1; if (dsn == _preSelectedDsn) clvi.Checked = true; clvis[i++] = clvi; } containerListView1.BeginUpdate(); containerListView1.Items.Clear(); containerListView1.Sort(0, SortOrder.Ascending, true); containerListView1.Items.AddRange(clvis); containerListView1.EndUpdate(); } else containerListView1.Items.Clear(); }
private void GetDatabaseList() { //get all installed mysql databases and list them in containerlistview StringCollection dbs = MySqlDatabaseManager.Databases; if (dbs != null) { ContainerListViewItem[] clvis = new ContainerListViewItem[dbs.Count]; ContainerListViewItem clvi = null; int i = 0; foreach (string db in dbs) { clvi = new ContainerListViewItem(db); clvi.Tag = db; clvi.ImageIndex = 0; if (db == _selectedDatabase) clvi.Checked = true; clvis[i++] = clvi; } containerListView1.BeginUpdate(); containerListView1.Items.Clear(); containerListView1.Sort(0, SortOrder.Ascending, true); containerListView1.Items.AddRange(clvis); containerListView1.EndUpdate(); } else containerListView1.Items.Clear(); this.label3.Text = MySqlDatabaseManager.Username; }
void MakeSureComputed(ContainerListViewItem item) { MakeSureComputed(item, false); }
public void Find(string text, bool forward, bool step) { if (text != "") { ContainerListViewItem item; if (SelectedItems.Count == 0) { if (Items.Count == 0) { item = null; } else { item = Items[0]; } } else { if (step) { if (forward) { item = SelectedItems[0].NextVisibleItem; } else { item = SelectedItems[0].PreviousVisibleItem; } } else { item = SelectedItems[0]; } } ContainerListViewItem firstItem = item; while (item != null) { if (item.Text.ToLower().Contains(text.ToLower())) { SelectedItems.Clear(); item.Focused = true; item.Selected = true; this.Invalidate(); break; } else { if (forward) { item = item.NextVisibleItem; } else { item = item.PreviousVisibleItem; } if (item == null) { if (forward) { item = Items[0]; } else { item = Items[Items.Count - 1]; } } } if (item == firstItem) { break; } } if (item != null) { EnsureVisible(item); } } }
private NProf() { Icon = new Icon(this.GetType().Assembly.GetManifestResourceStream("NProf.Resources.app-icon.ico")); Text = "NProf - v" + Profiler.Version; profiler = new Profiler(); runs = new ContainerListView(); ContainerListViewColumnHeader header = new ContainerListViewColumnHeader("Runs", 90); runs.Columns.Add(header); runs.SizeChanged += delegate { header.Width = runs.Size.Width - 5; }; runs.Dock = DockStyle.Left; runs.Width = 100; runs.DoubleClick += delegate { if (runs.SelectedItems.Count != 0) { ShowRun((Run)runs.SelectedItems[0].Tag); } }; callers = new MethodView("Callers"); callers.Size = new Size(100, 200); callers.Dock = DockStyle.Bottom; callers.GotFocus += delegate { callees.SelectedItems.Clear(); }; callers.DoubleClick += delegate { if (callers.SelectedItems.Count != 0) { callees.MoveTo(((FunctionInfo)callers.SelectedItems[0].Tag).ID); } }; callees = new MethodView("Callees"); callees.Size = new Size(100, 100); callees.Dock = DockStyle.Fill; callees.GotFocus += delegate { callers.SelectedItems.Clear(); }; callees.DoubleClick += delegate { if (callees.SelectedItems.Count != 0) { callers.MoveTo(((FunctionInfo)callees.SelectedItems[0].Tag).ID); } }; callees.SelectedItemsChanged += delegate { if (callees.SelectedItems.Count != 0) { ContainerListViewItem item = callees.SelectedItems[0]; if (item.Items.Count == 0) { foreach (FunctionInfo f in ((FunctionInfo)item.Tag).Children.Values) { callees.AddFunctionItem(item.Items, f); } } } }; findText = new TextBox(); findText.TextChanged += delegate { Find(true, false); }; findText.KeyDown += delegate(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { Find(true, true); e.Handled = true; } }; Menu = new MainMenu(new MenuItem[] { new MenuItem( "File", new MenuItem[] { new MenuItem( "&New", delegate { runs.Items.Clear(); NProf.arguments.Text = ""; NProf.application.Text = ""; callees.Items.Clear(); callers.Items.Clear(); }, Shortcut.CtrlN), new MenuItem("-"), new MenuItem("E&xit", delegate { Close(); }) }), new MenuItem( "Project", new MenuItem[] { new MenuItem( "Start", delegate { StartRun(); }, Shortcut.F5), new MenuItem("-"), new MenuItem("Find", delegate { ShowSearch(); }, Shortcut.CtrlF) }) }); Controls.AddRange(new Control[] { With(new Panel(), delegate(Panel panel) { panel.Dock = DockStyle.Fill; panel.Controls.AddRange(new Control[] { With(new Panel(), delegate(Panel methodPanel) { methodPanel.Size = new Size(100, 100); methodPanel.Dock = DockStyle.Fill; methodPanel.Controls.AddRange(new Control[] { callees, With(new Splitter(), delegate(Splitter splitter) { splitter.Dock = DockStyle.Bottom; }), callers, With(new FlowLayoutPanel(), delegate(FlowLayoutPanel p) { findPanel = p; findPanel.BorderStyle = BorderStyle.FixedSingle; p.Visible = false; p.WrapContents = false; p.AutoSize = true; p.Dock = DockStyle.Top; Button close = new Button(); close.Text = "x"; close.Width = 17; close.Height = 20; close.TextAlign = ContentAlignment.BottomLeft; close.Click += delegate { findPanel.Visible = false; }; p.Controls.Add(close); p.Controls.AddRange(new Control[] { With(new Label(), delegate(Label label) { label.Text = "Find:"; label.Dock = DockStyle.Fill; label.TextAlign = ContentAlignment.MiddleLeft; label.AutoSize = true; }), findText, With(new Button(), delegate(Button button) { button.AutoSize = true; button.Text = "Find next"; button.Click += new EventHandler(findNext_Click); }), With(new Button(), delegate(Button button) { button.AutoSize = true; button.FlatAppearance.BorderSize = 0; button.Click += new EventHandler(findPrevious_Click); button.Text = "Find previous"; }) }); } ) }); }), With(new Splitter(), delegate(Splitter splitter) { splitter.Dock = DockStyle.Left; }), runs }); }), With(new Splitter(), delegate(Splitter splitter) { splitter.Dock = DockStyle.Top; }), With(new TableLayoutPanel(), delegate(TableLayoutPanel panel) { application = With(new TextBox(), delegate(TextBox textBox) { textBox.Width = 300; }); arguments = With(new TextBox(), delegate(TextBox textBox) { textBox.Width = 300; }); panel.Height = 100; panel.AutoSize = true; panel.Dock = DockStyle.Top; panel.Controls.Add(With(new Label(), delegate(Label label) { label.Text = "Application:"; label.Dock = DockStyle.Fill; label.TextAlign = ContentAlignment.MiddleLeft; label.AutoSize = true; }), 0, 0); panel.Controls.Add(application, 1, 0); panel.Controls.Add(With(new Button(), delegate(Button button) { button.Text = "Browse..."; button.TabIndex = 0; button.Focus(); button.Click += delegate { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "Executable files (*.exe)|*.exe"; DialogResult dr = dialog.ShowDialog(); if (dr == DialogResult.OK) { application.Text = dialog.FileName; application.Focus(); application.SelectAll(); } }; }), 2, 0); panel.Controls.Add(With(new Label(), delegate(Label label) { label.Text = "Arguments:"; label.Dock = DockStyle.Fill; label.TextAlign = ContentAlignment.MiddleLeft; label.AutoSize = true; }), 0, 1); panel.Controls.Add(arguments, 1, 1); }), }); //Size = new Size(800, 600); //this.Validating+=delegate { // Size = new Size(800, 600); //}; this.Load += delegate { Size = new Size(800, 600); }; }