Please copy below code to some class file in Rhino C# Plugin and run “ScrollableBug” command few times. When we check for scroll position then srollable forces dialog to become very big.
Tested on Rhino 7 SR28 for Windows.
using Eto.Forms;
using Eto.Drawing;
using Rhino;
using Rhino.Commands;
using Rhino.UI;
using Command = Rhino.Commands.Command;
namespace Test
{
//Run this command few times and play with scrollbar. When dialog checks for scrollable position its size grows unintentionally
public class ScrollableBugDialogCommand : Command
{
public static ScrollableBugDialogCommand Instance { get; private set; }
public override string EnglishName { get; } = "ScrollableBug";
public ScrollableBugDialogCommand()
{
Instance = this;
}
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
new ScrollabeBugDialog().ShowModal(RhinoEtoApp.MainWindow);
return Result.Success;
}
}
public class ScrollabeBugDialog : Dialog
{
private static bool checkScrollPosition = false;
private Scrollable dialogScrollable;
public ScrollabeBugDialog()
{
dialogScrollable = new Scrollable()
{
Height = 200,
Width = 200,
Content = new Label
{
Text = "Some Label",
Font = new Font(SystemFont.Default, 20),
Size = new Size(300, 300)
},
};
var content = new DynamicLayout();
content.AddRow(null, dialogScrollable, null);
content.AddRow(null, new Button()
{
Text = "Some Button",
Font = new Font(SystemFont.Default, 20),
Size = new Size(300, 300)
});
Content = content;
if (checkScrollPosition) dialogScrollable.Scroll += (sender, e) => CheckScrollPosition();
else RhinoApp.WriteLine("Not checking scroll position.");
checkScrollPosition = !checkScrollPosition;
}
private void CheckScrollPosition()
{
RhinoApp.WriteLine("Scroll position is :" + dialogScrollable.ScrollPosition.ToString());
}
}
}