mymerge.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. using System.Windows.Forms;
  4. using Microsoft.VisualBasic.CompilerServices;
  5. namespace Dongke.IBOSS.PRD.Framework.Controls
  6. {
  7. [StandardModule]
  8. internal sealed class mymerge
  9. {
  10. public static int GetNextVisibleColumnIndex(DataGridView dgv, int colindex)
  11. {
  12. int result = -1;
  13. int columnCount = dgv.ColumnCount;
  14. checked
  15. {
  16. try
  17. {
  18. int displayIndex = dgv.Columns[colindex].DisplayIndex;
  19. bool flag = false;
  20. int num = displayIndex + 1;
  21. int num2 = columnCount - 1;
  22. for (int i = num; i <= num2; i++)
  23. {
  24. int num3 = 0;
  25. int num4 = columnCount - 1;
  26. for (int j = num3; j <= num4; j++)
  27. {
  28. if (dgv.Columns[j].DisplayIndex == i && dgv.Columns[j].Visible)
  29. {
  30. flag = true;
  31. result = j;
  32. break;
  33. }
  34. }
  35. if (flag)
  36. {
  37. break;
  38. }
  39. }
  40. }
  41. catch (Exception projectError)
  42. {
  43. ProjectData.SetProjectError(projectError);
  44. ProjectData.ClearProjectError();
  45. }
  46. return result;
  47. }
  48. }
  49. public static int GetPriorVisibleColumnIndex(DataGridView dgv, int colindex)
  50. {
  51. int result = -1;
  52. int columnCount = dgv.ColumnCount;
  53. checked
  54. {
  55. try
  56. {
  57. int displayIndex = dgv.Columns[colindex].DisplayIndex;
  58. bool flag = false;
  59. for (int i = displayIndex - 1; i >= 0; i += -1)
  60. {
  61. int num = 0;
  62. int num2 = columnCount - 1;
  63. for (int j = num; j <= num2; j++)
  64. {
  65. if (dgv.Columns[j].DisplayIndex == i && dgv.Columns[j].Visible)
  66. {
  67. flag = true;
  68. result = j;
  69. break;
  70. }
  71. }
  72. if (flag)
  73. {
  74. break;
  75. }
  76. }
  77. }
  78. catch (Exception projectError)
  79. {
  80. ProjectData.SetProjectError(projectError);
  81. ProjectData.ClearProjectError();
  82. }
  83. return result;
  84. }
  85. }
  86. public static float GetHMergeWidth(DataGridView dgv, int curcol, int currow, ref int colsmerged, ref int leftmerged, ref int rightmerged, ref int firstcolumn, ref int firstc, bool iscancheckheight)
  87. {
  88. DataGridViewCell dataGridViewCell = dgv.Rows[currow].Cells[curcol];
  89. float num = dgv.Columns[curcol].Width;
  90. firstcolumn = 0;
  91. firstc = curcol;
  92. checked
  93. {
  94. try
  95. {
  96. if ((Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "水平合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "#水平合并#", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "左合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "右合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "左上合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "左下合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "右上合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "右下合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "左边合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "右边合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "上边合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "下边合并", TextCompare: false) != 0))
  97. {
  98. colsmerged = 1;
  99. return num;
  100. }
  101. colsmerged = 1;
  102. rightmerged = 0;
  103. leftmerged = 0;
  104. int rowsmerged = 0;
  105. int downrowsmerged = 0;
  106. int uprowsmerged = 0;
  107. int firstrow = 0;
  108. int firstr = 0;
  109. if (iscancheckheight)
  110. {
  111. GetVMergeHeight(dgv, curcol, currow, ref rowsmerged, ref downrowsmerged, ref uprowsmerged, ref firstrow, ref firstr);
  112. }
  113. int nextVisibleColumnIndex = GetNextVisibleColumnIndex(dgv, curcol);
  114. int rowsmerged2 = 0;
  115. if ((Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "水平合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "#水平合并#", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "右合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "右下合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "右上合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "右边合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "上边合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "下边合并", TextCompare: false) == 0))
  116. {
  117. while (nextVisibleColumnIndex >= 0)
  118. {
  119. if (dgv.Columns[nextVisibleColumnIndex].Visible)
  120. {
  121. DataGridViewCell dataGridViewCell2 = dgv.Rows[currow].Cells[nextVisibleColumnIndex];
  122. if (((Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "水平合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "#水平合并#", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "左合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "左上合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "左下合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "左边合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "上边合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "下边合并", TextCompare: false) != 0)) || !dataGridViewCell.FormattedValue.Equals(RuntimeHelpers.GetObjectValue(dataGridViewCell2.FormattedValue)))
  123. {
  124. break;
  125. }
  126. GetVMergeHeight(dgv, nextVisibleColumnIndex, currow, ref rowsmerged2, ref downrowsmerged, ref uprowsmerged, ref firstrow, ref firstr);
  127. if (rowsmerged2 > 1 && rowsmerged2 != rowsmerged)
  128. {
  129. break;
  130. }
  131. num += (float)dgv.Columns[nextVisibleColumnIndex].Width;
  132. rightmerged++;
  133. if ((Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "左合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "左下合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "左上合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "左边合并", TextCompare: false) == 0))
  134. {
  135. break;
  136. }
  137. }
  138. nextVisibleColumnIndex = GetNextVisibleColumnIndex(dgv, nextVisibleColumnIndex);
  139. }
  140. }
  141. if ((Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "水平合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "#水平合并#", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "左合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "左下合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "左上合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "左边合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "上边合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "下边合并", TextCompare: false) == 0))
  142. {
  143. for (nextVisibleColumnIndex = GetPriorVisibleColumnIndex(dgv, curcol); nextVisibleColumnIndex >= 0; nextVisibleColumnIndex = GetPriorVisibleColumnIndex(dgv, nextVisibleColumnIndex))
  144. {
  145. if (dgv.Columns[nextVisibleColumnIndex].Visible)
  146. {
  147. DataGridViewCell dataGridViewCell3 = dgv.Rows[currow].Cells[nextVisibleColumnIndex];
  148. if (((Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "水平合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "#水平合并#", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "右合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "右上合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "右下合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "右边合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "上边合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "下边合并", TextCompare: false) != 0)) || !dataGridViewCell.FormattedValue.Equals(RuntimeHelpers.GetObjectValue(dataGridViewCell3.FormattedValue)))
  149. {
  150. break;
  151. }
  152. if (iscancheckheight)
  153. {
  154. GetVMergeHeight(dgv, nextVisibleColumnIndex, currow, ref rowsmerged2, ref downrowsmerged, ref uprowsmerged, ref firstrow, ref firstr);
  155. if (rowsmerged2 > 1 && rowsmerged2 != rowsmerged)
  156. {
  157. break;
  158. }
  159. }
  160. num += (float)dgv.Columns[nextVisibleColumnIndex].Width;
  161. leftmerged++;
  162. firstcolumn += dgv.Columns[nextVisibleColumnIndex].Width;
  163. firstc = nextVisibleColumnIndex;
  164. if ((Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "右合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "右下合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "右上合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "右边合并", TextCompare: false) == 0))
  165. {
  166. break;
  167. }
  168. }
  169. }
  170. }
  171. }
  172. catch (Exception projectError)
  173. {
  174. ProjectData.SetProjectError(projectError);
  175. colsmerged = 1;
  176. ProjectData.ClearProjectError();
  177. }
  178. colsmerged = rightmerged + leftmerged + 1;
  179. return num;
  180. }
  181. }
  182. public static int GetVMergeHeight(DataGridView dgv, int curcol, int currow, ref int rowsmerged, ref int downrowsmerged, ref int uprowsmerged, ref int firstrow, ref int firstr)
  183. {
  184. DataGridViewCell dataGridViewCell = dgv.Rows[currow].Cells[curcol];
  185. int num = dgv.Rows[currow].Height;
  186. firstrow = 0;
  187. firstr = currow;
  188. checked
  189. {
  190. try
  191. {
  192. if ((Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "垂直合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "#垂直合并#", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "上合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "下合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "左上合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "左下合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "右上合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "右下合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "上边合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "下边合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "左边合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "右边合并", TextCompare: false) != 0))
  193. {
  194. rowsmerged = 1;
  195. return num;
  196. }
  197. int rowCount = dgv.RowCount;
  198. downrowsmerged = 0;
  199. uprowsmerged = 0;
  200. rowsmerged = 1;
  201. if ((Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "垂直合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "#垂直合并#", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "下合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "左下合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "右下合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "下边合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "左边合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "右边合并", TextCompare: false) == 0))
  202. {
  203. int num2 = currow + 1;
  204. int num3 = rowCount - 1;
  205. for (int i = num2; i <= num3; i++)
  206. {
  207. if (dgv.Rows[i].Visible)
  208. {
  209. DataGridViewCell dataGridViewCell2 = dgv.Rows[i].Cells[curcol];
  210. if (((Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "垂直合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "#垂直合并#", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "上合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "左上合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "右上合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "上边合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "左边合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "右边合并", TextCompare: false) != 0)) || !dataGridViewCell.FormattedValue.Equals(RuntimeHelpers.GetObjectValue(dataGridViewCell2.FormattedValue)))
  211. {
  212. break;
  213. }
  214. float num4 = dgv.Rows[i].Height;
  215. num = (int)Math.Round((float)num + num4);
  216. downrowsmerged++;
  217. if ((Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "上合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "左上合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "右上合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell2.Tag), "上边合并", TextCompare: false) == 0))
  218. {
  219. break;
  220. }
  221. }
  222. }
  223. }
  224. if ((Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "垂直合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "#垂直合并#", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "上合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "左上合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "右上合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "上边合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "左边合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell.Tag), "右边合并", TextCompare: false) == 0))
  225. {
  226. for (int j = currow - 1; j >= 0; j += -1)
  227. {
  228. if (dgv.Rows[j].Visible)
  229. {
  230. DataGridViewCell dataGridViewCell3 = dgv.Rows[j].Cells[curcol];
  231. if (((Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "垂直合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "#垂直合并#", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "下合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "左下合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "右下合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "下边合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "左边合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "右边合并", TextCompare: false) != 0)) || !dataGridViewCell.FormattedValue.Equals(RuntimeHelpers.GetObjectValue(dataGridViewCell3.FormattedValue)))
  232. {
  233. break;
  234. }
  235. float num5 = dgv.Rows[j].Height;
  236. num = (int)Math.Round((float)num + num5);
  237. uprowsmerged++;
  238. firstrow = (int)Math.Round((float)firstrow + num5);
  239. firstr = j;
  240. if ((Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "下合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "左下合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "右下合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dataGridViewCell3.Tag), "下边合并", TextCompare: false) == 0))
  241. {
  242. break;
  243. }
  244. }
  245. }
  246. }
  247. }
  248. catch (Exception projectError)
  249. {
  250. ProjectData.SetProjectError(projectError);
  251. rowsmerged = 1;
  252. ProjectData.ClearProjectError();
  253. }
  254. rowsmerged = uprowsmerged + downrowsmerged + 1;
  255. return num;
  256. }
  257. }
  258. public static void GetHVMergeWidthAndHeight(DataGridView dgv, int curcol, int currow, ref float mywidth, ref float myheight, ref int rightmergecols, ref int leftmergecols, ref int upmergerows, ref int downmergerows, ref int firstcolumn, ref int firstrow, ref int firstc, ref int firstr)
  259. {
  260. int colsmerged = 1;
  261. int rowsmerged = 1;
  262. rightmergecols = 0;
  263. leftmergecols = 0;
  264. upmergerows = 0;
  265. downmergerows = 0;
  266. firstcolumn = 0;
  267. firstrow = 0;
  268. myheight = GetVMergeHeight(dgv, curcol, currow, ref rowsmerged, ref downmergerows, ref upmergerows, ref firstrow, ref firstr);
  269. if (rowsmerged == 1)
  270. {
  271. mywidth = GetHMergeWidth(dgv, curcol, currow, ref colsmerged, ref leftmergecols, ref rightmergecols, ref firstcolumn, ref firstc, iscancheckheight: true);
  272. return;
  273. }
  274. mywidth = GetHMergeWidth(dgv, curcol, currow, ref colsmerged, ref leftmergecols, ref rightmergecols, ref firstcolumn, ref firstc, iscancheckheight: true);
  275. if (colsmerged == 1)
  276. {
  277. return;
  278. }
  279. int num = curcol;
  280. firstcolumn = 0;
  281. mywidth = dgv.Columns[curcol].Width;
  282. int num2 = 1;
  283. int num3 = rightmergecols;
  284. int rowsmerged2 = 0;
  285. int downrowsmerged = 0;
  286. int uprowsmerged = 0;
  287. int firstrow2 = 0;
  288. int firstr2 = 0;
  289. checked
  290. {
  291. for (int i = num2; i <= num3; i++)
  292. {
  293. num = GetNextVisibleColumnIndex(dgv, num);
  294. if (dgv.Columns[num].Visible)
  295. {
  296. GetVMergeHeight(dgv, num, currow, ref rowsmerged2, ref downrowsmerged, ref uprowsmerged, ref firstrow2, ref firstr2);
  297. if ((rowsmerged2 < rowsmerged) | ((Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "左合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "左上合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "左下合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "左边合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "上边合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "下边合并", TextCompare: false) != 0)))
  298. {
  299. rightmergecols = i - 1;
  300. break;
  301. }
  302. mywidth += dgv.Columns[num].Width;
  303. if ((Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "左合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "左上合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "左下合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "左边合并", TextCompare: false) == 0))
  304. {
  305. break;
  306. }
  307. }
  308. }
  309. num = curcol;
  310. firstc = curcol;
  311. int num4 = num;
  312. int num5 = 1;
  313. int num6 = leftmergecols;
  314. for (int j = num5; j <= num6; j++)
  315. {
  316. num = GetPriorVisibleColumnIndex(dgv, num);
  317. if (dgv.Columns[num].Visible)
  318. {
  319. GetVMergeHeight(dgv, num, currow, ref rowsmerged2, ref downrowsmerged, ref uprowsmerged, ref firstrow2, ref firstr2);
  320. if ((rowsmerged2 < rowsmerged) | ((Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "右合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "右上合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "右下合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "右边合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "上边合并", TextCompare: false) != 0) & (Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "下边合并", TextCompare: false) != 0)))
  321. {
  322. leftmergecols = j - 1;
  323. break;
  324. }
  325. mywidth += dgv.Columns[num].Width;
  326. firstcolumn += dgv.Columns[num].Width;
  327. if ((Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "右合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "右上合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "右下合并", TextCompare: false) == 0) | (Operators.CompareString(Conversions.ToString(dgv.Rows[currow].Cells[num].Tag), "右边合并", TextCompare: false) == 0))
  328. {
  329. break;
  330. }
  331. }
  332. num4 = num;
  333. }
  334. firstc = num4;
  335. colsmerged = leftmergecols + rightmergecols + 1;
  336. }
  337. }
  338. }
  339. }