Fixed ScrollToCenter logic for EditItems
Use ScrollToCenter logic when text is changed or textbox is resized.
This commit is contained in:
parent
a6e07e9b52
commit
44396a7200
@ -1510,8 +1510,10 @@ 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);
|
//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.
|
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
|
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);
|
//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
|
//if (scrollValue >= MyStepPanel.VerticalScroll.Minimum && scrollValue <= MyStepPanel.VerticalScroll.Maximum) // If it is within range
|
||||||
MyStepPanel.VerticalScroll.Value = scrollValue; // Center the item
|
MyStepPanel.VerticalScroll.Value = scrollValue; // Center the item
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,18 +217,21 @@ namespace Volian.Controls.Library
|
|||||||
//// TIMING: DisplayItem.TimeIt("CSLARTB Top");
|
//// TIMING: DisplayItem.TimeIt("CSLARTB Top");
|
||||||
InitializeComponent();// TODO: Performance 25%
|
InitializeComponent();// TODO: Performance 25%
|
||||||
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, null, false);
|
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, null, false);
|
||||||
|
MyStepRTB.TextChanged += new EventHandler(MyStepRTB_TextChanged);
|
||||||
}
|
}
|
||||||
public RTBItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand, EditItem nextEditItem)
|
public RTBItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand, EditItem nextEditItem)
|
||||||
{
|
{
|
||||||
//// TIMING: DisplayItem.TimeIt("CSLARTB Top");
|
//// TIMING: DisplayItem.TimeIt("CSLARTB Top");
|
||||||
InitializeComponent();// TODO: Performance 25%
|
InitializeComponent();// TODO: Performance 25%
|
||||||
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, nextEditItem, false);
|
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, nextEditItem, false);
|
||||||
|
MyStepRTB.TextChanged += new EventHandler(MyStepRTB_TextChanged);
|
||||||
}
|
}
|
||||||
public RTBItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand, bool addFirstChld)
|
public RTBItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand, bool addFirstChld)
|
||||||
{
|
{
|
||||||
//// TIMING: DisplayItem.TimeIt("CSLARTB Top");
|
//// TIMING: DisplayItem.TimeIt("CSLARTB Top");
|
||||||
InitializeComponent();// TODO: Performance 25%
|
InitializeComponent();// TODO: Performance 25%
|
||||||
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, null, addFirstChld);
|
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, null, addFirstChld);
|
||||||
|
MyStepRTB.TextChanged += new EventHandler(MyStepRTB_TextChanged);
|
||||||
}
|
}
|
||||||
//private void SetupRTBItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand, EditItem nextEditItem)
|
//private void SetupRTBItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand, EditItem nextEditItem)
|
||||||
//{
|
//{
|
||||||
@ -353,7 +356,14 @@ namespace Volian.Controls.Library
|
|||||||
void _MyStepRTB_Resize(object sender, EventArgs e)
|
void _MyStepRTB_Resize(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (MyStepPanel != null && this == MyStepPanel.SelectedEditItem)
|
if (MyStepPanel != null && this == MyStepPanel.SelectedEditItem)
|
||||||
MyStepPanel.ScrollControlIntoView(this);
|
ScrollToCenter();
|
||||||
|
//MyStepPanel.ScrollControlIntoView(this);
|
||||||
|
}
|
||||||
|
void MyStepRTB_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (MyStepPanel != null && this == MyStepPanel.SelectedEditItem)
|
||||||
|
ScrollToCenter();
|
||||||
|
//MyStepPanel.ScrollControlIntoView(this);
|
||||||
}
|
}
|
||||||
private Label lblHeader = null;
|
private Label lblHeader = null;
|
||||||
private Label lblFooter = null;
|
private Label lblFooter = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user