Skip to content

[release/9.0] fix #13305 Baseline SnapLines do not appear in DesignSurface #13349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ private void TestHook_GetAllSnapLines(ref Message m)

if (host.GetDesigner(comp) is ControlDesigner designer)
{
foreach (SnapLine line in designer.SnapLinesInternal)
foreach (SnapLine line in designer.SnapLines)
{
snapLineInfo.Append($"{line}\tAssociated Control = {designer.Control.Name}:::");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ internal DragAssistanceManager(
/// </summary>
private void AddSnapLines(ControlDesigner controlDesigner, List<SnapLine> horizontalList, List<SnapLine> verticalList, bool isTarget, bool validTarget)
{
IList<SnapLine> snapLines = controlDesigner.SnapLinesInternal;
IList snapLines = controlDesigner.SnapLines;
// Used for padding snaplines
Rectangle controlRect = controlDesigner.Control.ClientRectangle;
// Used for all others
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,59 @@ public void SnapLine_ToString(string filter, string expected)

Assert.Equal(expected, snapLine.ToString());
}

// Unit test for https://github.com/dotnet/winforms/issues/13305
[Fact]
public void SnapLine_ReturnOverrided()
{
using ControlDesigner baseDesigner = new();
using Control control = new();
baseDesigner.Initialize(control);
baseDesigner.SnapLines.Count.Should().Be(8);

ControlDesigner derivedDesigner = new ButtonBaseDesigner();
using Button button = new();
derivedDesigner.Initialize(button);
derivedDesigner.SnapLines.Count.Should().Be(9);

derivedDesigner = new ComboBoxDesigner();
using ComboBox comboBox = new();
derivedDesigner.Initialize(comboBox);
derivedDesigner.SnapLines.Count.Should().Be(9);

derivedDesigner = new DateTimePickerDesigner();
using DateTimePicker dateTimePicker = new();
derivedDesigner.Initialize(dateTimePicker);
derivedDesigner.SnapLines.Count.Should().Be(9);

derivedDesigner = new LabelDesigner();
using Label label = new();
derivedDesigner.Initialize(label);
derivedDesigner.SnapLines.Count.Should().Be(9);

derivedDesigner = new ParentControlDesigner();
derivedDesigner.Initialize(control);
derivedDesigner.SnapLines.Count.Should().Be(12);

derivedDesigner = new SplitterPanelDesigner();
using SplitContainer splitContainer = new();
using SplitterPanel splitterPanel = new(splitContainer);
derivedDesigner.Initialize(splitterPanel);
derivedDesigner.SnapLines.Count.Should().Be(4);

derivedDesigner = new TextBoxBaseDesigner();
using TextBox textBox = new();
derivedDesigner.Initialize(textBox);
derivedDesigner.SnapLines.Count.Should().Be(9);

derivedDesigner = new ToolStripContentPanelDesigner();
using ToolStripContentPanel toolStripContentPanel = new();
derivedDesigner.Initialize(toolStripContentPanel);
derivedDesigner.SnapLines.Count.Should().Be(4);

derivedDesigner = new UpDownBaseDesigner();
using DomainUpDown domainUpDown = new();
derivedDesigner.Initialize(domainUpDown);
derivedDesigner.SnapLines.Count.Should().Be(9);
}
}