Esempio n. 1
0
        public static void AddObjectMouseDown <TGoo>(GH_Viewport vp, IAddObjectParam <TGoo> paramcontrol, object sender, MouseEventArgs e, bool isInputSide, float leftMove = 100, string init = null)
            where TGoo : class, IGH_Goo
        {
            if (paramcontrol.IconButtonBound.Contains(vp.UnprojectPoint(e.Location)))
            {
                if (paramcontrol.MyProxies.Length == 1)
                {
                    CreateNewObject(paramcontrol, isInputSide, 0, leftMove, init);
                }
                else if (paramcontrol.MyProxies.Length > 1)
                {
                    ContextMenuStrip menu = new ContextMenuStrip()
                    {
                        ShowImageMargin = true
                    };
                    for (int i = 0; i < paramcontrol.MyProxies.Length; i++)
                    {
                        void Item_Click(object sender1, EventArgs e1, int index)
                        {
                            CreateNewObject(paramcontrol, isInputSide, index, leftMove, init);
                        }

                        WinFormPlus.AddClickItem(menu, paramcontrol.MyProxies[i].Name + $" [{paramcontrol.MyProxies[i].Index}]", null,
                                                 paramcontrol.MyProxies[i].Icon.GetIcon(true, true), i, Item_Click, false);
                    }
                    menu.Show(Grasshopper.Instances.ActiveCanvas, e.Location);
                }
            }
        }
Esempio n. 2
0
        public static void ParamMouseDown <TGoo>(IAddObjectParam <TGoo> paramcontrol, Action <GH_Canvas, GH_CanvasMouseEvent> mouseEvent, object sender, MouseEventArgs e, bool isInputSide, float leftMove = 100, string init = null)
            where TGoo : class, IGH_Goo
        {
            GH_Viewport vp = Grasshopper.Instances.ActiveCanvas.Viewport;

            if (vp.Zoom >= 0.5f)
            {
                PointF mouseLoc = vp.UnprojectPoint(e.Location);
                if (paramcontrol.Bounds.Contains(mouseLoc))
                {
                    mouseEvent.Invoke(Grasshopper.Instances.ActiveCanvas, new GH_CanvasMouseEvent(vp, e));
                }
                else
                {
                    ParamControlHelper.AddObjectMouseDown(vp, paramcontrol, sender, e, isInputSide, leftMove, init);
                }
            }
        }