Exemple #1
0
        public void SetLineArea(int lineIdx, TableLine setLine)
        {
            List <TableLine> lineList = null;
            float            tbLength;

            if (setLine.lineDir == LineDir.HORIZONTAL)
            {
                lineList = rowLineList;
                tbLength = tbHeight;
            }
            else
            {
                lineList = colLineList;
                tbLength = tbWidth;
            }

            TableLine adjustLine = lineList[lineIdx];

            adjustLine.lineComputeMode          = setLine.lineComputeMode;
            adjustLine.computeParam             = setLine.computeParam;
            adjustLine.enableAutoAdjustRichSize = setLine.enableAutoAdjustRichSize;
            adjustLine.lineDir          = setLine.lineDir;
            adjustLine.minComputedValue = setLine.minComputedValue;
            adjustLine.maxComputedValue = setLine.maxComputedValue;
        }
Exemple #2
0
        public Table(int rowAmount = 0, int colAmount = 0)
        {
            tbPos.X  = 0;
            tbPos.Y  = 0;
            tbHeight = 0;
            tbWidth  = 0;

            this.rowAmount = rowAmount;
            this.colAmount = colAmount;

            matchType = MatchType.MatchParentSize;

            TableLine tableLine;

            for (int i = 0; i < rowAmount; i++)
            {
                tableLine = new TableLine(LineDir.HORIZONTAL);
                tableLine.lineComputeMode  = LineComputeMode.AUTO;
                tableLine.maxComputedValue = -1;
                tableLine.minComputedValue = -1;
                rowLineList.Add(tableLine);
            }

            //
            for (int i = 0; i < colAmount; i++)
            {
                tableLine = new TableLine(LineDir.VERTICAL);
                tableLine.lineComputeMode  = LineComputeMode.AUTO;
                tableLine.maxComputedValue = -1;
                tableLine.minComputedValue = -1;
                colLineList.Add(tableLine);
            }
        }
Exemple #3
0
        public void SetAutoTableLine(int idx, LineDir lineDir)
        {
            TableLine tableLine = new TableLine(lineDir);

            tableLine.lineComputeMode  = LineComputeMode.AUTO;
            tableLine.maxComputedValue = -1;
            tableLine.minComputedValue = -1;
            SetTableLine(idx, tableLine);
        }
Exemple #4
0
        public void SetTableLine(int idx, TableLine tableLine)
        {
            List <TableLine> lineList;
            int amount;

            if (tableLine.lineDir == LineDir.HORIZONTAL)
            {
                lineList = rowLineList;
                amount   = rowAmount;
            }
            else
            {
                lineList = colLineList;
                amount   = colAmount;
            }

            if (idx < lineList.Count)
            {
                TableLine tl = new TableLine(tableLine.lineDir);
                tl.computeParam     = tableLine.computeParam;
                tl.computedDistance = tableLine.computedDistance;
                tl.lineComputeMode  = tableLine.lineComputeMode;
                tl.minComputedValue = tableLine.minComputedValue;
                tl.maxComputedValue = tableLine.maxComputedValue;
                lineList[idx]       = tl;
            }
            else
            {
                int n = idx - lineList.Count;
                for (int i = 0; i < n; i++)
                {
                    TableLine tl = new TableLine(tableLine.lineDir);
                    tl.computeParam     = tableLine.computeParam;
                    tl.computedDistance = tableLine.computedDistance;
                    tl.lineComputeMode  = tableLine.lineComputeMode;
                    tl.minComputedValue = tableLine.minComputedValue;
                    tl.maxComputedValue = tableLine.maxComputedValue;
                    lineList.Add(tl);
                    amount++;
                }

                if (tableLine.lineDir == LineDir.HORIZONTAL)
                {
                    rowAmount = amount;
                }
                else
                {
                    colAmount = amount;
                }
            }
        }
Exemple #5
0
 void ModifyTableSize(LineDir lineDir, TableLine line, ref float usedLength, ref float tbLength)
 {
     if (matchType == MatchType.MatchParentSize ||
         (matchType == MatchType.MatchParentHeight && lineDir == LineDir.HORIZONTAL) ||
         (matchType == MatchType.MatchParentWidth && lineDir == LineDir.VERTICAL))
     {
         return;
     }
     else if (usedLength > tbLength)
     {
         usedLength           -= line.computeParam;
         line.computeParam     = tbLength - usedLength;
         usedLength           += line.computeParam;
         line.computedDistance = line.computeParam;
     }
 }
