예제 #1
0
 /// <summary>
 /// Set rows by column datas.
 /// </summary>
 internal protected virtual void SetRowsByDatas()
 {
     Rows.collection.Clear();
     if (Columns.Count == 0)
     {
         return;
     }
     MochaData[] datas = new MochaData[Columns.Count];
     for (int dataIndex = 0; dataIndex < Columns[0].Datas.Count; ++dataIndex)
     {
         for (int columnIndex = 0; columnIndex < Columns.Count; ++columnIndex)
         {
             MochaColumn currentColumn = Columns[columnIndex];
             if (currentColumn.Datas.Count < dataIndex + 1)
             {
                 datas[columnIndex] = new MochaData {
                     dataType = currentColumn.DataType,
                     data     = MochaData.TryGetData(currentColumn.DataType, string.Empty)
                 }
             }
             ;
             else
             {
                 datas[columnIndex] = currentColumn.Datas[dataIndex];
             }
         }
         Rows.collection.Add(new MochaRow(datas));
     }
 }
예제 #2
0
        /// <summary>
        /// Set rows by column datas.
        /// </summary>
        internal void SetRowsByDatas()
        {
            Rows.collection.Clear();

            MochaArray <MochaData> datas = new MochaData[Columns.Count];

            for (int dataIndex = 0; dataIndex < Columns[0].Datas.Count; dataIndex++)
            {
                for (int columnIndex = 0; columnIndex < Columns.Count; columnIndex++)
                {
                    MochaColumn currentColumn = Columns[columnIndex];
                    if (currentColumn.Datas.Count < dataIndex + 1)
                    {
                        datas[columnIndex] = new MochaData {
                            dataType = currentColumn.DataType,
                            data     = MochaData.TryGetData(currentColumn.DataType, "")
                        }
                    }
                    ;
                    else
                    {
                        datas[columnIndex] = currentColumn.Datas[dataIndex];
                    }
                }
                Rows.collection.Add(new MochaRow(datas));
            }
        }
예제 #3
0
        /// <summary>
        /// Set datas by row datas.
        /// </summary>
        internal void SetDatasByRows()
        {
            for (int columnIndex = 0; columnIndex < Columns.Count; columnIndex++)
            {
                //Columns[columnIndex].Datas.Changed-=Column_Changed;
                Columns[columnIndex].Datas.collection.Clear();
            }

            for (int rowIndex = 0; rowIndex < Rows.Count; rowIndex++)
            {
                MochaRow currentRow = Rows[rowIndex];

                if (currentRow.Datas.Count != Columns.Count)
                {
                    throw new MochaException("The number of data must be equal to the number of columns!");
                }

                for (int columnIndex = 0; columnIndex < Columns.Count; columnIndex++)
                {
                    MochaColumn currentColumn = Columns[columnIndex];

                    if (currentColumn.DataType != MochaDataType.AutoInt)
                    {
                        currentColumn.Datas.collection.Add(currentRow.Datas[columnIndex]);
                    }
                    else
                    {
                        MochaData data = new MochaData {
                            data = currentColumn.Datas.Count > 0 ?
                                   1 + (int)currentColumn.Datas[currentColumn.Datas.MaxIndex()].Data : 1,
                            dataType = MochaDataType.AutoInt
                        };
                        currentColumn.Datas.collection.Add(data);
                        currentRow.Datas.collection[columnIndex] = data;
                    }
                }
            }

            /*
             * for(int columnIndex = 0; columnIndex < Columns.Count; columnIndex++) {
             *  Columns[columnIndex].Datas.Changed+=Column_Changed;
             * }*/
        }
예제 #4
0
        /// <summary>
        /// Set datas by row datas.
        /// </summary>
        internal protected virtual void SetDatasByRows()
        {
            for (int columnIndex = 0; columnIndex < Columns.Count; ++columnIndex)
            {
                Columns[columnIndex].Datas.collection.Clear();
            }

            for (int rowIndex = 0; rowIndex < Rows.Count; ++rowIndex)
            {
                MochaRow currentRow = Rows[rowIndex];

                if (currentRow.Datas.Count != Columns.Count)
                {
                    throw new ArgumentException("The number of data must be equal to the number of columns!");
                }

                for (int columnIndex = 0; columnIndex < Columns.Count; ++columnIndex)
                {
                    MochaColumn currentColumn = Columns[columnIndex];

                    if (currentColumn.DataType != MochaDataType.AutoInt)
                    {
                        currentColumn.Datas.collection.Add(currentRow.Datas[columnIndex]);
                    }
                    else
                    {
                        MochaData data = new MochaData {
                            data = currentColumn.Datas.Count > 0 ?
                                   1 + (int)currentColumn.Datas[currentColumn.Datas.Count - 1].Data : 1,
                            dataType = MochaDataType.AutoInt
                        };
                        currentColumn.Datas.collection.Add(data);
                        currentRow.Datas.collection[columnIndex] = data;
                    }
                }
            }
        }