protected override void OnLoad(EventArgs e) { foreach (var network in IrcSettingsManager.Instance.Networks) { var net = new NetworkSettingsTreeNode(network, networkContextMenuStrip); foreach (var server in network.Servers) { var serverSettings = new ServerSettingsTreeNode(server, serverContextMenuStrip); net.AddServerNode(serverSettings); } ircSettingsTree.Nodes.Add(net); } HideBothPanes(); base.OnLoad(e); }
private void addServerToolStripMenuItem_Click(object sender, EventArgs e) { ContextMenuStrip cms = (ContextMenuStrip)((ToolStripMenuItem)sender).Owner; TreeView treeView = (TreeView)cms.SourceControl; TreeNode selectedNode = treeView.GetNodeAt(treeView.PointToClient(cms.Location)); if (selectedNode.GetType() != typeof(NetworkSettingsTreeNode)) //Not sure if this would actually ever happen { throw new InvalidOperationException(); } NetworkSettingsTreeNode netnode = (NetworkSettingsTreeNode)selectedNode; ServerSettings server = netnode.Settings.AddServer(); server.Description = "New Server"; var node = new ServerSettingsTreeNode(server, serverContextMenuStrip); netnode.AddServerNode(node); node.BeginEdit(); }