Пример #1
0
 public void InsertRow(int index)
 {
     Resize(Width > 0 ? Width : 1, Height + 1);
     for (int y = Height - 1; y > index; y--)
     {
         Rows[y] = Rows[y - 1];
     }
     if (index >= Height)
     {
         index = Height - 1;
     }
     VariableScalar[] vs = new VariableScalar[Width];
     Rows[index]        = new VariableTableRow();
     Rows[index].Values = new List <Variable>();
     Rows[index].Values.AddRange(vs);
 }
Пример #2
0
        public void Resize(int newWidth, int newHeight)
        {
            if (newWidth == 0 || newHeight == 0)
            {
                Rows.Clear();
                return;
            }
            if (newWidth == -1)
            {
                newWidth = Width;
            }
            if (newHeight == -1)
            {
                newHeight = Height;
            }
            int oldWidth = Width;

            if (Height < newHeight)
            {
                while (Height < newHeight)
                {
                    VariableTableRow vtr = new VariableTableRow();
                    vtr.Values.AddRange(new Variable[newWidth]);
                    Rows.Add(vtr);
                }
            }
            else if (Height > newHeight)
            {
                int num = Height - newHeight;
                Rows.RemoveRange(Height - (1 + num), num);
            }
            if (newWidth != oldWidth)
            {
                for (int i = 0; i < Height; i++)
                {
                    if (Rows[i].Values.Count > newWidth)
                    {
                        int num = Rows[i].Values.Count - newWidth;
                        Rows[i].Values.RemoveRange(Rows[i].Values.Count - (1 + num), num);
                    }
                    else if (Rows[i].Values.Count < newWidth)
                    {
                        Rows[i].Values.AddRange(new Variable[newWidth - Rows[i].Values.Count]);
                    }
                }
            }
        }