Ejemplo n.º 1
0
 /// <summary>
 /// Cleans the last Grid.
 /// </summary>
 public void CleanGrid()
 {
     if (_verticalGrids != null)
     {
         foreach (GameObject go in _verticalGrids)
         {
             Destroy(go);
         }
     }
     _horizontalGridPrefab.CalculateLayoutInputHorizontal();
     _heightMode = HeightMode.Empty;
     _widthMode  = WidthMode.Empty;
 }
Ejemplo n.º 2
0
    /// <summary>
    /// Build Grid Creates the node from json and creates a grid of text elements from that, its linked to a button on screen.
    /// </summary>
    public void BuildGrid()
    {
        node = null;
        node = SerializeJson();
        int totalColumns = node[HEADERS_STRING].Count;

        FetchColumns = totalColumns;
        int totalRows = node[DATA_STRING].Count;

        FetchRows = totalRows;
        CleanGrid();
        CreateGrid(totalRows, totalColumns, node[TITLE_STRING]);

        HeightMode = HeightMode.Homogeneous;
        WidthMode  = WidthMode.Homogeneous;
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Resize Width of grid, depends on the mode of resize.
    /// </summary>
    public void ReSizeWidth()
    {
        _fixedWidth  = FixedWidth;
        _fixedHeight = FixedHeight;
        _widthMode   = WidthMode;
        switch (WidthMode)
        {
        case WidthMode.Homogeneous:
            SetHomogeneousColumnWidth(true);
            break;

        case WidthMode.Fix:
            SetFixedValues();
            break;

        case WidthMode.BestFit:
            BestFitColumnWidth();
            break;
        }
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Generates the vertices of a thickened line strip.
    /// </summary>
    /// <param name="points">Points of the line strip</param>
    /// <param name="thickness">Thickness of the line</param>
    /// <param name="close">Whether to connect the last point back to the first</param>
    /// <param name="widthMode">How to place the weight of the line relative to it</param>
    /// <param name="zCoord">Z coordinate of the returned vertices.</param>
    /// <param name="verts">Generated vertices.</param>
    public static void CalculateLinePoints(PointF[] points, float thickness, bool close, WidthMode widthMode, float zCoord,
        out PositionColoredTextured[] verts)
    {
      PointF[] pathPoints = AdjustPoints(points);
      verts = null;
      if (pathPoints.Length < 3)
      {
        if (close) return;
        if (pathPoints.Length < 2)
          return;
      }

      int count = pathPoints.Length;
      if (pathPoints[count - 2] == pathPoints[count - 1])
        count--;
      Vector2[] vPoints = new Vector2[count];
      for (int i = 0; i < count; ++i)
        vPoints[i] = new Vector2(pathPoints[i].X, pathPoints[i].Y);

      Vector2 innerDistance = new Vector2(0, 0);
      switch (widthMode)
      {
        case WidthMode.Centered:
          //innerDistance =thickness / 2;
          innerDistance = new Vector2(thickness / 2, thickness / 2);
          break;
        case WidthMode.LeftHanded:
          //innerDistance = -thickness;
          innerDistance = new Vector2(-thickness, -thickness);
          break;
        case WidthMode.RightHanded:
          //innerDistance = thickness;
          innerDistance = new Vector2(thickness, thickness);
          break;
      }

      Vector2[] outPoints = new Vector2[(vPoints.Length + (close ? 1 : 0)) * 2];

      float slope, intercept;
      //Get the endpoints
      if (close)
      {
        //Get the overlap points
        int lastIndex = outPoints.Length - 4;
        outPoints[lastIndex] = InnerPoint(innerDistance, vPoints[vPoints.Length - 2], vPoints[vPoints.Length - 1], vPoints[0], out slope, out intercept);
        outPoints[0] = InnerPoint(innerDistance, ref slope, ref intercept, outPoints[lastIndex], vPoints[0], vPoints[1]);
      }
      else
      {
        //Take endpoints based on the end segments' normals alone
        outPoints[0] = Vector2.Multiply(innerDistance, GetNormal(vPoints[1] - vPoints[0]));
        outPoints[0] = vPoints[0] + outPoints[0];

        //outPoints[0] = points[0] + innerDistance * normal(points[1] - points[0]);
        Vector2 norm = Vector2.Multiply(innerDistance, GetNormal(vPoints[vPoints.Length - 1] - vPoints[vPoints.Length - 2])); //DEBUG

        outPoints[outPoints.Length - 2] = vPoints[vPoints.Length - 1] + norm;

        //Get the slope and intercept of the first segment to feed into the middle loop
        slope = VectorSlope(vPoints[1] - vPoints[0]);
        intercept = LineIntercept(outPoints[0], slope);
      }

      //Get the middle points
      for (int i = 1; i < vPoints.Length - 1; i++)
        outPoints[2 * i] = InnerPoint(innerDistance, ref slope, ref intercept, outPoints[2 * (i - 1)], vPoints[i], vPoints[i + 1]);

      //Derive the outer points from the inner points
      if (widthMode == WidthMode.Centered)
        for (int i = 0; i < vPoints.Length; i++)
          outPoints[2 * i + 1] = 2 * vPoints[i] - outPoints[2 * i];
      else
        for (int i = 0; i < vPoints.Length; i++)
          outPoints[2 * i + 1] = vPoints[i];

      //Closed strips must repeat the first two points
      if (close)
      {
        outPoints[outPoints.Length - 2] = outPoints[0];
        outPoints[outPoints.Length - 1] = outPoints[1];
      }
      int verticeCount = outPoints.Length;
      verts = new PositionColoredTextured[verticeCount];

      for (int i = 0; i < verticeCount; ++i)
        verts[i].Position = new Vector3(outPoints[i].X, outPoints[i].Y, zCoord);
    }
Ejemplo n.º 5
0
        /// <summary>
        /// Generates the vertices of a thickened line strip.
        /// </summary>
        /// <param name="points">Points of the line strip</param>
        /// <param name="thickness">Thickness of the line</param>
        /// <param name="close">Whether to connect the last point back to the first</param>
        /// <param name="widthMode">How to place the weight of the line relative to it</param>
        /// <param name="zCoord">Z coordinate of the returned vertices.</param>
        /// <param name="verts">Generated vertices.</param>
        public static void CalculateLinePoints(PointF[] points, float thickness, bool close, WidthMode widthMode, float zCoord,
                                               out PositionColoredTextured[] verts)
        {
            PointF[] pathPoints = AdjustPoints(points);
            verts = null;
            if (pathPoints.Length < 3)
            {
                if (close)
                {
                    return;
                }
                if (pathPoints.Length < 2)
                {
                    return;
                }
            }

            int count = pathPoints.Length;

            if (pathPoints[count - 2] == pathPoints[count - 1])
            {
                count--;
            }
            Vector2[] vPoints = new Vector2[count];
            for (int i = 0; i < count; ++i)
            {
                vPoints[i] = new Vector2(pathPoints[i].X, pathPoints[i].Y);
            }

            Vector2 innerDistance = new Vector2(0, 0);

            switch (widthMode)
            {
            case WidthMode.Centered:
                //innerDistance =thickness / 2;
                innerDistance = new Vector2(thickness / 2, thickness / 2);
                break;

            case WidthMode.LeftHanded:
                //innerDistance = -thickness;
                innerDistance = new Vector2(-thickness, -thickness);
                break;

            case WidthMode.RightHanded:
                //innerDistance = thickness;
                innerDistance = new Vector2(thickness, thickness);
                break;
            }

            Vector2[] outPoints = new Vector2[(vPoints.Length + (close ? 1 : 0)) * 2];

            float slope, intercept;

            //Get the endpoints
            if (close)
            {
                //Get the overlap points
                int lastIndex = outPoints.Length - 4;
                outPoints[lastIndex] = InnerPoint(innerDistance, vPoints[vPoints.Length - 2], vPoints[vPoints.Length - 1], vPoints[0], out slope, out intercept);
                outPoints[0]         = InnerPoint(innerDistance, ref slope, ref intercept, outPoints[lastIndex], vPoints[0], vPoints[1]);
            }
            else
            {
                //Take endpoints based on the end segments' normals alone
                outPoints[0] = Vector2.Multiply(innerDistance, GetNormal(vPoints[1] - vPoints[0]));
                outPoints[0] = vPoints[0] + outPoints[0];

                //outPoints[0] = points[0] + innerDistance * normal(points[1] - points[0]);
                Vector2 norm = Vector2.Multiply(innerDistance, GetNormal(vPoints[vPoints.Length - 1] - vPoints[vPoints.Length - 2])); //DEBUG

                outPoints[outPoints.Length - 2] = vPoints[vPoints.Length - 1] + norm;

                //Get the slope and intercept of the first segment to feed into the middle loop
                slope     = VectorSlope(vPoints[1] - vPoints[0]);
                intercept = LineIntercept(outPoints[0], slope);
            }

            //Get the middle points
            for (int i = 1; i < vPoints.Length - 1; i++)
            {
                outPoints[2 * i] = InnerPoint(innerDistance, ref slope, ref intercept, outPoints[2 * (i - 1)], vPoints[i], vPoints[i + 1]);
            }

            //Derive the outer points from the inner points
            if (widthMode == WidthMode.Centered)
            {
                for (int i = 0; i < vPoints.Length; i++)
                {
                    outPoints[2 * i + 1] = 2 * vPoints[i] - outPoints[2 * i];
                }
            }
            else
            {
                for (int i = 0; i < vPoints.Length; i++)
                {
                    outPoints[2 * i + 1] = vPoints[i];
                }
            }

            //Closed strips must repeat the first two points
            if (close)
            {
                outPoints[outPoints.Length - 2] = outPoints[0];
                outPoints[outPoints.Length - 1] = outPoints[1];
            }
            int verticeCount = outPoints.Length;

            verts = new PositionColoredTextured[verticeCount];

            for (int i = 0; i < verticeCount; ++i)
            {
                verts[i].Position = new Vector3(outPoints[i].X, outPoints[i].Y, zCoord);
            }
        }
Ejemplo n.º 6
0
 public void AddColumn(string displayFormat, string displayName, UnitValue?width = null, WidthMode widthMode = WidthMode.Auto, Alignment alignment = Alignment.Left, string hideValue = null)
 {
     _columns.Add(displayFormat, new TableColumn {
         Value = displayFormat, Title = displayName, Width = width, Align = alignment, HideValue = hideValue, WidthMode = widthMode
     });
 }