Example #1
0
        ///
        /// ------------------------------------------------------------------------------------------------
        /// Name		GetXY
        ///
        /// <summary>
        /// Get the X & Y coordinate of the view.
        /// </summary>
        ///
        ///  <param name="view"> The view to get coordinates.</param>
        ///
        /// <remarks>
        /// </remarks>
        /// ------------------------------------------------------------------------------------------------
        ///
        public Point GetXY(View view)
        {
            _trianglePosition = TrianglePoistion.Above;

            var x = view.X;

            if (view.GetType() == typeof(BoxView))
            {
                x = CustomViewX;
            }
            var parentX = view.ParentView;

            try
            {
                while (parentX != null)
                {
                    x      += parentX.X;
                    parentX = parentX.ParentView;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            if (x <= 0)
            {
                x = 1;
            }
            if (x + _width >= _contentArea.Width)
            {
                x = _contentArea.Width - (_width + 1);
                if (x < 0)
                {
                    x      = 1;
                    _width = _contentArea.Width - 2;
                }
            }

            var y = view.Y;

            if (view.GetType() == typeof(BoxView))
            {
                y = CustomViewY;
            }
            var parentY = view.ParentView;

            try
            {
                while (parentY != null)
                {
                    if (parentY.GetType().Name == "ScrollView")
                    {
                        if ((parentY as ScrollView).ScrollY > 0)
                        {
                            var _yScroll = (parentY as ScrollView);
                            _scrollOffset = _yScroll.ScrollY;

                            y -= _scrollOffset;
                        }
                    }
                    else
                    {
                        y += parentY.Y;
                    }
                    parentY = parentY.ParentView;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            y += _scrollVset;
            if (y <= 0)
            {
                y = 1;
            }
            var y1 = y + _relativeTo.Height / 2;
            var y2 = _contentArea.Height - (y + _relativeTo.Height / 2);

            if (y1 > y2)
            {
                if (_height > y1)
                {
                    _height = y1 -= (_relativeTo.Height / 2) + 1;
                }
                _trianglePosition = TrianglePoistion.Below;

                y -= _height;
                if (y < 1)
                {
                    y = 1;
                }
            }
            else
            {
                if (_height > y2)
                {
                    _height = (y2 -= _relativeTo.Height / 2);
                }
                _trianglePosition = TrianglePoistion.Above;
                y += _relativeTo.Height;
                if (y + _height >= _contentArea.Height)
                {
                    var dif = Math.Abs(y + _height - _contentArea.Height);
                    _height -= dif;
                    if (Math.Abs(dif) < .001)
                    {
                        _height -= 1;
                    }
                }
            }
            return(new Point(x, y));
        }
Example #2
0
        public Point GetXY(View view)
        {
            _trianglePosition = TrianglePoistion.Above;
            
            var x = view.X;

            var parentX = view.ParentView;

            try
            {
                while (parentX != null)
                {
                    x += parentX.X;
                    parentX = parentX.ParentView;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            if (x <= 0)
            {
                x = 1;
            }
            if (x + _width >= _contentArea.Width)
            {
                x = _contentArea.Width - (_width + 1);
                if (x < 0)
                {
                    x = 1;
                    _width = _contentArea.Width - 2;
                }
                
            }
             
            var y = view.Y;
           
            var parentY = view.ParentView;
           
            try
            {
                while (parentY != null)
                {

                    if (parentY.GetType().Name == "ScrollView")
                    {
                        if ((parentY as ScrollView).ScrollY > 0)
                        {
                            var _yScroll = (parentY as ScrollView);
                            _scrollOffset = _yScroll.ScrollY;
                           
                            y -= _scrollOffset;
                        }
                    }
                    else
                    {
                        y += parentY.Y;
                       
                    }
                    parentY = parentY.ParentView;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            y += _scrollVset;
            if (y <= 0)
            {
                y = 1;
            }
            var y1 = y + _relativeTo.Height / 2;
            var y2 = _contentArea.Height - (y + _relativeTo.Height / 2);
            if (y1 > y2)
            {
                if (_height > y1)
                {
                    _height = y1 -= (_relativeTo.Height / 2) + 1;
                }
                _trianglePosition = TrianglePoistion.Below;
              
                y -= _height; 
                if (y < 1)
                    y = 1;
            }
            else
            {
                if (_height > y2)
                {
                    _height = (y2 -= _relativeTo.Height / 2);
                    
                }
                _trianglePosition = TrianglePoistion.Above;
                y += _relativeTo.Height;
                if (y + _height >= _contentArea.Height)
                {
                    var dif = Math.Abs(y + _height - _contentArea.Height);
                    _height -= dif;
                    if (Math.Abs(dif) < .001)
                    {
                        _height -= 1;
                    }
                   
                }
                
             
            }
            return new Point(x, y);
        }