Пример #1
0
        void treeMouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                // Select the clicked node
                tree.SelectedNode = tree.GetNodeAt(e.X, e.Y);

                ContextMenuStrip menu = treemenu;
                if (tree.SelectedNode != null)
                {
                    // Menu selection if elses.. for each node type there is a if else branch
                    // TODO! shoot myself for creating such structure..
                    if (tree.SelectedNode.Tag != null)
                    {
                        if (tree.SelectedNode.Tag is ContainerController)
                        {
                            menu = containerMenu;
                        }
                        else if (tree.SelectedNode.Tag is LayerController)
                        {
                            LayerController lc = (LayerController)tree.SelectedNode.Tag;
                            if (!lc.alreadyInUse())
                            {
                                menu = layerMenu;
                            }
                            else
                            {
                                menu = basicMenu;
                            }
                        }
                        else if (tree.SelectedNode.Tag is FieldController)
                        {
                            menu = basicMenu;
                        }
                        else if (tree.SelectedNode.Tag is PolygonController)
                        {
                            menu = basicMenu;
                        }
                        else if (tree.SelectedNode.Tag is TextController)
                        {
                            menu = basicMenu;
                        }
                    }
                }
                menu.Show(tree, e.Location);
            }
        }