public override GH_ObjectResponse RespondToMouseUp(GH_Canvas sender, GH_CanvasMouseEvent e)
        {
            GHCustomComponent  owner  = Owner as GHCustomComponent;
            GHMouseEventResult result = GHMouseEventResult.None;
            var backup = sender.Cursor;

            if (Bounds.Contains(e.CanvasLocation))
            {
                foreach (GHControl item in owner.CustomControls.Values)
                {
                    if (!item.Enabled)
                    {
                        continue;
                    }
                    if (item.Bounds.Contains(e.CanvasLocation))
                    {
                        item.MouseKeyUp(sender, owner, e, ref result);
                        if (item is GHParameter && !((GHParameter)item).UpdateSolution)
                        {
                            result &= ~GHMouseEventResult.UpdateSolution;
                        }
                        if (result.HasFlag(GHMouseEventResult.Handled))
                        {
                            break;
                        }
                    }
                }

                if (result.HasFlag(GHMouseEventResult.Invalidated))
                {
                    sender.Invalidate();
                }

                if (result.HasFlag(GHMouseEventResult.UpdateSolution))
                {
                    owner.ExpireSolution(true);
                }


                if (result.HasFlag(GHMouseEventResult.Handled))
                {
                    return(GH_ObjectResponse.Handled);
                }
            }
            return(base.RespondToMouseUp(sender, e));
        }
        public override GH_ObjectResponse RespondToMouseDown(GH_Canvas sender, GH_CanvasMouseEvent e)
        {
            GHCustomComponent owner = Owner as GHCustomComponent;

            if (Bounds.Contains(e.CanvasLocation))
            {
                // click is inside the component
                // check which control is clicked
                GHMouseEventResult result = GHMouseEventResult.None;
                foreach (GHControl control in owner.CustomControls.Values)
                {
                    if (control.Bounds.Contains(e.CanvasLocation))
                    {
                        // click happened in this control
                        if (e.Button == System.Windows.Forms.MouseButtons.Left)
                        {
                            control.MouseLeftClick(sender, owner, e, ref result);
                        }
                        else if (e.Button == System.Windows.Forms.MouseButtons.Right)
                        {
                            control.MouseRightClick(sender, owner, e, ref result);
                        }
                        if (control is GHParameter && !((GHParameter)control).UpdateSolution)
                        {
                            result &= ~GHMouseEventResult.UpdateSolution;
                        }
                    }
                }
                if (result.HasFlag(GHMouseEventResult.Invalidated))
                {
                    sender.Invalidate();
                }
                if (result.HasFlag(GHMouseEventResult.UpdateSolution))
                {
                    owner.ExpireSolution(true);
                }
                if (result.HasFlag(GHMouseEventResult.Handled))
                {
                    return(GH_ObjectResponse.Handled);
                }
            }

            return(base.RespondToMouseDown(sender, e));
        }
Exemple #3
0
 internal override void MouseRightClick(GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result)
 {
 }
Exemple #4
0
 internal virtual void MouseLeave(GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result)
 {
     if (isMouseIn)
     {
         isMouseIn = false;
         result    = result | GHMouseEventResult.Invalidated | GHMouseEventResult.Handled;
         return;
     }
     if (this is IGHPanel)
     {
         ((IGHPanel)this).MouseOverChildren(sender, customComponent, e, ref result);
         if (result.HasFlag(GHMouseEventResult.Invalidated | GHMouseEventResult.Handled))
         {
             return;
         }
     }
 }
Exemple #5
0
        internal virtual void MouseOver(GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result)
        {
            if (this is IGHPanel)
            {
                ((IGHPanel)this).MouseOverChildren(sender, customComponent, e, ref result);
                if (result.HasFlag(GHMouseEventResult.Invalidated | GHMouseEventResult.Handled))
                {
                    return;
                }
            }

            if (ActiveZone.Contains(e.CanvasLocation))
            {
                if (!isMouseIn)
                {
                    isMouseIn = true;
                    result    = result | GHMouseEventResult.Invalidated | GHMouseEventResult.Handled;
                    return;
                }
            }
            else
            {
                if (isMouseIn)
                {
                    isMouseIn = false;
                    result    = result | GHMouseEventResult.Invalidated | GHMouseEventResult.Handled;
                }
            }
        }
Exemple #6
0
 internal virtual void MouseKeyUp(GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result)
 {
     if (this is IGHPanel)
     {
         IGHPanel panel = (IGHPanel)this;
         foreach (GHControl control in panel.Items)
         {
             if (control.Bounds.Contains(e.CanvasLocation))
             {
                 control.MouseKeyUp(sender, customComponent, e, ref result);
                 if (result.HasFlag(GHMouseEventResult.Handled))
                 {
                     return;
                 }
             }
         }
     }
 }
