/// <summary> /// This function will create a table and return a list of starting points in which you may write data into the table. This will only draw a table outline. /// </summary> /// <param name="sectionCount"></param> /// <param name="secOneCustomPercent"></param> /// <exception cref="Exception"></exception> public static List <int> MakeTable(SectionCount sectionCount, int secOneCustomPercent) { var percentList = new List <int>(); int secCount = ConvertToInt(sectionCount); if (secCount > 1) { secCount -= 1; var remainingPercent = 100 - secOneCustomPercent; percentList.Add(secOneCustomPercent); for (var i = 0; i < secCount; i++) { percentList.Add(remainingPercent / secCount); } } else { percentList.Add(100); } var sum = 0; for (var i = 0; i < percentList.Count; i++) { sum += percentList[i]; } if (sum > 105 || sum < 95) { throw new Exception("Percentage needs to be 100"); } return(TableCore(percentList)); }
private static int ConvertToInt(SectionCount count) { int value = 1; switch (count) { case SectionCount.One: value = 1; break; case SectionCount.Two: value = 2; break; case SectionCount.Three: value = 3; break; case SectionCount.Four: value = 4; break; case SectionCount.Five: value = 5; break; default: throw new ArgumentOutOfRangeException(nameof(count), count, null); } return(value); }
/// <summary> /// This function will create a table and return a list of starting points in which you may write data into the table. This will only draw a table outline. /// </summary> /// <param name="sectionCount"></param> /// <param name="secOneCustomPercent"></param> /// <param name="secTwoCustomPercent"></param> /// <param name="secThreeCustomPercent"></param> /// <param name="secFourCustomPercent"></param> /// <exception cref="Exception"></exception> public static List <int> MakeTable(SectionCount sectionCount, int secOneCustomPercent, int secTwoCustomPercent, int secThreeCustomPercent, int secFourCustomPercent) { var percentList = new List <int>(); int secCount = ConvertToInt(sectionCount); if (secCount > 1) { if (secCount < 4) { throw new Exception("Selection count it lower then supplied section percentages."); } var perUsed = secOneCustomPercent + secTwoCustomPercent + secThreeCustomPercent + secFourCustomPercent; var remainingPercent = 100 - perUsed; percentList.Add(secOneCustomPercent); percentList.Add(secTwoCustomPercent); percentList.Add(secThreeCustomPercent); percentList.Add(secFourCustomPercent); if (secCount > 4) { for (int i = 0; i < secCount; i++) { secCount -= 4; percentList.Add(remainingPercent / secCount); } } } else { percentList.Add(100); } var sum = 0; for (var i = 0; i < percentList.Count; i++) { sum += percentList[i]; } if (sum > 105 || sum < 95) { throw new Exception("Percentage needs to be 100"); } return(TableCore(percentList)); }
/// <summary> /// This function will create a table and return a list of starting points in which you may write data into the table. This will only draw a table outline. /// </summary> /// <param name="sectionCount"></param> /// <exception cref="Exception"></exception> public static List <int> MakeTable(SectionCount sectionCount) { var percentList = new List <int>(); int secCount = ConvertToInt(sectionCount); if (secCount > 1) { for (var i = 0; i < secCount; i++) { percentList.Add(100 / secCount); } } else { percentList.Add(100); } return(TableCore(percentList)); }