B2022-137 Table (grid) performance improvements.
B2022-137 added method to get font size from RTF string (used for tables) B2022-137 Table (grid) performance improvements getting font sizes B2022-137 Table (grid) performance improvements showing table cell shading
This commit is contained in:
		@@ -824,12 +824,12 @@ namespace Volian.Controls.Library
 | 
			
		||||
			{
 | 
			
		||||
				_MyLog.WarnFormat("Attempt to give Focus to Disposed Object {0}", MyID);
 | 
			
		||||
			}
 | 
			
		||||
			ScrollToCenter();
 | 
			
		||||
			//ScrollToCenter();
 | 
			
		||||
		}
 | 
			
		||||
		public override void ItemShow()
 | 
			
		||||
		{
 | 
			
		||||
			MyFlexGrid.Focus();
 | 
			
		||||
			ScrollToCenter();
 | 
			
		||||
			//ScrollToCenter();
 | 
			
		||||
		}
 | 
			
		||||
		public StepRTB DisplayRoStepRTB;
 | 
			
		||||
		public override StepRTB MyStepRTB 
 | 
			
		||||
 
 | 
			
		||||
@@ -2716,6 +2716,22 @@ namespace Volian.Controls.Library
 | 
			
		||||
			}
 | 
			
		||||
			return (differentFonts || lastSZ == 0) ? 0 : lastSZ/2; // divide the RTF font size by two to get the font point size
 | 
			
		||||
		}
 | 
			
		||||
		// F2022-137 Table performance improvements
 | 
			
		||||
		public static float GetRTFFontSize(string rtf)
 | 
			
		||||
		{
 | 
			
		||||
			MatchCollection mc = Regex.Matches(rtf, @"\\fs([0-9]+)");
 | 
			
		||||
			bool differentFonts = false;
 | 
			
		||||
			float lastSZ = 0;
 | 
			
		||||
			foreach (Match match in mc)
 | 
			
		||||
			{
 | 
			
		||||
				float sz = float.Parse(match.Groups[1].Value);
 | 
			
		||||
				if (lastSZ == 0)
 | 
			
		||||
					lastSZ = sz;
 | 
			
		||||
				else if (lastSZ != sz)
 | 
			
		||||
					differentFonts = true;
 | 
			
		||||
			}
 | 
			
		||||
			return (differentFonts || lastSZ == 0) ? 0 : lastSZ / 2; // divide the RTF font size by two to get the font point size
 | 
			
		||||
		}
 | 
			
		||||
		private static Form ParentForm(Control ctrl)
 | 
			
		||||
		{
 | 
			
		||||
			while (!(ctrl.Parent is Form || ctrl.Parent is EditItem)) 
 | 
			
		||||
 
 | 
			
		||||
@@ -2636,41 +2636,10 @@ namespace Volian.Controls.Library
 | 
			
		||||
				// Selected table cell is not in edit mode. Go into edit mode and position according
 | 
			
		||||
				// to the pass in selOpt.
 | 
			
		||||
				// B2021-090 don't try to get the font size on an RO table
 | 
			
		||||
				// B2022-137 Table performance improvements
 | 
			
		||||
				if (MyFlexGrid != null && MyFlexGrid.Editor == null && !MyFlexGrid.IsRoTable)
 | 
			
		||||
				{
 | 
			
		||||
					float fntSz = 0;
 | 
			
		||||
					C1.Win.C1FlexGrid.CellRange cr = MyFlexGrid.Selection; // get the selected grid cell range
 | 
			
		||||
					for (int r = cr.r1; r <= cr.r2; r++)
 | 
			
		||||
						for (int c = cr.c1; c <= cr.c2; c++)
 | 
			
		||||
						{
 | 
			
		||||
							if (rtnFontSize == 0) continue;
 | 
			
		||||
							MyFlexGrid._GettingFontSize = true;
 | 
			
		||||
							MyFlexGrid.Select(r, c);
 | 
			
		||||
							MyFlexGrid.StartEditing();
 | 
			
		||||
							switch (selOpt)
 | 
			
		||||
							{
 | 
			
		||||
								case SelectionOption.Start:
 | 
			
		||||
									MyStepRTB.Select(0, 0);
 | 
			
		||||
									break;
 | 
			
		||||
								case SelectionOption.All:
 | 
			
		||||
									MyStepRTB.SelectAll();
 | 
			
		||||
									break;
 | 
			
		||||
								case SelectionOption.End:
 | 
			
		||||
									MyStepRTB.Select(MyStepRTB.TextLength, 0);
 | 
			
		||||
									break;
 | 
			
		||||
								default:
 | 
			
		||||
									MyStepRTB.Select(0, 0);
 | 
			
		||||
									break;
 | 
			
		||||
							}
 | 
			
		||||
							fntSz = MyStepRTB.GetRTFFontSize(); // returns 0 when there are mulitiple font sizes
 | 
			
		||||
							if (rtnFontSize == -1)
 | 
			
		||||
								rtnFontSize = fntSz; // first time getting font size in the foreach loop
 | 
			
		||||
							else if (fntSz == 0 || fntSz != rtnFontSize)
 | 
			
		||||
								rtnFontSize = 0; // indicates multiple font sizes in the selection
 | 
			
		||||
						}
 | 
			
		||||
					MyFlexGrid.Select(cr);
 | 
			
		||||
					MyFlexGrid.Focus();
 | 
			
		||||
					MyFlexGrid._GettingFontSize = false; // _GettingFontSize prevents the cell text editor from flashing on/off when getting font size
 | 
			
		||||
					rtnFontSize = StepRTB.GetRTFFontSize(MyFlexGrid.Selection.Clip);
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
					rtnFontSize = MyStepRTB.GetRTFFontSize(); // returns 0 when there are mulitiple font sizes
 | 
			
		||||
 
 | 
			
		||||
@@ -4784,7 +4784,8 @@ namespace Volian.Controls.Library
 | 
			
		||||
			{
 | 
			
		||||
				float fnSz = GetRTFFontSize(); // returns the font size in pts from the text's RTF
 | 
			
		||||
				_owner.SelectedFontSize = fnSz; // will trigger the changing of the font size from VlnFlexGrid class
 | 
			
		||||
				_owner.ShowTableCellShading(); //C2021-004 display any background color change when you move off a cell
 | 
			
		||||
				// B2022-137 Table performance improvements - moved ShowTableCellShading to the onLeave call
 | 
			
		||||
				//_owner.ShowTableCellShading(); //C2021-004 display any background color change when you move off a cell
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@@ -4986,6 +4987,7 @@ namespace Volian.Controls.Library
 | 
			
		||||
 | 
			
		||||
			// done for now, hide editor
 | 
			
		||||
			Visible = false;
 | 
			
		||||
			_owner.ShowTableCellShading(); // B2022-137 restore shading if table after editing a cell
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// we will handle the Tab key ourselves
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user