Exemple #6
0
        void AddNewCol(
            bool enableAutoAdjustRichSize   = false,
            LineComputeMode lineComputeMode = LineComputeMode.AUTO,
            float computeParam     = 0,
            float computedDistance = 0)
        {
            colAmount += 1;

            TableLine tableLine = new TableLine(LineDir.VERTICAL);

            tableLine.enableAutoAdjustRichSize = enableAutoAdjustRichSize;
            tableLine.lineComputeMode          = lineComputeMode;
            tableLine.computeParam             = computeParam;
            tableLine.computedDistance         = computedDistance;
            tableLine.maxComputedValue         = -1;
            tableLine.minComputedValue         = -1;
            colLineList.Add(tableLine);
        }
Exemple #7
0
        void AddNewRow(
            bool enableAutoAdjustRichSize   = false,
            LineComputeMode lineComputeMode = LineComputeMode.AUTO,
            float computeParam     = 0,
            float computedDistance = 0)
        {
            rowAmount += 1;

            TableLine tableLine = new TableLine(LineDir.HORIZONTAL);

            tableLine.enableAutoAdjustRichSize = enableAutoAdjustRichSize;
            tableLine.lineComputeMode          = lineComputeMode;
            tableLine.computeParam             = computeParam;
            tableLine.computedDistance         = computedDistance;
            tableLine.maxComputedValue         = -1;
            tableLine.minComputedValue         = -1;
            rowLineList.Add(tableLine);
        }
Exemple #8
0
        public Table(float x, float y, float tbWidth, float tbHeight, int rowAmount = 0, int colAmount = 0)
        {
            this.tbPos.X  = x;
            this.tbPos.Y  = y;
            this.tbHeight = tbHeight;
            this.tbWidth  = tbWidth;

            this.rowAmount = rowAmount;
            this.colAmount = colAmount;

            //
            TableLine tableLine;
            float     rowComputedDist = tbHeight / rowAmount;
            float     rowPercent      = 1f / rowAmount;

            for (int i = 0; i < rowAmount; i++)
            {
                tableLine = new TableLine(LineDir.HORIZONTAL);
                tableLine.lineComputeMode  = LineComputeMode.PERCENTAGE;
                tableLine.computeParam     = rowPercent;
                tableLine.computedDistance = rowComputedDist;
                tableLine.maxComputedValue = -1;
                tableLine.minComputedValue = -1;
                rowLineList.Add(tableLine);
            }

            //
            float colComputedDist = tbWidth / colAmount;
            float colPercent      = 1f / colAmount;

            for (int i = 0; i < colAmount; i++)
            {
                tableLine = new TableLine(LineDir.VERTICAL);
                tableLine.lineComputeMode  = LineComputeMode.PERCENTAGE;
                tableLine.computeParam     = colPercent;
                tableLine.computedDistance = colComputedDist;
                tableLine.maxComputedValue = -1;
                tableLine.minComputedValue = -1;
                colLineList.Add(tableLine);
            }
        }
        public void CreateTables(int width, int height)
        {
            size.Width  = width;
            size.Height = height;

            int w = height - 10;

            if (width < height)
            {
                w = width - 10;
            }

            int xpos = width / 2 - w / 2;
            int ypos = height / 2 - w / 2;

            RectangleF rect = new RectangleF();

            rect.X      = xpos;
            rect.Y      = ypos;
            rect.Width  = w;
            rect.Height = w;

            int xCount = boardPieceViews.GetLength(0);
            int yCount = boardPieceViews.GetLength(1);

            table = new Table(rect, 3, 3);
            TableLine tableLine = new TableLine(LineDir.HORIZONTAL);

            tableLine.lineComputeMode = LineComputeMode.PERCENTAGE;
            tableLine.computeParam    = 1 / 17f;
            table.SetLineArea(2, tableLine);
            tableLine.computeParam = 1 / 17f;
            table.SetLineArea(0, tableLine);
            tableLine.computeParam = 15 / 17f;
            table.SetLineArea(1, tableLine);

            tableLine = new TableLine(LineDir.VERTICAL);
            tableLine.lineComputeMode = LineComputeMode.PERCENTAGE;
            tableLine.computeParam    = 1 / 17f;
            table.SetLineArea(0, tableLine);
            tableLine.computeParam = 1 / 17f;
            table.SetLineArea(2, tableLine);
            tableLine.computeParam = 15 / 17f;
            table.SetLineArea(1, tableLine);

            boardTable = new Table(xCount, yCount);
            table.AddCellChildTable(1, 1, boardTable);

            leftLanTable = new Table(8, 1);
            table.AddCellChildTable(1, 0, leftLanTable);

            rightLanTable = new Table(8, 1);
            table.AddCellChildTable(1, 2, rightLanTable);

            topLanTable = new Table(1, 8);
            table.AddCellChildTable(0, 1, topLanTable);

            bottomLanTable = new Table(1, 8);
            table.AddCellChildTable(2, 1, bottomLanTable);

            table.ReLayout();
        }