public static int GetLastVisibleSelectedAddress(IViewPort viewPort)
        {
            for (int y = viewPort.Height - 1; y >= 0; y--)
            {
                for (int x = viewPort.Width - 1; x >= 0; x--)
                {
                    if (!viewPort.IsSelected(new Point(x, y)))
                    {
                        continue;
                    }
                    return(viewPort.DataOffset + y * viewPort.Width + x);
                }
            }

            return(-1);
        }
        public static int GetFirstVisibleSelectedAddress(IViewPort viewPort)
        {
            for (int y = 0; y < viewPort.Height; y++)
            {
                for (int x = 0; x < viewPort.Width; x++)
                {
                    if (!viewPort.IsSelected(new Point(x, y)))
                    {
                        continue;
                    }
                    return(viewPort.DataOffset + y * viewPort.Width + x);
                }
            }

            return(-1);
        }