/// <summary> /// Starting point, width and height. Initializes a new instance of the <see cref="selectRangeArea"/> struct. /// </summary> /// <param name="start">The start.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> public selectRangeArea(selectRange start, Int32 width, Int32 height) { TopLeft = new selectRange(start.x, start.y); BottomRight = new selectRange(start.x + width, start.y + height); // size = new selectRange(width, height); }
/// <summary> /// Builds the columns in targeted zone - respecting provided relative withs /// </summary> /// <param name="numberOfColumns">Number of columns to build inside the zone. Use small numbers.</param> /// <param name="relWidth">Relative width ratio for each column. If less is provided than <c>numberOfColumns</c> the rest of columns will have relWidth=1</param> /// <remarks> /// <para>Widths are relative to each other. If you want first column to be double in width than each of the other two use: 2,1,1</para> /// </remarks> public void buildColumns(Int32 numberOfColumns, params Int32[] relWidth) { List <Int32> widthList = relWidth.getFlatList <Int32>(); Int32 widthsMissing = numberOfColumns - widthList.Count(); if (widthsMissing > 0) { for (int i = 0; i < widthsMissing; i++) { widthList.Add(1); } } Int32 widthTotal = widthList.Sum(); if (widthTotal == 0) { throw new ArgumentOutOfRangeException(nameof(relWidth), "Total relative width is 0 -- "); } selectRange zw = c.selectToCorner(textCursorZoneCorner.Right); decimal widthUnit = Convert.ToDecimal(zw.x / widthTotal); c.moveToCorner(textCursorZoneCorner.Left); var zSize = c.selectZone(); Int32 height = zSize.y; cursorZone sub = null; String key = ""; foreach (Int32 cWidth in widthList) { sub = new cursorZone(); sub.padding.Learn(target.padding); sub.margin.left = c.x; sub.margin.top = c.y; sub.margin.right = 0; sub.margin.bottom = 0; c.moveInDirection(textCursorZoneCorner.Right, Convert.ToInt32(Math.Ceiling(cWidth * widthUnit))); sub.width = c.x; sub.height = height; key = target.subzones.Add(cursorZoneRole.column, sub); } if (sub.innerRightPosition < target.innerRightPosition) { sub.width += (target.innerRightPosition - sub.innerRightPosition); } }
/// <summary> /// Selects the current zone RangeArea accorting to marigin, pading and ZoneMode /// </summary> /// <returns>Area struct with coordinates and dimensions</returns> public selectRangeArea selectZoneArea() { Int32 __x = x; Int32 __y = y; selectRange cursorStart = new selectRange(x, y); moveToCorner(textCursorZoneCorner.UpLeft); selectRange zoneTopLeft = new selectRange(x, y); moveToCorner(textCursorZoneCorner.DownRight); x = __x; y = __y; selectRangeArea output = new selectRangeArea(zoneTopLeft.x, zoneTopLeft.y, x, y); return(output); }
/// <summary> /// Vraca rastojanje izmedju trenutne pozicije kursora i datog kraja/coska /// </summary> /// <param name="__corner">The corner.</param> /// <returns></returns> public selectRange selectToCorner(textCursorZoneCorner __corner = textCursorZoneCorner.default_corner) { if (__corner == textCursorZoneCorner.default_corner) { __corner = default_direction; } Int32 __x = x; Int32 __y = y; moveToCorner(__corner); Int32 _dX = x - __x; Int32 _dY = y - __y; selectRange res = new selectRange(_dX, _dY); x = __x; y = __y; return(res); }
/// <summary> /// Absolute coordinate constructor: TopLeft + BottomRight. Initializes a new instance of the <see cref="selectRangeArea"/> struct. /// </summary> /// <param name="x">The x.</param> /// <param name="y">The y.</param> /// <param name="x_end">The x end.</param> /// <param name="y_end">The y end.</param> public selectRangeArea(Int32 x, Int32 y, Int32 x_end, Int32 y_end) { TopLeft = new selectRange(x, y); BottomRight = new selectRange(x_end, y_end); //size = new selectRange(x_end - x, y_end - y); }
/// <summary> /// Initializes a new instance of the <see cref="selectRangeArea"/> class. /// </summary> /// <param name="x_end">Width</param> /// <param name="y_end">Height</param> public selectRangeArea(Int32 x_end, Int32 y_end) { TopLeft = new selectRange(0, 0); BottomRight = new selectRange(x_end, y_end); }
/// <summary> /// Returns coordinates of a corner, within the area. <see cref="textCursorZoneCorner"/> /// </summary> /// <param name="corner">The corner.</param> /// <returns></returns> public selectRange GetCornerPoint(textCursorZoneCorner corner) { selectRange output = new selectRange(x, y); switch (corner) { case textCursorZoneCorner.Bottom: output.y = BottomRight.y; output.x = xCenter; break; case textCursorZoneCorner.center: output.y = yCenter; output.x = xCenter; break; case textCursorZoneCorner.default_corner: break; case textCursorZoneCorner.DownLeft: output.y = BottomRight.y; output.x = x; break; case textCursorZoneCorner.DownRight: output.y = BottomRight.y; output.x = BottomRight.x; break; case textCursorZoneCorner.Left: output.y = yCenter; output.x = x; break; case textCursorZoneCorner.none: break; case textCursorZoneCorner.Right: output.y = yCenter; output.x = BottomRight.x; break; case textCursorZoneCorner.Top: output.y = TopLeft.y; output.x = xCenter; break; case textCursorZoneCorner.UpLeft: output.y = y; output.x = x; break; case textCursorZoneCorner.UpRight: output.y = y; output.x = BottomRight.x; break; default: break; } return(output); }
/// <summary> /// Two-point constructor: Initializes a new instance of the <see cref="selectRangeArea"/> struct. /// </summary> /// <param name="topLeft">The top left.</param> /// <param name="bottomRight">The bottom right.</param> public selectRangeArea(selectRange start, selectRange end) { TopLeft = new selectRange(start.x, start.y); BottomRight = new selectRange(end.x, end.y); }