private void CreateCollection() { _collection.Clear(); var node = _root; var cs = new CustomShortcut(GetType((string)node.Tag), node.Text); _collection.Add(cs); FillNode(cs, node.Nodes); }
private static void FillNode(CustomShortcut shortcut, TreeNodeCollection nodes) { foreach (TreeNode node in nodes) { var cs = new CustomShortcut( GetType((string)node.Tag), node.Text); shortcut.Nodes.Add(cs); FillNode(cs, node.Nodes); } }
public object Clone() { var cs = new CustomShortcut(_owner, _name); foreach (var de in HashTable) { cs.HashTable.Add(de.Key, de.Value); } cs.Nodes.AddRange(Nodes); return(cs); }
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(InstanceDescriptor) && value is CustomShortcut) { MemberInfo mi; object[] arguments; var cs = (CustomShortcut)value; if (cs.Nodes.Count == 0) { var typeConstruct = new[] { typeof(Type), typeof(string) }; mi = typeof(CustomShortcut) .GetConstructor(typeConstruct); arguments = new object[] { cs.OwnerType, cs.Name }; } else { var typeConstruct = new[] { typeof(Type), typeof(string), typeof(CustomShortcut[]) }; mi = typeof(CustomShortcut) .GetConstructor(typeConstruct); var csRange = new CustomShortcut[checked ((uint)cs.Nodes.Count)]; cs.Nodes.CopyTo(csRange, 0); arguments = new object[] { cs.OwnerType, cs.Name, csRange }; } return(new InstanceDescriptor(mi, arguments)); } return(base.ConvertTo(context, culture, value, destinationType)); }
private void Initialize(Type owner, string name) { _parent = null; _owner = owner; _name = name; foreach (var mi in _owner.GetMethods(_bindingFlags)) { var attr = (MethodShortcutAttribute)Attribute .GetCustomAttribute(mi, typeof(MethodShortcutAttribute)); if (attr != null && attr.Shortcut != Shortcut.None) { _shortcuts.Add(attr.Shortcut, mi.Name); } } }
private void LoadShortcuts() { try { _treeView.BeginUpdate(); _treeView.Nodes.Clear(); BuildTree(_treeView.Nodes, _manager.Nodes); } finally { _treeView.EndUpdate(); } _shortcut = null; if (_treeView.Nodes.Count > 0) { _treeView.SelectedNode = _treeView.Nodes[0]; _treeView.ExpandAll(); } }
public override object EditValue( ITypeDescriptorContext context, IServiceProvider provider, object value) { var service = (IWindowsFormsEditorService)provider .GetService(typeof (IWindowsFormsEditorService)); if (service != null) { var host = (IDesignerHost)context .GetService(typeof (IDesignerHost)); var trans = host .CreateTransaction("NodesCollectionEditor"); var dialog = new EditorNodes(); var collection = (ShortcutCollection)value; if (collection.Count == 0) { var root = new CustomShortcut(typeof (Type), "Base"); collection.Add(root); } dialog._collection = collection; if (service.ShowDialog(dialog) == DialogResult.OK) { context.OnComponentChanged(); context.OnComponentChanging(); trans.Commit(); return dialog._collection; } trans.Cancel(); return value; } return value; }
public override object EditValue( ITypeDescriptorContext context, IServiceProvider provider, object value) { var service = (IWindowsFormsEditorService)provider .GetService(typeof(IWindowsFormsEditorService)); if (service != null) { var host = (IDesignerHost)context .GetService(typeof(IDesignerHost)); var trans = host .CreateTransaction("NodesCollectionEditor"); var dialog = new EditorNodes(); var collection = (ShortcutCollection)value; if (collection.Count == 0) { var root = new CustomShortcut(typeof(Type), "Base"); collection.Add(root); } dialog._collection = collection; if (service.ShowDialog(dialog) == DialogResult.OK) { context.OnComponentChanged(); context.OnComponentChanging(); trans.Commit(); return(dialog._collection); } trans.Cancel(); return(value); } return(value); }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { _shortcut = (CustomShortcut)e.Node.Tag; FillListBox(false); }
public object Clone() { var cs = new CustomShortcut(_owner, _name); foreach (var de in HashTable) cs.HashTable.Add(de.Key, de.Value); cs.Nodes.AddRange(Nodes); return cs; }
private void Initialize(Type owner, string name) { _parent = null; _owner = owner; _name = name; foreach (var mi in _owner.GetMethods(_bindingFlags)) { var attr = (MethodShortcutAttribute)Attribute .GetCustomAttribute(mi, typeof (MethodShortcutAttribute)); if (attr != null && attr.Shortcut != Shortcut.None) _shortcuts.Add(attr.Shortcut, mi.Name); } }