Beispiel #1
0
                public IEditableUIControl ControlAtPosition(PointF position)
                {
                    IEditableUIControl consumingControl = null;

                    // create a position outside the canvas. As soon as we find an item we're hovering over,
                    // we'll send the rest of the controls this position to force them to discontinue their hover state
                    PointF oobPos = new PointF(-100, -100);

                    // let each child add itself and its children
                    int i;

                    for (i = 0; i < ChildControls.Count; i++)
                    {
                        IEditableUIControl editableControl = ChildControls[i] as IEditableUIControl;
                        if (editableControl != null)
                        {
                            consumingControl = editableControl.HandleMouseHover(position);
                            if (consumingControl != null)
                            {
                                break;
                            }
                        }
                    }

                    // now let the remainig children turn off
                    i++;
                    for ( ; i < ChildControls.Count; i++)
                    {
                        IEditableUIControl editableControl = ChildControls[i] as IEditableUIControl;
                        if (editableControl != null)
                        {
                            editableControl.HandleMouseHover(oobPos);
                        }
                    }

                    // and return the control consuming this hover
                    return(consumingControl);
                }
Beispiel #2
0
                public IEditableUIControl HandleMouseHover(PointF mousePos)
                {
                    IEditableUIControl consumingControl = null;
                    bool hoveringChildControl           = false;

                    // create a position outside the canvas. As soon as we find an item we're hovering over,
                    // we'll send the rest of the controls this position to force them to discontinue their hover state
                    PointF oobPos = new PointF(-100, -100);

                    // see if any of our child controls contain the point
                    int i;

                    for (i = 0; i < ChildControls.Count; i++)
                    {
                        IEditableUIControl editControl = ChildControls[i] as IEditableUIControl;
                        if (editControl != null)
                        {
                            // if we're hovering over any control, flag it, but don't stop checking
                            consumingControl = editControl.HandleMouseHover(mousePos);
                            if (consumingControl != null)
                            {
                                hoveringChildControl = true;
                                break;
                            }
                        }
                    }

                    // now let the remainig children turn off
                    i++;
                    for ( ; i < ChildControls.Count; i++)
                    {
                        IEditableUIControl editableControl = ChildControls[i] as IEditableUIControl;
                        if (editableControl != null)
                        {
                            editableControl.HandleMouseHover(oobPos);
                        }
                    }


                    // JHM 5-8-17 - Only show hover for the children. Don't highlight the paragraph. It's pointless and distracting
                    // if we're over a child
                    if (hoveringChildControl == true)
                    {
                        return(consumingControl);
                    }

                    return(null);

                    // if we're over a child
                    //if( hoveringChildControl == true )
                    //{
                    //    // restore the color
                    //    BorderView.BackgroundColor = OrigBackgroundColor;
                    //}
                    //else
                    //{
                    //    // otherwise, see if we're hovering over the paragraph, and if we are, highlight it
                    //    RectangleF frame = GetFrame( );
                    //    frame.Inflate( CornerExtensionSize, CornerExtensionSize );

                    //    // are we hovering over this control?
                    //    bool mouseHovering = frame.Contains( mousePos );
                    //    if( mouseHovering == true )
                    //    {
                    //        // take us as the consumer
                    //        consumingControl = this;

                    //        // set the hover appearance
                    //        BorderView.BackgroundColor = 0xFFFFFF77;
                    //    }
                    //    // we're NOT hovering
                    //    else
                    //    {
                    //        // so revert the color
                    //        BorderView.BackgroundColor = OrigBackgroundColor;
                    //    }
                    //}

                    //return consumingControl;
                }