Fixed ScrollToCenter logic for EditItems

Use ScrollToCenter logic when text is changed or textbox is resized.
This commit is contained in:
Rich
2012-12-04 19:56:34 +00:00
parent a6e07e9b52
commit 44396a7200
2 changed files with 15 additions and 3 deletions

View File

@@ -1510,9 +1510,11 @@ namespace Volian.Controls.Library
//Console.WriteLine("CenterScroll {0} Current {1} Top {2} Bottom {3} Limit {4}", _MyItem.ItemID, _Panel.VerticalScroll.Value, Top, Bottom, _Panel.Height);
if (Top >= 0 && Bottom <= MyStepPanel.Height) return;// Don't move if within screen.
int scrollValue = MyStepPanel.VerticalScroll.Value + (Top - (MyStepPanel.Height / 2)); // calculate scroll center for the item
// Limit scroll location within allowable values
scrollValue = Math.Max(MyStepPanel.VerticalScroll.Minimum,Math.Min(MyStepPanel.VerticalScroll.Maximum,scrollValue));
//Console.WriteLine("CenterScroll {0} Current {1} New {2} Min {3} Max {4}", _MyItem.ItemID, _Panel.VerticalScroll.Value, scrollValue, _Panel.VerticalScroll.Minimum, _Panel.VerticalScroll.Maximum);
if (scrollValue >= MyStepPanel.VerticalScroll.Minimum && scrollValue <= MyStepPanel.VerticalScroll.Maximum) // If it is within range
MyStepPanel.VerticalScroll.Value = scrollValue; // Center the item
//if (scrollValue >= MyStepPanel.VerticalScroll.Minimum && scrollValue <= MyStepPanel.VerticalScroll.Maximum) // If it is within range
MyStepPanel.VerticalScroll.Value = scrollValue; // Center the item
}
/// <summary>