public static void all_for_each(F.TreeNodeCollection collection, @delegate d) { foreach (F.TreeNode n in collection) { d(n); all_for_each(n.Nodes, d); } }
public static void wait(F.WebBrowser @this) { @this.DocumentText = null; F.HtmlDocument document = @this.Document; while (document.Body == null) { F.Application.DoEvents(); } }
public static void remove_all(F.TreeNodeCollection collection, @predicate d) { foreach (F.TreeNode n in collection) { if(d(n)) { collection.Remove(n); } } }
public static F.TreeNode find(F.TreeNodeCollection collection, @predicate d) { foreach (F.TreeNode n in collection) { if (d(n)) { return n; } } return null; }
public static ContextMenuTag CreateCommonMenuItems( MSWinForms.ContextMenuStrip Menu, MSWinForms.ListView LV, Options options = null) { // Use default options if none were passed if (options == null) options = new Options(); // If no menu passed, use the menu associated with the LV if (Menu == null) Menu = LV.ContextMenuStrip; // // Create the context var Context = new ContextMenuTag() { lv = LV, options = options, menu = Menu }; var DynMenus = new List<MSWinForms.ToolStripItem>(); // // Copy/Select All if (options.MFlags.HasFlag(MenuFlags.CopyAndSelect)) { // Copy Context.CopyItemMenu = new MSWinForms.ToolStripMenuItem() { ShortcutKeys = (MSWinForms.Keys.Control | MSWinForms.Keys.C), Text = "Copy" }; Context.CopyItemMenu.Click += new EventHandler(menuCommonLVCopyItem_Click); // Select All Context.SelectAllMenu = new MSWinForms.ToolStripMenuItem() { ShortcutKeys = (MSWinForms.Keys.Control | MSWinForms.Keys.A), Text = "Select all" }; Context.SelectAllMenu.Click += new EventHandler(menuCommonLVSelectAll_Click); // DeSelect All Context.DeSelectAllMenu = new MSWinForms.ToolStripMenuItem() { ShortcutKeys = (MSWinForms.Keys.Control | MSWinForms.Keys.D), Text = "De-Select all" }; Context.DeSelectAllMenu.Click += new EventHandler(menuCommonLVDeSelectAll_Click); DynMenus.AddRange(new MSWinForms.ToolStripItem[] { Context.CopyItemMenu, Context.SelectAllMenu, Context.DeSelectAllMenu, new MSWinForms.ToolStripSeparator(), }); } // // Find if (options.MFlags.HasFlag(MenuFlags.Find)) { // FindFirst Context.FindFirstMenu = new MSWinForms.ToolStripMenuItem() { ShortcutKeys = (MSWinForms.Keys.Control | MSWinForms.Keys.F), Text = "Find", }; Context.FindFirstMenu.Click += new EventHandler(menuCommonLVFindFirst_Click); // FindNext Context.FindNextMenu = new MSWinForms.ToolStripMenuItem() { ShortcutKeys = MSWinForms.Keys.F3, Text = "Find Next", }; Context.FindNextMenu.Click += new EventHandler(menuCommonLVFindNext_Click); DynMenus.AddRange(new MSWinForms.ToolStripItem[] { Context.FindFirstMenu, Context.FindNextMenu, new MSWinForms.ToolStripSeparator(), }); } // // Delete if (options.MFlags.HasFlag(MenuFlags.Delete)) { // Delete Context.DeleteMenu = new MSWinForms.ToolStripMenuItem() { ShortcutKeys = MSWinForms.Keys.Delete, Text = "Delete" }; Context.DeleteMenu.Click += new EventHandler(menuCommonLVDeleteItem_Click); DynMenus.AddRange(new MSWinForms.ToolStripItem[] { Context.DeleteMenu, new MSWinForms.ToolStripSeparator() }); } // // Export if (options.MFlags.HasFlag(MenuFlags.Export)) { var ExportToTextFile = new MSWinForms.ToolStripMenuItem() { ShortcutKeys = (MSWinForms.Keys.Control | MSWinForms.Keys.S), Text = "Export to text file" }; ExportToTextFile.Click += new EventHandler(menuCommonLVExportToTextFile_Click); DynMenus.AddRange(new MSWinForms.ToolStripItem[] { ExportToTextFile, new MSWinForms.ToolStripSeparator() }); } // // Add all the dynamic menu items now if (DynMenus.Count > 0) { if (DynMenus[DynMenus.Count - 1] is MSWinForms.ToolStripSeparator) DynMenus.RemoveAt(DynMenus.Count - 1); foreach (var m in DynMenus) Menu.Items.Add(m); } // // Dynamic menu to be created based on column item click? if (options.OnGenColItemMenuItem != null && options.OnColItemMenuClick != null) { Menu.Opening += new CancelEventHandler(menuCommonLV_Opening); Menu.Closed += new MSWinForms.ToolStripDropDownClosedEventHandler(menuCommonLV_Closed); } // // Install column sorter if (options.WantColSorting) LV.ColumnClick += new MSWinForms.ColumnClickEventHandler(lvCommon_ColumnClick); // // Associate the context with the tags of the listview and the menu Menu.Tag = Context; LV.Tag = Context; // Associate the menu with the LV LV.ContextMenuStrip = Menu; return Context; }
private static void lvCommon_ColumnClick( object sender, MSWinForms.ColumnClickEventArgs e) { var lvCtx = GetCommonLVContext(sender); if (lvCtx == null) return; var lv = lvCtx.lv; SimpleListViewItemComparer sorter = lv.ListViewItemSorter as SimpleListViewItemComparer; if (sorter == null) { sorter = new SimpleListViewItemComparer(e.Column); lv.ListViewItemSorter = sorter; } else { sorter.Column = e.Column; } sorter.Ascending = !sorter.Ascending; lv.Sort(); }
private static void menuCommonLV_Closed( object sender, MSWinForms.ToolStripDropDownClosedEventArgs e) { // Get context var lvCtx = GetCommonLVContext(sender); if (lvCtx == null || lvCtx.GenColItemMenu == null) return; // Remove the user menus foreach (var mi in lvCtx.GenColItemMenu) lvCtx.menu.Items.Remove(mi); // Clear the list lvCtx.GenColItemMenu.Clear(); }
public static F.HtmlElement append(F.HtmlElement parent, string tag) { F.HtmlElement element = parent.Document.CreateElement(tag); parent.AppendChild(element); return element; }