diff --git a/PROMS/Volian.Controls.Library/DisplayItem.cs b/PROMS/Volian.Controls.Library/DisplayItem.cs index c3ab694d..0903896b 100644 --- a/PROMS/Volian.Controls.Library/DisplayItem.cs +++ b/PROMS/Volian.Controls.Library/DisplayItem.cs @@ -452,6 +452,7 @@ namespace Volian.Controls.Library _StepData = item.ActiveFormat.PlantFormat.FormatData.StepDataList[_Type%10000]; break; } + //this.Move += new EventHandler(DisplayItem_Move); } else { @@ -532,6 +533,13 @@ namespace Volian.Controls.Library _Loading = false; //// TIMING: vlnCSLARTB.TimeIt("CSLARTB Controls Add"); } + + //void DisplayItem_Move(object sender, EventArgs e) + //{ + // if(_MyItem != null) + // if(_MyItem.ItemID == 981) + // vlnStackTrace.ShowStack("DisplayItem_Move = {0} ({1},{2})", _MyItem.ItemID, Left, Top);// Show StackTrace + //} //void _DisplayRTB_MouseClick(object sender, MouseEventArgs e) //{ // _DisplayRTB.Select(); @@ -558,7 +566,12 @@ namespace Volian.Controls.Library //} public void AutoExpand() { - Expand(_Type >= 20000); + if (CanExpand && Expanded == false)// TODO: May need to do some additional checking for subsections + { + //vlnStackTrace.ShowStack(">AutoExpand ID {0} - Can {1} Expanded {2}", _MyItem.ItemID, CanExpand, Expanded); + Expand(_Type >= 20000); + //Console.WriteLine(" _Panel.VerticalScroll.Minimum && scrollValue <= _Panel.VerticalScroll.Maximum) // If it isn't within range - _Panel.VerticalScroll.Value = scrollValue; // Center the item + _DisplayRTB.Select(0, 0); + // if (CanExpand) AutoExpand(); // Expand the item if you can + CenterScroll(); } public void ItemShow() { _DisplayRTB.Focus(); + CenterScroll(); + } + private void CenterScroll() + { + //vlnStackTrace.ShowStack("CenterScroll {0} Current {1} Top {2} Bottom {3} Limit {4}", _MyItem.ItemID, _Panel.VerticalScroll.Value, Top, Bottom, _Panel.Height);// Show StackTrace + //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 <= _Panel.Height) return;// Don't move if within screen. int scrollValue = _Panel.VerticalScroll.Value + (Top - (_Panel.Height / 2)); // calculate scroll center for the item - if(scrollValue > _Panel.VerticalScroll.Minimum && scrollValue <= _Panel.VerticalScroll.Maximum) // If it isn't within range + //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 >= _Panel.VerticalScroll.Minimum && scrollValue <= _Panel.VerticalScroll.Maximum) // If it is within range _Panel.VerticalScroll.Value = scrollValue; // Center the item } private void vlnCSLARTB_Paint(object sender, PaintEventArgs e)