Ejemplo n.º 1
0
 /// <summary>
 /// Sets the temporary zone by adjusting
 /// </summary>
 /// <param name="rel_width">From current position to <c>rel_width</c>.</param>
 /// <param name="rel_height">Height of the relative<c>rel_height</c></param>
 /// <param name="startPosition">The start position.</param>
 /// <param name="leftRightPadding">The left right padding.</param>
 /// <param name="topBottomPadding">The top bottom padding.</param>
 public cursorZone setTempFrame(Int32 rel_width, Int32 rel_height, textCursorZoneCorner startPosition = textCursorZoneCorner.none, Int32 leftRightPadding = 0, Int32 topBottomPadding = 0)
 {
     tempFrame    = new cursorZone(x + rel_width, y + rel_height, x, y, leftRightPadding, topBottomPadding);
     useTempFrame = true;
     moveToCorner(startPosition);
     return(tempFrame);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="cursor"/> class.
 /// </summary>
 /// <param name="__target">The target.</param>
 /// <param name="__mode">The mode.</param>
 /// <param name="__zone">The zone.</param>
 public cursor(cursorZone __target, textCursorMode __mode, textCursorZone __zone, String __name = "c")
 {
     name        = __name;
     frame       = __target;
     mode        = __mode;
     currentZone = __zone;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Sets the temporary frame by using subzone preset
 /// </summary>
 /// <param name="sub">The sub.</param>
 /// <param name="startPosition">The start position.</param>
 /// <returns></returns>
 public cursorZone setTempFrame(cursorSubzoneFrame sub, textCursorZoneCorner startPosition = textCursorZoneCorner.none)
 {
     tempFrame    = new cursorZone(this.frame, sub);
     useTempFrame = true;
     moveToCorner(startPosition);
     return(tempFrame);
 }
 public cursorZoneCollection(cursorZone __master = null)
 {
     Add(cursorZoneRole.master, __master);
     if (__master != null)
     {
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Cancels temporal frame if tempFrame was used
 /// </summary>
 /// <param name="startPosition">The start position.</param>
 public void backToMainFrame(textCursorZoneCorner startPosition = textCursorZoneCorner.none, Boolean exceptionIfWasInMain = false)
 {
     if ((!isTempFrameActive) && exceptionIfWasInMain)
     {
         throw new NotSupportedException(nameof(backToMainFrame) + " backToMainZone called but cursor is already in the main frame!");
     }
     tempFrame    = null;
     useTempFrame = false;
     moveToCorner(startPosition);
 }
Ejemplo n.º 6
0
        public cursorZone setToSubFrame(cursorZoneRole role, Int32 index = 0, textCursorZoneCorner __corner = textCursorZoneCorner.default_corner)
        {
            cursorZone subframe = frame.subzones[role, index];

            if (subframe != null)
            {
                tempFrame = subframe;
            }
            return(subframe);
        }
        /// <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>
        /// Adds a zone into collection. Null <c>zone</c> will be ignored.
        /// </summary>
        /// <remarks>
        /// <para>If role is supports multiple items (column, section) on existing zone for the role it will create indexed key.</para>
        /// <para>If its a singular (footer, header, master) role it will replace any existing.</para>
        /// <para>If <c>master</c> zone is set, all zones will have the <c>master</c> zone set as parent.</para>
        /// <para>You may set the <c>master</c> zone with constructor or any time later with Add() call - it will automatically set parent for existing zones</para>
        /// </remarks>
        /// <param name="role">The role for the zone</param>
        /// <param name="zone">The zone to add into collection</param>
        /// <returns>Key that was finally used for the zone. Possibly important in case of roles supporting multiple entries</returns>
        public String Add(cursorZoneRole role, cursorZone zone)
        {
            if (zone == null)
            {
                return("");
            }

            String key = role.ToString();

            Int32 c = 0;

            if (role == cursorZoneRole.section || role == cursorZoneRole.column)
            {
                while (items.ContainsKey(key))
                {
                    c++;
                    key = role.ToString() + c.ToString();
                }
            }
            else if (role == cursorZoneRole.master)
            {
                foreach (KeyValuePair <String, cursorZone> pair in items)
                {
                    if (pair.Key != "master")
                    {
                        pair.Value.parent = zone;
                    }
                }
            }

            if (items.ContainsKey("master"))
            {
                var master = this[cursorZoneRole.master];
                if (master != zone)
                {
                    zone.parent = master;
                }
            }

            if (items.ContainsKey(key))
            {
                items[key] = zone;
            }
            else
            {
                items.Add(key, zone);
            }

            return(key);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Subzone frame by preset <see cref="cursorZone"/>
        /// </summary>
        /// <param name="sourceZone">The source zone.</param>
        /// <param name="sz">Subzone preset</param>
        public cursorZone(cursorZone sourceZone, cursorSubzoneFrame sz) : base(sourceZone.width, sourceZone.margin.leftAndRight, sourceZone.padding.leftAndRight)
        {
            margin.Learn(sourceZone.margin);
            padding.Learn(sourceZone.padding);

            height = sourceZone.height;
            switch (sz)
            {
            case cursorSubzoneFrame.fullFrame:
                width = sourceZone.width;
                break;

            case cursorSubzoneFrame.h1:
                width = sourceZone.width / 2;
                break;

            case cursorSubzoneFrame.h2:
                margin.left = sourceZone.width / 2;
                width       = sourceZone.width - margin.left;
                break;

            case cursorSubzoneFrame.q1:
                width = sourceZone.width / 4;
                break;

            case cursorSubzoneFrame.q2:
                width       = sourceZone.width / 4;
                margin.left = width;
                break;

            case cursorSubzoneFrame.q3:
                width       = sourceZone.width / 4;
                margin.left = width * 2;
                break;

            case cursorSubzoneFrame.q4:
                width       = sourceZone.width / 4;
                margin.left = sourceZone.width - width;
                break;
            }
        }
        /// <summary>
        /// Builds the zone.
        /// </summary>
        /// <param name="layoutPreset">The layout preset.</param>
        /// <param name="spatialPreset">The spatial preset.</param>
        /// <param name="target">The target.</param>
        /// <returns>Resulting zone</returns>
        /// <exception cref="System.ArgumentOutOfRangeException">If Layout presed never implemented</exception>
        public static cursorZone setZoneStructure(this cursorZone target, cursorZoneLayoutPreset layoutPreset, Boolean removeExistingSubzones = true)
        {
            if (target == null)
            {
                target = new cursorZone();
            }

            //target.subzones

            cursorZoneBuilder builder = new cursorZoneBuilder(target);

            target.margin  = new fourSideSetting(0);
            target.padding = new fourSideSetting(1);

            switch (layoutPreset)
            {
            case cursorZoneLayoutPreset.none:
                break;

            case cursorZoneLayoutPreset.oneFullPage:
                break;

            case cursorZoneLayoutPreset.fourColumn:
                builder.buildColumns(4, 1, 1, 1, 1);

                break;

            case cursorZoneLayoutPreset.oneMajorTwoMinorColumn:
                builder.buildColumns(3, 3, 1, 1);

                break;

            case cursorZoneLayoutPreset.oneMinorTwoMajorColumn:
                builder.buildColumns(3, 1, 2, 2);

                break;

            case cursorZoneLayoutPreset.twoColumn:
                builder.buildColumns(2, 1, 1, 1, 1);
                break;

            case cursorZoneLayoutPreset.headFourColumn:
                builder.buildColumns(4, 1, 1, 1, 1);
                break;

            case cursorZoneLayoutPreset.headTwoColumn:
                builder.buildColumns(2, 1, 1, 1, 1);
                break;

            //case cursorZoneLayoutPreset.headFullPage:
            //    break;
            case cursorZoneLayoutPreset.headFourColumnFooter:
                builder.buildColumns(4, 1, 1, 1, 1);
                break;

            case cursorZoneLayoutPreset.headTwoColumnFooter:
                builder.buildColumns(2, 1, 1, 1, 1);
                break;
            //case cursorZoneLayoutPreset.headFullPageFooter:

            //    break;
            default:
                throw new ArgumentOutOfRangeException();
            }

            return(target);
        }
 /// <summary>
 /// Builder to create subzones in speficied target. Target is <see cref="cursorZoneBuilder"/> class
 /// </summary>
 /// <param name="__target">The target.</param>
 public cursorZoneBuilder(cursorZone __target)
 {
     target = __target;
     c      = new cursor(__target, textCursorMode.scroll, textCursorZone.outterZone);
 }