// determines whether the button has been hit
            public bool IsHit(IInputModeContext context, PointD location)
            {
                // see if the button is visible at all
                IOrientedRectangle orientedRectangle = label.GetLayout();

                if (orientedRectangle.Contains(location, context.HitTestRadius))
                {
                    location = location - orientedRectangle.GetAnchorLocation();

                    double upX = orientedRectangle.UpX;
                    double upY = orientedRectangle.UpY;

                    double tx = location.X * -upY + location.Y * upX;
                    double ty = location.X * upX + location.Y * upY;

                    // consider auto flipping of the label contents
                    if (upY > 0)
                    {
                        return
                            (new RectD(inset, inset, 20, orientedRectangle.Height - 2 * inset).Contains(new PointD(tx, ty),
                                                                                                        context.HitTestRadius));
                    }
                    else
                    {
                        return
                            (new RectD(orientedRectangle.Width - (inset + buttonWidth), inset, buttonWidth,
                                       orientedRectangle.Height - 2 * inset).Contains(new PointD(tx, ty),
                                                                                      context.HitTestRadius));
                    }
                }
                else
                {
                    return(false);
                }
            }
Exemplo n.º 2
0
 /// <inheritdoc/>
 protected override bool IsHit(IInputModeContext context, PointD location, ILabel label)
 {
     Configure(label);
     return(label.GetLayout().Contains(location, context.HitTestRadius) ||
            textBounds.Contains(location, context.HitTestRadius) ||
            dummyEdge.Style.Renderer.GetHitTestable(dummyEdge, dummyEdge.Style).IsHit(context, location));
 }