59 instantiations of SnapLine
System.Windows.Forms.Design (36)
System\Windows\Forms\Design\Behavior\ResizeBehavior.cs (8)
164lines.Add(new SnapLine(SnapLineType.Bottom, loc.Y - 1)); 167lines.Add(new SnapLine(SnapLineType.Horizontal, loc.Y + _primaryControl.Margin.Bottom, SnapLine.MarginBottom, SnapLinePriority.Always)); 172lines.Add(new SnapLine(SnapLineType.Top, loc.Y)); 175lines.Add(new SnapLine(SnapLineType.Horizontal, loc.Y - _primaryControl.Margin.Top, SnapLine.MarginTop, SnapLinePriority.Always)); 181lines.Add(new SnapLine(SnapLineType.Right, loc.X - 1)); 184lines.Add(new SnapLine(SnapLineType.Vertical, loc.X + _primaryControl.Margin.Right, SnapLine.MarginRight, SnapLinePriority.Always)); 189lines.Add(new SnapLine(SnapLineType.Left, loc.X)); 192lines.Add(new SnapLine(SnapLineType.Vertical, loc.X - _primaryControl.Margin.Left, SnapLine.MarginLeft, SnapLinePriority.Always));
System\Windows\Forms\Design\ButtonBaseDesigner.cs (1)
99snapLines.Add(new SnapLine(SnapLineType.Baseline, baseline, SnapLinePriority.Medium));
System\Windows\Forms\Design\ComboBoxDesigner.cs (1)
37snapLines.Add(new SnapLine(SnapLineType.Baseline, baseline, SnapLinePriority.Medium));
System\Windows\Forms\Design\ControlCommandSet.cs (6)
480lines.Add(new SnapLine(SnapLineType.Right, pt.X + primaryControl.Width - 1)); 481lines.Add(new SnapLine(SnapLineType.Vertical, pt.X + primaryControl.Width + primaryControl.Margin.Right, SnapLine.MarginRight, SnapLinePriority.Always)); 488lines.Add(new SnapLine(SnapLineType.Left, pt.X)); 489lines.Add(new SnapLine(SnapLineType.Vertical, pt.X - primaryControl.Margin.Left, SnapLine.MarginLeft, SnapLinePriority.Always)); 501lines.Add(new SnapLine(SnapLineType.Bottom, pt.Y + primaryControl.Height - 1)); 502lines.Add(new SnapLine(SnapLineType.Horizontal, pt.Y + primaryControl.Height + primaryControl.Margin.Bottom, SnapLine.MarginBottom, SnapLinePriority.Always));
System\Windows\Forms\Design\ControlDesigner.cs (8)
352snapLines.Add(new SnapLine(SnapLineType.Top, 0, SnapLinePriority.Low)); 353snapLines.Add(new SnapLine(SnapLineType.Bottom, height - 1, SnapLinePriority.Low)); 354snapLines.Add(new SnapLine(SnapLineType.Left, 0, SnapLinePriority.Low)); 355snapLines.Add(new SnapLine(SnapLineType.Right, width - 1, SnapLinePriority.Low)); 360snapLines.Add(new SnapLine(SnapLineType.Horizontal, -margin.Top, SnapLine.MarginTop, SnapLinePriority.Always)); 361snapLines.Add(new SnapLine(SnapLineType.Horizontal, margin.Bottom + height, SnapLine.MarginBottom, SnapLinePriority.Always)); 362snapLines.Add(new SnapLine(SnapLineType.Vertical, -margin.Left, SnapLine.MarginLeft, SnapLinePriority.Always)); 363snapLines.Add(new SnapLine(SnapLineType.Vertical, margin.Right + width, SnapLine.MarginRight, SnapLinePriority.Always));
System\Windows\Forms\Design\DateTimePickerDesigner.cs (1)
31snapLines.Add(new SnapLine(SnapLineType.Baseline, baseline, SnapLinePriority.Medium));
System\Windows\Forms\Design\LabelDesigner.cs (1)
62snapLines.Add(new SnapLine(SnapLineType.Baseline, baseline, SnapLinePriority.Medium));
System\Windows\Forms\Design\ParentControlDesigner.cs (8)
319snapLines.Add(new SnapLine(SnapLineType.Vertical, displayRectangle.Left, SnapLine.PaddingLeft, SnapLinePriority.Always)); 320snapLines.Add(new SnapLine(SnapLineType.Vertical, displayRectangle.Right, SnapLine.PaddingRight, SnapLinePriority.Always)); 321snapLines.Add(new SnapLine(SnapLineType.Horizontal, displayRectangle.Top, SnapLine.PaddingTop, SnapLinePriority.Always)); 322snapLines.Add(new SnapLine(SnapLineType.Horizontal, displayRectangle.Bottom, SnapLine.PaddingBottom, SnapLinePriority.Always)); 848new SnapLine(SnapLineType.Left, r.Right), 849new SnapLine(SnapLineType.Right, r.Right), 850new SnapLine(SnapLineType.Bottom, r.Bottom), 851new SnapLine(SnapLineType.Top, r.Bottom)
System\Windows\Forms\Design\TextBoxBaseDesigner.cs (1)
56snapLines.Add(new SnapLine(SnapLineType.Baseline, baseline, SnapLinePriority.Medium));
System\Windows\Forms\Design\UpDownBaseDesigner.cs (1)
54snapLines.Add(new SnapLine(SnapLineType.Baseline, baseline, SnapLinePriority.Medium));
System.Windows.Forms.Design.Tests (23)
System\Windows\Forms\Design\Behavior\SnapLineTests.cs (23)
18SnapLine snapLine = new(SnapLineType.Baseline, DefaultOffset); 29SnapLine snapLine = new(SnapLineType.Baseline, DefaultOffset, DefaultFilter); 40SnapLine snapLine = new(SnapLineType.Baseline, DefaultOffset, DefaultPriority); 51SnapLine snapLine = new(SnapLineType.Baseline, DefaultOffset, DefaultFilter, DefaultPriority); 69SnapLine snapLine = new(type, DefaultOffset, DefaultFilter, DefaultPriority); 84SnapLine snapLine = new(type, DefaultOffset, DefaultFilter, DefaultPriority); 101SnapLine snapLine = new(type, DefaultOffset, DefaultFilter, DefaultPriority); 113SnapLine snapLine = new(SnapLineType.Baseline, offset, DefaultFilter, DefaultPriority); 122SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, DefaultFilter, DefaultPriority); 123SnapLine snapLine2 = new(SnapLineType.Baseline, DefaultOffset, DefaultFilter, DefaultPriority); 131SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, null, DefaultPriority); 132SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, null, SnapLinePriority.Low); 140SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, null, DefaultPriority); 141SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, DefaultFilter, SnapLinePriority.Low); 176SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, snapLine1Filter, DefaultPriority); 177SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, snapLine2Filter, SnapLinePriority.Low); 206SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, snapLine1Filter, DefaultPriority); 207SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, snapLine2Filter, SnapLinePriority.Low); 215SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, "custom filter", DefaultPriority); 216SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, "custom filter", SnapLinePriority.Low); 224SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, "custom filter", DefaultPriority); 225SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, "another filter", SnapLinePriority.Low); 235SnapLine snapLine = new(SnapLineType.Baseline, DefaultOffset, filter, DefaultPriority);
170 references to SnapLine
System.Design (1)
artifacts\obj\System.Design.Facade\Release\net9.0\System.Design.Forwards.cs (1)
80[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Windows.Forms.Design.Behavior.SnapLine))]
System.Windows.Forms.Design (90)
System\Windows\Forms\Design\Behavior\BehaviorService.cs (1)
805foreach (SnapLine line in designer.SnapLinesInternal)
System\Windows\Forms\Design\Behavior\DragAssistanceManager.cs (33)
33private readonly List<SnapLine> _verticalSnapLines = []; 34private readonly List<SnapLine> _horizontalSnapLines = []; 36private readonly List<SnapLine> _targetVerticalSnapLines = []; 37private readonly List<SnapLine> _targetHorizontalSnapLines = []; 59private readonly Dictionary<SnapLine, Rectangle> _snapLineToBounds = []; 194private void AddSnapLines(ControlDesigner controlDesigner, List<SnapLine> horizontalList, List<SnapLine> verticalList, bool isTarget, bool validTarget) 196IList<SnapLine> snapLines = controlDesigner.SnapLinesInternal; 219foreach (SnapLine snapLine in snapLines) 224if (snapLine.Filter is not null && snapLine.Filter.StartsWith(SnapLine.Padding, StringComparison.Ordinal)) 243if ((snapLine.Filter is not null) && snapLine.Filter.StartsWith(SnapLine.Padding, StringComparison.Ordinal)) 270private int BuildDistanceArray(List<SnapLine> snapLines, List<SnapLine> targetSnapLines, int[] distances, Rectangle dragBounds) 277SnapLine snapLine = snapLines[i]; 291SnapLine targetSnapLine = targetSnapLines[j]; 293if (SnapLine.ShouldSnap(snapLine, targetSnapLine)) 443private void IdentifyAndStoreValidLines(List<SnapLine> snapLines, int[] distances, Rectangle dragBounds, int smallestDistance) 649private static bool IsMarginOrPaddingSnapLine(SnapLine snapLine) 652&& (snapLine.Filter.StartsWith(SnapLine.Margin, StringComparison.Ordinal) 653|| snapLine.Filter.StartsWith(SnapLine.Padding, StringComparison.Ordinal)); 666foreach (SnapLine snapline in targetSnaplines) 749private static int FindSmallestValidDistance(List<SnapLine> snapLines, int[] distances, int min, int max, int direction) 924private void StoreSnapLine(SnapLine snapLine, Rectangle dragBounds) 932type = snapLine.Filter!.StartsWith(SnapLine.Margin, StringComparison.Ordinal) ? LineType.Margin : LineType.Padding; 973case SnapLine.PaddingRight: 976case SnapLine.PaddingLeft: 979case SnapLine.PaddingTop: 982case SnapLine.PaddingBottom: 999private bool ValidateMarginOrPaddingLine(SnapLine snapLine, Rectangle dragBounds) 1035internal Point OnMouseMove(Rectangle dragBounds, SnapLine[] snapLines) 1046internal Point OnMouseMove(Rectangle dragBounds, SnapLine[] snapLines, ref bool didSnap, bool shouldSnapHorizontally) 1056foreach (SnapLine snapline in snapLines) 1085internal Point OnMouseMove(Control targetControl, SnapLine[] snapLines, ref bool didSnap, bool shouldSnapHorizontally)
System\Windows\Forms\Design\Behavior\ResizeBehavior.cs (6)
158private SnapLine[] GenerateSnapLines(SelectionRules rules, Point loc) 160List<SnapLine> lines = new(2); 167lines.Add(new SnapLine(SnapLineType.Horizontal, loc.Y + _primaryControl.Margin.Bottom, SnapLine.MarginBottom, SnapLinePriority.Always)); 175lines.Add(new SnapLine(SnapLineType.Horizontal, loc.Y - _primaryControl.Margin.Top, SnapLine.MarginTop, SnapLinePriority.Always)); 184lines.Add(new SnapLine(SnapLineType.Vertical, loc.X + _primaryControl.Margin.Right, SnapLine.MarginRight, SnapLinePriority.Always)); 192lines.Add(new SnapLine(SnapLineType.Vertical, loc.X - _primaryControl.Margin.Left, SnapLine.MarginLeft, SnapLinePriority.Always));
System\Windows\Forms\Design\Behavior\SnapLine.cs (2)
117public static bool ShouldSnap(SnapLine line1, SnapLine line2)
System\Windows\Forms\Design\Behavior\ToolboxItemSnapLineBehavior.cs (5)
233private static SnapLine[] GenerateNewToolSnapLines(Rectangle r) 240new(SnapLineType.Horizontal, r.Top - 4, SnapLine.MarginTop, SnapLinePriority.Always), 241new(SnapLineType.Horizontal, r.Bottom + 3, SnapLine.MarginBottom, SnapLinePriority.Always), 242new(SnapLineType.Vertical, r.Left - 4, SnapLine.MarginLeft, SnapLinePriority.Always), 243new(SnapLineType.Vertical, r.Right + 3, SnapLine.MarginRight, SnapLinePriority.Always)
System\Windows\Forms\Design\ButtonBaseDesigner.cs (1)
47IList<SnapLine> snapLines = SnapLinesInternal;
System\Windows\Forms\Design\ComboBoxDesigner.cs (1)
32IList<SnapLine> snapLines = SnapLinesInternal;
System\Windows\Forms\Design\ControlCommandSet.cs (6)
462private List<SnapLine> GenerateSnapLines(SelectionRules rules, Control primaryControl, int directionOffsetX, int directionOffsetY) 464List<SnapLine> lines = new(2); 481lines.Add(new SnapLine(SnapLineType.Vertical, pt.X + primaryControl.Width + primaryControl.Margin.Right, SnapLine.MarginRight, SnapLinePriority.Always)); 489lines.Add(new SnapLine(SnapLineType.Vertical, pt.X - primaryControl.Margin.Left, SnapLine.MarginLeft, SnapLinePriority.Always)); 502lines.Add(new SnapLine(SnapLineType.Horizontal, pt.Y + primaryControl.Height + primaryControl.Margin.Bottom, SnapLine.MarginBottom, SnapLinePriority.Always)); 631List<SnapLine> targetSnaplines = GenerateSnapLines(des.SelectionRules, primaryControl, moveOffsetX, moveOffsetY);
System\Windows\Forms\Design\ControlDesigner.cs (8)
341internal IList<SnapLine> SnapLinesInternal => EdgeAndMarginSnapLines(); 343internal IList<SnapLine> EdgeAndMarginSnapLines() => EdgeAndMarginSnapLines(Control.Margin); 345internal IList<SnapLine> EdgeAndMarginSnapLines(Padding margin) 347List<SnapLine> snapLines = new(8); 360snapLines.Add(new SnapLine(SnapLineType.Horizontal, -margin.Top, SnapLine.MarginTop, SnapLinePriority.Always)); 361snapLines.Add(new SnapLine(SnapLineType.Horizontal, margin.Bottom + height, SnapLine.MarginBottom, SnapLinePriority.Always)); 362snapLines.Add(new SnapLine(SnapLineType.Vertical, -margin.Left, SnapLine.MarginLeft, SnapLinePriority.Always)); 363snapLines.Add(new SnapLine(SnapLineType.Vertical, margin.Right + width, SnapLine.MarginRight, SnapLinePriority.Always));
System\Windows\Forms\Design\DateTimePickerDesigner.cs (1)
24IList<SnapLine> snapLines = SnapLinesInternal;
System\Windows\Forms\Design\FlowPanelDesigner.cs (3)
17IList<SnapLine> snapLines = SnapLinesInternal; 22if (snapLines[i] is SnapLine line 23&& line.Filter?.Contains(SnapLine.Padding) == true)
System\Windows\Forms\Design\FormDocumentDesigner.cs (8)
189IList<SnapLine> snapLines = null; 194snapLines = new List<SnapLine>(4); 204if (snapLines[i] is SnapLine snapLine && snapLine.Filter is not null && snapLine.Filter.StartsWith(SnapLine.Padding, StringComparison.Ordinal)) 206if (snapLine.Filter.Equals(SnapLine.PaddingLeft) || snapLine.Filter.Equals(SnapLine.PaddingTop)) 212if (snapLine.Filter.Equals(SnapLine.PaddingRight) || snapLine.Filter.Equals(SnapLine.PaddingBottom))
System\Windows\Forms\Design\LabelDesigner.cs (2)
32IList<SnapLine> snapLines = SnapLinesInternal; 80SnapLine snapLine = snapLines[i];
System\Windows\Forms\Design\ParentControlDesigner.cs (11)
298=> AddPaddingSnapLinesCommon((snapLines ??= new(4)).Adapt<SnapLine>()); 300internal void AddPaddingSnapLines(ref IList<SnapLine> snapLines) 301=> AddPaddingSnapLinesCommon(snapLines ??= new List<SnapLine>(4)); 303private void AddPaddingSnapLinesCommon(IList<SnapLine> snapLines) 319snapLines.Add(new SnapLine(SnapLineType.Vertical, displayRectangle.Left, SnapLine.PaddingLeft, SnapLinePriority.Always)); 320snapLines.Add(new SnapLine(SnapLineType.Vertical, displayRectangle.Right, SnapLine.PaddingRight, SnapLinePriority.Always)); 321snapLines.Add(new SnapLine(SnapLineType.Horizontal, displayRectangle.Top, SnapLine.PaddingTop, SnapLinePriority.Always)); 322snapLines.Add(new SnapLine(SnapLineType.Horizontal, displayRectangle.Bottom, SnapLine.PaddingBottom, SnapLinePriority.Always)); 335IList<SnapLine> snapLines = SnapLinesInternal; 340snapLines = new List<SnapLine>(4); 844private static SnapLine[] GenerateNewToolSnapLines(Rectangle r)
System\Windows\Forms\Design\TextBoxBaseDesigner.cs (1)
55IList<SnapLine> snapLines = SnapLinesInternal;
System\Windows\Forms\Design\UpDownBaseDesigner.cs (1)
44IList<SnapLine> snapLines = SnapLinesInternal;
System.Windows.Forms.Design.Tests (79)
System\Windows\Forms\Design\Behavior\SnapLineTests.cs (58)
8private static readonly string[] s_margins = [SnapLine.MarginLeft, SnapLine.MarginTop, SnapLine.MarginRight, SnapLine.MarginBottom]; 9private static readonly string[] s_paddings = [SnapLine.PaddingLeft, SnapLine.PaddingTop, SnapLine.PaddingRight, SnapLine.PaddingBottom]; 18SnapLine snapLine = new(SnapLineType.Baseline, DefaultOffset); 29SnapLine snapLine = new(SnapLineType.Baseline, DefaultOffset, DefaultFilter); 40SnapLine snapLine = new(SnapLineType.Baseline, DefaultOffset, DefaultPriority); 51SnapLine snapLine = new(SnapLineType.Baseline, DefaultOffset, DefaultFilter, DefaultPriority); 69SnapLine snapLine = new(type, DefaultOffset, DefaultFilter, DefaultPriority); 84SnapLine snapLine = new(type, DefaultOffset, DefaultFilter, DefaultPriority); 101SnapLine snapLine = new(type, DefaultOffset, DefaultFilter, DefaultPriority); 113SnapLine snapLine = new(SnapLineType.Baseline, offset, DefaultFilter, DefaultPriority); 122SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, DefaultFilter, DefaultPriority); 123SnapLine snapLine2 = new(SnapLineType.Baseline, DefaultOffset, DefaultFilter, DefaultPriority); 125Assert.False(SnapLine.ShouldSnap(snapLine1, snapLine2)); 131SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, null, DefaultPriority); 132SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, null, SnapLinePriority.Low); 134Assert.True(SnapLine.ShouldSnap(snapLine1, snapLine2)); 140SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, null, DefaultPriority); 141SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, DefaultFilter, SnapLinePriority.Low); 143Assert.False(SnapLine.ShouldSnap(snapLine1, snapLine2)); 148return EnumerateFilterMarginPaths(SnapLine.MarginRight, SnapLine.MarginLeft, SnapLine.PaddingRight) 149.Union(EnumerateFilterMarginPaths(SnapLine.MarginLeft, SnapLine.MarginRight, SnapLine.PaddingLeft)) 150.Union(EnumerateFilterMarginPaths(SnapLine.MarginTop, SnapLine.MarginBottom, SnapLine.PaddingTop)) 151.Union(EnumerateFilterMarginPaths(SnapLine.MarginBottom, SnapLine.MarginTop, SnapLine.PaddingBottom)); 176SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, snapLine1Filter, DefaultPriority); 177SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, snapLine2Filter, SnapLinePriority.Low); 179Assert.Equal(expected, SnapLine.ShouldSnap(snapLine1, snapLine2)); 184return EnumerateFilterPaddingPaths(SnapLine.PaddingLeft, SnapLine.MarginLeft) 185.Union(EnumerateFilterPaddingPaths(SnapLine.PaddingRight, SnapLine.MarginRight)) 186.Union(EnumerateFilterPaddingPaths(SnapLine.PaddingTop, SnapLine.MarginTop)) 187.Union(EnumerateFilterPaddingPaths(SnapLine.PaddingBottom, SnapLine.MarginBottom)); 206SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, snapLine1Filter, DefaultPriority); 207SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, snapLine2Filter, SnapLinePriority.Low); 209Assert.Equal(expected, SnapLine.ShouldSnap(snapLine1, snapLine2)); 215SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, "custom filter", DefaultPriority); 216SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, "custom filter", SnapLinePriority.Low); 218Assert.True(SnapLine.ShouldSnap(snapLine1, snapLine2)); 224SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, "custom filter", DefaultPriority); 225SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, "another filter", SnapLinePriority.Low); 227Assert.False(SnapLine.ShouldSnap(snapLine1, snapLine2)); 235SnapLine snapLine = new(SnapLineType.Baseline, DefaultOffset, filter, DefaultPriority);
System\Windows\Forms\Design\FlowPanelDesignerTests.cs (4)
43var snapLines = designer.SnapLines as IList<SnapLine>; 46snapLines.Should().NotContain(line => line.Filter is object && line.Filter.Contains(SnapLine.Padding)); 54var snapLines = designer.SnapLines as IList<SnapLine>; 57snapLines.Should().Contain(line => line.Filter == null || !line.Filter.Contains(SnapLine.Padding));
System\Windows\Forms\Design\TextBoxBaseDesignerTests.cs (4)
53List<SnapLine> snapLines = (List<SnapLine>)_designer.SnapLines; 57SnapLine? baselineSnapLine = snapLines.Cast<SnapLine>().FirstOrDefault(sl => sl.SnapLineType == SnapLineType.Baseline);
System\Windows\Forms\Design\ToolStripContentPanelDesignerTests.cs (8)
31IList<SnapLine> snapLines = _toolStripContentPanelDesigner.SnapLines.Cast<SnapLine>().ToList(); 39string?[] paddingFilters = [SnapLine.PaddingLeft, SnapLine.PaddingRight, SnapLine.PaddingTop, SnapLine.PaddingBottom]; 41List<SnapLine> snapLines = _toolStripContentPanelDesigner.SnapLines.Cast<SnapLine>().ToList();
System\Windows\Forms\Design\UpDownBaseDesignerTests.cs (5)
54List<SnapLine> snapLines = (List<SnapLine>)_designer.SnapLines; 57SnapLine? baselineSnapLine = snapLines.FirstOrDefault(sl => sl.SnapLineType == SnapLineType.Baseline); 58baselineSnapLine.Should().BeOfType<SnapLine>().Which.Priority.Should().Be(SnapLinePriority.Medium); 61baselineSnapLine.Should().BeOfType<SnapLine>().Which.Offset.Should().Be(expectedBaseline);