/// <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; * }*/ }
/// <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; } } } }