This commit is contained in:
		| @@ -1975,7 +1975,7 @@ namespace Volian.Controls.Library | |||||||
| 	  } | 	  } | ||||||
| 	  private void SplitSelectionColumns() | 	  private void SplitSelectionColumns() | ||||||
| 	  { | 	  { | ||||||
| 		  bool nonMergedInSelection = false; | 		  bool hasNonMergedColumn = false; | ||||||
| 		  //Console.WriteLine("SplitSelectionColumns this.selection {0}", this.Selection); | 		  //Console.WriteLine("SplitSelectionColumns this.selection {0}", this.Selection); | ||||||
| 		  //Debug_WritelineMySelection(); | 		  //Debug_WritelineMySelection(); | ||||||
| 		  CellRange cr = this.Selection; | 		  CellRange cr = this.Selection; | ||||||
| @@ -1983,10 +1983,16 @@ namespace Volian.Controls.Library | |||||||
| 		  foreach (CellRange sel in MySelection) | 		  foreach (CellRange sel in MySelection) | ||||||
| 		  { | 		  { | ||||||
| 			  if (!this.MergedRanges.Contains(sel)) | 			  if (!this.MergedRanges.Contains(sel)) | ||||||
| 				  nonMergedInSelection = true; | 				  hasNonMergedColumn = true; | ||||||
|  | 			  else | ||||||
|  | 			  { | ||||||
|  | 				  CellRange mr = GetMergedRange(sel.r1, sel.c1); | ||||||
|  | 				  if (mr.c1 == mr.c2) | ||||||
|  | 					  hasNonMergedColumn = true; | ||||||
|  | 			  } | ||||||
| 		  } | 		  } | ||||||
| 		  // for each column in the selection, add a new column | 		  // for each column in the selection, add a new column | ||||||
| 		  if (nonMergedInSelection) | 		  if (hasNonMergedColumn) | ||||||
| 		  { | 		  { | ||||||
| 			  for (int c = cr.c2; c >= cr.c1; c--) | 			  for (int c = cr.c2; c >= cr.c1; c--) | ||||||
| 			  { | 			  { | ||||||
| @@ -1995,7 +2001,7 @@ namespace Volian.Controls.Library | |||||||
| 			  } | 			  } | ||||||
| 		  } | 		  } | ||||||
| 		  // include new columns in selection | 		  // include new columns in selection | ||||||
| 		  this.Select(cr.r1, cr.c1, cr.r2, cr.c2 + ((nonMergedInSelection) ? numSelCols : 0)); | 		  this.Select(cr.r1, cr.c1, cr.r2, cr.c2 + ((hasNonMergedColumn) ? numSelCols : 0)); | ||||||
| 		  //if a merged range is part of the selectin, try to split it | 		  //if a merged range is part of the selectin, try to split it | ||||||
| 		  foreach (CellRange sel in MySelection) | 		  foreach (CellRange sel in MySelection) | ||||||
| 		  { | 		  { | ||||||
| @@ -2004,7 +2010,7 @@ namespace Volian.Controls.Library | |||||||
| 				  SplitMergedRange(sel, true); | 				  SplitMergedRange(sel, true); | ||||||
| 		  } | 		  } | ||||||
| 		  cr = this.Selection; | 		  cr = this.Selection; | ||||||
| 		  if (nonMergedInSelection) | 		  if (hasNonMergedColumn) | ||||||
| 		  { | 		  { | ||||||
| 			  for (int r = 0; r < this.Rows.Count; r++) | 			  for (int r = 0; r < this.Rows.Count; r++) | ||||||
| 				  for (int c = cr.c1; c <= cr.c2; c += 2) | 				  for (int c = cr.c1; c <= cr.c2; c += 2) | ||||||
| @@ -2036,17 +2042,32 @@ namespace Volian.Controls.Library | |||||||
|  |  | ||||||
| 		private void SplitSelectionRows() | 		private void SplitSelectionRows() | ||||||
| 		{ | 		{ | ||||||
|  | 			bool hasNonMergedRow = false; | ||||||
| 			CellRange cr = this.Selection; | 			CellRange cr = this.Selection; | ||||||
| 			int numSelRows = (cr.r2 - cr.r1) + 1; | 			int numSelRows = (cr.r2 - cr.r1) + 1; | ||||||
| 			//Console.WriteLine("numSelRows = {0}", numSelRows); | 			//Console.WriteLine("numSelRows = {0}", numSelRows); | ||||||
| 			//Console.WriteLine("Inital Selection [{0},{1}] - [{2},{3}]", cr.r1, cr.c1, cr.r2, cr.c2); | 			//Console.WriteLine("Inital Selection [{0},{1}] - [{2},{3}]", cr.r1, cr.c1, cr.r2, cr.c2); | ||||||
|  | 			foreach (CellRange sel in MySelection) | ||||||
|  | 			{ | ||||||
|  | 				if (!this.MergedRanges.Contains(sel)) | ||||||
|  | 					hasNonMergedRow = true; | ||||||
|  | 				else | ||||||
|  | 				{ | ||||||
|  | 					CellRange mr = GetMergedRange(sel.r1, sel.c1); | ||||||
|  | 					if (mr.r1 == mr.r2) | ||||||
|  | 						hasNonMergedRow = true; | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
| 			// for each row in the selection, add a new row | 			// for each row in the selection, add a new row | ||||||
|  | 			if (hasNonMergedRow) | ||||||
|  | 			{ | ||||||
| 				for (int r = cr.r2; r >= cr.r1; r--) | 				for (int r = cr.r2; r >= cr.r1; r--) | ||||||
| 				{ | 				{ | ||||||
| 					//Console.WriteLine("Inserted new Row at [{0},{1}]", r, cr.c1); | 					//Console.WriteLine("Inserted new Row at [{0},{1}]", r, cr.c1); | ||||||
| 					Select(r, cr.c1, r, cr.c2); | 					Select(r, cr.c1, r, cr.c2); | ||||||
| 					InsertRowAfter(); | 					InsertRowAfter(); | ||||||
| 				} | 				} | ||||||
|  | 			} | ||||||
| 			// include new rows in selection | 			// include new rows in selection | ||||||
| 			this.Select(cr.r1, cr.c1, cr.r2 + numSelRows, cr.c2); | 			this.Select(cr.r1, cr.c1, cr.r2 + numSelRows, cr.c2); | ||||||
| 			//if a merged range is part of the selectin, try to split it | 			//if a merged range is part of the selectin, try to split it | ||||||
| @@ -2058,6 +2079,8 @@ namespace Volian.Controls.Library | |||||||
| 			} | 			} | ||||||
| 			cr = this.Selection; | 			cr = this.Selection; | ||||||
| 			//Console.WriteLine("  After Insert [{0},{1}] - [{2},{3}]", cr.r1, cr.c1, cr.r2, cr.c2); | 			//Console.WriteLine("  After Insert [{0},{1}] - [{2},{3}]", cr.r1, cr.c1, cr.r2, cr.c2); | ||||||
|  | 			if (hasNonMergedRow) | ||||||
|  | 			{ | ||||||
| 				for (int c = 0; c < this.Cols.Count; c++) | 				for (int c = 0; c < this.Cols.Count; c++) | ||||||
| 					for (int r = cr.r1; r <= cr.r2; r += 2) | 					for (int r = cr.r1; r <= cr.r2; r += 2) | ||||||
| 					{ | 					{ | ||||||
| @@ -2080,7 +2103,7 @@ namespace Volian.Controls.Library | |||||||
| 					//this.Rows[r].Height = Math.Max(recHeight / 2, _minRowSplitHeight); | 					//this.Rows[r].Height = Math.Max(recHeight / 2, _minRowSplitHeight); | ||||||
| 					//Console.WriteLine("Cell[{0},{1}].Height = {2}", r, cr.c1, recHeight); | 					//Console.WriteLine("Cell[{0},{1}].Height = {2}", r, cr.c1, recHeight); | ||||||
| 				} | 				} | ||||||
|  | 			} | ||||||
| 			//foreach (CellRange crng in this.MergedRanges) | 			//foreach (CellRange crng in this.MergedRanges) | ||||||
| 			//    Console.WriteLine("merge ranges [{0},{1}] - [{2},{3}]", crng.r1, crng.c1, crng.r2, crng.c2); | 			//    Console.WriteLine("merge ranges [{0},{1}] - [{2},{3}]", crng.r1, crng.c1, crng.r2, crng.c2); | ||||||
| 		} | 		} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user