Beispiel #1
0
        private static object CoerceCursorHeight(DependencyObject d, object value)
        {
            TiledImageControl tic = (TiledImageControl)d;
            int cursorHeight      = (int)value;

            if (cursorHeight < 0)
            {
                cursorHeight = 0;
            }
            if (cursorHeight > (tic.Source?.PixelHeight ?? 0))
            {
                cursorHeight = tic.Source?.PixelHeight ?? 0;
            }
            return(cursorHeight);
        }
Beispiel #2
0
        private static object CoerceCursorWidth(DependencyObject d, object value)
        {
            TiledImageControl tic = (TiledImageControl)d;
            int cursorWidth       = (int)value;

            if (cursorWidth < 0)
            {
                cursorWidth = 0;
            }
            if (cursorWidth > (tic.Source?.PixelWidth ?? 0))
            {
                cursorWidth = tic.Source?.PixelWidth ?? 0;
            }
            return(cursorWidth);
        }
Beispiel #3
0
        private static object CoerceCursorY(DependencyObject d, object value)
        {
            TiledImageControl tic = (TiledImageControl)d;
            int cursorY           = (int)value;

            if (cursorY < 0)
            {
                cursorY = 0;
            }
            int div = tic.CursorHeight > 0 ? (tic.Source?.PixelHeight ?? 0) / tic.CursorHeight : 0;

            if ((cursorY + 1) * tic.CursorHeight >= (tic.Source?.PixelHeight ?? 0))
            {
                cursorY = div - 1;        // Maximum CursorY can be
            }
            return(cursorY);
        }
Beispiel #4
0
        private static object CoerceCursorX(DependencyObject d, object value)
        {
            TiledImageControl tic = (TiledImageControl)d;
            int cursorX           = (int)value;

            if (cursorX < 0)
            {
                cursorX = 0;
            }
            int div = tic.CursorWidth > 0 ? (tic.Source?.PixelWidth ?? 0) / tic.CursorWidth : 0;

            if ((cursorX + 1) * tic.CursorWidth >= (tic.Source?.PixelWidth ?? 0))
            {
                cursorX = div - 1;        // Maximum CursorX can be
            }
            return(cursorX);
        }