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 AddObjectMouseDown <TGoo>(IAddObjectParam <TGoo> paramcontrol, 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)
            {
                AddObjectMouseDown(vp, paramcontrol, sender, e, isInputSide, leftMove, init);
            }
        }
Esempio n. 3
0
        public static AddProxyParams[] GetAddProxyOutputParams <TGoo>(IAddObjectParam <TGoo> paramControl) where TGoo : class, IGH_Goo
        {
            string keyname = paramControl.Target.Type.FullName;

            if (paramControl.Owner.CreateProxyDictOutput.ContainsKey(keyname))
            {
                return(paramControl.Owner.CreateProxyDictOutput[keyname]);
            }
            else
            {
                return(new AddProxyParams[0]);
            }
        }
Esempio n. 4
0
 public static void IconRender <TGoo>(IAddObjectParam <TGoo> paramcontrol, GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel) where TGoo : class, IGH_Goo
 {
     if (channel == GH_CanvasChannel.Objects)
     {
         if (paramcontrol.MyProxies.Length > 1)
         {
             ParamControlHelper.RenderParamButtonIcon(graphics, paramcontrol.Target.Icon_24x24, paramcontrol.IconButtonBound);
         }
         else if (paramcontrol.MyProxies.Length == 1)
         {
             ParamControlHelper.RenderParamButtonIcon(graphics, paramcontrol.MyProxies[0].Icon.GetIcon(!paramcontrol.Target.Locked, true), paramcontrol.IconButtonBound);
         }
     }
 }
Esempio n. 5
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);
                }
            }
        }
Esempio n. 6
0
 public static void CreateNewObject <TGoo>(IAddObjectParam <TGoo> paramcontrol, bool isInputSide, int index = 0, float leftMove = 100, string init = null) where TGoo : class, IGH_Goo
 {
     CreateNewObject(paramcontrol.MyProxies, paramcontrol.Target, isInputSide, index, leftMove, init);
 }