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)
97snapLines.Add(new SnapLine(SnapLineType.Baseline, baseline, SnapLinePriority.Medium));
System\Windows\Forms\Design\ComboBoxDesigner.cs (1)
35snapLines.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)
60snapLines.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)
52snapLines.Add(new SnapLine(SnapLineType.Baseline, baseline, SnapLinePriority.Medium));
System.Windows.Forms.Design.Tests (23)
System\Windows\Forms\Design\Behavior\SnapLineTests.cs (23)
20SnapLine snapLine = new(SnapLineType.Baseline, DefaultOffset); 31SnapLine snapLine = new(SnapLineType.Baseline, DefaultOffset, DefaultFilter); 42SnapLine snapLine = new(SnapLineType.Baseline, DefaultOffset, DefaultPriority); 53SnapLine snapLine = new(SnapLineType.Baseline, DefaultOffset, DefaultFilter, DefaultPriority); 71SnapLine snapLine = new(type, DefaultOffset, DefaultFilter, DefaultPriority); 86SnapLine snapLine = new(type, DefaultOffset, DefaultFilter, DefaultPriority); 103SnapLine snapLine = new(type, DefaultOffset, DefaultFilter, DefaultPriority); 115SnapLine snapLine = new(SnapLineType.Baseline, offset, DefaultFilter, DefaultPriority); 124SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, DefaultFilter, DefaultPriority); 125SnapLine snapLine2 = new(SnapLineType.Baseline, DefaultOffset, DefaultFilter, DefaultPriority); 133SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, null, DefaultPriority); 134SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, null, SnapLinePriority.Low); 142SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, null, DefaultPriority); 143SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, DefaultFilter, SnapLinePriority.Low); 178SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, snapLine1Filter, DefaultPriority); 179SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, snapLine2Filter, SnapLinePriority.Low); 208SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, snapLine1Filter, DefaultPriority); 209SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, snapLine2Filter, SnapLinePriority.Low); 217SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, "custom filter", DefaultPriority); 218SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, "custom filter", SnapLinePriority.Low); 226SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, "custom filter", DefaultPriority); 227SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, "another filter", SnapLinePriority.Low); 237SnapLine snapLine = new(SnapLineType.Baseline, DefaultOffset, filter, DefaultPriority);
170 references to SnapLine
System.Design (1)
artifacts\obj\System.Design.Facade\Release\net10.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)
45IList<SnapLine> snapLines = SnapLinesInternal;
System\Windows\Forms\Design\ComboBoxDesigner.cs (1)
30IList<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)
30IList<SnapLine> snapLines = SnapLinesInternal; 78SnapLine 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)
42IList<SnapLine> snapLines = SnapLinesInternal;
System.Windows.Forms.Design.Tests (79)
System\Windows\Forms\Design\Behavior\SnapLineTests.cs (58)
10private static readonly string[] s_margins = [SnapLine.MarginLeft, SnapLine.MarginTop, SnapLine.MarginRight, SnapLine.MarginBottom]; 11private static readonly string[] s_paddings = [SnapLine.PaddingLeft, SnapLine.PaddingTop, SnapLine.PaddingRight, SnapLine.PaddingBottom]; 20SnapLine snapLine = new(SnapLineType.Baseline, DefaultOffset); 31SnapLine snapLine = new(SnapLineType.Baseline, DefaultOffset, DefaultFilter); 42SnapLine snapLine = new(SnapLineType.Baseline, DefaultOffset, DefaultPriority); 53SnapLine snapLine = new(SnapLineType.Baseline, DefaultOffset, DefaultFilter, DefaultPriority); 71SnapLine snapLine = new(type, DefaultOffset, DefaultFilter, DefaultPriority); 86SnapLine snapLine = new(type, DefaultOffset, DefaultFilter, DefaultPriority); 103SnapLine snapLine = new(type, DefaultOffset, DefaultFilter, DefaultPriority); 115SnapLine snapLine = new(SnapLineType.Baseline, offset, DefaultFilter, DefaultPriority); 124SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, DefaultFilter, DefaultPriority); 125SnapLine snapLine2 = new(SnapLineType.Baseline, DefaultOffset, DefaultFilter, DefaultPriority); 127Assert.False(SnapLine.ShouldSnap(snapLine1, snapLine2)); 133SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, null, DefaultPriority); 134SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, null, SnapLinePriority.Low); 136Assert.True(SnapLine.ShouldSnap(snapLine1, snapLine2)); 142SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, null, DefaultPriority); 143SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, DefaultFilter, SnapLinePriority.Low); 145Assert.False(SnapLine.ShouldSnap(snapLine1, snapLine2)); 150return EnumerateFilterMarginPaths(SnapLine.MarginRight, SnapLine.MarginLeft, SnapLine.PaddingRight) 151.Union(EnumerateFilterMarginPaths(SnapLine.MarginLeft, SnapLine.MarginRight, SnapLine.PaddingLeft)) 152.Union(EnumerateFilterMarginPaths(SnapLine.MarginTop, SnapLine.MarginBottom, SnapLine.PaddingTop)) 153.Union(EnumerateFilterMarginPaths(SnapLine.MarginBottom, SnapLine.MarginTop, SnapLine.PaddingBottom)); 178SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, snapLine1Filter, DefaultPriority); 179SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, snapLine2Filter, SnapLinePriority.Low); 181Assert.Equal(expected, SnapLine.ShouldSnap(snapLine1, snapLine2)); 186return EnumerateFilterPaddingPaths(SnapLine.PaddingLeft, SnapLine.MarginLeft) 187.Union(EnumerateFilterPaddingPaths(SnapLine.PaddingRight, SnapLine.MarginRight)) 188.Union(EnumerateFilterPaddingPaths(SnapLine.PaddingTop, SnapLine.MarginTop)) 189.Union(EnumerateFilterPaddingPaths(SnapLine.PaddingBottom, SnapLine.MarginBottom)); 208SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, snapLine1Filter, DefaultPriority); 209SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, snapLine2Filter, SnapLinePriority.Low); 211Assert.Equal(expected, SnapLine.ShouldSnap(snapLine1, snapLine2)); 217SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, "custom filter", DefaultPriority); 218SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, "custom filter", SnapLinePriority.Low); 220Assert.True(SnapLine.ShouldSnap(snapLine1, snapLine2)); 226SnapLine snapLine1 = new(SnapLineType.Top, DefaultOffset, "custom filter", DefaultPriority); 227SnapLine snapLine2 = new(SnapLineType.Top, DefaultOffset, "another filter", SnapLinePriority.Low); 229Assert.False(SnapLine.ShouldSnap(snapLine1, snapLine2)); 237SnapLine snapLine = new(SnapLineType.Baseline, DefaultOffset, filter, DefaultPriority);
System\Windows\Forms\Design\FlowPanelDesignerTests.cs (4)
41var snapLines = designer.SnapLines as IList<SnapLine>; 44snapLines.Should().NotContain(line => line.Filter is object && line.Filter.Contains(SnapLine.Padding)); 52var snapLines = designer.SnapLines as IList<SnapLine>; 55snapLines.Should().Contain(line => line.Filter == null || !line.Filter.Contains(SnapLine.Padding));
System\Windows\Forms\Design\TextBoxBaseDesignerTests.cs (4)
51List<SnapLine> snapLines = (List<SnapLine>)_designer.SnapLines; 55SnapLine? baselineSnapLine = snapLines.Cast<SnapLine>().FirstOrDefault(sl => sl.SnapLineType == SnapLineType.Baseline);
System\Windows\Forms\Design\ToolStripContentPanelDesignerTests.cs (8)
29IList<SnapLine> snapLines = _toolStripContentPanelDesigner.SnapLines.Cast<SnapLine>().ToList(); 37string?[] paddingFilters = [SnapLine.PaddingLeft, SnapLine.PaddingRight, SnapLine.PaddingTop, SnapLine.PaddingBottom]; 39List<SnapLine> snapLines = _toolStripContentPanelDesigner.SnapLines.Cast<SnapLine>().ToList();
System\Windows\Forms\Design\UpDownBaseDesignerTests.cs (5)
52List<SnapLine> snapLines = (List<SnapLine>)_designer.SnapLines; 55SnapLine? baselineSnapLine = snapLines.FirstOrDefault(sl => sl.SnapLineType == SnapLineType.Baseline); 56baselineSnapLine.Should().BeOfType<SnapLine>().Which.Priority.Should().Be(SnapLinePriority.Medium); 59baselineSnapLine.Should().BeOfType<SnapLine>().Which.Offset.Should().Be(expectedBaseline);