예제 #1
0
        /// <summary>Sets the parent Screen.</summary>
        /// <param name="parent">The parent.</param>
        /// <returns><c>true</c> if the parent was changed successfully; otherwise, <c>false</c>.</returns>
        public bool SetParent(BrailleIOScreen parent)
        {
            bool success = false;

            if (parent != null)
            {
                if (parent.GetViewRange(Name) == null || !parent.GetViewRange(Name).Equals(this))
                {
                    parent.AddViewRange(this.Name, this);
                }
                Parent  = parent;
                success = true;
                firePropertyChangedEvent("Parent");
            }
            return(success);
        }
예제 #2
0
        /// <summary>
        /// Gets the view at a position.
        /// </summary>
        /// <param name="x">The horizontal position on the device.</param>
        /// <param name="y">The vertical position on the device.</param>
        /// <returns>The topmost view range that containing the point or <c>null</c></returns>
        public BrailleIOViewRange GetViewAtPosition(int x, int y)
        {
            if (x >= 0 || y >= 0)
            {
                var views = getVisibleViews();
                if (views != null && views.Count > 0)
                {
                    var keys = views.Keys;
                    if (keys != null && keys.Count > 0)
                    {
                        var k = keys.ToArray();

                        for (int i = keys.Count - 1; i >= 0; i--)
                        {
                            var view = views[k[i]];
                            if (view != null)
                            {
                                if (view is BrailleIOViewRange)
                                {
                                    // TODO: check if point is inside
                                    if (((BrailleIOViewRange)view).ContainsPoint(x, y))
                                    {
                                        return((BrailleIOViewRange)view);
                                    }
                                }
                                else if (view is BrailleIOScreen)
                                {
                                    BrailleIOScreen s = (BrailleIOScreen)view;

                                    // get all visible view ranges of the screen
                                    var vv = s.GetVisibleViewRangeAtPosition(x, y);
                                    if (vv != null)
                                    {
                                        return(vv);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(null);
        }