Exemple #7
0
 internal abstract void MouseRightClick(GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result);
        //internal override void MouseOver(GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result)
        //{

        //    //if (Highlighted==0)
        //    //    return;
        //    //result = result | GHMouseEventResult.Invalidated ;
        //    //Highlighted = 0;



        //}

        //internal override void MouseLeave(GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result)
        //{

        //    //if (Highlighted!=0)
        //    //    return;
        //    //Highlighted = -1;
        //    result = result | GHMouseEventResult.Invalidated;


        //}

        internal override void MouseLeftClick(GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result)
        {
            //if (Bounds.Contains(e.CanvasLocation))
            //{
            //    // clicked on this toggle
            //    if (IsSelected)
            //        return; // already selected nothing happens
            //    IsSelected = true;
            //    result = result | GHMouseEventResult.Handled | GHMouseEventResult.UpdateSolution;
            //}
            //else {
            //    // outside of this toggle
            //    if (!IsSelected)
            //        return; // nothing happens
            //    IsSelected = false;
            //    result = result | GHMouseEventResult.Invalidated;

            //}
        }
 /// <summary>
 /// finds the children in which the cursor is inside and then call the MouseOver method for that child
 /// </summary>
 /// <param name="gHContainer"></param>
 /// <param name="customComponent"></param>
 /// <param name="e"></param>
 /// <param name="result"></param>
 public static void MouseOverChildren(this IGHPanel gHContainer, GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result)
 {
     foreach (GHControl control in gHContainer.Items)
     {
         if (control.Bounds.Contains(e.CanvasLocation) && control.Enabled)
         {
             control.MouseOver(sender, customComponent, e, ref result);
             if (result.HasFlag(GHMouseEventResult.Invalidated)) // no need to continue as this child already set the flag
             {
                 return;
             }
         }
         else
         {
             control.MouseLeave(sender, customComponent, e, ref result);
             //if (result.HasFlag(GHMouseEventResult.Invalidated)) // no need to continue as this child already set the flag
             //    return;
         }
     }
 }
 /// <summary>
 /// finds the children in which the cursor is inside and then call the MouseClick method for that child
 /// </summary>
 /// <param name="gHContainer"></param>
 /// <param name="customComponent"></param>
 /// <param name="e"></param>
 /// <param name="result"></param>
 public static void MouseClickChildren(this IGHPanel gHContainer, GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result)
 {
     foreach (GHControl control in gHContainer.Items)
     {
         if (control.Enabled && control.Bounds.Contains(e.CanvasLocation))
         {
             if (e.Button == System.Windows.Forms.MouseButtons.Left)
             {
                 control.MouseLeftClick(sender, customComponent, e, ref result);
             }
             else
             {
                 control.MouseRightClick(sender, customComponent, e, ref result);
             }
             if (control is GHParameter && !((GHParameter)control).UpdateSolution)
             {
                 result &= ~GHMouseEventResult.UpdateSolution;
             }
             if (result.HasFlag(GHMouseEventResult.Handled))
             {
                 return;
             }
         }
     }
 }
Exemple #11
0
        //internal override void SetupToolTip(PointF canvasPoint, GH_TooltipDisplayEventArgs e)
        //{
        //    e.Title = Name;
        //    //e.Description = Description;
        //    e.Text = Description;
        //}

        public abstract void OnMouseClick(GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result);
Exemple #12
0
 internal override void MouseLeftClick(GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result)
 {
     OnMouseClick(sender, customComponent, e, ref result);
 }
        internal override void MouseRightClick(GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result)
        {
            base.MouseRightClick(sender, customComponent, e, ref result);
            if (result.HasFlag(GHMouseEventResult.Handled))
            {
                return;
            }
            decimal d = Convert.ToDecimal(CurrentValue);
            NumericUpDownData <decimal> numeric = new NumericUpDownData <decimal>(d, Convert.ToDecimal(_min), Convert.ToDecimal(_max), FormatString);

            if (numeric.GetInput(PointToScreen(sender, Pos), out decimal val))
            {
                CurrentValue = (float)val;
                result       = result | GHMouseEventResult.UpdateSolution | GHMouseEventResult.Handled;
            }
            else
            {
                result = result | GHMouseEventResult.Handled;
            }
            showLabel = true;
        }
        internal override void MouseRightClick(GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result)
        {
            base.MouseRightClick(sender, customComponent, e, ref result);
            if (result.HasFlag(GHMouseEventResult.Handled))
            {
                return;
            }
            double d = (double)CurrentValue;
            NumericUpDownData <double> numeric = new NumericUpDownData <double>(d, _min, _max, FormatString);

            //float s = GH_FontServer.MeasureString("A", SmallFont).Height * sender.Viewport.Zoom / 20;
            if (numeric.GetInput(PointToScreen(sender, Pos), out double val))
            {
                CurrentValue = val;
                result       = result | GHMouseEventResult.UpdateSolution | GHMouseEventResult.Handled;
            }
            else
            {
                result = result | GHMouseEventResult.Handled;
            }
            showLabel = true;
        }
Exemple #15
0
 internal override void MouseLeftClick(GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result)
 {
     if (_toggleRec.Contains(e.CanvasLocation))
     {
         // click inside the button
         CurrentValue = !(bool)CurrentValue;
         result       = result | GHMouseEventResult.Handled | GHMouseEventResult.Invalidated | GHMouseEventResult.UpdateSolution;
     }
 }
        internal override void MouseRightClick(GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result)
        {
            base.MouseRightClick(sender, customComponent, e, ref result);
            if (result.HasFlag(GHMouseEventResult.Handled))
            {
                return;
            }
            int d = (int)CurrentValue;
            NumericUpDownData <int> numeric = new NumericUpDownData <int>(d, (int)_min, (int)_max, FormatString);

            if (numeric.GetInput(PointToScreen(sender, Pos), out int val))
            {
                CurrentValue = val;
                result       = result | GHMouseEventResult.UpdateSolution | GHMouseEventResult.Handled;
            }
            else
            {
                result = result | GHMouseEventResult.Handled;
            }
            showLabel = true;
        }