Пример #1
0
        protected void GetModifyPointers(int nHandle, ref int ppx, ref int ppy, ref int px, ref int py, bool bModify)
        {
            Debug.Assert(nHandle >= 0);
            Debug.Assert(nHandle <= 8);

            if (nHandle == (int)TrackerHit.hitMiddle)
            {
                nHandle = (int)TrackerHit.hitTopLeft;                   // same as hitting top-left
            }
            ppx = -1;
            ppy = -1;

            // fill in the part of the rect that this handle modifies
            //  (Note: handles that map to themselves along a given axis when that
            //   axis is inverted don't modify the value on that axis)

            HANDLEINFO handleInfo = HandleInfo[nHandle];

            if (handleInfo.nInvertX != nHandle)
            {
                ppx = (int)handleInfo.nOffsetX;
                if (bModify)
                {
                    px = GetRectInt(ppx);
                }
            }
            else
            {
                // middle handle on X axis
                if (bModify)
                {
                    px = m_rect.Left + Math.Abs(m_rect.Width) / 2;
                }
            }
            if (handleInfo.nInvertY != nHandle)
            {
                ppy = (int)handleInfo.nOffsetY;
                if (bModify)
                {
                    py = GetRectInt(ppy);
                }
            }
            else
            {
                // middle handle on Y axis
                if (bModify)
                {
                    py = m_rect.Top + Math.Abs(m_rect.Height) / 2;
                }
            }
        }
Пример #2
0
        protected void GetHandleRect(int nHandle, ref Rectangle Changerect)
        {
            System.Diagnostics.Debug.Assert(nHandle < 8);

            // get normalized rectangle of the tracker
            Rectangle rectT = m_rect;

            NormalizeRect(ref rectT);

            if ((m_nStyle & (StyleFlags.solidLine | StyleFlags.dottedLine)) != 0)
            {
                rectT.Inflate(+1, +1);
            }

            // since the rectangle itself was normalized, we also have to invert the
            //  resize handles.
            nHandle = NormalizeHit(nHandle);

            // handle case of resize handles outside the tracker
            int size = GetHandleSize(new Rectangle());

            if ((m_nStyle & StyleFlags.resizeOutside) != 0)
            {
                rectT.Inflate(size, size);
            }

            // calculate position of the resize handle
            int        nWidth     = rectT.Width;
            int        nHeight    = rectT.Height;
            Rectangle  rect       = new Rectangle();
            HANDLEINFO handleInfo = HandleInfo[nHandle];

            int[] arr = new int[4] {
                rectT.Left, rectT.Right, rectT.Top, rectT.Bottom
            };

            rect.X      = arr[(int)handleInfo.nOffsetX];
            rect.Y      = arr[(int)handleInfo.nOffsetY];
            rect.X     += size * handleInfo.nHandleX;
            rect.Y     += size * handleInfo.nHandleY;
            rect.X     += handleInfo.nCenterX * (nWidth - size) / 2;
            rect.Y     += handleInfo.nCenterY * (nHeight - size) / 2;
            rect.Width  = size;
            rect.Height = size;

            Changerect = rect;
        }
Пример #3
0
        protected int NormalizeHit(int nHandle)
        {
            Debug.Assert(nHandle <= 8 && nHandle >= -1);
            if (nHandle == (int)TrackerHit.hitMiddle || nHandle == (int)TrackerHit.hitNothing)
            {
                return(nHandle);
            }

            HANDLEINFO handleInfo = HandleInfo[nHandle];

            if (m_rect.Width < 0)
            {
                nHandle    = handleInfo.nInvertX;
                handleInfo = HandleInfo[nHandle];
            }
            if (m_rect.Height < 0)
            {
                nHandle = handleInfo.nInvertY;
            }
            return(nHandle);
        }