Esempio n. 1
0
        public Form1()
        {
            InitializeComponent();

            Tree.MouseDown  += new MouseEventHandler(this.RightClick);
            chkP1.MouseDown += new MouseEventHandler(this.RightClick);
            chkP2.MouseDown += new MouseEventHandler(this.RightClick);
            chkP3.MouseDown += new MouseEventHandler(this.RightClick);
            picA.MouseDown  += new MouseEventHandler(this.RightClick);
            picB.MouseDown  += new MouseEventHandler(this.RightClick);
            picC.MouseDown  += new MouseEventHandler(this.RightClick);

            SomePart part;

            //Put the first part in the tree and the checkbox and the image
            part = new SomePart();
            TreeNode Node = new TreeNode();

            Node.Text = part.ID;
            Node.Tag  = part;
            Tree.Nodes.Add(Node);
            chkP1.Text = part.ID;
            chkP1.Tag  = part;
            picA.Image = part.img;
            picA.Tag   = part;

            part      = new SomePart();
            Node      = new TreeNode();
            Node.Text = part.ID;
            Node.Tag  = part;
            Tree.Nodes.Add(Node);
            chkP2.Text = part.ID;
            chkP2.Tag  = part;
            picB.Image = part.img;
            picB.Tag   = part;

            part      = new SomePart();
            Node      = new TreeNode();
            Node.Text = part.ID;
            Node.Tag  = part;
            Tree.Nodes.Add(Node);
            chkP3.Text = part.ID;
            chkP3.Tag  = part;
            picC.Image = part.img;
            picC.Tag   = part;
        }
Esempio n. 2
0
        private void RightClick(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            if (sender is TreeView)
            {
                Engine = (SomePart)Tree.SelectedNode.Tag;
            }
            else if (sender is PictureBox)
            {
                PictureBox p = (PictureBox)sender;
                Engine = (SomePart)p.Tag;
            }
            else if (sender is CheckBox)
            {
                CheckBox c = (CheckBox)sender;
                Engine = (SomePart)c.Tag;
            }

            Engine.ShowMenu((Control)sender, new Point(e.X, e.Y));
        }