예제 #1
0
        public static IRowCol Add(this IRowCol Value1, IRowCol Value2)
        {
            int rowNum = Value1.RowNum + Value2.RowNum;
            int colNum = Value1.ColNum + Value2.ColNum;

            return(Value1.NewRowCol(rowNum, colNum));
        }
예제 #2
0
        public static IRowCol Negate(this IRowCol RowCol)
        {
            var rowNum = RowCol.RowNum * -1;
            var colNum = RowCol.ColNum * -1;

            return(RowCol.NewRowCol(rowNum, colNum));
        }
예제 #3
0
        public static IRowCol AdvanceUp(this IRowCol RowCol)
        {
            int colNum = RowCol.ColNum;
            int rowNum = RowCol.RowNum - 1;

            rowNum = RowCol.WrapVertical(rowNum);
            return(RowCol.NewRowCol(rowNum, colNum));
        }
예제 #4
0
        public static IRowCol ToContentRelative(
            this IRowCol RowCol, ScreenContent ScreenContent)
        {
            if (RowCol.RowColRelative == ScreenContent.ContentRelative)
            {
                return(RowCol);
            }

            // convert RowCol to location relative to a window.
            else if (RowCol.RowColRelative == RowColRelative.Parent)
            {
                var rowNum = RowCol.RowNum - ScreenContent.StartRowCol.RowNum;
                var colNum = RowCol.ColNum - ScreenContent.StartRowCol.ColNum;
                return(RowCol.NewRowCol(rowNum, colNum, ScreenContent));
            }

            // convert RowCol from local to window to absolute screen loc.
            else
            {
                var rowNum = RowCol.RowNum + RowCol.ContentStart.Y;
                var colNum = RowCol.ColNum + RowCol.ContentStart.X;
                return(RowCol.NewRowCol(rowNum, colNum, ScreenContent));
            }
        }
예제 #5
0
        /// <summary>
        /// convert RowCol from whatever it is relative to to a value that is
        /// relative to the entire telnet screen.
        /// </summary>
        /// <param name="RowCol"></param>
        /// <param name="WindowContent"></param>
        /// <returns></returns>
        public static IRowCol ToParentRelative(
            this IRowCol RowCol, ScreenContent WindowContent)
        {
            if (RowCol.RowColRelative == RowColRelative.Parent)
            {
                return(RowCol);
            }

            // convert RowCol from local to window to absolute screen loc.
            else
            {
                var  rowNum = RowCol.RowNum + RowCol.ContentStart.Y;
                var  colNum = RowCol.ColNum + RowCol.ContentStart.X;
                bool forceParentRelative = true;
                return(RowCol.NewRowCol(rowNum, colNum, null, forceParentRelative));
            }
        }