.net - C# List<T>.Find(x=>x.Rectangle.Contains(Point)) FAIL -
For my life, I can not understand why this code generates the following output ...
< P> I think there is a bug or something while using the list and lambda, if type one rectangle exposes the property and you use the included method of rectangle object ... and the clear statement proves true while Find list method fails ....Onway
Code
Public Gridskeyr Warldtokapadsb (Point location) {location = _Map.WorldToClient (location); Gridsquare gs = this.find (x => x.Rectangle.Contains (location)); GridSquare KP = G.Find (X => X. laxative canteen (location)); & Lt; GridSquare & gt; List = kp.FindAll (x => x.Rectangle.Contains (location)); U.dp (list.Count); Gridskare sub = KP.Fid (X => X. laxative canteen (location)); If (sub == faucet) {u.dp (place to look for "location"); U.dp ("The location found in the grid category" + GS toaster ()); U.dp ("Grid Square Bounds" + gs.Rectangle.ToString ()); U.dp ("location found in keypad" + kp.ToString ()); U.dp ("The key pad limit" + + KP rankangle.tostring ()); U.dp ("sub keypad print all subkeys in this grid." Keyboard); Forech (Gridskare T in KP) {u.dp (T. toaster (+) + "" + T. Rankangle.tostring ()); } U.dp ("sub key pad print finds clear"); Foreach (GridScore t in KP) {if (location.X> gt = = t.Location.X & amp; amp; amp; amp ;;;;;;;;;;;;;;;;;; A; Amp; space; x & lt; = t. Space x + t. Rectangle. Method and location. Y and lieutenant; = t. Location. Y + t. Racketang.height) {u.dp (true) ); U.dp (t.ToString () + "" + t.Rectangle.ToString ()); }} Returning sub; } This generates the following output ...
Notice how the clear rectangle (aka manual method) grid places the squares .... The GDI version fails in ....
to see the location {X = 1476, Y = 1716} found in grid squares GS: 14.3.0.0 grid class limit {X = 1398, Y = 1650, width = 100, height = 100} Keypad found in GS Place: 14.3.6.0 Key pad limit {X = 1465, Y = 1683, width = 33, height = 34} Sub key pad print Print all subkeys in this grid. Keypad GS: 14.3.6.7 {X = 1465, Y = 1683, width = 11, height = 11} GS: 14.3.6.8 {X = 1476, Y = 1683, width = 11 , Height = 11} GS: 14.3.6.6 {X = 1487, Y = 1683, width = 11, height = 11} GS: 14.3.6.4 {X = 1465, Y = 16 9 4, width = 11, height = 11 } GS: 14.3.6.5 {X = 1476, Y = 1694, width = 11, height = 11} GS: 14.3.6.6 {X = 1487, Y = 1694, width = 11, height = 11} GS: 14.3.6.1 {X = 1465, Y = 1705, width = 11, height = 11} GS: 14.3.6.2 {X = 1476, Y = 1705, width = 11, height = 11} GS: 14.3.6.3 {X = 1487, Y = 1705, width = 11, height = 11} The sub key pad print finds the true GS: 14.3.6.1 {X = 1465, Y = 1705, width = 11, Height = 11} True GS: 14.3.6.2 {X = 1476, Y = 1705, width = 11, height = 11} Exception of type 'System.NullReferenceException' is a first exception exception.
rectangle Incorporate (point) is unique (strictly short)
For example, in your reference, there should be equivalent check by Rectangle.Contains (Point) Should:
foreach (gridscare t in kP) {if (location.x> gt; = t.Location.X & amp; location.Y> gt; = location. Y & amp; Location.x.lt; T.Location.X + t.Rectangle.Width // & lt; & lt; = & amp; location instead.Y & lt; T.Location.Y + t .Rectangle.Height) // & lt; Instead & lt; = {U.dp (true); U.dp (t.ToString () + "" + t.Rectangle.ToString ()); }}
As you can see, instead of the upper boundaries, instead of at least or equal, your method and Rectangle.Contains (Point < P> The location passed in your exemple is {X = 1476, Y = 1716}, which is when it passed to include those rectangles: GS: 14.3.6.1 {X = 1465 , Y = 1705, width = 11, height = 11} GS: 14.3.6.2 {X = 1476, Y = 1705, width = 11, height = 11} will return a false point, when Your truth will come back.
This is the reason that kp.Find (x => x.Rectangle.Contains (location)); Do not return empty, but your manual checks are returning right.
Comments
Post a Comment